2 Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
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
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.
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.
31 .. _Building_Your_Own_Application:
33 Building Your Own Application
34 =============================
36 Compiling a Sample Application in the Development Kit Directory
37 ---------------------------------------------------------------
39 When compiling a sample application (for example, hello world), the following variables must be exported:
40 RTE_SDK and RTE_TARGET.
42 .. code-block:: console
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
50 INSTALL-APP helloworld
51 INSTALL-MAP helloworld.map
53 The binary is generated in the build directory by default:
55 .. code-block:: console
57 ~/DPDK/examples/helloworld$ ls build/app
58 helloworld helloworld.map
60 Build Your Own Application Outside the Development Kit
61 ------------------------------------------------------
63 The sample application (Hello World) can be duplicated in a new directory as a starting point for your development:
65 .. code-block:: console
67 ~$ cp -r DPDK/examples/helloworld 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
74 INSTALL-APP helloworld
75 INSTALL-MAP helloworld.map
83 The default makefile provided with the Hello World sample application is a good starting point. It includes:
85 * $(RTE_SDK)/mk/rte.vars.mk at the beginning
87 * $(RTE_SDK)/mk/rte.extapp.mk at the end
89 The user must define several variables:
91 * APP: Contains the name of the application.
93 * SRCS-y: List of source files (\*.c, \*.S).
98 It is also possible to build a library in the same way:
100 * Include $(RTE_SDK)/mk/rte.vars.mk at the beginning.
102 * Include $(RTE_SDK)/mk/rte.extlib.mk at the end.
104 The only difference is that APP should be replaced by LIB, which contains the name of the library. For example, libfoo.a.
106 Customize Makefile Actions
107 ~~~~~~~~~~~~~~~~~~~~~~~~~~
109 Some 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>`
115 * VPATH: The path list where the build system will search for sources. By default,
116 RTE_SRCDIR will be included in VPATH.
118 * CFLAGS_my_file.o: The specific flags to add for C compilation of my_file.c.
120 * CFLAGS: The flags to use for C compilation.
122 * LDFLAGS: The flags to use for linking.
124 * CPPFLAGS: The flags to use to provide flags to the C preprocessor (only useful when assembling .S files)
126 * LDLIBS: A list of libraries to link with (for example, -L /path/to/libfoo - lfoo)