3 # This creates a static library.
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
10 # All output is writtin to .o files in the build directory
12 # See defaults.mak for information about LOCAL
14 # Some local definitions
15 LOCAL := 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
21 # Install the command hooks
22 headers: $($(LOCAL)-HEADERS)
23 library: $($(LOCAL)-LIB)
25 veryclean: veryclean/$(LOCAL)
28 MKDIRS += $(OBJ) $(DEP) $(LIB) $(dir $($(LOCAL)-HEADERS))
31 .PHONY: clean/$(LOCAL) veryclean/$(LOCAL)
33 -rm -f $($(@F)-OBJS) $($(@F)-DEP)
34 veryclean/$(LOCAL): clean/$(LOCAL)
35 -rm -f $($(@F)-HEADERS) $($(@F)-LIB)
37 # Build rules for the two symlinks
38 .PHONY: $($(LOCAL)-LIB)
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,$^)
45 ifneq ($(words $(RANLIB)),0)
52 echo Compiling $< to $@
53 $(CXX) -c $(INLINEDEPFLAG) $(CPPFLAGS) $(CXXFLAGS) -o $@ $<
56 # Include the dependencies that are available
57 The_DFiles = $(wildcard $($(LOCAL)-DEP))
58 ifneq ($(words $(The_DFiles)),0)