3 # This creates a shared library.
6 # $(SOURCE) - The source code to use
7 # $(HEADERS) - Exported header files and private header files
8 # $(LIBRARY) - The name of the library without lib or .so
9 # $(MAJOR) - The major version number of this library
10 # $(MINOR) - The minor version number of this library
11 # $(APT_DOMAIN) - The text domain for this library
13 # All output is writtin to .opic files in the build directory to
14 # signify the PIC output.
16 # See defaults.mak for information about LOCAL
18 # Some local definitions
19 LOCAL := lib$(LIBRARY).so.$(MAJOR).$(MINOR)
20 $(LOCAL)-OBJS := $(addprefix $(OBJ)/,$(addsuffix .opic,$(notdir $(basename $(SOURCE)))))
21 $(LOCAL)-DEP := $(addprefix $(DEP)/,$(addsuffix .opic.d,$(notdir $(basename $(SOURCE)))))
22 $(LOCAL)-HEADERS := $(addprefix $(INCLUDE)/,$(HEADERS))
23 $(LOCAL)-SONAME := lib$(LIBRARY).so.$(MAJOR)
24 $(LOCAL)-SLIBS := $(SLIBS)
25 $(LOCAL)-LIBRARY := $(LIBRARY)
30 # Install the command hooks
31 headers: $($(LOCAL)-HEADERS)
32 library: $(LIB)/lib$(LIBRARY).so $(LIB)/lib$(LIBRARY).so.$(MAJOR)
34 veryclean: veryclean/$(LOCAL)
37 MKDIRS += $(OBJ) $(DEP) $(LIB) $(dir $($(LOCAL)-HEADERS))
40 .PHONY: clean/$(LOCAL) veryclean/$(LOCAL)
42 -rm -f $($(@F)-OBJS) $($(@F)-DEP)
43 veryclean/$(LOCAL): clean/$(LOCAL)
44 -rm -f $($(@F)-HEADERS) $(LIB)/lib$($(@F)-LIBRARY)*.so*
46 # Build rules for the two symlinks
47 .PHONY: $(LIB)/lib$(LIBRARY).so.$(MAJOR) $(LIB)/lib$(LIBRARY).so
48 $(LIB)/lib$(LIBRARY).so.$(MAJOR): $(LIB)/lib$(LIBRARY).so.$(MAJOR).$(MINOR)
50 $(LIB)/lib$(LIBRARY).so: $(LIB)/lib$(LIBRARY).so.$(MAJOR).$(MINOR)
53 # The binary build rule
54 $(LIB)/lib$(LIBRARY).so.$(MAJOR).$(MINOR): $($(LOCAL)-HEADERS) $($(LOCAL)-OBJS) $(LIBRARYDEPENDS)
55 -rm -f $(LIB)/lib$($(@F)-LIBRARY)*.so* 2> /dev/null
56 echo Building shared library $@
57 $(CXX) $(CXXFLAGS) $(LDFLAGS) $(PICFLAGS) $(LFLAGS) $(LFLAGS_SO)\
58 -o $@ $(SONAME_MAGIC)$($(@F)-SONAME) -shared \
64 $(OBJ)/%.opic: %.cc $(LIBRARYDEPENDS)
65 echo Compiling $< to $@
66 $(CXX) -c $(INLINEDEPFLAG) $(CPPFLAGS) $(CXXFLAGS) $(PICFLAGS) -o $@ $(abspath $<)
69 # Include the dependencies that are available
70 The_DFiles = $(wildcard $($(LOCAL)-DEP))
71 ifneq ($(words $(The_DFiles)),0)