1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2010-2014 Intel Corporation
4 include $(RTE_SDK)/mk/internal/rte.compile-pre.mk
5 include $(RTE_SDK)/mk/internal/rte.install-pre.mk
6 include $(RTE_SDK)/mk/internal/rte.clean-pre.mk
7 include $(RTE_SDK)/mk/internal/rte.build-pre.mk
11 # VPATH contains at least SRCDIR
14 LIBABIVER ?= $(shell cat $(RTE_SRCDIR)/ABI_VERSION)
15 SOVER := $(basename $(LIBABIVER))
16 ifeq ($(shell grep -s "^DPDK_" $(SRCDIR)/$(EXPORT_MAP)),)
17 # EXPERIMENTAL ABI is versioned as 0.major+minor, e.g. 0.201 for 20.1 ABI
18 LIBABIVER := 0.$(shell echo $(LIBABIVER) | awk 'BEGIN { FS="." }; { print $$1$$2"."$$3 }')
22 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
23 SONAME := $(patsubst %.a,%.so.$(SOVER),$(LIB))
24 LIB := $(patsubst %.a,%.so.$(LIBABIVER),$(LIB))
25 ifeq ($(EXTLIB_BUILD),n)
26 CPU_LDFLAGS += --version-script=$(SRCDIR)/$(EXPORT_MAP)
32 PREINSTALL = $(SYMLINK-FILES-y)
33 _INSTALL = $(INSTALL-FILES-y) $(RTE_OUTPUT)/lib/$(LIB)
36 LDLIBS += $(EXECENV_LDLIBS-y)
42 ifeq ($(SYMLINK-FILES-y),)
43 install: build _postinstall
45 install: _preinstall build _postinstall
54 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
56 ifeq ($(LINK_USING_CC),1)
57 # Override the definition of LD here, since we're linking with CC
58 LD := $(CC) $(CPU_CFLAGS) $(EXTRA_CFLAGS)
59 _CPU_LDFLAGS := $(call linkerprefix,$(CPU_LDFLAGS))
60 override EXTRA_LDFLAGS := $(call linkerprefix,$(EXTRA_LDFLAGS))
62 _CPU_LDFLAGS := $(CPU_LDFLAGS)
65 O_TO_A = $(AR) crDs $(LIB) $(OBJS-y)
66 O_TO_A_STR = $(subst ','\'',$(O_TO_A)) #'# fix syntax highlight
67 O_TO_A_DISP = $(if $(V),"$(O_TO_A_STR)"," AR $(@)")
68 O_TO_A_CMD = "cmd_$@ = $(O_TO_A_STR)"
69 O_TO_A_DO = @set -e; \
70 echo $(O_TO_A_DISP); \
72 echo $(O_TO_A_CMD) > $(call exe2cmd,$(@))
74 ifneq ($(CC_SUPPORTS_Z),false)
75 NO_UNDEFINED := -z defs
78 O_TO_S = $(LD) -L$(RTE_SDK_BIN)/lib $(_CPU_LDFLAGS) $(EXTRA_LDFLAGS) \
79 -shared $(OBJS-y) $(NO_UNDEFINED) $(LDLIBS) -Wl,-soname,$(SONAME) -o $(LIB)
80 O_TO_S_STR = $(subst ','\'',$(O_TO_S)) #'# fix syntax highlight
81 O_TO_S_DISP = $(if $(V),"$(O_TO_S_STR)"," LD $(@)")
82 O_TO_S_DO = @set -e; \
83 echo $(O_TO_S_DISP); \
85 echo $(O_TO_S_CMD) > $(call exe2cmd,$(@))
90 # Archive objects in .a file if needed
92 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
93 $(LIB): $(OBJS-y) $(DEP_$(LIB)) FORCE
95 @echo "Must Specify a $(LIB) ABI version"
98 @[ -d $(dir $@) ] || mkdir -p $(dir $@)
100 @echo -n "$< -> $@ " ; \
101 echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
102 echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_S_STR))) " ; \
103 echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
104 echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
107 $(call cmdline_changed,$(O_TO_S_STR)),\
113 $(LIB): $(OBJS-y) $(DEP_$(LIB)) FORCE
114 @[ -d $(dir $@) ] || mkdir -p $(dir $@)
116 @echo -n "$< -> $@ " ; \
117 echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
118 echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_A_STR))) " ; \
119 echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
120 echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
123 $(call cmdline_changed,$(O_TO_A_STR)),\
130 # install lib in $(RTE_OUTPUT)/lib
132 $(RTE_OUTPUT)/lib/$(LIB): $(LIB)
133 @echo " INSTALL-LIB $(LIB)"
134 @[ -d $(RTE_OUTPUT)/lib ] || mkdir -p $(RTE_OUTPUT)/lib
135 $(Q)cp -f $(LIB) $(RTE_OUTPUT)/lib
136 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
137 $(Q)ln -s -f $< $(shell echo $@ | sed 's/\.so.*/.so/')
138 $(Q)if [ $(SOVER) != $(LIBABIVER) ]; then \
139 ln -s -f $< $(shell echo $@ | sed 's/\.so.*/.so.$(SOVER)/') ; \
144 # Clean all generated files
151 $(Q)rm -rf $(LIB) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
152 $(CMDS-all) .$(LIB).cmd $(INSTALL-FILES-all) *.pmd.c *.pmd.o
153 $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
155 include $(RTE_SDK)/mk/internal/rte.compile-post.mk
156 include $(RTE_SDK)/mk/internal/rte.install-post.mk
157 include $(RTE_SDK)/mk/internal/rte.clean-post.mk
158 include $(RTE_SDK)/mk/internal/rte.build-post.mk