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 ifneq ($(CONFIG_RTE_MAJOR_ABI),)
16 LIBABIVER := $(CONFIG_RTE_MAJOR_ABI)
20 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
21 LIB := $(patsubst %.a,%.so.$(LIBABIVER),$(LIB))
22 ifeq ($(EXTLIB_BUILD),n)
23 ifeq ($(CONFIG_RTE_MAJOR_ABI),)
24 ifeq ($(CONFIG_RTE_NEXT_ABI),y)
28 CPU_LDFLAGS += --version-script=$(SRCDIR)/$(EXPORT_MAP)
34 PREINSTALL = $(SYMLINK-FILES-y)
35 _INSTALL = $(INSTALL-FILES-y) $(RTE_OUTPUT)/lib/$(LIB)
38 LDLIBS += $(EXECENV_LDLIBS-y)
44 ifeq ($(SYMLINK-FILES-y),)
45 install: build _postinstall
47 install: _preinstall build _postinstall
56 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
58 ifeq ($(LINK_USING_CC),1)
59 # Override the definition of LD here, since we're linking with CC
60 LD := $(CC) $(CPU_CFLAGS) $(EXTRA_CFLAGS)
61 _CPU_LDFLAGS := $(call linkerprefix,$(CPU_LDFLAGS))
62 override EXTRA_LDFLAGS := $(call linkerprefix,$(EXTRA_LDFLAGS))
64 _CPU_LDFLAGS := $(CPU_LDFLAGS)
67 O_TO_A = $(AR) crDs $(LIB) $(OBJS-y)
68 O_TO_A_STR = $(subst ','\'',$(O_TO_A)) #'# fix syntax highlight
69 O_TO_A_DISP = $(if $(V),"$(O_TO_A_STR)"," AR $(@)")
70 O_TO_A_CMD = "cmd_$@ = $(O_TO_A_STR)"
71 O_TO_A_DO = @set -e; \
72 echo $(O_TO_A_DISP); \
74 echo $(O_TO_A_CMD) > $(call exe2cmd,$(@))
76 ifneq ($(CC_SUPPORTS_Z),false)
77 NO_UNDEFINED := -z defs
80 O_TO_S = $(LD) -L$(RTE_SDK_BIN)/lib $(_CPU_LDFLAGS) $(EXTRA_LDFLAGS) \
81 -shared $(OBJS-y) $(NO_UNDEFINED) $(LDLIBS) -Wl,-soname,$(LIB) -o $(LIB)
82 O_TO_S_STR = $(subst ','\'',$(O_TO_S)) #'# fix syntax highlight
83 O_TO_S_DISP = $(if $(V),"$(O_TO_S_STR)"," LD $(@)")
84 O_TO_S_DO = @set -e; \
85 echo $(O_TO_S_DISP); \
87 echo $(O_TO_S_CMD) > $(call exe2cmd,$(@))
92 # Archive objects in .a file if needed
94 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
95 $(LIB): $(OBJS-y) $(DEP_$(LIB)) FORCE
97 @echo "Must Specify a $(LIB) ABI version"
100 @[ -d $(dir $@) ] || mkdir -p $(dir $@)
102 @echo -n "$< -> $@ " ; \
103 echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
104 echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_S_STR))) " ; \
105 echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
106 echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
109 $(call cmdline_changed,$(O_TO_S_STR)),\
115 $(LIB): $(OBJS-y) $(DEP_$(LIB)) FORCE
116 @[ -d $(dir $@) ] || mkdir -p $(dir $@)
118 @echo -n "$< -> $@ " ; \
119 echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
120 echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_A_STR))) " ; \
121 echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
122 echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
125 $(call cmdline_changed,$(O_TO_A_STR)),\
132 # install lib in $(RTE_OUTPUT)/lib
134 $(RTE_OUTPUT)/lib/$(LIB): $(LIB)
135 @echo " INSTALL-LIB $(LIB)"
136 @[ -d $(RTE_OUTPUT)/lib ] || mkdir -p $(RTE_OUTPUT)/lib
137 $(Q)cp -f $(LIB) $(RTE_OUTPUT)/lib
138 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
139 $(Q)ln -s -f $< $(shell echo $@ | sed 's/\.so.*/.so/')
143 # Clean all generated files
150 $(Q)rm -rf $(LIB) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
151 $(CMDS-all) .$(LIB).cmd $(INSTALL-FILES-all) *.pmd.c *.pmd.o
152 $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
154 include $(RTE_SDK)/mk/internal/rte.compile-post.mk
155 include $(RTE_SDK)/mk/internal/rte.install-post.mk
156 include $(RTE_SDK)/mk/internal/rte.clean-post.mk
157 include $(RTE_SDK)/mk/internal/rte.build-post.mk