]> git.saurik.com Git - apt.git/blame - buildlib/library.mak
Work better if there are duplicate sources.list entries.
[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
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
12# All output is writtin to .opic files in the build directory to
13# signify the PIC output.
14
15# See defaults.mak for information about LOCAL
16
17# Some local definitions
a5b7cd82 18LOCAL := lib$(LIBRARY)$(LIBEXT).so.$(MAJOR).$(MINOR)
094a497d 19$(LOCAL)-OBJS := $(addprefix $(OBJ)/,$(addsuffix .opic,$(notdir $(basename $(SOURCE)))))
e1b1ae50 20$(LOCAL)-DEP := $(addprefix $(DEP)/,$(addsuffix .opic.d,$(notdir $(basename $(SOURCE)))))
094a497d 21$(LOCAL)-HEADERS := $(addprefix $(INCLUDE)/,$(HEADERS))
a5b7cd82 22$(LOCAL)-SONAME := lib$(LIBRARY)$(LIBEXT).so.$(MAJOR)
880e9be4 23$(LOCAL)-SLIBS := $(SLIBS)
3763d79d 24$(LOCAL)-LIBRARY := $(LIBRARY)
094a497d
AL
25
26# Install the command hooks
27headers: $($(LOCAL)-HEADERS)
a5b7cd82 28library: $(LIB)/lib$(LIBRARY).so $(LIB)/lib$(LIBRARY)$(LIBEXT).so.$(MAJOR)
094a497d
AL
29clean: clean/$(LOCAL)
30veryclean: veryclean/$(LOCAL)
31
b2e465d6
AL
32# Make Directories
33MKDIRS += $(OBJ) $(DEP) $(LIB) $(dir $($(LOCAL)-HEADERS))
34
094a497d
AL
35# The clean rules
36.PHONY: clean/$(LOCAL) veryclean/$(LOCAL)
37clean/$(LOCAL):
38 -rm -f $($(@F)-OBJS) $($(@F)-DEP)
39veryclean/$(LOCAL): clean/$(LOCAL)
a5b7cd82 40 -rm -f $($(@F)-HEADERS) $(LIB)/lib$($(@F)-LIBRARY)*.so*
094a497d
AL
41
42# Build rules for the two symlinks
a5b7cd82
AL
43.PHONY: $(LIB)/lib$(LIBRARY)$(LIBEXT).so.$(MAJOR) $(LIB)/lib$(LIBRARY).so
44$(LIB)/lib$(LIBRARY)$(LIBEXT).so.$(MAJOR): $(LIB)/lib$(LIBRARY)$(LIBEXT).so.$(MAJOR).$(MINOR)
094a497d 45 ln -sf $(<F) $@
a5b7cd82 46$(LIB)/lib$(LIBRARY).so: $(LIB)/lib$(LIBRARY)$(LIBEXT).so.$(MAJOR).$(MINOR)
094a497d
AL
47 ln -sf $(<F) $@
48
49# The binary build rule
a5b7cd82
AL
50$(LIB)/lib$(LIBRARY)$(LIBEXT).so.$(MAJOR).$(MINOR): $($(LOCAL)-HEADERS) $($(LOCAL)-OBJS)
51 -rm -f $(LIB)/lib$($(@F)-LIBRARY)*.so* 2> /dev/null
094a497d 52 echo Building shared library $@
70fbac25
AL
53 $(CXX) $(CXXFLAGS) $(LDFLAGS) $(PICFLAGS) $(LFLAGS) $(LFLAGS_SO)\
54 -o $@ $(SONAME_MAGIC)$($(@F)-SONAME) -shared \
55 $(filter %.opic,$^) \
56 $($(@F)-SLIBS)
094a497d
AL
57
58# Compilation rules
59vpath %.cc $(SUBDIRS)
60$(OBJ)/%.opic: %.cc
61 echo Compiling $< to $@
62 $(CXX) -c $(INLINEDEPFLAG) $(CPPFLAGS) $(CXXFLAGS) $(PICFLAGS) -o $@ $<
63 $(DoDep)
64
65# Include the dependencies that are available
66The_DFiles = $(wildcard $($(LOCAL)-DEP))
67ifneq ($(words $(The_DFiles)),0)
68include $(The_DFiles)
69endif