]> git.saurik.com Git - apt.git/blame - buildlib/library.mak
Fixed cisco cacheengine lameness
[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
18LOCAL := lib$(LIBRARY).so.$(MAJOR).$(MINOR)
19$(LOCAL)-OBJS := $(addprefix $(OBJ)/,$(addsuffix .opic,$(notdir $(basename $(SOURCE)))))
e1b1ae50 20$(LOCAL)-DEP := $(addprefix $(DEP)/,$(addsuffix .opic.d,$(notdir $(basename $(SOURCE)))))
094a497d
AL
21$(LOCAL)-HEADERS := $(addprefix $(INCLUDE)/,$(HEADERS))
22$(LOCAL)-SONAME := lib$(LIBRARY).so.$(MAJOR)
880e9be4 23$(LOCAL)-SLIBS := $(SLIBS)
e1b1ae50 24$(LOCAL)-LIBRARY := $(LIBARARY)
094a497d
AL
25
26# Install the command hooks
27headers: $($(LOCAL)-HEADERS)
28library: $(LIB)/lib$(LIBRARY).so $(LIB)/lib$(LIBRARY).so.$(MAJOR)
29clean: clean/$(LOCAL)
30veryclean: veryclean/$(LOCAL)
31
32# The clean rules
33.PHONY: clean/$(LOCAL) veryclean/$(LOCAL)
34clean/$(LOCAL):
35 -rm -f $($(@F)-OBJS) $($(@F)-DEP)
36veryclean/$(LOCAL): clean/$(LOCAL)
e1b1ae50 37 -rm -f $($(@F)-HEADERS) $(LIB)/lib$($(@F)-LIBRARY).so*
094a497d
AL
38
39# Build rules for the two symlinks
40.PHONY: $(LIB)/lib$(LIBRARY).so.$(MAJOR) $(LIB)/lib$(LIBRARY).so
41$(LIB)/lib$(LIBRARY).so.$(MAJOR): $(LIB)/lib$(LIBRARY).so.$(MAJOR).$(MINOR)
42 ln -sf $(<F) $@
43$(LIB)/lib$(LIBRARY).so: $(LIB)/lib$(LIBRARY).so.$(MAJOR).$(MINOR)
44 ln -sf $(<F) $@
45
46# The binary build rule
47$(LIB)/lib$(LIBRARY).so.$(MAJOR).$(MINOR): $($(LOCAL)-HEADERS) $($(LOCAL)-OBJS)
48 echo Building shared library $@
49 $(CXX) $(CXXFLAGS) $(LDFLAGS) $(PICFLAGS) $(LFLAGS) -o $@ \
880e9be4
AL
50 -Wl,-soname -Wl,$($(@F)-SONAME) -shared $(filter %.opic,$^) \
51 $($(@F)-SLIBS)
094a497d
AL
52
53# Compilation rules
54vpath %.cc $(SUBDIRS)
55$(OBJ)/%.opic: %.cc
56 echo Compiling $< to $@
57 $(CXX) -c $(INLINEDEPFLAG) $(CPPFLAGS) $(CXXFLAGS) $(PICFLAGS) -o $@ $<
58 $(DoDep)
59
60# Include the dependencies that are available
61The_DFiles = $(wildcard $($(LOCAL)-DEP))
62ifneq ($(words $(The_DFiles)),0)
63include $(The_DFiles)
64endif