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_LIBRTE_DISTRIBUTOR),y)
65 LDLIBS += -lrte_distributor
68 ifeq ($(CONFIG_RTE_LIBRTE_KNI),y)
69 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
74 ifeq ($(CONFIG_RTE_LIBRTE_IVSHMEM),y)
75 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
76 LDLIBS += -lrte_ivshmem
80 ifeq ($(CONFIG_RTE_LIBRTE_TIMER),y)
84 ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
88 ifeq ($(CONFIG_RTE_LIBRTE_LPM),y)
92 ifeq ($(CONFIG_RTE_LIBRTE_POWER),y)
96 ifeq ($(CONFIG_RTE_LIBRTE_ACL),y)
100 ifeq ($(CONFIG_RTE_LIBRTE_METER),y)
101 LDLIBS += -lrte_meter
104 ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
105 LDLIBS += -lrte_sched
110 LDLIBS += --start-group
112 ifeq ($(CONFIG_RTE_LIBRTE_KVARGS),y)
113 LDLIBS += -lrte_kvargs
116 ifeq ($(CONFIG_RTE_LIBRTE_MBUF),y)
120 ifeq ($(CONFIG_RTE_LIBRTE_IP_FRAG),y)
121 LDLIBS += -lrte_ip_frag
124 ifeq ($(CONFIG_RTE_LIBRTE_ETHER),y)
128 ifeq ($(CONFIG_RTE_LIBRTE_MALLOC),y)
129 LDLIBS += -lrte_malloc
132 ifeq ($(CONFIG_RTE_LIBRTE_MEMPOOL),y)
133 LDLIBS += -lrte_mempool
136 ifeq ($(CONFIG_RTE_LIBRTE_RING),y)
140 ifeq ($(CONFIG_RTE_LIBC),y)
145 ifeq ($(CONFIG_RTE_LIBGLOSS),y)
149 ifeq ($(CONFIG_RTE_LIBRTE_EAL),y)
153 ifeq ($(CONFIG_RTE_LIBRTE_CMDLINE),y)
154 LDLIBS += -lrte_cmdline
157 ifeq ($(CONFIG_RTE_LIBRTE_PMD_XENVIRT),y)
158 LDLIBS += -lrte_pmd_xenvirt
162 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),n)
164 ifeq ($(CONFIG_RTE_LIBRTE_VMXNET3_PMD),y)
165 LDLIBS += -lrte_pmd_vmxnet3_uio
168 ifeq ($(CONFIG_RTE_LIBRTE_VIRTIO_PMD),y)
169 LDLIBS += -lrte_pmd_virtio_uio
172 ifeq ($(CONFIG_RTE_LIBRTE_IXGBE_PMD),y)
173 LDLIBS += -lrte_pmd_ixgbe
176 ifeq ($(CONFIG_RTE_LIBRTE_E1000_PMD),y)
177 LDLIBS += -lrte_pmd_e1000
180 ifeq ($(CONFIG_RTE_LIBRTE_PMD_RING),y)
181 LDLIBS += -lrte_pmd_ring
184 ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y)
185 LDLIBS += -lrte_pmd_pcap -lpcap
190 LDLIBS += $(EXECENV_LDLIBS)
192 LDLIBS += --end-group
194 LDLIBS += --no-whole-archive
196 endif # ifeq ($(NO_AUTOLIBS),)
198 LDLIBS += $(CPU_LDLIBS)
204 install: build _postinstall
211 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
213 ifeq ($(RTE_BUILD_COMBINE_LIBS),y)
214 LDLIBS += -l$(RTE_LIBNAME)
217 ifeq ($(LINK_USING_CC),1)
218 LDLIBS := $(call linkerprefix,$(LDLIBS))
219 LDFLAGS := $(call linkerprefix,$(LDFLAGS))
220 override EXTRA_LDFLAGS := $(call linkerprefix,$(EXTRA_LDFLAGS))
221 O_TO_EXE = $(CC) $(CFLAGS) $(LDFLAGS_$(@)) \
222 -Wl,-Map=$(@).map,--cref -o $@ $(OBJS-y) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDLIBS)
224 O_TO_EXE = $(LD) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
225 -Map=$(@).map --cref -o $@ $(OBJS-y) $(LDLIBS)
227 O_TO_EXE_STR = $(subst ','\'',$(O_TO_EXE)) #'# fix syntax highlight
228 O_TO_EXE_DISP = $(if $(V),"$(O_TO_EXE_STR)"," LD $(@)")
229 O_TO_EXE_CMD = "cmd_$@ = $(O_TO_EXE_STR)"
230 O_TO_EXE_DO = @set -e; \
231 echo $(O_TO_EXE_DISP); \
233 echo $(O_TO_EXE_CMD) > $(call exe2cmd,$(@))
237 # path where libraries are retrieved
238 LDLIBS_PATH := $(subst -Wl$(comma)-L,,$(filter -Wl$(comma)-L%,$(LDLIBS)))
239 LDLIBS_PATH += $(subst -L,,$(filter -L%,$(LDLIBS)))
241 # list of .a files that are linked to this application
242 LDLIBS_NAMES := $(patsubst -l%,lib%.a,$(filter -l%,$(LDLIBS)))
243 LDLIBS_NAMES += $(patsubst -Wl$(comma)-l%,lib%.a,$(filter -Wl$(comma)-l%,$(LDLIBS)))
245 # list of found libraries files (useful for deps). If not found, the
246 # library is silently ignored and dep won't be checked
247 LDLIBS_FILES := $(wildcard $(foreach dir,$(LDLIBS_PATH),\
248 $(addprefix $(dir)/,$(LDLIBS_NAMES))))
251 # Compile executable file if needed
253 $(APP): $(OBJS-y) $(LDLIBS_FILES) $(DEP_$(APP)) $(LDSCRIPT) FORCE
254 @[ -d $(dir $@) ] || mkdir -p $(dir $@)
256 @echo -n "$< -> $@ " ; \
257 echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
258 echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_EXE_STR))) " ; \
259 echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
260 echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
263 $(call cmdline_changed,$(O_TO_EXE_STR)),\
269 # install app in $(RTE_OUTPUT)/app
271 $(RTE_OUTPUT)/app/$(APP): $(APP)
272 @echo " INSTALL-APP $(APP)"
273 @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
274 $(Q)cp -f $(APP) $(RTE_OUTPUT)/app
277 # install app map file in $(RTE_OUTPUT)/app
279 $(RTE_OUTPUT)/app/$(APP).map: $(APP)
280 @echo " INSTALL-MAP $(APP).map"
281 @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
282 $(Q)cp -f $(APP).map $(RTE_OUTPUT)/app
285 # Clean all generated files
289 $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
293 $(Q)rm -rf $(APP) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
294 $(CMDS-all) $(INSTALL-FILES-all) .$(APP).cmd
297 include $(RTE_SDK)/mk/internal/rte.compile-post.mk
298 include $(RTE_SDK)/mk/internal/rte.install-post.mk
299 include $(RTE_SDK)/mk/internal/rte.clean-post.mk
300 include $(RTE_SDK)/mk/internal/rte.build-post.mk
301 include $(RTE_SDK)/mk/internal/rte.depdirs-post.mk
303 ifneq ($(wildcard $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk),)
304 include $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk
306 include $(RTE_SDK)/mk/target/generic/rte.app.mk