virtio: rename library
[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_IVSHMEM),y)
68 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
69 LDLIBS += -lrte_ivshmem
70 endif
71 endif
72
73 ifeq ($(CONFIG_RTE_LIBRTE_E1000_PMD),y)
74 LDLIBS += -lrte_pmd_e1000
75 endif
76
77 ifeq ($(CONFIG_RTE_LIBRTE_IXGBE_PMD),y)
78 LDLIBS += -lrte_pmd_ixgbe
79 endif
80
81 ifeq ($(CONFIG_RTE_LIBRTE_VIRTIO_PMD),y)
82 LDLIBS += -lrte_pmd_virtio_uio
83 endif
84
85 ifeq ($(CONFIG_RTE_LIBRTE_VMXNET3_PMD),y)
86 LDLIBS += -lrte_pmd_vmxnet3
87 endif
88
89 ifeq ($(CONFIG_RTE_LIBRTE_TIMER),y)
90 LDLIBS += -lrte_timer
91 endif
92
93 ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
94 LDLIBS += -lrte_hash
95 endif
96
97 ifeq ($(CONFIG_RTE_LIBRTE_LPM),y)
98 LDLIBS += -lrte_lpm
99 endif
100
101 ifeq ($(CONFIG_RTE_LIBRTE_POWER),y)
102 LDLIBS += -lrte_power
103 endif
104
105 ifeq ($(CONFIG_RTE_LIBRTE_ACL),y)
106 LDLIBS += -lrte_acl
107 endif
108
109 ifeq ($(CONFIG_RTE_LIBRTE_METER),y)
110 LDLIBS += -lrte_meter
111 endif
112
113 ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
114 LDLIBS += -lrte_sched
115 LDLIBS += -lm
116 LDLIBS += -lrt
117 endif
118
119 LDLIBS += --start-group
120
121 ifeq ($(CONFIG_RTE_LIBRTE_KVARGS),y)
122 LDLIBS += -lrte_kvargs
123 endif
124
125 ifeq ($(CONFIG_RTE_LIBRTE_MBUF),y)
126 LDLIBS += -lrte_mbuf
127 endif
128
129 ifeq ($(CONFIG_RTE_LIBRTE_ETHER),y)
130 LDLIBS += -lethdev
131 endif
132
133 ifeq ($(CONFIG_RTE_LIBRTE_PMD_RING),y)
134 LDLIBS += -lrte_pmd_ring
135 endif
136
137 ifeq ($(CONFIG_RTE_LIBRTE_MALLOC),y)
138 LDLIBS += -lrte_malloc
139 endif
140
141 ifeq ($(CONFIG_RTE_LIBRTE_MEMPOOL),y)
142 LDLIBS += -lrte_mempool
143 endif
144
145 ifeq ($(CONFIG_RTE_LIBRTE_RING),y)
146 LDLIBS += -lrte_ring
147 endif
148
149 ifeq ($(CONFIG_RTE_LIBC),y)
150 LDLIBS += -lc
151 LDLIBS += -lm
152 endif
153
154 ifeq ($(CONFIG_RTE_LIBGLOSS),y)
155 LDLIBS += -lgloss
156 endif
157
158 ifeq ($(CONFIG_RTE_LIBRTE_EAL),y)
159 LDLIBS += -lrte_eal
160 endif
161
162
163 ifeq ($(CONFIG_RTE_LIBRTE_PMD_XENVIRT),y)
164 LDLIBS += -lrte_pmd_xenvirt
165 LDLIBS += -lxenstore
166 endif
167
168 ifeq ($(CONFIG_RTE_LIBRTE_CMDLINE),y)
169 LDLIBS += -lrte_cmdline
170 endif
171
172 ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y)
173 LDLIBS += -lrte_pmd_pcap -lpcap
174 endif
175
176 LDLIBS += $(EXECENV_LDLIBS)
177
178 LDLIBS += --end-group
179
180 endif # ifeq ($(NO_AUTOLIBS),)
181
182 LDLIBS += $(CPU_LDLIBS)
183
184 .PHONY: all
185 all: install
186
187 .PHONY: install
188 install: build _postinstall
189
190 _postinstall: build
191
192 .PHONY: build
193 build: _postbuild
194
195 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
196
197 ifeq ($(RTE_BUILD_COMBINE_LIBS),y)
198 LDLIBS += -l$(RTE_LIBNAME)
199 endif
200
201 ifeq ($(LINK_USING_CC),1)
202 comma := ,
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)
208 else
209 O_TO_EXE = $(LD) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
210         -Map=$(@).map --cref -o $@ $(OBJS-y) $(LDLIBS)
211 endif
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); \
217         $(O_TO_EXE) && \
218         echo $(O_TO_EXE_CMD) > $(call exe2cmd,$(@))
219
220 -include .$(APP).cmd
221
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)))
225
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)))
229
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))))
234
235 #
236 # Compile executable file if needed
237 #
238 $(APP): $(OBJS-y) $(LDLIBS_FILES) $(DEP_$(APP)) $(LDSCRIPT) FORCE
239         @[ -d $(dir $@) ] || mkdir -p $(dir $@)
240         $(if $(D),\
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)) ")
246         $(if $(or \
247                 $(file_missing),\
248                 $(call cmdline_changed,$(O_TO_EXE_STR)),\
249                 $(depfile_missing),\
250                 $(depfile_newer)),\
251                 $(O_TO_EXE_DO))
252
253 #
254 # install app in $(RTE_OUTPUT)/app
255 #
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
260
261 #
262 # install app map file in $(RTE_OUTPUT)/app
263 #
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
268
269 #
270 # Clean all generated files
271 #
272 .PHONY: clean
273 clean: _postclean
274         $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
275
276 .PHONY: doclean
277 doclean:
278         $(Q)rm -rf $(APP) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
279           $(CMDS-all) $(INSTALL-FILES-all) .$(APP).cmd
280
281
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
287
288 ifneq ($(wildcard $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk),)
289 include $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk
290 else
291 include $(RTE_SDK)/mk/target/generic/rte.app.mk
292 endif
293
294 .PHONY: FORCE
295 FORCE: