]> git.saurik.com Git - apt-legacy.git/blame - buildlib/program.mak
I am sick of that Package: error.
[apt-legacy.git] / buildlib / program.mak
CommitLineData
da6ee469
JF
1# -*- make -*-
2
3# This creates a program
4
5# Input
6# $(SOURCE) - The source code to use
7# $(PROGRAM) - The name of the program
8# $(SLIBS) - Shared libs to link against
9# $(LIB_MAKES) - Shared libary make files to depend on - to ensure we get
10# remade when the shared library version increases.
11
12# See defaults.mak for information about LOCAL
13
14# Some local definitions
15LOCAL := $(PROGRAM)
16$(LOCAL)-OBJS := $(addprefix $(OBJ)/,$(addsuffix .o,$(notdir $(basename $(SOURCE)))))
17$(LOCAL)-DEP := $(addprefix $(DEP)/,$(addsuffix .o.d,$(notdir $(basename $(SOURCE)))))
18$(LOCAL)-BIN := $(BIN)/$(PROGRAM)
19$(LOCAL)-SLIBS := $(SLIBS)
20$(LOCAL)-MKS := $(addprefix $(BASE)/,$(LIB_MAKES))
21
22# Install the command hooks
23program: $(BIN)/$(PROGRAM)
24clean: clean/$(LOCAL)
25veryclean: veryclean/$(LOCAL)
26
27TYPE = src
28include $(PODOMAIN_H)
29
30# Make Directories
31MKDIRS += $(OBJ) $(DEP) $(BIN)
32
33# The clean rules
34.PHONY: clean/$(LOCAL) veryclean/$(LOCAL)
35clean/$(LOCAL):
36 -rm -f $($(@F)-OBJS) $($(@F)-DEP)
37veryclean/$(LOCAL): clean/$(LOCAL)
38 -rm -f $($(@F)-BIN)
39
40# The convience binary build rule
41.PHONY: $(PROGRAM)
42$(PROGRAM): $($(LOCAL)-BIN)
43
44# The binary build rule
45$($(LOCAL)-BIN): $($(LOCAL)-OBJS) $($(LOCAL)-MKS)
46 echo Building program $@
47 echo $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LFLAGS) -o $@ $(filter %.o,$^) $($(@F)-SLIBS) $(LEFLAGS)
48 $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LFLAGS) -o $@ $(filter %.o,$^) $($(@F)-SLIBS) $(LEFLAGS)
49
50# Compilation rules
51vpath %.cc $(SUBDIRS)
52$(OBJ)/%.o: %.cc
53 echo Compiling $< to $@
54 $(CXX) -c $(INLINEDEPFLAG) $(CPPFLAGS) $(CXXFLAGS) -o $@ $<
55 $(DoDep)
56
57# Include the dependencies that are available
58The_DFiles = $(wildcard $($(LOCAL)-DEP))
59ifneq ($(words $(The_DFiles)),0)
60include $(The_DFiles)
61endif