]> git.saurik.com Git - apt.git/blame - buildlib/library.mak
fix Alt-Filename handling of file method
[apt.git] / buildlib / library.mak
CommitLineData
094a497d
AL
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
10c9f030 8# $(LIBRARY) - The name of the library without lib or .so
094a497d
AL
9# $(MAJOR) - The major version number of this library
10# $(MINOR) - The minor version number of this library
c6e8074f 11# $(APT_DOMAIN) - The text domain for this library
094a497d
AL
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
44c8b5df 19LOCAL := lib$(LIBRARY).so.$(MAJOR).$(MINOR)
094a497d 20$(LOCAL)-OBJS := $(addprefix $(OBJ)/,$(addsuffix .opic,$(notdir $(basename $(SOURCE)))))
e1b1ae50 21$(LOCAL)-DEP := $(addprefix $(DEP)/,$(addsuffix .opic.d,$(notdir $(basename $(SOURCE)))))
094a497d 22$(LOCAL)-HEADERS := $(addprefix $(INCLUDE)/,$(HEADERS))
44c8b5df 23$(LOCAL)-SONAME := lib$(LIBRARY).so.$(MAJOR)
ae97af1f 24$(LOCAL)-VERSIONSCRIPT := $(LIB)/lib$(LIBRARY)-$(MAJOR)-$(MINOR).symver
880e9be4 25$(LOCAL)-SLIBS := $(SLIBS)
3763d79d 26$(LOCAL)-LIBRARY := $(LIBRARY)
094a497d 27
80948457
AL
28TYPE = src
29include $(PODOMAIN_H)
30
094a497d
AL
31# Install the command hooks
32headers: $($(LOCAL)-HEADERS)
44c8b5df 33library: $(LIB)/lib$(LIBRARY).so $(LIB)/lib$(LIBRARY).so.$(MAJOR)
094a497d
AL
34clean: clean/$(LOCAL)
35veryclean: veryclean/$(LOCAL)
36
b2e465d6
AL
37# Make Directories
38MKDIRS += $(OBJ) $(DEP) $(LIB) $(dir $($(LOCAL)-HEADERS))
39
094a497d
AL
40# The clean rules
41.PHONY: clean/$(LOCAL) veryclean/$(LOCAL)
42clean/$(LOCAL):
ae97af1f 43 -rm -f $($(@F)-OBJS) $($(@F)-DEP) $($(@F)-VERSIONSCRIPT)
094a497d 44veryclean/$(LOCAL): clean/$(LOCAL)
a5b7cd82 45 -rm -f $($(@F)-HEADERS) $(LIB)/lib$($(@F)-LIBRARY)*.so*
094a497d
AL
46
47# Build rules for the two symlinks
44c8b5df
DK
48.PHONY: $(LIB)/lib$(LIBRARY).so.$(MAJOR) $(LIB)/lib$(LIBRARY).so
49$(LIB)/lib$(LIBRARY).so.$(MAJOR): $(LIB)/lib$(LIBRARY).so.$(MAJOR).$(MINOR)
094a497d 50 ln -sf $(<F) $@
44c8b5df 51$(LIB)/lib$(LIBRARY).so: $(LIB)/lib$(LIBRARY).so.$(MAJOR).$(MINOR)
094a497d 52 ln -sf $(<F) $@
80948457 53
ae97af1f
DK
54$($(LOCAL)-VERSIONSCRIPT):
55 echo '$(shell echo '$(LIBRARY)' | tr -d '-' | tr 'a-z' 'A-Z')_$(MAJOR) { global: *; };' > $@
56
094a497d 57# The binary build rule
ae97af1f 58$(LIB)/lib$(LIBRARY).so.$(MAJOR).$(MINOR): $($(LOCAL)-HEADERS) $($(LOCAL)-OBJS) $(LIBRARYDEPENDS) $($(LOCAL)-VERSIONSCRIPT)
a5b7cd82 59 -rm -f $(LIB)/lib$($(@F)-LIBRARY)*.so* 2> /dev/null
094a497d 60 echo Building shared library $@
c3c77d09 61 $(CXX) $(CXXSTD) $(CXXFLAGS) $(LDFLAGS) -Wl,--version-script=$($(@F)-VERSIONSCRIPT) $(PICFLAGS) $(LFLAGS) $(LFLAGS_SO)\
70fbac25
AL
62 -o $@ $(SONAME_MAGIC)$($(@F)-SONAME) -shared \
63 $(filter %.opic,$^) \
64 $($(@F)-SLIBS)
094a497d
AL
65
66# Compilation rules
67vpath %.cc $(SUBDIRS)
564fcbf9 68$(OBJ)/%.opic: %.cc $(LIBRARYDEPENDS)
094a497d 69 echo Compiling $< to $@
85a67355 70 $(CXX) -c $(INLINEDEPFLAG) $(CPPFLAGS) $(CXXSTD) $(CXXFLAGS) $(PICFLAGS) -o $@ '$(abspath $<)'
094a497d
AL
71 $(DoDep)
72
73# Include the dependencies that are available
74The_DFiles = $(wildcard $($(LOCAL)-DEP))
75ifneq ($(words $(The_DFiles)),0)
76include $(The_DFiles)
80948457 77endif