]> git.saurik.com Git - apt.git/blame - buildlib/staticlibrary.mak
restore ABI and prepare next ABI via #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
[apt.git] / buildlib / staticlibrary.mak
CommitLineData
e1b1ae50
AL
1# -*- make -*-
2
3# This creates a static 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
10# All output is writtin to .o files in the build directory
11
12# See defaults.mak for information about LOCAL
13
14# Some local definitions
15LOCAL := lib$(LIBRARY).a
16$(LOCAL)-OBJS := $(addprefix $(OBJ)/,$(addsuffix .o,$(notdir $(basename $(SOURCE)))))
17$(LOCAL)-DEP := $(addprefix $(DEP)/,$(addsuffix .o.d,$(notdir $(basename $(SOURCE)))))
18$(LOCAL)-HEADERS := $(addprefix $(INCLUDE)/,$(HEADERS))
19$(LOCAL)-LIB := $(LIB)/lib$(LIBRARY).a
20
21# Install the command hooks
22headers: $($(LOCAL)-HEADERS)
23library: $($(LOCAL)-LIB)
24clean: clean/$(LOCAL)
25veryclean: veryclean/$(LOCAL)
26
b2e465d6
AL
27# Make Directories
28MKDIRS += $(OBJ) $(DEP) $(LIB) $(dir $($(LOCAL)-HEADERS))
29
e1b1ae50
AL
30# The clean rules
31.PHONY: clean/$(LOCAL) veryclean/$(LOCAL)
32clean/$(LOCAL):
33 -rm -f $($(@F)-OBJS) $($(@F)-DEP)
34veryclean/$(LOCAL): clean/$(LOCAL)
35 -rm -f $($(@F)-HEADERS) $($(@F)-LIB)
36
37# Build rules for the two symlinks
38.PHONY: $($(LOCAL)-LIB)
39
40# The binary build rule
41$($(LOCAL)-LIB): $($(LOCAL)-HEADERS) $($(LOCAL)-OBJS)
42 echo Building library $@
43 -rm $@ > /dev/null 2>&1
44 $(AR) cq $@ $(filter %.o,$^)
b819effd
AL
45ifneq ($(words $(RANLIB)),0)
46 $(RANLIB) $@
47endif
e1b1ae50
AL
48
49# Compilation rules
50vpath %.cc $(SUBDIRS)
51$(OBJ)/%.o: %.cc
52 echo Compiling $< to $@
53 $(CXX) -c $(INLINEDEPFLAG) $(CPPFLAGS) $(CXXFLAGS) -o $@ $<
54 $(DoDep)
55
56# Include the dependencies that are available
57The_DFiles = $(wildcard $($(LOCAL)-DEP))
58ifneq ($(words $(The_DFiles)),0)
59include $(The_DFiles)
60endif