rte.app.mk revision 3d9b7210
1#   BSD LICENSE
2#
3#   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
4#   Copyright(c) 2014-2015 6WIND S.A.
5#   All rights reserved.
6#
7#   Redistribution and use in source and binary forms, with or without
8#   modification, are permitted provided that the following conditions
9#   are met:
10#
11#     * Redistributions of source code must retain the above copyright
12#       notice, this list of conditions and the following disclaimer.
13#     * Redistributions in binary form must reproduce the above copyright
14#       notice, this list of conditions and the following disclaimer in
15#       the documentation and/or other materials provided with the
16#       distribution.
17#     * Neither the name of Intel Corporation nor the names of its
18#       contributors may be used to endorse or promote products derived
19#       from this software without specific prior written permission.
20#
21#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33include $(RTE_SDK)/mk/internal/rte.compile-pre.mk
34include $(RTE_SDK)/mk/internal/rte.install-pre.mk
35include $(RTE_SDK)/mk/internal/rte.clean-pre.mk
36include $(RTE_SDK)/mk/internal/rte.build-pre.mk
37include $(RTE_SDK)/mk/internal/rte.depdirs-pre.mk
38
39# VPATH contains at least SRCDIR
40VPATH += $(SRCDIR)
41
42_BUILD = $(APP)
43_INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y)
44_INSTALL += $(RTE_OUTPUT)/app/$(APP) $(RTE_OUTPUT)/app/$(APP).map
45POSTINSTALL += target-appinstall
46_CLEAN = doclean
47POSTCLEAN += target-appclean
48
49ifeq ($(NO_LDSCRIPT),)
50LDSCRIPT = $(RTE_LDSCRIPT)
51endif
52
53# Link only the libraries used in the application
54LDFLAGS += --as-needed
55
56# default path for libs
57_LDLIBS-y += -L$(RTE_SDK_BIN)/lib
58
59#
60# Order is important: from higher level to lower level
61#
62
63ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
64_LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
65endif
66
67_LDLIBS-$(CONFIG_RTE_LIBRTE_PIPELINE)       += -lrte_pipeline
68_LDLIBS-$(CONFIG_RTE_LIBRTE_TABLE)          += -lrte_table
69_LDLIBS-$(CONFIG_RTE_LIBRTE_PORT)           += -lrte_port
70
71_LDLIBS-$(CONFIG_RTE_LIBRTE_PDUMP)          += -lrte_pdump
72_LDLIBS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)    += -lrte_distributor
73_LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
74_LDLIBS-$(CONFIG_RTE_LIBRTE_IP_FRAG)        += -lrte_ip_frag
75_LDLIBS-$(CONFIG_RTE_LIBRTE_METER)          += -lrte_meter
76_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
77_LDLIBS-$(CONFIG_RTE_LIBRTE_LPM)            += -lrte_lpm
78# librte_acl needs --whole-archive because of weak functions
79_LDLIBS-$(CONFIG_RTE_LIBRTE_ACL)            += --whole-archive
80_LDLIBS-$(CONFIG_RTE_LIBRTE_ACL)            += -lrte_acl
81_LDLIBS-$(CONFIG_RTE_LIBRTE_ACL)            += --no-whole-archive
82_LDLIBS-$(CONFIG_RTE_LIBRTE_JOBSTATS)       += -lrte_jobstats
83_LDLIBS-$(CONFIG_RTE_LIBRTE_POWER)          += -lrte_power
84
85_LDLIBS-y += --whole-archive
86
87_LDLIBS-$(CONFIG_RTE_LIBRTE_TIMER)          += -lrte_timer
88_LDLIBS-$(CONFIG_RTE_LIBRTE_HASH)           += -lrte_hash
89_LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST)          += -lrte_vhost
90
91_LDLIBS-$(CONFIG_RTE_LIBRTE_KVARGS)         += -lrte_kvargs
92_LDLIBS-$(CONFIG_RTE_LIBRTE_MBUF)           += -lrte_mbuf
93_LDLIBS-$(CONFIG_RTE_LIBRTE_NET)            += -lrte_net
94_LDLIBS-$(CONFIG_RTE_LIBRTE_ETHER)          += -lrte_ethdev
95_LDLIBS-$(CONFIG_RTE_LIBRTE_CRYPTODEV)      += -lrte_cryptodev
96_LDLIBS-$(CONFIG_RTE_LIBRTE_MEMPOOL)        += -lrte_mempool
97_LDLIBS-$(CONFIG_RTE_LIBRTE_RING)           += -lrte_ring
98_LDLIBS-$(CONFIG_RTE_LIBRTE_EAL)            += -lrte_eal
99_LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -lrte_cmdline
100_LDLIBS-$(CONFIG_RTE_LIBRTE_CFGFILE)        += -lrte_cfgfile
101
102_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_BOND)       += -lrte_pmd_bond
103_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT)    += -lrte_pmd_xenvirt -lxenstore
104
105ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),n)
106# plugins (link only if static libraries)
107
108_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AF_PACKET)  += -lrte_pmd_af_packet
109_LDLIBS-$(CONFIG_RTE_LIBRTE_BNX2X_PMD)      += -lrte_pmd_bnx2x -lz
110_LDLIBS-$(CONFIG_RTE_LIBRTE_BNXT_PMD)       += -lrte_pmd_bnxt
111_LDLIBS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD)      += -lrte_pmd_cxgbe
112_LDLIBS-$(CONFIG_RTE_LIBRTE_E1000_PMD)      += -lrte_pmd_e1000
113_LDLIBS-$(CONFIG_RTE_LIBRTE_ENA_PMD)        += -lrte_pmd_ena
114_LDLIBS-$(CONFIG_RTE_LIBRTE_ENIC_PMD)       += -lrte_pmd_enic
115_LDLIBS-$(CONFIG_RTE_LIBRTE_FM10K_PMD)      += -lrte_pmd_fm10k
116_LDLIBS-$(CONFIG_RTE_LIBRTE_I40E_PMD)       += -lrte_pmd_i40e
117_LDLIBS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD)      += -lrte_pmd_ixgbe
118_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += -lrte_pmd_mlx4 -libverbs
119_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -lrte_pmd_mlx5 -libverbs
120_LDLIBS-$(CONFIG_RTE_LIBRTE_MPIPE_PMD)      += -lrte_pmd_mpipe -lgxio
121_LDLIBS-$(CONFIG_RTE_LIBRTE_NFP_PMD)        += -lrte_pmd_nfp -lm
122_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL)       += -lrte_pmd_null
123_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP)       += -lrte_pmd_pcap -lpcap
124_LDLIBS-$(CONFIG_RTE_LIBRTE_QEDE_PMD)       += -lrte_pmd_qede
125_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_RING)       += -lrte_pmd_ring
126_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2)   += -lrte_pmd_szedata2 -lsze2
127_LDLIBS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += -lrte_pmd_thunderx_nicvf -lm
128_LDLIBS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD)     += -lrte_pmd_virtio
129ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y)
130_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_VHOST)      += -lrte_pmd_vhost
131endif # $(CONFIG_RTE_LIBRTE_VHOST)
132_LDLIBS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD)    += -lrte_pmd_vmxnet3_uio
133
134ifeq ($(CONFIG_RTE_LIBRTE_CRYPTODEV),y)
135_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_MB)    += -lrte_pmd_aesni_mb
136_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_MB)    += -L$(AESNI_MULTI_BUFFER_LIB_PATH) -lIPSec_MB
137_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_GCM)   += -lrte_pmd_aesni_gcm -lcrypto
138_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_GCM)   += -L$(AESNI_MULTI_BUFFER_LIB_PATH) -lIPSec_MB
139_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_OPENSSL)     += -lrte_pmd_openssl -lcrypto
140_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO) += -lrte_pmd_null_crypto
141_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_QAT)         += -lrte_pmd_qat -lcrypto
142_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G)      += -lrte_pmd_snow3g
143_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G)      += -L$(LIBSSO_SNOW3G_PATH)/build -lsso_snow3g
144_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KASUMI)      += -lrte_pmd_kasumi
145_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KASUMI)      += -L$(LIBSSO_KASUMI_PATH)/build -lsso_kasumi
146_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_ZUC)         += -lrte_pmd_zuc
147_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_ZUC)         += -L$(LIBSSO_ZUC_PATH)/build -lsso_zuc
148endif # CONFIG_RTE_LIBRTE_CRYPTODEV
149
150endif # !CONFIG_RTE_BUILD_SHARED_LIBS
151
152_LDLIBS-y += --no-whole-archive
153
154ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),n)
155# The static libraries do not know their dependencies.
156# So linking with static library requires explicit dependencies.
157_LDLIBS-$(CONFIG_RTE_LIBRTE_EAL)            += -lrt
158_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lm
159_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrt
160_LDLIBS-$(CONFIG_RTE_LIBRTE_METER)          += -lm
161ifeq ($(CONFIG_RTE_LIBRTE_VHOST_NUMA),y)
162_LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST)          += -lnuma
163endif
164_LDLIBS-$(CONFIG_RTE_PORT_PCAP)             += -lpcap
165endif # !CONFIG_RTE_BUILD_SHARED_LIBS
166
167_LDLIBS-y += $(EXECENV_LDLIBS)
168
169LDLIBS += $(_LDLIBS-y) $(CPU_LDLIBS) $(EXTRA_LDLIBS)
170
171# Eliminate duplicates without sorting
172LDLIBS := $(shell echo $(LDLIBS) | \
173	awk '{for (i = 1; i <= NF; i++) { \
174		if ($$i !~ /^-l.*/ || !seen[$$i]++) print $$i }}')
175
176ifeq ($(RTE_DEVEL_BUILD)$(CONFIG_RTE_BUILD_SHARED_LIB),yy)
177LDFLAGS += -rpath=$(RTE_SDK_BIN)/lib
178endif
179
180MAPFLAGS = -Map=$@.map --cref
181
182.PHONY: all
183all: install
184
185.PHONY: install
186install: build _postinstall
187
188_postinstall: build
189
190.PHONY: build
191build: _postbuild
192
193exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
194
195ifeq ($(LINK_USING_CC),1)
196O_TO_EXE = $(CC) -o $@ $(CFLAGS) $(OBJS-y) $(call linkerprefix, \
197	$(LDLIBS) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
198	$(MAPFLAGS))
199else
200O_TO_EXE = $(LD) -o $@ $(OBJS-y) \
201	$(LDLIBS) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
202	$(MAPFLAGS)
203endif
204O_TO_EXE_STR = $(subst ','\'',$(O_TO_EXE)) #'# fix syntax highlight
205O_TO_EXE_DISP = $(if $(V),"$(O_TO_EXE_STR)","  LD $(@)")
206O_TO_EXE_CMD = "cmd_$@ = $(O_TO_EXE_STR)"
207O_TO_EXE_DO = @set -e; \
208	echo $(O_TO_EXE_DISP); \
209	$(O_TO_EXE) && \
210	echo $(O_TO_EXE_CMD) > $(call exe2cmd,$(@))
211
212-include .$(APP).cmd
213
214# path where libraries are retrieved
215LDLIBS_PATH := $(subst -Wl$(comma)-L,,$(filter -Wl$(comma)-L%,$(LDLIBS)))
216LDLIBS_PATH += $(subst -L,,$(filter -L%,$(LDLIBS)))
217
218# list of .a files that are linked to this application
219LDLIBS_NAMES := $(patsubst -l%,lib%.a,$(filter -l%,$(LDLIBS)))
220LDLIBS_NAMES += $(patsubst -Wl$(comma)-l%,lib%.a,$(filter -Wl$(comma)-l%,$(LDLIBS)))
221
222# list of found libraries files (useful for deps). If not found, the
223# library is silently ignored and dep won't be checked
224LDLIBS_FILES := $(wildcard $(foreach dir,$(LDLIBS_PATH),\
225	$(addprefix $(dir)/,$(LDLIBS_NAMES))))
226
227#
228# Compile executable file if needed
229#
230$(APP): $(OBJS-y) $(LDLIBS_FILES) $(DEP_$(APP)) $(LDSCRIPT) FORCE
231	@[ -d $(dir $@) ] || mkdir -p $(dir $@)
232	$(if $(D),\
233		@echo -n "$< -> $@ " ; \
234		echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
235		echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_EXE_STR))) " ; \
236		echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
237		echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
238	$(if $(or \
239		$(file_missing),\
240		$(call cmdline_changed,$(O_TO_EXE_STR)),\
241		$(depfile_missing),\
242		$(depfile_newer)),\
243		$(O_TO_EXE_DO))
244
245#
246# install app in $(RTE_OUTPUT)/app
247#
248$(RTE_OUTPUT)/app/$(APP): $(APP)
249	@echo "  INSTALL-APP $(APP)"
250	@[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
251	$(Q)cp -f $(APP) $(RTE_OUTPUT)/app
252
253#
254# install app map file in $(RTE_OUTPUT)/app
255#
256$(RTE_OUTPUT)/app/$(APP).map: $(APP)
257	@echo "  INSTALL-MAP $(APP).map"
258	@[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
259	$(Q)cp -f $(APP).map $(RTE_OUTPUT)/app
260
261#
262# Clean all generated files
263#
264.PHONY: clean
265clean: _postclean
266	$(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
267
268.PHONY: doclean
269doclean:
270	$(Q)rm -rf $(APP) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
271	  $(CMDS-all) $(INSTALL-FILES-all) .$(APP).cmd
272
273
274include $(RTE_SDK)/mk/internal/rte.compile-post.mk
275include $(RTE_SDK)/mk/internal/rte.install-post.mk
276include $(RTE_SDK)/mk/internal/rte.clean-post.mk
277include $(RTE_SDK)/mk/internal/rte.build-post.mk
278include $(RTE_SDK)/mk/internal/rte.depdirs-post.mk
279
280ifneq ($(wildcard $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk),)
281include $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk
282else
283include $(RTE_SDK)/mk/target/generic/rte.app.mk
284endif
285
286.PHONY: FORCE
287FORCE:
288