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.
32 # version: DPDK.L.1.2.3-3
34 include $(RTE_SDK)/mk/internal/rte.compile-pre.mk
35 include $(RTE_SDK)/mk/internal/rte.install-pre.mk
36 include $(RTE_SDK)/mk/internal/rte.clean-pre.mk
37 include $(RTE_SDK)/mk/internal/rte.build-pre.mk
38 include $(RTE_SDK)/mk/internal/rte.depdirs-pre.mk
40 # VPATH contains at least SRCDIR
44 _INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y)
45 _INSTALL += $(RTE_OUTPUT)/app/$(APP) $(RTE_OUTPUT)/app/$(APP).map
46 POSTINSTALL += target-appinstall
48 POSTCLEAN += target-appclean
50 ifeq ($(NO_LDSCRIPT),)
51 LDSCRIPT = $(RTE_LDSCRIPT)
54 # default path for libs
55 LDLIBS += -L$(RTE_SDK_BIN)/lib
58 # Include libraries depending on config if NO_AUTOLIBS is not set
59 # Order is important: from higher level to lower level
61 ifeq ($(NO_AUTOLIBS),)
63 ifeq ($(CONFIG_RTE_LIBRTE_IGB_PMD),y)
64 LDLIBS += -lrte_pmd_igb
67 ifeq ($(CONFIG_RTE_LIBRTE_IXGBE_PMD),y)
68 LDLIBS += -lrte_pmd_ixgbe
71 ifeq ($(CONFIG_RTE_LIBRTE_MBUF),y)
75 ifeq ($(CONFIG_RTE_LIBRTE_CMDLINE),y)
76 LDLIBS += -lrte_cmdline
79 ifeq ($(CONFIG_RTE_LIBRTE_TIMER),y)
83 ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
87 ifeq ($(CONFIG_RTE_LIBRTE_LPM),y)
91 LDLIBS += --start-group
93 ifeq ($(CONFIG_RTE_LIBRTE_ETHER),y)
97 ifeq ($(CONFIG_RTE_LIBRTE_MALLOC),y)
98 LDLIBS += -lrte_malloc
101 ifeq ($(CONFIG_RTE_LIBRTE_MEMPOOL),y)
102 LDLIBS += -lrte_mempool
105 ifeq ($(CONFIG_RTE_LIBRTE_RING),y)
109 ifeq ($(CONFIG_RTE_LIBC),y)
113 ifeq ($(CONFIG_RTE_LIBGLOSS),y)
117 ifeq ($(CONFIG_RTE_LIBRTE_EAL),y)
121 LDLIBS += $(EXECENV_LDLIBS)
123 LDLIBS += --end-group
125 endif # ifeq ($(NO_AUTOLIBS),)
127 LDLIBS += $(CPU_LDLIBS)
133 install: build _postinstall
140 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
142 ifeq ($(LINK_USING_CC),1)
144 LDLIBS := $(addprefix -Wl$(comma),$(LDLIBS))
145 LDFLAGS := $(addprefix -Wl$(comma),$(LDFLAGS))
146 EXTRA_LDFLAGS := $(addprefix -Wl$(comma),$(EXTRA_LDFLAGS))
147 O_TO_EXE = $(CC) $(CFLAGS) $(LDFLAGS_$(@)) \
148 -Wl,-Map=$(@).map,--cref -o $@ $(OBJS-y) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDLIBS)
150 O_TO_EXE = $(LD) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
151 -Map=$(@).map --cref -o $@ $(OBJS-y) $(LDLIBS)
153 O_TO_EXE_STR = $(subst ','\'',$(O_TO_EXE)) #'# fix syntax highlight
154 O_TO_EXE_DISP = $(if $(V),"$(O_TO_EXE_STR)"," LD $(@)")
155 O_TO_EXE_CMD = "cmd_$@ = $(O_TO_EXE_STR)"
156 O_TO_EXE_DO = @set -e; \
157 echo $(O_TO_EXE_DISP); \
159 echo $(O_TO_EXE_CMD) > $(call exe2cmd,$(@))
163 # path where libraries are retrieved
164 LDLIBS_PATH := $(subst -Wl$(comma)-L,,$(filter -Wl$(comma)-L%,$(LDLIBS)))
165 LDLIBS_PATH += $(subst -L,,$(filter -L%,$(LDLIBS)))
167 # list of .a files that are linked to this application
168 LDLIBS_NAMES := $(patsubst -l%,lib%.a,$(filter -l%,$(LDLIBS)))
169 LDLIBS_NAMES += $(patsubst -Wl$(comma)-l%,lib%.a,$(filter -Wl$(comma)-l%,$(LDLIBS)))
171 # list of found libraries files (useful for deps). If not found, the
172 # library is silently ignored and dep won't be checked
173 LDLIBS_FILES := $(wildcard $(foreach dir,$(LDLIBS_PATH),\
174 $(addprefix $(dir)/,$(LDLIBS_NAMES))))
177 # Compile executable file if needed
179 $(APP): $(OBJS-y) $(LDLIBS_FILES) $(DEP_$(APP)) $(LDSCRIPT) FORCE
180 @[ -d $(dir $@) ] || mkdir -p $(dir $@)
182 @echo -n "$< -> $@ " ; \
183 echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
184 echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_EXE_STR))) " ; \
185 echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
186 echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
189 $(call cmdline_changed,$(O_TO_EXE_STR)),\
195 # install app in $(RTE_OUTPUT)/app
197 $(RTE_OUTPUT)/app/$(APP): $(APP)
198 @echo " INSTALL-APP $(APP)"
199 @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
200 $(Q)cp -f $(APP) $(RTE_OUTPUT)/app
203 # install app map file in $(RTE_OUTPUT)/app
205 $(RTE_OUTPUT)/app/$(APP).map: $(APP)
206 @echo " INSTALL-MAP $(APP).map"
207 @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
208 $(Q)cp -f $(APP).map $(RTE_OUTPUT)/app
211 # Clean all generated files
215 $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
219 $(Q)rm -rf $(APP) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
220 $(CMDS-all) $(INSTALL-FILES-all) .$(APP).cmd
223 include $(RTE_SDK)/mk/internal/rte.compile-post.mk
224 include $(RTE_SDK)/mk/internal/rte.install-post.mk
225 include $(RTE_SDK)/mk/internal/rte.clean-post.mk
226 include $(RTE_SDK)/mk/internal/rte.build-post.mk
227 include $(RTE_SDK)/mk/internal/rte.depdirs-post.mk
229 ifneq ($(wildcard $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk),)
230 include $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk
232 include $(RTE_SDK)/mk/target/generic/rte.app.mk