doc: fix spelling in bonding guide
[dpdk.git] / mk / rte.shared.mk
1 # BSD LICENSE
2 #
3 # Copyright 2012-2013 6WIND S.A.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 #
9 #   * Redistributions of source code must retain the above copyright
10 #     notice, this list of conditions and the following disclaimer.
11 #   * Redistributions in binary form must reproduce the above copyright
12 #     notice, this list of conditions and the following disclaimer in
13 #     the documentation and/or other materials provided with the
14 #     distribution.
15 #   * Neither the name of 6WIND S.A. nor the names of its
16 #     contributors may be used to endorse or promote products derived
17 #     from this software without specific prior written permission.
18 #
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 include $(RTE_SDK)/mk/internal/rte.compile-pre.mk
32 include $(RTE_SDK)/mk/internal/rte.install-pre.mk
33 include $(RTE_SDK)/mk/internal/rte.clean-pre.mk
34 include $(RTE_SDK)/mk/internal/rte.build-pre.mk
35 include $(RTE_SDK)/mk/internal/rte.depdirs-pre.mk
36
37 # VPATH contains at least SRCDIR
38 VPATH += $(SRCDIR)
39
40 _BUILD = $(SHARED)
41 _INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y) $(RTE_OUTPUT)/lib/$(SHARED)
42 _CLEAN = doclean
43
44 # Set fPIC in CFLAGS for .so generation
45 CFLAGS += -fPIC
46
47 .PHONY: all
48 all: install
49
50 .PHONY: install
51 install: build _postinstall
52
53 _postinstall: build
54
55 .PHONY: build
56 build: _postbuild
57
58 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
59
60 ifeq ($(LINK_USING_CC),1)
61 override EXTRA_LDFLAGS := $(call linkerprefix,$(EXTRA_LDFLAGS))
62 O_TO_SO = $(CC) $(call linkerprefix,$(LDFLAGS)) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
63         -shared -o $@ $(OBJS-y) $(call linkerprefix,$(LDLIBS))
64 else
65 O_TO_SO = $(LD) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
66         -shared -o $@ $(OBJS-y) $(LDLIBS)
67 endif
68
69 O_TO_SO_STR = $(subst ','\'',$(O_TO_SO)) #'# fix syntax highlight
70 O_TO_SO_DISP = $(if $(V),"$(O_TO_SO_STR)","  LD $(@)")
71 O_TO_SO_CMD = "cmd_$@ = $(O_TO_SO_STR)"
72 O_TO_SO_DO = @set -e; \
73         echo $(O_TO_SO_DISP); \
74         $(O_TO_SO) && \
75         echo $(O_TO_SO_CMD) > $(call exe2cmd,$(@))
76
77 -include .$(SHARED).cmd
78
79 # path where libraries are retrieved
80 LDLIBS_PATH := $(subst -Wl$(comma)-L,,$(filter -Wl$(comma)-L%,$(LDLIBS)))
81 LDLIBS_PATH += $(subst -L,,$(filter -L%,$(LDLIBS)))
82
83 # list of .a files that are linked to this application
84 LDLIBS_NAMES := $(patsubst -l%,lib%.a,$(filter -l%,$(LDLIBS)))
85 LDLIBS_NAMES += $(patsubst -Wl$(comma)-l%,lib%.a,$(filter -Wl$(comma)-l%,$(LDLIBS)))
86
87 # list of found libraries files (useful for deps). If not found, the
88 # library is silently ignored and dep won't be checked
89 LDLIBS_FILES := $(wildcard $(foreach dir,$(LDLIBS_PATH),\
90         $(addprefix $(dir)/,$(LDLIBS_NAMES))))
91
92 #
93 # Archive objects in .so file if needed
94 #
95 $(SHARED): $(OBJS-y) $(LDLIBS_FILES) $(DEP_$(SHARED)) FORCE
96         @[ -d $(dir $@) ] || mkdir -p $(dir $@)
97         $(if $(D),\
98                 @echo -n "$< -> $@ " ; \
99                 echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
100                 echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_SO_STR))) " ; \
101                 echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
102                 echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
103         $(if $(or \
104                 $(file_missing),\
105                 $(call cmdline_changed,$(O_TO_SO_STR)),\
106                 $(depfile_missing),\
107                 $(depfile_newer)),\
108                 $(O_TO_SO_DO))
109
110 #
111 # install lib in $(RTE_OUTPUT)/lib
112 #
113 $(RTE_OUTPUT)/lib/$(SHARED): $(SHARED)
114         @echo "  INSTALL-SHARED $(SHARED)"
115         @[ -d $(RTE_OUTPUT)/lib ] || mkdir -p $(RTE_OUTPUT)/lib
116         $(Q)cp -f $(SHARED) $(RTE_OUTPUT)/lib
117
118 #
119 # Clean all generated files
120 #
121 .PHONY: clean
122 clean: _postclean
123
124 .PHONY: doclean
125 doclean:
126         $(Q)rm -rf $(SHARED) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
127           $(CMDS-all) $(INSTALL-FILES-all)
128         $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
129
130 include $(RTE_SDK)/mk/internal/rte.compile-post.mk
131 include $(RTE_SDK)/mk/internal/rte.install-post.mk
132 include $(RTE_SDK)/mk/internal/rte.clean-post.mk
133 include $(RTE_SDK)/mk/internal/rte.build-post.mk
134 include $(RTE_SDK)/mk/internal/rte.depdirs-post.mk
135
136 .PHONY: FORCE
137 FORCE: