3 # Copyright(c) 2010-2016 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
37 include $(RTE_SDK)/mk/internal/rte.depdirs-pre.mk
39 # VPATH contains at least SRCDIR
43 _INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y)
44 _INSTALL += $(RTE_OUTPUT)/app/$(APP) $(RTE_OUTPUT)/app/$(APP).map
45 POSTINSTALL += target-appinstall
47 POSTCLEAN += target-appclean
49 ifeq ($(NO_LDSCRIPT),)
50 LDSCRIPT = $(RTE_LDSCRIPT)
53 # Link only the libraries used in the application
54 LDFLAGS += --as-needed
56 # default path for libs
57 _LDLIBS-y += -L$(RTE_SDK_BIN)/lib
60 # Order is important: from higher level to lower level
63 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
64 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI) += -lrte_kni
65 _LDLIBS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += -lrte_ivshmem
68 _LDLIBS-$(CONFIG_RTE_LIBRTE_PIPELINE) += -lrte_pipeline
69 _LDLIBS-$(CONFIG_RTE_LIBRTE_TABLE) += -lrte_table
70 _LDLIBS-$(CONFIG_RTE_LIBRTE_PORT) += -lrte_port
72 _LDLIBS-$(CONFIG_RTE_LIBRTE_PDUMP) += -lrte_pdump
73 _LDLIBS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += -lrte_distributor
74 _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER) += -lrte_reorder
75 _LDLIBS-$(CONFIG_RTE_LIBRTE_IP_FRAG) += -lrte_ip_frag
76 _LDLIBS-$(CONFIG_RTE_LIBRTE_METER) += -lrte_meter
77 _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED) += -lrte_sched
78 _LDLIBS-$(CONFIG_RTE_LIBRTE_LPM) += -lrte_lpm
79 _LDLIBS-$(CONFIG_RTE_LIBRTE_ACL) += -lrte_acl
80 _LDLIBS-$(CONFIG_RTE_LIBRTE_JOBSTATS) += -lrte_jobstats
81 _LDLIBS-$(CONFIG_RTE_LIBRTE_POWER) += -lrte_power
83 _LDLIBS-y += --whole-archive
85 _LDLIBS-$(CONFIG_RTE_LIBRTE_TIMER) += -lrte_timer
86 _LDLIBS-$(CONFIG_RTE_LIBRTE_HASH) += -lrte_hash
87 _LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST) += -lrte_vhost
89 _LDLIBS-$(CONFIG_RTE_LIBRTE_KVARGS) += -lrte_kvargs
90 _LDLIBS-$(CONFIG_RTE_LIBRTE_MBUF) += -lrte_mbuf
91 _LDLIBS-$(CONFIG_RTE_LIBRTE_ETHER) += -lethdev
92 _LDLIBS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += -lrte_cryptodev
93 _LDLIBS-$(CONFIG_RTE_LIBRTE_MEMPOOL) += -lrte_mempool
94 _LDLIBS-$(CONFIG_RTE_LIBRTE_RING) += -lrte_ring
95 _LDLIBS-$(CONFIG_RTE_LIBRTE_EAL) += -lrte_eal
96 _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE) += -lrte_cmdline
97 _LDLIBS-$(CONFIG_RTE_LIBRTE_CFGFILE) += -lrte_cfgfile
99 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += -lrte_pmd_bond
100 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += -lrte_pmd_xenvirt -lxenstore
102 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),n)
103 # plugins (link only if static libraries)
105 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AF_PACKET) += -lrte_pmd_af_packet
106 _LDLIBS-$(CONFIG_RTE_LIBRTE_BNX2X_PMD) += -lrte_pmd_bnx2x -lz
107 _LDLIBS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += -lrte_pmd_cxgbe
108 _LDLIBS-$(CONFIG_RTE_LIBRTE_E1000_PMD) += -lrte_pmd_e1000
109 _LDLIBS-$(CONFIG_RTE_LIBRTE_ENA_PMD) += -lrte_pmd_ena
110 _LDLIBS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += -lrte_pmd_enic
111 _LDLIBS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += -lrte_pmd_fm10k
112 _LDLIBS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += -lrte_pmd_i40e
113 _LDLIBS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += -lrte_pmd_ixgbe
114 _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += -lrte_pmd_mlx4 -libverbs
115 _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += -lrte_pmd_mlx5 -libverbs
116 _LDLIBS-$(CONFIG_RTE_LIBRTE_MPIPE_PMD) += -lrte_pmd_mpipe -lgxio
117 _LDLIBS-$(CONFIG_RTE_LIBRTE_NFP_PMD) += -lrte_pmd_nfp -lm
118 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL) += -lrte_pmd_null
119 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += -lrte_pmd_pcap -lpcap
120 _LDLIBS-$(CONFIG_RTE_LIBRTE_QEDE_PMD) += -lrte_pmd_qede -lz
121 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_RING) += -lrte_pmd_ring
122 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2) += -lrte_pmd_szedata2 -lsze2
123 _LDLIBS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += -lrte_pmd_virtio
124 ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y)
125 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += -lrte_pmd_vhost
126 endif # $(CONFIG_RTE_LIBRTE_VHOST)
127 _LDLIBS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += -lrte_pmd_vmxnet3_uio
129 ifeq ($(CONFIG_RTE_LIBRTE_CRYPTODEV),y)
130 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_MB) += -lrte_pmd_aesni_mb
131 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_MB) += -L$(AESNI_MULTI_BUFFER_LIB_PATH) -lIPSec_MB
132 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_GCM) += -lrte_pmd_aesni_gcm -lcrypto
133 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_GCM) += -L$(AESNI_MULTI_BUFFER_LIB_PATH) -lIPSec_MB
134 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO) += -lrte_pmd_null_crypto
135 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_QAT) += -lrte_pmd_qat -lcrypto
136 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G) += -lrte_pmd_snow3g
137 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G) += -L$(LIBSSO_PATH)/build -lsso
138 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KASUMI) += -lrte_pmd_kasumi
139 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KASUMI) += -L$(LIBSSO_KASUMI_PATH)/build -lsso_kasumi
140 endif # CONFIG_RTE_LIBRTE_CRYPTODEV
142 endif # !CONFIG_RTE_BUILD_SHARED_LIBS
144 _LDLIBS-y += --no-whole-archive
146 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),n)
147 # The static libraries do not know their dependencies.
148 # So linking with static library requires explicit dependencies.
149 _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED) += -lm
150 _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED) += -lrt
151 _LDLIBS-$(CONFIG_RTE_LIBRTE_METER) += -lm
152 ifeq ($(CONFIG_RTE_LIBRTE_VHOST_NUMA),y)
153 _LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST) += -lnuma
155 ifeq ($(CONFIG_RTE_LIBRTE_VHOST_USER),n)
156 _LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST) += -lfuse
158 _LDLIBS-$(CONFIG_RTE_PORT_PCAP) += -lpcap
159 endif # !CONFIG_RTE_BUILD_SHARED_LIBS
161 _LDLIBS-y += $(EXECENV_LDLIBS)
163 LDLIBS += $(_LDLIBS-y) $(CPU_LDLIBS) $(EXTRA_LDLIBS)
165 # Eliminate duplicates without sorting
166 LDLIBS := $(shell echo $(LDLIBS) | \
167 awk '{for (i = 1; i <= NF; i++) { if (!seen[$$i]++) print $$i }}')
169 ifeq ($(RTE_DEVEL_BUILD)$(CONFIG_RTE_BUILD_SHARED_LIB),yy)
170 LDFLAGS += -rpath=$(RTE_SDK_BIN)/lib
177 install: build _postinstall
184 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
186 ifeq ($(LINK_USING_CC),1)
187 override EXTRA_LDFLAGS := $(call linkerprefix,$(EXTRA_LDFLAGS))
188 O_TO_EXE = $(CC) $(CFLAGS) $(LDFLAGS_$(@)) \
189 -Wl,-Map=$(@).map,--cref -o $@ $(OBJS-y) $(call linkerprefix,$(LDFLAGS)) \
190 $(EXTRA_LDFLAGS) $(call linkerprefix,$(LDLIBS))
192 O_TO_EXE = $(LD) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
193 -Map=$(@).map --cref -o $@ $(OBJS-y) $(LDLIBS)
195 O_TO_EXE_STR = $(subst ','\'',$(O_TO_EXE)) #'# fix syntax highlight
196 O_TO_EXE_DISP = $(if $(V),"$(O_TO_EXE_STR)"," LD $(@)")
197 O_TO_EXE_CMD = "cmd_$@ = $(O_TO_EXE_STR)"
198 O_TO_EXE_DO = @set -e; \
199 echo $(O_TO_EXE_DISP); \
201 echo $(O_TO_EXE_CMD) > $(call exe2cmd,$(@))
205 # path where libraries are retrieved
206 LDLIBS_PATH := $(subst -Wl$(comma)-L,,$(filter -Wl$(comma)-L%,$(LDLIBS)))
207 LDLIBS_PATH += $(subst -L,,$(filter -L%,$(LDLIBS)))
209 # list of .a files that are linked to this application
210 LDLIBS_NAMES := $(patsubst -l%,lib%.a,$(filter -l%,$(LDLIBS)))
211 LDLIBS_NAMES += $(patsubst -Wl$(comma)-l%,lib%.a,$(filter -Wl$(comma)-l%,$(LDLIBS)))
213 # list of found libraries files (useful for deps). If not found, the
214 # library is silently ignored and dep won't be checked
215 LDLIBS_FILES := $(wildcard $(foreach dir,$(LDLIBS_PATH),\
216 $(addprefix $(dir)/,$(LDLIBS_NAMES))))
219 # Compile executable file if needed
221 $(APP): $(OBJS-y) $(LDLIBS_FILES) $(DEP_$(APP)) $(LDSCRIPT) FORCE
222 @[ -d $(dir $@) ] || mkdir -p $(dir $@)
224 @echo -n "$< -> $@ " ; \
225 echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
226 echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_EXE_STR))) " ; \
227 echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
228 echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
231 $(call cmdline_changed,$(O_TO_EXE_STR)),\
237 # install app in $(RTE_OUTPUT)/app
239 $(RTE_OUTPUT)/app/$(APP): $(APP)
240 @echo " INSTALL-APP $(APP)"
241 @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
242 $(Q)cp -f $(APP) $(RTE_OUTPUT)/app
245 # install app map file in $(RTE_OUTPUT)/app
247 $(RTE_OUTPUT)/app/$(APP).map: $(APP)
248 @echo " INSTALL-MAP $(APP).map"
249 @[ -d $(RTE_OUTPUT)/app ] || mkdir -p $(RTE_OUTPUT)/app
250 $(Q)cp -f $(APP).map $(RTE_OUTPUT)/app
253 # Clean all generated files
257 $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
261 $(Q)rm -rf $(APP) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
262 $(CMDS-all) $(INSTALL-FILES-all) .$(APP).cmd
265 include $(RTE_SDK)/mk/internal/rte.compile-post.mk
266 include $(RTE_SDK)/mk/internal/rte.install-post.mk
267 include $(RTE_SDK)/mk/internal/rte.clean-post.mk
268 include $(RTE_SDK)/mk/internal/rte.build-post.mk
269 include $(RTE_SDK)/mk/internal/rte.depdirs-post.mk
271 ifneq ($(wildcard $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk),)
272 include $(RTE_SDK)/mk/target/$(RTE_TARGET)/rte.app.mk
274 include $(RTE_SDK)/mk/target/generic/rte.app.mk