]> git.saurik.com Git - apt.git/blob - buildlib/library.mak
sanify unused ReportMirrorFailure a tiny bit
[apt.git] / buildlib / library.mak
1 # -*- make -*-
2
3 # This creates a shared library.
4
5 # Input
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
12
13 # All output is writtin to .opic files in the build directory to
14 # signify the PIC output.
15
16 # See defaults.mak for information about LOCAL
17
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)-VERSIONSCRIPT := $(LIB)/lib$(LIBRARY)-$(MAJOR)-$(MINOR).symver
25 $(LOCAL)-SLIBS := $(SLIBS)
26 $(LOCAL)-LIBRARY := $(LIBRARY)
27
28 TYPE = src
29 include $(PODOMAIN_H)
30
31 # Install the command hooks
32 headers: $($(LOCAL)-HEADERS)
33 library: $(LIB)/lib$(LIBRARY).so $(LIB)/lib$(LIBRARY).so.$(MAJOR)
34 clean: clean/$(LOCAL)
35 veryclean: veryclean/$(LOCAL)
36
37 # Make Directories
38 MKDIRS += $(OBJ) $(DEP) $(LIB) $(dir $($(LOCAL)-HEADERS))
39
40 # The clean rules
41 .PHONY: clean/$(LOCAL) veryclean/$(LOCAL)
42 clean/$(LOCAL):
43 -rm -f $($(@F)-OBJS) $($(@F)-DEP) $($(@F)-VERSIONSCRIPT)
44 veryclean/$(LOCAL): clean/$(LOCAL)
45 -rm -f $($(@F)-HEADERS) $(LIB)/lib$($(@F)-LIBRARY)*.so*
46
47 # Build rules for the two symlinks
48 .PHONY: $(LIB)/lib$(LIBRARY).so.$(MAJOR) $(LIB)/lib$(LIBRARY).so
49 $(LIB)/lib$(LIBRARY).so.$(MAJOR): $(LIB)/lib$(LIBRARY).so.$(MAJOR).$(MINOR)
50 ln -sf $(<F) $@
51 $(LIB)/lib$(LIBRARY).so: $(LIB)/lib$(LIBRARY).so.$(MAJOR).$(MINOR)
52 ln -sf $(<F) $@
53
54 $($(LOCAL)-VERSIONSCRIPT):
55 echo '$(shell echo '$(LIBRARY)' | tr -d '-' | tr 'a-z' 'A-Z')_$(MAJOR) { global: *; };' > $@
56
57 # The binary build rule
58 $(LIB)/lib$(LIBRARY).so.$(MAJOR).$(MINOR): $($(LOCAL)-HEADERS) $($(LOCAL)-OBJS) $(LIBRARYDEPENDS) $($(LOCAL)-VERSIONSCRIPT)
59 -rm -f $(LIB)/lib$($(@F)-LIBRARY)*.so* 2> /dev/null
60 echo Building shared library $@
61 $(CXX) $(CXXSTD) $(CXXFLAGS) $(LDFLAGS) -Wl,--version-script=$($(@F)-VERSIONSCRIPT) $(PICFLAGS) $(LFLAGS) $(LFLAGS_SO)\
62 -o $@ $(SONAME_MAGIC)$($(@F)-SONAME) -shared \
63 $(filter %.opic,$^) \
64 $($(@F)-SLIBS)
65
66 # Compilation rules
67 vpath %.cc $(SUBDIRS)
68 $(OBJ)/%.opic: %.cc $(LIBRARYDEPENDS)
69 echo Compiling $< to $@
70 $(CXX) -c $(INLINEDEPFLAG) $(CPPFLAGS) $(CXXSTD) $(CXXFLAGS) $(PICFLAGS) -o $@ '$(abspath $<)'
71 $(DoDep)
72
73 # Include the dependencies that are available
74 The_DFiles = $(wildcard $($(LOCAL)-DEP))
75 ifneq ($(words $(The_DFiles)),0)
76 include $(The_DFiles)
77 endif