3 # Copyright 2012-2013 6WIND S.A.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
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
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.
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.
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
36 # VPATH contains at least SRCDIR
40 _INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y) $(RTE_OUTPUT)/lib/$(SHARED)
43 # Set fPIC in CFLAGS for .so generation
50 install: build _postinstall
57 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
59 ifeq ($(LINK_USING_CC),1)
60 override EXTRA_LDFLAGS := $(call linkerprefix,$(EXTRA_LDFLAGS))
61 O_TO_SO = $(CC) $(call linkerprefix,$(LDFLAGS)) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
62 -shared -o $@ $(OBJS-y) $(call linkerprefix,$(LDLIBS))
64 O_TO_SO = $(LD) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
65 -shared -o $@ $(OBJS-y) $(LDLIBS)
68 O_TO_SO_STR = $(subst ','\'',$(O_TO_SO)) #'# fix syntax highlight
69 O_TO_SO_DISP = $(if $(V),"$(O_TO_SO_STR)"," LD $(@)")
70 O_TO_SO_CMD = "cmd_$@ = $(O_TO_SO_STR)"
71 O_TO_SO_DO = @set -e; \
72 echo $(O_TO_SO_DISP); \
74 echo $(O_TO_SO_CMD) > $(call exe2cmd,$(@))
76 -include .$(SHARED).cmd
78 # path where libraries are retrieved
79 LDLIBS_PATH := $(subst -Wl$(comma)-L,,$(filter -Wl$(comma)-L%,$(LDLIBS)))
80 LDLIBS_PATH += $(subst -L,,$(filter -L%,$(LDLIBS)))
82 # list of .a files that are linked to this application
83 LDLIBS_NAMES := $(patsubst -l%,lib%.a,$(filter -l%,$(LDLIBS)))
84 LDLIBS_NAMES += $(patsubst -Wl$(comma)-l%,lib%.a,$(filter -Wl$(comma)-l%,$(LDLIBS)))
86 # list of found libraries files (useful for deps). If not found, the
87 # library is silently ignored and dep won't be checked
88 LDLIBS_FILES := $(wildcard $(foreach dir,$(LDLIBS_PATH),\
89 $(addprefix $(dir)/,$(LDLIBS_NAMES))))
92 # Archive objects in .so file if needed
94 $(SHARED): $(OBJS-y) $(LDLIBS_FILES) $(DEP_$(SHARED)) FORCE
95 @[ -d $(dir $@) ] || mkdir -p $(dir $@)
97 @echo -n "$< -> $@ " ; \
98 echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
99 echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_SO_STR))) " ; \
100 echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
101 echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
104 $(call cmdline_changed,$(O_TO_SO_STR)),\
110 # install lib in $(RTE_OUTPUT)/lib
112 $(RTE_OUTPUT)/lib/$(SHARED): $(SHARED)
113 @echo " INSTALL-SHARED $(SHARED)"
114 @[ -d $(RTE_OUTPUT)/lib ] || mkdir -p $(RTE_OUTPUT)/lib
115 $(Q)cp -f $(SHARED) $(RTE_OUTPUT)/lib
118 # Clean all generated files
125 $(Q)rm -rf $(SHARED) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
126 $(CMDS-all) $(INSTALL-FILES-all)
127 $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
129 include $(RTE_SDK)/mk/internal/rte.compile-post.mk
130 include $(RTE_SDK)/mk/internal/rte.install-post.mk
131 include $(RTE_SDK)/mk/internal/rte.clean-post.mk
132 include $(RTE_SDK)/mk/internal/rte.build-post.mk