eal: remove experimental tag for user mbuf pool ops
[dpdk.git] / mk / rte.shared.mk
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright 2012-2013 6WIND S.A.
3
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
8
9 # VPATH contains at least SRCDIR
10 VPATH += $(SRCDIR)
11
12 _BUILD = $(SHARED)
13 _INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y) $(RTE_OUTPUT)/lib/$(SHARED)
14 _CLEAN = doclean
15
16 # Set fPIC in CFLAGS for .so generation
17 CFLAGS += -fPIC
18
19 .PHONY: all
20 all: install
21
22 .PHONY: install
23 install: build _postinstall
24
25 _postinstall: build
26
27 .PHONY: build
28 build: _postbuild
29
30 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
31
32 ifeq ($(LINK_USING_CC),1)
33 override EXTRA_LDFLAGS := $(call linkerprefix,$(EXTRA_LDFLAGS))
34 O_TO_SO = $(CC) $(call linkerprefix,$(LDFLAGS)) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
35         -shared -o $@ $(OBJS-y) $(call linkerprefix,$(LDLIBS))
36 else
37 O_TO_SO = $(LD) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
38         -shared -o $@ $(OBJS-y) $(LDLIBS)
39 endif
40
41 O_TO_SO_STR = $(subst ','\'',$(O_TO_SO)) #'# fix syntax highlight
42 O_TO_SO_DISP = $(if $(V),"$(O_TO_SO_STR)","  LD $(@)")
43 O_TO_SO_CMD = "cmd_$@ = $(O_TO_SO_STR)"
44 O_TO_SO_DO = @set -e; \
45         echo $(O_TO_SO_DISP); \
46         $(O_TO_SO) && \
47         echo $(O_TO_SO_CMD) > $(call exe2cmd,$(@))
48
49 -include .$(SHARED).cmd
50
51 # path where libraries are retrieved
52 LDLIBS_PATH := $(subst -Wl$(comma)-L,,$(filter -Wl$(comma)-L%,$(LDLIBS)))
53 LDLIBS_PATH += $(subst -L,,$(filter -L%,$(LDLIBS)))
54
55 # list of .a files that are linked to this application
56 LDLIBS_NAMES := $(patsubst -l%,lib%.a,$(filter -l%,$(LDLIBS)))
57 LDLIBS_NAMES += $(patsubst -Wl$(comma)-l%,lib%.a,$(filter -Wl$(comma)-l%,$(LDLIBS)))
58
59 # list of found libraries files (useful for deps). If not found, the
60 # library is silently ignored and dep won't be checked
61 LDLIBS_FILES := $(sort $(wildcard $(foreach dir,$(LDLIBS_PATH),\
62         $(addprefix $(dir)/,$(LDLIBS_NAMES)))))
63
64 #
65 # Archive objects in .so file if needed
66 #
67 $(SHARED): $(OBJS-y) $(LDLIBS_FILES) $(DEP_$(SHARED)) FORCE
68         @[ -d $(dir $@) ] || mkdir -p $(dir $@)
69         $(if $(D),\
70                 @echo -n "$< -> $@ " ; \
71                 echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
72                 echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_SO_STR))) " ; \
73                 echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
74                 echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
75         $(if $(or \
76                 $(file_missing),\
77                 $(call cmdline_changed,$(O_TO_SO_STR)),\
78                 $(depfile_missing),\
79                 $(depfile_newer)),\
80                 $(O_TO_SO_DO))
81
82 #
83 # install lib in $(RTE_OUTPUT)/lib
84 #
85 $(RTE_OUTPUT)/lib/$(SHARED): $(SHARED)
86         @echo "  INSTALL-SHARED $(SHARED)"
87         @[ -d $(RTE_OUTPUT)/lib ] || mkdir -p $(RTE_OUTPUT)/lib
88         $(Q)cp -f $(SHARED) $(RTE_OUTPUT)/lib
89
90 #
91 # Clean all generated files
92 #
93 .PHONY: clean
94 clean: _postclean
95
96 .PHONY: doclean
97 doclean:
98         $(Q)rm -rf $(SHARED) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
99           $(CMDS-all) $(INSTALL-FILES-all)
100         $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
101
102 include $(RTE_SDK)/mk/internal/rte.compile-post.mk
103 include $(RTE_SDK)/mk/internal/rte.install-post.mk
104 include $(RTE_SDK)/mk/internal/rte.clean-post.mk
105 include $(RTE_SDK)/mk/internal/rte.build-post.mk
106
107 .PHONY: FORCE
108 FORCE: