update Intel copyright years to 2014
[dpdk.git] / mk / rte.app.mk
1 #   BSD LICENSE
2
3 #   Copyright(c) 2010-2014 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 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
37
38 # VPATH contains at least SRCDIR
39 VPATH += $(SRCDIR)
40
41 _BUILD = $(APP)
42 _INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y)
43 _INSTALL += $(RTE_OUTPUT)/app/$(APP) $(RTE_OUTPUT)/app/$(APP).map
44 POSTINSTALL += target-appinstall
45 _CLEAN = doclean
46 POSTCLEAN += target-appclean
47
48 ifeq ($(NO_LDSCRIPT),)
49 LDSCRIPT = $(RTE_LDSCRIPT)
50 endif
51
52 # default path for libs
53 LDLIBS += -L$(RTE_SDK_BIN)/lib
54
55 #
56 # Include libraries depending on config if NO_AUTOLIBS is not set
57 # Order is important: from higher level to lower level
58 #
59 ifeq ($(NO_AUTOLIBS),)
60
61 ifeq ($(CONFIG_RTE_LIBRTE_KNI),y)
62 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
63 LDLIBS += -lrte_kni
64 endif
65 endif
66
67 ifeq ($(CONFIG_RTE_LIBRTE_E1000_PMD),y)
68 LDLIBS += -lrte_pmd_e1000
69 endif
70
71 ifeq ($(CONFIG_RTE_LIBRTE_IXGBE_PMD),y)
72 LDLIBS += -lrte_pmd_ixgbe
73 endif
74
75 ifeq ($(CONFIG_RTE_LIBRTE_VIRTIO_PMD),y)
76 LDLIBS += -lrte_pmd_virtio
77 endif
78
79 ifeq ($(CONFIG_RTE_LIBRTE_CMDLINE),y)
80 LDLIBS += -lrte_cmdline
81 endif
82
83 ifeq ($(CONFIG_RTE_LIBRTE_TIMER),y)
84 LDLIBS += -lrte_timer
85 endif
86
87 ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
88 LDLIBS += -lrte_hash
89 endif
90
91 ifeq ($(CONFIG_RTE_LIBRTE_LPM),y)
92 LDLIBS += -lrte_lpm
93 endif
94
95 ifeq ($(CONFIG_RTE_LIBRTE_POWER),y)
96 LDLIBS += -lrte_power
97 endif
98
99 ifeq ($(CONFIG_RTE_LIBRTE_ACL),y)
100 LDLIBS += -lrte_acl
101 endif
102
103 ifeq ($(CONFIG_RTE_LIBRTE_METER),y)
104 LDLIBS += -lrte_meter
105 endif
106
107 ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
108 LDLIBS += -lrte_sched
109 LDLIBS += -lm
110 LDLIBS += -lrt
111 endif
112
113 LDLIBS += --start-group
114
115 ifeq ($(CONFIG_RTE_LIBRTE_MBUF),y)
116 LDLIBS += -lrte_mbuf
117 endif
118
119 ifeq ($(CONFIG_RTE_LIBRTE_ETHER),y)
120 LDLIBS += -lethdev
121 endif
122
123 ifeq ($(CONFIG_RTE_LIBRTE_PMD_RING),y)
124 LDLIBS += -lrte_pmd_ring
125 endif
126
127 ifeq ($(CONFIG_RTE_LIBRTE_MALLOC),y)
128 LDLIBS += -lrte_malloc
129 endif
130
131 ifeq ($(CONFIG_RTE_LIBRTE_MEMPOOL),y)
132 LDLIBS += -lrte_mempool
133 endif
134
135 ifeq ($(CONFIG_RTE_LIBRTE_RING),y)
136 LDLIBS += -lrte_ring
137 endif
138
139 ifeq ($(CONFIG_RTE_LIBC),y)
140 LDLIBS += -lc
141 LDLIBS += -lm
142 endif
143
144 ifeq ($(CONFIG_RTE_LIBGLOSS),y)
145 LDLIBS += -lgloss
146 endif
147
148 ifeq ($(CONFIG_RTE_LIBRTE_EAL),y)
149 LDLIBS += -lrte_eal
150 endif
151
152 ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y)
153 LDLIBS += -lrte_pmd_pcap -lpcap
154 endif
155
156 LDLIBS += $(EXECENV_LDLIBS)
157
158 LDLIBS += --end-group
159
160 endif # ifeq ($(NO_AUTOLIBS),)
161
162 LDLIBS += $(CPU_LDLIBS)
163
164 .PHONY: all
165 all: install
166
167 .PHONY: install
168 install: build _postinstall
169
170 _postinstall: build
171
172 .PHONY: build
173 build: _postbuild
174
175 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
176
177 ifeq ($(RTE_BUILD_COMBINE_LIBS),y)
178 LDLIBS += -l$(RTE_LIBNAME)
179 endif
180
181 ifeq ($(LINK_USING_CC),1)
182 comma := ,
183 LDLIBS := $(addprefix -Wl$(comma),$(LDLIBS))
184 LDFLAGS := $(addprefix -Wl$(comma),$(LDFLAGS))
185 EXTRA_LDFLAGS := $(addprefix -Wl$(comma),$(EXTRA_LDFLAGS))
186 O_TO_EXE = $(CC) $(CFLAGS) $(LDFLAGS_$(@)) \
187         -Wl,-Map=$(@).map,--cref -o $@ $(OBJS-y) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDLIBS)
188 else
189 O_TO_EXE = $(LD) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
190         -Map=$(@).map --cref -o $@ $(OBJS-y) $(LDLIBS)
191 endif
192 O_TO_EXE_STR = $(subst ','\'',$(O_TO_EXE)) #'# fix syntax highlight
193 O_TO_EXE_DISP = $(if $(V),"$(O_TO_EXE_STR)","  LD $(@)")
194 O_TO_EXE_CMD = "cmd_$@ = $(O_TO_EXE_STR)"
195 O_TO_EXE_DO = @set -e; \
196         echo $(O_TO_EXE_DISP); \
197         $(O_TO_EXE) && \
198         echo $(O_TO_EXE_CMD) > $(call exe2cmd,$(@))
199
200 -include .$(APP).cmd
201
202 # path where libraries are retrieved
203 LDLIBS_PATH := $(subst -Wl$(comma)-L,,$(filter -Wl$(comma)-L%,$(LDLIBS)))
204 LDLIBS_PATH += $(subst -L,,$(filter -L%,$(LDLIBS)))
205
206 # list of .a files that are linked to this application
207 LDLIBS_NAMES := $(patsubst -l%,lib%.a,$(filter -l%,$(LDLIBS)))
208 LDLIBS_NAMES += $(patsubst -Wl$(comma)-l%,lib%.a,$(filter -Wl$(comma)-l%,$(LDLIBS)))
209
210 # list of found libraries files (useful for deps). If not found, the
211 # library is silently ignored and dep won't be checked
212 LDLIBS_FILES := $(wildcard $(foreach dir,$(LDLIBS_PATH),\
213         $(addprefix $(dir)/,$(LDLIBS_NAMES))))
214
215 #
216 # Compile executable file if needed
217 #
218 $(APP): $(OBJS-y) $(LDLIBS_FILES) $(DEP_$(APP)) $(LDSCRIPT) FORCE
219         @[ -d $(dir $@) ] || mkdir -p $(dir $@)
220         $(if $(D),\
221                 @echo -n "$< -> $@ " ; \
222                 echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
223                 echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_EXE_STR))) " ; \
224                 echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
225                 echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
226         $(if $(or \
227                 $(file_missing),\
228                 $(call cmdline_changed,$(O_TO_EXE_STR)),\
229                 $(depfile_missing),\
230                 $(depfile_newer)),\
231                 $(O_TO_EXE_DO))
232
233 #
234 # install app in $(RTE_OUTPUT)/app
235 #
236 $(RTE_OUTPUT)/app/$(APP): $(APP)
237         @echo "  INSTALL-APP $(APP)"
238         @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
239         $(Q)cp -f $(APP) $(RTE_OUTPUT)/app
240
241 #
242 # install app map file in $(RTE_OUTPUT)/app
243 #
244 $(RTE_OUTPUT)/app/$(APP).map: $(APP)
245         @echo "  INSTALL-MAP $(APP).map"
246         @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
247         $(Q)cp -f $(APP).map $(RTE_OUTPUT)/app
248
249 #
250 # Clean all generated files
251 #
252 .PHONY: clean
253 clean: _postclean
254         $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
255
256 .PHONY: doclean
257 doclean:
258         $(Q)rm -rf $(APP) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
259           $(CMDS-all) $(INSTALL-FILES-all) .$(APP).cmd
260
261
262 include $(RTE_SDK)/mk/internal/rte.compile-post.mk
263 include $(RTE_SDK)/mk/internal/rte.install-post.mk
264 include $(RTE_SDK)/mk/internal/rte.clean-post.mk
265 include $(RTE_SDK)/mk/internal/rte.build-post.mk
266 include $(RTE_SDK)/mk/internal/rte.depdirs-post.mk
267
268 ifneq ($(wildcard $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk),)
269 include $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk
270 else
271 include $(RTE_SDK)/mk/target/generic/rte.app.mk
272 endif
273
274 .PHONY: FORCE
275 FORCE: