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)
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,$(LIB) -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/')
141 # Clean all generated files
148 $(Q)rm -rf $(LIB) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
149 $(CMDS-all) .$(LIB).cmd $(INSTALL-FILES-all) *.pmd.c *.pmd.o
150 $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
152 include $(RTE_SDK)/mk/internal/rte.compile-post.mk
153 include $(RTE_SDK)/mk/internal/rte.install-post.mk
154 include $(RTE_SDK)/mk/internal/rte.clean-post.mk
155 include $(RTE_SDK)/mk/internal/rte.build-post.mk