3 # Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
10 # * Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # * Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in
14 # the documentation and/or other materials provided with the
16 # * Neither the name of Intel Corporation nor the names of its
17 # contributors may be used to endorse or promote products derived
18 # from this software without specific prior written permission.
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 include $(RTE_SDK)/mk/internal/rte.compile-pre.mk
33 include $(RTE_SDK)/mk/internal/rte.install-pre.mk
34 include $(RTE_SDK)/mk/internal/rte.clean-pre.mk
35 include $(RTE_SDK)/mk/internal/rte.build-pre.mk
36 include $(RTE_SDK)/mk/internal/rte.depdirs-pre.mk
38 # VPATH contains at least SRCDIR
42 _INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y)
43 _INSTALL += $(RTE_OUTPUT)/app/$(APP) $(RTE_OUTPUT)/app/$(APP).map
44 POSTINSTALL += target-appinstall
46 POSTCLEAN += target-appclean
48 ifeq ($(NO_LDSCRIPT),)
49 LDSCRIPT = $(RTE_LDSCRIPT)
52 # default path for libs
53 LDLIBS += -L$(RTE_SDK_BIN)/lib
56 # Include libraries depending on config if NO_AUTOLIBS is not set
57 # Order is important: from higher level to lower level
59 ifeq ($(NO_AUTOLIBS),)
61 ifeq ($(CONFIG_RTE_LIBRTE_KNI),y)
62 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
67 ifeq ($(CONFIG_RTE_LIBRTE_IVSHMEM),y)
68 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
69 LDLIBS += -lrte_ivshmem
73 ifeq ($(CONFIG_RTE_LIBRTE_E1000_PMD),y)
74 LDLIBS += -lrte_pmd_e1000
77 ifeq ($(CONFIG_RTE_LIBRTE_IXGBE_PMD),y)
78 LDLIBS += -lrte_pmd_ixgbe
81 ifeq ($(CONFIG_RTE_LIBRTE_VIRTIO_PMD),y)
82 LDLIBS += -lrte_pmd_virtio
85 ifeq ($(CONFIG_RTE_LIBRTE_VMXNET3_PMD),y)
86 LDLIBS += -lrte_pmd_vmxnet3
89 ifeq ($(CONFIG_RTE_LIBRTE_TIMER),y)
93 ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
97 ifeq ($(CONFIG_RTE_LIBRTE_LPM),y)
101 ifeq ($(CONFIG_RTE_LIBRTE_POWER),y)
102 LDLIBS += -lrte_power
105 ifeq ($(CONFIG_RTE_LIBRTE_ACL),y)
109 ifeq ($(CONFIG_RTE_LIBRTE_METER),y)
110 LDLIBS += -lrte_meter
113 ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
114 LDLIBS += -lrte_sched
119 LDLIBS += --start-group
121 ifeq ($(CONFIG_RTE_LIBRTE_KVARGS),y)
122 LDLIBS += -lrte_kvargs
125 ifeq ($(CONFIG_RTE_LIBRTE_MBUF),y)
129 ifeq ($(CONFIG_RTE_LIBRTE_ETHER),y)
133 ifeq ($(CONFIG_RTE_LIBRTE_PMD_RING),y)
134 LDLIBS += -lrte_pmd_ring
137 ifeq ($(CONFIG_RTE_LIBRTE_MALLOC),y)
138 LDLIBS += -lrte_malloc
141 ifeq ($(CONFIG_RTE_LIBRTE_MEMPOOL),y)
142 LDLIBS += -lrte_mempool
145 ifeq ($(CONFIG_RTE_LIBRTE_RING),y)
149 ifeq ($(CONFIG_RTE_LIBC),y)
154 ifeq ($(CONFIG_RTE_LIBGLOSS),y)
158 ifeq ($(CONFIG_RTE_LIBRTE_EAL),y)
163 ifeq ($(CONFIG_RTE_LIBRTE_PMD_XENVIRT),y)
164 LDLIBS += -lrte_pmd_xenvirt
168 ifeq ($(CONFIG_RTE_LIBRTE_CMDLINE),y)
169 LDLIBS += -lrte_cmdline
172 ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y)
173 LDLIBS += -lrte_pmd_pcap -lpcap
176 LDLIBS += $(EXECENV_LDLIBS)
178 LDLIBS += --end-group
180 endif # ifeq ($(NO_AUTOLIBS),)
182 LDLIBS += $(CPU_LDLIBS)
188 install: build _postinstall
195 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
197 ifeq ($(RTE_BUILD_COMBINE_LIBS),y)
198 LDLIBS += -l$(RTE_LIBNAME)
201 ifeq ($(LINK_USING_CC),1)
203 LDLIBS := $(addprefix -Wl$(comma),$(LDLIBS))
204 LDFLAGS := $(addprefix -Wl$(comma),$(LDFLAGS))
205 override EXTRA_LDFLAGS := $(addprefix -Wl$(comma),$(EXTRA_LDFLAGS))
206 O_TO_EXE = $(CC) $(CFLAGS) $(LDFLAGS_$(@)) \
207 -Wl,-Map=$(@).map,--cref -o $@ $(OBJS-y) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDLIBS)
209 O_TO_EXE = $(LD) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
210 -Map=$(@).map --cref -o $@ $(OBJS-y) $(LDLIBS)
212 O_TO_EXE_STR = $(subst ','\'',$(O_TO_EXE)) #'# fix syntax highlight
213 O_TO_EXE_DISP = $(if $(V),"$(O_TO_EXE_STR)"," LD $(@)")
214 O_TO_EXE_CMD = "cmd_$@ = $(O_TO_EXE_STR)"
215 O_TO_EXE_DO = @set -e; \
216 echo $(O_TO_EXE_DISP); \
218 echo $(O_TO_EXE_CMD) > $(call exe2cmd,$(@))
222 # path where libraries are retrieved
223 LDLIBS_PATH := $(subst -Wl$(comma)-L,,$(filter -Wl$(comma)-L%,$(LDLIBS)))
224 LDLIBS_PATH += $(subst -L,,$(filter -L%,$(LDLIBS)))
226 # list of .a files that are linked to this application
227 LDLIBS_NAMES := $(patsubst -l%,lib%.a,$(filter -l%,$(LDLIBS)))
228 LDLIBS_NAMES += $(patsubst -Wl$(comma)-l%,lib%.a,$(filter -Wl$(comma)-l%,$(LDLIBS)))
230 # list of found libraries files (useful for deps). If not found, the
231 # library is silently ignored and dep won't be checked
232 LDLIBS_FILES := $(wildcard $(foreach dir,$(LDLIBS_PATH),\
233 $(addprefix $(dir)/,$(LDLIBS_NAMES))))
236 # Compile executable file if needed
238 $(APP): $(OBJS-y) $(LDLIBS_FILES) $(DEP_$(APP)) $(LDSCRIPT) FORCE
239 @[ -d $(dir $@) ] || mkdir -p $(dir $@)
241 @echo -n "$< -> $@ " ; \
242 echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
243 echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_EXE_STR))) " ; \
244 echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
245 echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
248 $(call cmdline_changed,$(O_TO_EXE_STR)),\
254 # install app in $(RTE_OUTPUT)/app
256 $(RTE_OUTPUT)/app/$(APP): $(APP)
257 @echo " INSTALL-APP $(APP)"
258 @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
259 $(Q)cp -f $(APP) $(RTE_OUTPUT)/app
262 # install app map file in $(RTE_OUTPUT)/app
264 $(RTE_OUTPUT)/app/$(APP).map: $(APP)
265 @echo " INSTALL-MAP $(APP).map"
266 @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
267 $(Q)cp -f $(APP).map $(RTE_OUTPUT)/app
270 # Clean all generated files
274 $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
278 $(Q)rm -rf $(APP) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
279 $(CMDS-all) $(INSTALL-FILES-all) .$(APP).cmd
282 include $(RTE_SDK)/mk/internal/rte.compile-post.mk
283 include $(RTE_SDK)/mk/internal/rte.install-post.mk
284 include $(RTE_SDK)/mk/internal/rte.clean-post.mk
285 include $(RTE_SDK)/mk/internal/rte.build-post.mk
286 include $(RTE_SDK)/mk/internal/rte.depdirs-post.mk
288 ifneq ($(wildcard $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk),)
289 include $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk
291 include $(RTE_SDK)/mk/target/generic/rte.app.mk