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
35 include $(RTE_SDK)/mk/internal/rte.depdirs-pre.mk
37 # VPATH contains at least SRCDIR
41 _INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y) $(RTE_OUTPUT)/lib/$(SHARED)
44 # Set fPIC in CFLAGS for .so generation
51 install: build _postinstall
58 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
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))
65 O_TO_SO = $(LD) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
66 -shared -o $@ $(OBJS-y) $(LDLIBS)
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); \
75 echo $(O_TO_SO_CMD) > $(call exe2cmd,$(@))
77 -include .$(SHARED).cmd
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)))
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)))
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))))
93 # Archive objects in .so file if needed
95 $(SHARED): $(OBJS-y) $(LDLIBS_FILES) $(DEP_$(SHARED)) FORCE
96 @[ -d $(dir $@) ] || mkdir -p $(dir $@)
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)) ")
105 $(call cmdline_changed,$(O_TO_SO_STR)),\
111 # install lib in $(RTE_OUTPUT)/lib
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
119 # Clean all generated files
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)
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