3 # Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
4 # Copyright(c) 2014 6WIND S.A.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
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
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.
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.
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
39 # VPATH contains at least SRCDIR
43 _INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y)
44 _INSTALL += $(RTE_OUTPUT)/app/$(APP) $(RTE_OUTPUT)/app/$(APP).map
45 POSTINSTALL += target-appinstall
47 POSTCLEAN += target-appclean
49 ifeq ($(NO_LDSCRIPT),)
50 LDSCRIPT = $(RTE_LDSCRIPT)
53 # default path for libs
54 LDLIBS += -L$(RTE_SDK_BIN)/lib
57 # Include libraries depending on config if NO_AUTOLIBS is not set
58 # Order is important: from higher level to lower level
60 ifeq ($(NO_AUTOLIBS),)
62 LDLIBS += --whole-archive
64 ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS),y)
65 LDLIBS += -l$(RTE_LIBNAME)
68 ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS),n)
70 ifeq ($(CONFIG_RTE_LIBRTE_DISTRIBUTOR),y)
71 LDLIBS += -lrte_distributor
74 ifeq ($(CONFIG_RTE_LIBRTE_KNI),y)
75 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
80 ifeq ($(CONFIG_RTE_LIBRTE_IVSHMEM),y)
81 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
82 LDLIBS += -lrte_ivshmem
86 ifeq ($(CONFIG_RTE_LIBRTE_PIPELINE),y)
87 LDLIBS += -lrte_pipeline
90 ifeq ($(CONFIG_RTE_LIBRTE_TABLE),y)
94 ifeq ($(CONFIG_RTE_LIBRTE_PORT),y)
98 ifeq ($(CONFIG_RTE_LIBRTE_TIMER),y)
102 ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
106 ifeq ($(CONFIG_RTE_LIBRTE_LPM),y)
110 ifeq ($(CONFIG_RTE_LIBRTE_POWER),y)
111 LDLIBS += -lrte_power
114 ifeq ($(CONFIG_RTE_LIBRTE_ACL),y)
118 ifeq ($(CONFIG_RTE_LIBRTE_METER),y)
119 LDLIBS += -lrte_meter
122 ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
123 LDLIBS += -lrte_sched
128 endif # ! CONFIG_RTE_BUILD_COMBINE_LIBS
130 ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y)
134 ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y)
138 LDLIBS += --start-group
140 ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS),n)
142 ifeq ($(CONFIG_RTE_LIBRTE_KVARGS),y)
143 LDLIBS += -lrte_kvargs
146 ifeq ($(CONFIG_RTE_LIBRTE_MBUF),y)
150 ifeq ($(CONFIG_RTE_LIBRTE_IP_FRAG),y)
151 LDLIBS += -lrte_ip_frag
154 ifeq ($(CONFIG_RTE_LIBRTE_ETHER),y)
158 ifeq ($(CONFIG_RTE_LIBRTE_MALLOC),y)
159 LDLIBS += -lrte_malloc
162 ifeq ($(CONFIG_RTE_LIBRTE_MEMPOOL),y)
163 LDLIBS += -lrte_mempool
166 ifeq ($(CONFIG_RTE_LIBRTE_RING),y)
170 ifeq ($(CONFIG_RTE_LIBRTE_EAL),y)
174 ifeq ($(CONFIG_RTE_LIBRTE_CMDLINE),y)
175 LDLIBS += -lrte_cmdline
178 ifeq ($(CONFIG_RTE_LIBRTE_CFGFILE),y)
179 LDLIBS += -lrte_cfgfile
182 ifeq ($(CONFIG_RTE_LIBRTE_PMD_BOND),y)
183 LDLIBS += -lrte_pmd_bond
186 ifeq ($(CONFIG_RTE_LIBRTE_PMD_XENVIRT),y)
187 LDLIBS += -lrte_pmd_xenvirt
191 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),n)
192 # plugins (link only if static libraries)
194 ifeq ($(CONFIG_RTE_LIBRTE_VMXNET3_PMD),y)
195 LDLIBS += -lrte_pmd_vmxnet3_uio
198 ifeq ($(CONFIG_RTE_LIBRTE_VIRTIO_PMD),y)
199 LDLIBS += -lrte_pmd_virtio_uio
202 ifeq ($(CONFIG_RTE_LIBRTE_VHOST), y)
203 LDLIBS += -lrte_vhost
206 ifeq ($(CONFIG_RTE_LIBRTE_ENIC_PMD),y)
207 LDLIBS += -lrte_pmd_enic
210 ifeq ($(CONFIG_RTE_LIBRTE_I40E_PMD),y)
211 LDLIBS += -lrte_pmd_i40e
214 ifeq ($(CONFIG_RTE_LIBRTE_IXGBE_PMD),y)
215 LDLIBS += -lrte_pmd_ixgbe
218 ifeq ($(CONFIG_RTE_LIBRTE_E1000_PMD),y)
219 LDLIBS += -lrte_pmd_e1000
222 ifeq ($(CONFIG_RTE_LIBRTE_PMD_RING),y)
223 LDLIBS += -lrte_pmd_ring
226 ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y)
227 LDLIBS += -lrte_pmd_pcap
230 ifeq ($(CONFIG_RTE_LIBRTE_PMD_AF_PACKET),y)
231 LDLIBS += -lrte_pmd_af_packet
236 endif # ! CONFIG_RTE_BUILD_COMBINE_LIBS
238 LDLIBS += $(EXECENV_LDLIBS)
240 LDLIBS += --end-group
242 LDLIBS += --no-whole-archive
244 endif # ifeq ($(NO_AUTOLIBS),)
246 LDLIBS += $(CPU_LDLIBS)
252 install: build _postinstall
259 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
261 ifeq ($(LINK_USING_CC),1)
262 override EXTRA_LDFLAGS := $(call linkerprefix,$(EXTRA_LDFLAGS))
263 O_TO_EXE = $(CC) $(CFLAGS) $(LDFLAGS_$(@)) \
264 -Wl,-Map=$(@).map,--cref -o $@ $(OBJS-y) $(call linkerprefix,$(LDFLAGS)) \
265 $(EXTRA_LDFLAGS) $(call linkerprefix,$(LDLIBS))
267 O_TO_EXE = $(LD) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
268 -Map=$(@).map --cref -o $@ $(OBJS-y) $(LDLIBS)
270 O_TO_EXE_STR = $(subst ','\'',$(O_TO_EXE)) #'# fix syntax highlight
271 O_TO_EXE_DISP = $(if $(V),"$(O_TO_EXE_STR)"," LD $(@)")
272 O_TO_EXE_CMD = "cmd_$@ = $(O_TO_EXE_STR)"
273 O_TO_EXE_DO = @set -e; \
274 echo $(O_TO_EXE_DISP); \
276 echo $(O_TO_EXE_CMD) > $(call exe2cmd,$(@))
280 # path where libraries are retrieved
281 LDLIBS_PATH := $(subst -Wl$(comma)-L,,$(filter -Wl$(comma)-L%,$(LDLIBS)))
282 LDLIBS_PATH += $(subst -L,,$(filter -L%,$(LDLIBS)))
284 # list of .a files that are linked to this application
285 LDLIBS_NAMES := $(patsubst -l%,lib%.a,$(filter -l%,$(LDLIBS)))
286 LDLIBS_NAMES += $(patsubst -Wl$(comma)-l%,lib%.a,$(filter -Wl$(comma)-l%,$(LDLIBS)))
288 # list of found libraries files (useful for deps). If not found, the
289 # library is silently ignored and dep won't be checked
290 LDLIBS_FILES := $(wildcard $(foreach dir,$(LDLIBS_PATH),\
291 $(addprefix $(dir)/,$(LDLIBS_NAMES))))
294 # Compile executable file if needed
296 $(APP): $(OBJS-y) $(LDLIBS_FILES) $(DEP_$(APP)) $(LDSCRIPT) FORCE
297 @[ -d $(dir $@) ] || mkdir -p $(dir $@)
299 @echo -n "$< -> $@ " ; \
300 echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
301 echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_EXE_STR))) " ; \
302 echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
303 echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
306 $(call cmdline_changed,$(O_TO_EXE_STR)),\
312 # install app in $(RTE_OUTPUT)/app
314 $(RTE_OUTPUT)/app/$(APP): $(APP)
315 @echo " INSTALL-APP $(APP)"
316 @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
317 $(Q)cp -f $(APP) $(RTE_OUTPUT)/app
320 # install app map file in $(RTE_OUTPUT)/app
322 $(RTE_OUTPUT)/app/$(APP).map: $(APP)
323 @echo " INSTALL-MAP $(APP).map"
324 @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
325 $(Q)cp -f $(APP).map $(RTE_OUTPUT)/app
328 # Clean all generated files
332 $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
336 $(Q)rm -rf $(APP) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
337 $(CMDS-all) $(INSTALL-FILES-all) .$(APP).cmd
340 include $(RTE_SDK)/mk/internal/rte.compile-post.mk
341 include $(RTE_SDK)/mk/internal/rte.install-post.mk
342 include $(RTE_SDK)/mk/internal/rte.clean-post.mk
343 include $(RTE_SDK)/mk/internal/rte.build-post.mk
344 include $(RTE_SDK)/mk/internal/rte.depdirs-post.mk
346 ifneq ($(wildcard $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk),)
347 include $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk
349 include $(RTE_SDK)/mk/target/generic/rte.app.mk