3 # Copyright(c) 2010-2017 Intel Corporation. All rights reserved.
4 # Copyright(c) 2014-2015 6WIND S.A.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
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
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.
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.
33 include $(RTE_SDK)/mk/internal/rte.compile-pre.mk
34 include $(RTE_SDK)/mk/internal/rte.install-pre.mk
35 include $(RTE_SDK)/mk/internal/rte.clean-pre.mk
36 include $(RTE_SDK)/mk/internal/rte.build-pre.mk
38 # VPATH contains at least SRCDIR
42 _INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y)
43 _INSTALL += $(RTE_OUTPUT)/app/$(APP) $(RTE_OUTPUT)/app/$(APP).map
44 POSTINSTALL += target-appinstall
46 POSTCLEAN += target-appclean
48 ifeq ($(NO_LDSCRIPT),)
49 LDSCRIPT = $(RTE_LDSCRIPT)
52 # Link only the libraries used in the application
53 LDFLAGS += --as-needed
55 # default path for libs
56 _LDLIBS-y += -L$(RTE_SDK_BIN)/lib
59 # Order is important: from higher level to lower level
61 _LDLIBS-$(CONFIG_RTE_LIBRTE_PIPELINE) += -lrte_pipeline
62 _LDLIBS-$(CONFIG_RTE_LIBRTE_TABLE) += -lrte_table
63 _LDLIBS-$(CONFIG_RTE_LIBRTE_PORT) += -lrte_port
65 _LDLIBS-$(CONFIG_RTE_LIBRTE_PDUMP) += -lrte_pdump
66 _LDLIBS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += -lrte_distributor
67 _LDLIBS-$(CONFIG_RTE_LIBRTE_IP_FRAG) += -lrte_ip_frag
68 _LDLIBS-$(CONFIG_RTE_LIBRTE_METER) += -lrte_meter
69 _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED) += -lrte_sched
70 _LDLIBS-$(CONFIG_RTE_LIBRTE_LPM) += -lrte_lpm
71 # librte_acl needs --whole-archive because of weak functions
72 _LDLIBS-$(CONFIG_RTE_LIBRTE_ACL) += --whole-archive
73 _LDLIBS-$(CONFIG_RTE_LIBRTE_ACL) += -lrte_acl
74 _LDLIBS-$(CONFIG_RTE_LIBRTE_ACL) += --no-whole-archive
75 _LDLIBS-$(CONFIG_RTE_LIBRTE_JOBSTATS) += -lrte_jobstats
76 _LDLIBS-$(CONFIG_RTE_LIBRTE_POWER) += -lrte_power
78 _LDLIBS-$(CONFIG_RTE_LIBRTE_TIMER) += -lrte_timer
79 _LDLIBS-$(CONFIG_RTE_LIBRTE_EFD) += -lrte_efd
80 _LDLIBS-$(CONFIG_RTE_LIBRTE_CFGFILE) += -lrte_cfgfile
82 _LDLIBS-y += --whole-archive
84 _LDLIBS-$(CONFIG_RTE_LIBRTE_HASH) += -lrte_hash
85 _LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST) += -lrte_vhost
86 _LDLIBS-$(CONFIG_RTE_LIBRTE_KVARGS) += -lrte_kvargs
87 _LDLIBS-$(CONFIG_RTE_LIBRTE_MBUF) += -lrte_mbuf
88 _LDLIBS-$(CONFIG_RTE_LIBRTE_NET) += -lrte_net
89 _LDLIBS-$(CONFIG_RTE_LIBRTE_ETHER) += -lrte_ethdev
90 _LDLIBS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += -lrte_cryptodev
91 _LDLIBS-$(CONFIG_RTE_LIBRTE_EVENTDEV) += -lrte_eventdev
92 _LDLIBS-$(CONFIG_RTE_LIBRTE_MEMPOOL) += -lrte_mempool
93 _LDLIBS-$(CONFIG_RTE_LIBRTE_RING) += -lrte_ring
94 _LDLIBS-$(CONFIG_RTE_LIBRTE_EAL) += -lrte_eal
95 _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE) += -lrte_cmdline
96 _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER) += -lrte_reorder
98 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
99 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI) += -lrte_kni
102 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),n)
103 # plugins (link only if static libraries)
104 _LDLIBS-$(CONFIG_RTE_DRIVER_MEMPOOL_RING) += -lrte_mempool_ring
105 _LDLIBS-$(CONFIG_RTE_DRIVER_MEMPOOL_STACK) += -lrte_mempool_stack
107 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AF_PACKET) += -lrte_pmd_af_packet
108 _LDLIBS-$(CONFIG_RTE_LIBRTE_AVP_PMD) += -lrte_pmd_avp
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_PMD_BOND) += -lrte_pmd_bond
112 _LDLIBS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += -lrte_pmd_cxgbe
113 _LDLIBS-$(CONFIG_RTE_LIBRTE_E1000_PMD) += -lrte_pmd_e1000
114 _LDLIBS-$(CONFIG_RTE_LIBRTE_ENA_PMD) += -lrte_pmd_ena
115 _LDLIBS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += -lrte_pmd_enic
116 _LDLIBS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += -lrte_pmd_fm10k
117 _LDLIBS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += -lrte_pmd_i40e
118 _LDLIBS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += -lrte_pmd_ixgbe
119 ifeq ($(CONFIG_RTE_LIBRTE_KNI),y)
120 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KNI) += -lrte_pmd_kni
122 _LDLIBS-$(CONFIG_RTE_LIBRTE_LIO_PMD) += -lrte_pmd_lio
123 _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += -lrte_pmd_mlx4 -libverbs
124 _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += -lrte_pmd_mlx5 -libverbs
125 _LDLIBS-$(CONFIG_RTE_LIBRTE_NFP_PMD) += -lrte_pmd_nfp -lm
126 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL) += -lrte_pmd_null
127 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += -lrte_pmd_pcap -lpcap
128 _LDLIBS-$(CONFIG_RTE_LIBRTE_QEDE_PMD) += -lrte_pmd_qede
129 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_RING) += -lrte_pmd_ring
130 _LDLIBS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += -lrte_pmd_sfc_efx
131 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2) += -lrte_pmd_szedata2 -lsze2
132 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_TAP) += -lrte_pmd_tap
133 _LDLIBS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += -lrte_pmd_thunderx_nicvf -lm
134 _LDLIBS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += -lrte_pmd_virtio
135 ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y)
136 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += -lrte_pmd_vhost
137 endif # $(CONFIG_RTE_LIBRTE_VHOST)
138 _LDLIBS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += -lrte_pmd_vmxnet3_uio
139 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += -lrte_pmd_xenvirt -lxenstore
141 ifeq ($(CONFIG_RTE_LIBRTE_CRYPTODEV),y)
142 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_MB) += -lrte_pmd_aesni_mb
143 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_MB) += -L$(AESNI_MULTI_BUFFER_LIB_PATH) -lIPSec_MB
144 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_GCM) += -lrte_pmd_aesni_gcm -lisal_crypto
145 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_OPENSSL) += -lrte_pmd_openssl -lcrypto
146 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO) += -lrte_pmd_null_crypto
147 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_QAT) += -lrte_pmd_qat -lcrypto
148 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G) += -lrte_pmd_snow3g
149 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G) += -L$(LIBSSO_SNOW3G_PATH)/build -lsso_snow3g
150 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KASUMI) += -lrte_pmd_kasumi
151 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KASUMI) += -L$(LIBSSO_KASUMI_PATH)/build -lsso_kasumi
152 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_ZUC) += -lrte_pmd_zuc
153 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_ZUC) += -L$(LIBSSO_ZUC_PATH)/build -lsso_zuc
154 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_ARMV8_CRYPTO) += -lrte_pmd_armv8
155 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_ARMV8_CRYPTO) += -L$(ARMV8_CRYPTO_LIB_PATH) -larmv8_crypto
156 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_CRYPTO_SCHEDULER) += -lrte_pmd_crypto_scheduler
157 endif # CONFIG_RTE_LIBRTE_CRYPTODEV
159 ifeq ($(CONFIG_RTE_LIBRTE_EVENTDEV),y)
160 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_EVENTDEV) += -lrte_pmd_skeleton_event
161 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SW_EVENTDEV) += -lrte_pmd_sw_event
162 endif # CONFIG_RTE_LIBRTE_EVENTDEV
164 endif # !CONFIG_RTE_BUILD_SHARED_LIBS
166 _LDLIBS-y += --no-whole-archive
168 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),n)
169 # The static libraries do not know their dependencies.
170 # So linking with static library requires explicit dependencies.
171 _LDLIBS-$(CONFIG_RTE_LIBRTE_EAL) += -lrt
172 _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED) += -lm
173 _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED) += -lrt
174 _LDLIBS-$(CONFIG_RTE_LIBRTE_METER) += -lm
175 ifeq ($(CONFIG_RTE_LIBRTE_VHOST_NUMA),y)
176 _LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST) += -lnuma
178 _LDLIBS-$(CONFIG_RTE_PORT_PCAP) += -lpcap
179 endif # !CONFIG_RTE_BUILD_SHARED_LIBS
181 _LDLIBS-y += $(EXECENV_LDLIBS)
183 LDLIBS += $(_LDLIBS-y) $(CPU_LDLIBS) $(EXTRA_LDLIBS)
185 # Eliminate duplicates without sorting
186 LDLIBS := $(shell echo $(LDLIBS) | \
187 awk '{for (i = 1; i <= NF; i++) { \
188 if ($$i !~ /^-l.*/ || !seen[$$i]++) print $$i }}')
190 ifeq ($(RTE_DEVEL_BUILD)$(CONFIG_RTE_BUILD_SHARED_LIB),yy)
191 LDFLAGS += -rpath=$(RTE_SDK_BIN)/lib
194 MAPFLAGS = -Map=$@.map --cref
200 install: build _postinstall
207 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
209 ifeq ($(LINK_USING_CC),1)
210 O_TO_EXE = $(CC) -o $@ $(CFLAGS) $(OBJS-y) $(call linkerprefix, \
211 $(LDLIBS) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
214 O_TO_EXE = $(LD) -o $@ $(OBJS-y) \
215 $(LDLIBS) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
218 O_TO_EXE_STR = $(subst ','\'',$(O_TO_EXE)) #'# fix syntax highlight
219 O_TO_EXE_DISP = $(if $(V),"$(O_TO_EXE_STR)"," LD $(@)")
220 O_TO_EXE_CMD = "cmd_$@ = $(O_TO_EXE_STR)"
221 O_TO_EXE_DO = @set -e; \
222 echo $(O_TO_EXE_DISP); \
224 echo $(O_TO_EXE_CMD) > $(call exe2cmd,$(@))
228 # path where libraries are retrieved
229 LDLIBS_PATH := $(subst -Wl$(comma)-L,,$(filter -Wl$(comma)-L%,$(LDLIBS)))
230 LDLIBS_PATH += $(subst -L,,$(filter -L%,$(LDLIBS)))
232 # list of .a files that are linked to this application
233 LDLIBS_NAMES := $(patsubst -l%,lib%.a,$(filter -l%,$(LDLIBS)))
234 LDLIBS_NAMES += $(patsubst -Wl$(comma)-l%,lib%.a,$(filter -Wl$(comma)-l%,$(LDLIBS)))
236 # list of found libraries files (useful for deps). If not found, the
237 # library is silently ignored and dep won't be checked
238 LDLIBS_FILES := $(wildcard $(foreach dir,$(LDLIBS_PATH),\
239 $(addprefix $(dir)/,$(LDLIBS_NAMES))))
242 # Compile executable file if needed
244 $(APP): $(OBJS-y) $(LDLIBS_FILES) $(DEP_$(APP)) $(LDSCRIPT) FORCE
245 @[ -d $(dir $@) ] || mkdir -p $(dir $@)
247 @echo -n "$< -> $@ " ; \
248 echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
249 echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_EXE_STR))) " ; \
250 echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
251 echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
254 $(call cmdline_changed,$(O_TO_EXE_STR)),\
260 # install app in $(RTE_OUTPUT)/app
262 $(RTE_OUTPUT)/app/$(APP): $(APP)
263 @echo " INSTALL-APP $(APP)"
264 @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
265 $(Q)cp -f $(APP) $(RTE_OUTPUT)/app
268 # install app map file in $(RTE_OUTPUT)/app
270 $(RTE_OUTPUT)/app/$(APP).map: $(APP)
271 @echo " INSTALL-MAP $(APP).map"
272 @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
273 $(Q)cp -f $(APP).map $(RTE_OUTPUT)/app
276 # Clean all generated files
280 $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
284 $(Q)rm -rf $(APP) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
285 $(CMDS-all) $(INSTALL-FILES-all) .$(APP).cmd $(APP).map
288 include $(RTE_SDK)/mk/internal/rte.compile-post.mk
289 include $(RTE_SDK)/mk/internal/rte.install-post.mk
290 include $(RTE_SDK)/mk/internal/rte.clean-post.mk
291 include $(RTE_SDK)/mk/internal/rte.build-post.mk
293 ifneq ($(wildcard $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk),)
294 include $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk
296 include $(RTE_SDK)/mk/target/generic/rte.app.mk