3 # Copyright(c) 2010-2012 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.
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 ifeq ($(CONFIG_RTE_LIBRTE_KNI),y)
63 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
68 ifeq ($(CONFIG_RTE_LIBRTE_E1000_PMD),y)
69 LDLIBS += -lrte_pmd_e1000
72 ifeq ($(CONFIG_RTE_LIBRTE_IXGBE_PMD),y)
73 LDLIBS += -lrte_pmd_ixgbe
76 ifeq ($(CONFIG_RTE_LIBRTE_MBUF),y)
80 ifeq ($(CONFIG_RTE_LIBRTE_CMDLINE),y)
81 LDLIBS += -lrte_cmdline
84 ifeq ($(CONFIG_RTE_LIBRTE_TIMER),y)
88 ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
92 ifeq ($(CONFIG_RTE_LIBRTE_LPM),y)
96 ifeq ($(CONFIG_RTE_LIBRTE_PMAC),y)
100 LDLIBS += --start-group
102 ifeq ($(CONFIG_RTE_LIBRTE_ETHER),y)
106 ifeq ($(CONFIG_RTE_LIBRTE_MALLOC),y)
107 LDLIBS += -lrte_malloc
110 ifeq ($(CONFIG_RTE_LIBRTE_MEMPOOL),y)
111 LDLIBS += -lrte_mempool
114 ifeq ($(CONFIG_RTE_LIBRTE_RING),y)
118 ifeq ($(CONFIG_RTE_LIBC),y)
122 ifeq ($(CONFIG_RTE_LIBGLOSS),y)
126 ifeq ($(CONFIG_RTE_LIBRTE_EAL),y)
130 LDLIBS += $(EXECENV_LDLIBS)
132 LDLIBS += --end-group
134 endif # ifeq ($(NO_AUTOLIBS),)
136 LDLIBS += $(CPU_LDLIBS)
142 install: build _postinstall
149 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
151 ifeq ($(LINK_USING_CC),1)
153 LDLIBS := $(addprefix -Wl$(comma),$(LDLIBS))
154 LDFLAGS := $(addprefix -Wl$(comma),$(LDFLAGS))
155 EXTRA_LDFLAGS := $(addprefix -Wl$(comma),$(EXTRA_LDFLAGS))
156 O_TO_EXE = $(CC) $(CFLAGS) $(LDFLAGS_$(@)) \
157 -Wl,-Map=$(@).map,--cref -o $@ $(OBJS-y) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDLIBS)
159 O_TO_EXE = $(LD) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
160 -Map=$(@).map --cref -o $@ $(OBJS-y) $(LDLIBS)
162 O_TO_EXE_STR = $(subst ','\'',$(O_TO_EXE)) #'# fix syntax highlight
163 O_TO_EXE_DISP = $(if $(V),"$(O_TO_EXE_STR)"," LD $(@)")
164 O_TO_EXE_CMD = "cmd_$@ = $(O_TO_EXE_STR)"
165 O_TO_EXE_DO = @set -e; \
166 echo $(O_TO_EXE_DISP); \
168 echo $(O_TO_EXE_CMD) > $(call exe2cmd,$(@))
172 # path where libraries are retrieved
173 LDLIBS_PATH := $(subst -Wl$(comma)-L,,$(filter -Wl$(comma)-L%,$(LDLIBS)))
174 LDLIBS_PATH += $(subst -L,,$(filter -L%,$(LDLIBS)))
176 # list of .a files that are linked to this application
177 LDLIBS_NAMES := $(patsubst -l%,lib%.a,$(filter -l%,$(LDLIBS)))
178 LDLIBS_NAMES += $(patsubst -Wl$(comma)-l%,lib%.a,$(filter -Wl$(comma)-l%,$(LDLIBS)))
180 # list of found libraries files (useful for deps). If not found, the
181 # library is silently ignored and dep won't be checked
182 LDLIBS_FILES := $(wildcard $(foreach dir,$(LDLIBS_PATH),\
183 $(addprefix $(dir)/,$(LDLIBS_NAMES))))
186 # Compile executable file if needed
188 $(APP): $(OBJS-y) $(LDLIBS_FILES) $(DEP_$(APP)) $(LDSCRIPT) FORCE
189 @[ -d $(dir $@) ] || mkdir -p $(dir $@)
191 @echo -n "$< -> $@ " ; \
192 echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
193 echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_EXE_STR))) " ; \
194 echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
195 echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
198 $(call cmdline_changed,$(O_TO_EXE_STR)),\
204 # install app in $(RTE_OUTPUT)/app
206 $(RTE_OUTPUT)/app/$(APP): $(APP)
207 @echo " INSTALL-APP $(APP)"
208 @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
209 $(Q)cp -f $(APP) $(RTE_OUTPUT)/app
212 # install app map file in $(RTE_OUTPUT)/app
214 $(RTE_OUTPUT)/app/$(APP).map: $(APP)
215 @echo " INSTALL-MAP $(APP).map"
216 @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
217 $(Q)cp -f $(APP).map $(RTE_OUTPUT)/app
220 # Clean all generated files
224 $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
228 $(Q)rm -rf $(APP) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
229 $(CMDS-all) $(INSTALL-FILES-all) .$(APP).cmd
232 include $(RTE_SDK)/mk/internal/rte.compile-post.mk
233 include $(RTE_SDK)/mk/internal/rte.install-post.mk
234 include $(RTE_SDK)/mk/internal/rte.clean-post.mk
235 include $(RTE_SDK)/mk/internal/rte.build-post.mk
236 include $(RTE_SDK)/mk/internal/rte.depdirs-post.mk
238 ifneq ($(wildcard $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk),)
239 include $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk
241 include $(RTE_SDK)/mk/target/generic/rte.app.mk