1.. BSD LICENSE 2 Copyright(c) 2010-2014 Intel Corporation. All rights reserved. 3 All rights reserved. 4 5 Redistribution and use in source and binary forms, with or without 6 modification, are permitted provided that the following conditions 7 are met: 8 9 * Redistributions of source code must retain the above copyright 10 notice, this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright 12 notice, this list of conditions and the following disclaimer in 13 the documentation and/or other materials provided with the 14 distribution. 15 * Neither the name of Intel Corporation nor the names of its 16 contributors may be used to endorse or promote products derived 17 from this software without specific prior written permission. 18 19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 31.. _Building_Your_Own_Application: 32 33Building Your Own Application 34============================= 35 36Compiling a Sample Application in the Development Kit Directory 37--------------------------------------------------------------- 38 39When compiling a sample application (for example, hello world), the following variables must be exported: 40RTE_SDK and RTE_TARGET. 41 42.. code-block:: console 43 44 ~/DPDK$ cd examples/helloworld/ 45 ~/DPDK/examples/helloworld$ export RTE_SDK=/home/user/DPDK 46 ~/DPDK/examples/helloworld$ export RTE_TARGET=x86_64-native-linuxapp-gcc 47 ~/DPDK/examples/helloworld$ make 48 CC main.o 49 LD helloworld 50 INSTALL-APP helloworld 51 INSTALL-MAP helloworld.map 52 53The binary is generated in the build directory by default: 54 55.. code-block:: console 56 57 ~/DPDK/examples/helloworld$ ls build/app 58 helloworld helloworld.map 59 60Build Your Own Application Outside the Development Kit 61------------------------------------------------------ 62 63The sample application (Hello World) can be duplicated in a new directory as a starting point for your development: 64 65.. code-block:: console 66 67 ~$ cp -r DPDK/examples/helloworld my_rte_app 68 ~$ cd my_rte_app/ 69 ~/my_rte_app$ export RTE_SDK=/home/user/DPDK 70 ~/my_rte_app$ export RTE_TARGET=x86_64-native-linuxapp-gcc 71 ~/my_rte_app$ make 72 CC main.o 73 LD helloworld 74 INSTALL-APP helloworld 75 INSTALL-MAP helloworld.map 76 77Customizing Makefiles 78--------------------- 79 80Application Makefile 81~~~~~~~~~~~~~~~~~~~~ 82 83The default makefile provided with the Hello World sample application is a good starting point. It includes: 84 85* $(RTE_SDK)/mk/DPDK.vars.mk at the beginning 86 87* $(RTE_SDK)/mk/DPDK.extapp.mk at the end 88 89The user must define several variables: 90 91* APP: Contains the name of the application. 92 93* SRCS-y: List of source files (\*.c, \*.S). 94 95Library Makefile 96~~~~~~~~~~~~~~~~ 97 98It is also possible to build a library in the same way: 99 100* Include $(RTE_SDK)/mk/DPDK.vars.mk at the beginning. 101 102* Include $(RTE_SDK)/mk/DPDK.extlib.mk at the end. 103 104The only difference is that APP should be replaced by LIB, which contains the name of the library. For example, libfoo.a. 105 106Customize Makefile Actions 107~~~~~~~~~~~~~~~~~~~~~~~~~~ 108 109Some variables can be defined to customize Makefile actions. The most common are listed below. Refer to 110:ref:`Makefile Description <Makefile_Description>` section in 111:ref:`Development Kit Build System <Development_Kit_Build_System>` 112 113chapter for details. 114 115* VPATH: The path list where the build system will search for sources. By default, 116 RTE_SRCDIR will be included in VPATH. 117 118* CFLAGS_my_file.o: The specific flags to add for C compilation of my_file.c. 119 120* CFLAGS: The flags to use for C compilation. 121 122* LDFLAGS: The flags to use for linking. 123 124* CPPFLAGS: The flags to use to provide flags to the C preprocessor (only useful when assembling .S files) 125 126* LDLIBS: A list of libraries to link with (for example, -L /path/to/libfoo - lfoo) 127 128* NO_AUTOLIBS: If set, the libraries provided by the framework will not be included in the LDLIBS variable automatically. 129