remove trailing whitespaces
[dpdk.git] / mk / rte.app.mk
1 #   BSD LICENSE
2 #
3 #   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
4 #   Copyright(c) 2014 6WIND S.A.
5 #   All rights reserved.
6 #
7 #   Redistribution and use in source and binary forms, with or without
8 #   modification, are permitted provided that the following conditions
9 #   are met:
10 #
11 #     * Redistributions of source code must retain the above copyright
12 #       notice, this list of conditions and the following disclaimer.
13 #     * Redistributions in binary form must reproduce the above copyright
14 #       notice, this list of conditions and the following disclaimer in
15 #       the documentation and/or other materials provided with the
16 #       distribution.
17 #     * Neither the name of Intel Corporation nor the names of its
18 #       contributors may be used to endorse or promote products derived
19 #       from this software without specific prior written permission.
20 #
21 #   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 #   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 #   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 #   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 #   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 #   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 #   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 #   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 #   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 #   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 #   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 include $(RTE_SDK)/mk/internal/rte.compile-pre.mk
34 include $(RTE_SDK)/mk/internal/rte.install-pre.mk
35 include $(RTE_SDK)/mk/internal/rte.clean-pre.mk
36 include $(RTE_SDK)/mk/internal/rte.build-pre.mk
37 include $(RTE_SDK)/mk/internal/rte.depdirs-pre.mk
38
39 # VPATH contains at least SRCDIR
40 VPATH += $(SRCDIR)
41
42 _BUILD = $(APP)
43 _INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y)
44 _INSTALL += $(RTE_OUTPUT)/app/$(APP) $(RTE_OUTPUT)/app/$(APP).map
45 POSTINSTALL += target-appinstall
46 _CLEAN = doclean
47 POSTCLEAN += target-appclean
48
49 ifeq ($(NO_LDSCRIPT),)
50 LDSCRIPT = $(RTE_LDSCRIPT)
51 endif
52
53 # default path for libs
54 LDLIBS += -L$(RTE_SDK_BIN)/lib
55
56 #
57 # Include libraries depending on config if NO_AUTOLIBS is not set
58 # Order is important: from higher level to lower level
59 #
60 ifeq ($(NO_AUTOLIBS),)
61
62 LDLIBS += --whole-archive
63
64 ifeq ($(CONFIG_RTE_LIBRTE_KNI),y)
65 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
66 LDLIBS += -lrte_kni
67 endif
68 endif
69
70 ifeq ($(CONFIG_RTE_LIBRTE_IVSHMEM),y)
71 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
72 LDLIBS += -lrte_ivshmem
73 endif
74 endif
75
76 ifeq ($(CONFIG_RTE_LIBRTE_TIMER),y)
77 LDLIBS += -lrte_timer
78 endif
79
80 ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
81 LDLIBS += -lrte_hash
82 endif
83
84 ifeq ($(CONFIG_RTE_LIBRTE_LPM),y)
85 LDLIBS += -lrte_lpm
86 endif
87
88 ifeq ($(CONFIG_RTE_LIBRTE_POWER),y)
89 LDLIBS += -lrte_power
90 endif
91
92 ifeq ($(CONFIG_RTE_LIBRTE_ACL),y)
93 LDLIBS += -lrte_acl
94 endif
95
96 ifeq ($(CONFIG_RTE_LIBRTE_METER),y)
97 LDLIBS += -lrte_meter
98 endif
99
100 ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
101 LDLIBS += -lrte_sched
102 LDLIBS += -lm
103 LDLIBS += -lrt
104 endif
105
106 LDLIBS += --start-group
107
108 ifeq ($(CONFIG_RTE_LIBRTE_KVARGS),y)
109 LDLIBS += -lrte_kvargs
110 endif
111
112 ifeq ($(CONFIG_RTE_LIBRTE_MBUF),y)
113 LDLIBS += -lrte_mbuf
114 endif
115
116 ifeq ($(CONFIG_RTE_LIBRTE_ETHER),y)
117 LDLIBS += -lethdev
118 endif
119
120 ifeq ($(CONFIG_RTE_LIBRTE_MALLOC),y)
121 LDLIBS += -lrte_malloc
122 endif
123
124 ifeq ($(CONFIG_RTE_LIBRTE_MEMPOOL),y)
125 LDLIBS += -lrte_mempool
126 endif
127
128 ifeq ($(CONFIG_RTE_LIBRTE_RING),y)
129 LDLIBS += -lrte_ring
130 endif
131
132 ifeq ($(CONFIG_RTE_LIBC),y)
133 LDLIBS += -lc
134 LDLIBS += -lm
135 endif
136
137 ifeq ($(CONFIG_RTE_LIBGLOSS),y)
138 LDLIBS += -lgloss
139 endif
140
141 ifeq ($(CONFIG_RTE_LIBRTE_EAL),y)
142 LDLIBS += -lrte_eal
143 endif
144
145 ifeq ($(CONFIG_RTE_LIBRTE_CMDLINE),y)
146 LDLIBS += -lrte_cmdline
147 endif
148
149 ifeq ($(CONFIG_RTE_LIBRTE_PMD_XENVIRT),y)
150 LDLIBS += -lrte_pmd_xenvirt
151 LDLIBS += -lxenstore
152 endif
153
154 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),n)
155
156 ifeq ($(CONFIG_RTE_LIBRTE_VMXNET3_PMD),y)
157 LDLIBS += -lrte_pmd_vmxnet3_uio
158 endif
159
160 ifeq ($(CONFIG_RTE_LIBRTE_VIRTIO_PMD),y)
161 LDLIBS += -lrte_pmd_virtio_uio
162 endif
163
164 ifeq ($(CONFIG_RTE_LIBRTE_IXGBE_PMD),y)
165 LDLIBS += -lrte_pmd_ixgbe
166 endif
167
168 ifeq ($(CONFIG_RTE_LIBRTE_E1000_PMD),y)
169 LDLIBS += -lrte_pmd_e1000
170 endif
171
172 ifeq ($(CONFIG_RTE_LIBRTE_PMD_RING),y)
173 LDLIBS += -lrte_pmd_ring
174 endif
175
176 ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y)
177 LDLIBS += -lrte_pmd_pcap -lpcap
178 endif
179
180 endif
181
182 LDLIBS += $(EXECENV_LDLIBS)
183
184 LDLIBS += --end-group
185
186 LDLIBS += --no-whole-archive
187
188 endif # ifeq ($(NO_AUTOLIBS),)
189
190 LDLIBS += $(CPU_LDLIBS)
191
192 .PHONY: all
193 all: install
194
195 .PHONY: install
196 install: build _postinstall
197
198 _postinstall: build
199
200 .PHONY: build
201 build: _postbuild
202
203 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
204
205 ifeq ($(RTE_BUILD_COMBINE_LIBS),y)
206 LDLIBS += -l$(RTE_LIBNAME)
207 endif
208
209 ifeq ($(LINK_USING_CC),1)
210 LDLIBS := $(call linkerprefix,$(LDLIBS))
211 LDFLAGS := $(call linkerprefix,$(LDFLAGS))
212 override EXTRA_LDFLAGS := $(call linkerprefix,$(EXTRA_LDFLAGS))
213 O_TO_EXE = $(CC) $(CFLAGS) $(LDFLAGS_$(@)) \
214         -Wl,-Map=$(@).map,--cref -o $@ $(OBJS-y) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDLIBS)
215 else
216 O_TO_EXE = $(LD) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
217         -Map=$(@).map --cref -o $@ $(OBJS-y) $(LDLIBS)
218 endif
219 O_TO_EXE_STR = $(subst ','\'',$(O_TO_EXE)) #'# fix syntax highlight
220 O_TO_EXE_DISP = $(if $(V),"$(O_TO_EXE_STR)","  LD $(@)")
221 O_TO_EXE_CMD = "cmd_$@ = $(O_TO_EXE_STR)"
222 O_TO_EXE_DO = @set -e; \
223         echo $(O_TO_EXE_DISP); \
224         $(O_TO_EXE) && \
225         echo $(O_TO_EXE_CMD) > $(call exe2cmd,$(@))
226
227 -include .$(APP).cmd
228
229 # path where libraries are retrieved
230 LDLIBS_PATH := $(subst -Wl$(comma)-L,,$(filter -Wl$(comma)-L%,$(LDLIBS)))
231 LDLIBS_PATH += $(subst -L,,$(filter -L%,$(LDLIBS)))
232
233 # list of .a files that are linked to this application
234 LDLIBS_NAMES := $(patsubst -l%,lib%.a,$(filter -l%,$(LDLIBS)))
235 LDLIBS_NAMES += $(patsubst -Wl$(comma)-l%,lib%.a,$(filter -Wl$(comma)-l%,$(LDLIBS)))
236
237 # list of found libraries files (useful for deps). If not found, the
238 # library is silently ignored and dep won't be checked
239 LDLIBS_FILES := $(wildcard $(foreach dir,$(LDLIBS_PATH),\
240         $(addprefix $(dir)/,$(LDLIBS_NAMES))))
241
242 #
243 # Compile executable file if needed
244 #
245 $(APP): $(OBJS-y) $(LDLIBS_FILES) $(DEP_$(APP)) $(LDSCRIPT) FORCE
246         @[ -d $(dir $@) ] || mkdir -p $(dir $@)
247         $(if $(D),\
248                 @echo -n "$< -> $@ " ; \
249                 echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
250                 echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_EXE_STR))) " ; \
251                 echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
252                 echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
253         $(if $(or \
254                 $(file_missing),\
255                 $(call cmdline_changed,$(O_TO_EXE_STR)),\
256                 $(depfile_missing),\
257                 $(depfile_newer)),\
258                 $(O_TO_EXE_DO))
259
260 #
261 # install app in $(RTE_OUTPUT)/app
262 #
263 $(RTE_OUTPUT)/app/$(APP): $(APP)
264         @echo "  INSTALL-APP $(APP)"
265         @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
266         $(Q)cp -f $(APP) $(RTE_OUTPUT)/app
267
268 #
269 # install app map file in $(RTE_OUTPUT)/app
270 #
271 $(RTE_OUTPUT)/app/$(APP).map: $(APP)
272         @echo "  INSTALL-MAP $(APP).map"
273         @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
274         $(Q)cp -f $(APP).map $(RTE_OUTPUT)/app
275
276 #
277 # Clean all generated files
278 #
279 .PHONY: clean
280 clean: _postclean
281         $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
282
283 .PHONY: doclean
284 doclean:
285         $(Q)rm -rf $(APP) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
286           $(CMDS-all) $(INSTALL-FILES-all) .$(APP).cmd
287
288
289 include $(RTE_SDK)/mk/internal/rte.compile-post.mk
290 include $(RTE_SDK)/mk/internal/rte.install-post.mk
291 include $(RTE_SDK)/mk/internal/rte.clean-post.mk
292 include $(RTE_SDK)/mk/internal/rte.build-post.mk
293 include $(RTE_SDK)/mk/internal/rte.depdirs-post.mk
294
295 ifneq ($(wildcard $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk),)
296 include $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk
297 else
298 include $(RTE_SDK)/mk/target/generic/rte.app.mk
299 endif
300
301 .PHONY: FORCE
302 FORCE: