first public release
[dpdk.git] / mk / rte.app.mk
1 #   BSD LICENSE
2
3 #   Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
4 #   All rights reserved.
5
6 #   Redistribution and use in source and binary forms, with or without 
7 #   modification, are permitted provided that the following conditions 
8 #   are met:
9
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 
15 #       distribution.
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.
19
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.
31
32 #  version: DPDK.L.1.2.3-3
33
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
39
40 # VPATH contains at least SRCDIR
41 VPATH += $(SRCDIR)
42
43 _BUILD = $(APP)
44 _INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y)
45 _INSTALL += $(RTE_OUTPUT)/app/$(APP) $(RTE_OUTPUT)/app/$(APP).map
46 POSTINSTALL += target-appinstall
47 _CLEAN = doclean
48 POSTCLEAN += target-appclean
49
50 ifeq ($(NO_LDSCRIPT),)
51 LDSCRIPT = $(RTE_LDSCRIPT)
52 endif
53
54 # default path for libs
55 LDLIBS += -L$(RTE_SDK_BIN)/lib
56
57 #
58 # Include libraries depending on config if NO_AUTOLIBS is not set
59 # Order is important: from higher level to lower level
60 #
61 ifeq ($(NO_AUTOLIBS),)
62
63 ifeq ($(CONFIG_RTE_LIBRTE_IGB_PMD),y)
64 LDLIBS += -lrte_pmd_igb
65 endif
66
67 ifeq ($(CONFIG_RTE_LIBRTE_IXGBE_PMD),y)
68 LDLIBS += -lrte_pmd_ixgbe
69 endif
70
71 ifeq ($(CONFIG_RTE_LIBRTE_MBUF),y)
72 LDLIBS += -lrte_mbuf
73 endif
74
75 ifeq ($(CONFIG_RTE_LIBRTE_CMDLINE),y)
76 LDLIBS += -lrte_cmdline
77 endif
78
79 ifeq ($(CONFIG_RTE_LIBRTE_TIMER),y)
80 LDLIBS += -lrte_timer
81 endif
82
83 ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
84 LDLIBS += -lrte_hash
85 endif
86
87 ifeq ($(CONFIG_RTE_LIBRTE_LPM),y)
88 LDLIBS += -lrte_lpm
89 endif
90
91 LDLIBS += --start-group
92
93 ifeq ($(CONFIG_RTE_LIBRTE_ETHER),y)
94 LDLIBS += -lethdev
95 endif
96
97 ifeq ($(CONFIG_RTE_LIBRTE_MALLOC),y)
98 LDLIBS += -lrte_malloc
99 endif
100
101 ifeq ($(CONFIG_RTE_LIBRTE_MEMPOOL),y)
102 LDLIBS += -lrte_mempool
103 endif
104
105 ifeq ($(CONFIG_RTE_LIBRTE_RING),y)
106 LDLIBS += -lrte_ring
107 endif
108
109 ifeq ($(CONFIG_RTE_LIBC),y)
110 LDLIBS += -lc
111 endif
112
113 ifeq ($(CONFIG_RTE_LIBGLOSS),y)
114 LDLIBS += -lgloss
115 endif
116
117 ifeq ($(CONFIG_RTE_LIBRTE_EAL),y)
118 LDLIBS += -lrte_eal
119 endif
120
121 LDLIBS += $(EXECENV_LDLIBS)
122
123 LDLIBS += --end-group
124
125 endif # ifeq ($(NO_AUTOLIBS),)
126
127 LDLIBS += $(CPU_LDLIBS)
128
129 .PHONY: all
130 all: install
131
132 .PHONY: install
133 install: build _postinstall
134
135 _postinstall: build
136
137 .PHONY: build
138 build: _postbuild
139
140 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
141
142 ifeq ($(LINK_USING_CC),1)
143 comma := ,
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)
149 else
150 O_TO_EXE = $(LD) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
151         -Map=$(@).map --cref -o $@ $(OBJS-y) $(LDLIBS)
152 endif
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); \
158         $(O_TO_EXE) && \
159         echo $(O_TO_EXE_CMD) > $(call exe2cmd,$(@))
160
161 -include .$(APP).cmd
162
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)))
166
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)))
170
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))))
175
176 #
177 # Compile executable file if needed
178 #
179 $(APP): $(OBJS-y) $(LDLIBS_FILES) $(DEP_$(APP)) $(LDSCRIPT) FORCE
180         @[ -d $(dir $@) ] || mkdir -p $(dir $@)
181         $(if $(D),\
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)) ")
187         $(if $(or \
188                 $(file_missing),\
189                 $(call cmdline_changed,$(O_TO_EXE_STR)),\
190                 $(depfile_missing),\
191                 $(depfile_newer)),\
192                 $(O_TO_EXE_DO))
193
194 #
195 # install app in $(RTE_OUTPUT)/app
196 #
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
201
202 #
203 # install app map file in $(RTE_OUTPUT)/app
204 #
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
209
210 #
211 # Clean all generated files
212 #
213 .PHONY: clean
214 clean: _postclean
215         $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
216
217 .PHONY: doclean
218 doclean:
219         $(Q)rm -rf $(APP) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
220           $(CMDS-all) $(INSTALL-FILES-all) .$(APP).cmd
221
222
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
228
229 ifneq ($(wildcard $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk),)
230 include $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk
231 else
232 include $(RTE_SDK)/mk/target/generic/rte.app.mk
233 endif
234
235 .PHONY: FORCE
236 FORCE: