]> git.saurik.com Git - apt.git/blame_incremental - buildlib/program.mak
Fixed docs
[apt.git] / buildlib / program.mak
... / ...
CommitLineData
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
10# See defaults.mak for information about LOCAL
11
12# Some local definitions
13LOCAL := $(PROGRAM)
14$(LOCAL)-OBJS := $(addprefix $(OBJ)/,$(addsuffix .o,$(notdir $(basename $(SOURCE)))))
15$(LOCAL)-DEP := $(addprefix $(DEP)/,$(addsuffix .d,$(notdir $(basename $(SOURCE)))))
16$(LOCAL)-BIN := $(BIN)/$(PROGRAM)
17$(LOCAL)-SLIBS := $(SLIBS)
18
19# Install the command hooks
20program: $(BIN)/$(PROGRAM)
21clean: clean/$(LOCAL)
22veryclean: veryclean/$(LOCAL)
23
24# The clean rules
25.PHONY: clean/$(LOCAL) veryclean/$(LOCAL)
26clean/$(LOCAL):
27 -rm -f $($(@F)-OBJS) $($(@F)-DEP)
28veryclean/$(LOCAL): clean/$(LOCAL)
29 -rm -f $($(@F)-BIN)
30
31# The binary build rule
32$($(LOCAL)-BIN): $($(LOCAL)-OBJS)
33 echo Building program $@
34 $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LFLAGS) $($(LOCAL)-SLIBS) -o $@ $(filter %.o,$^)
35
36# Compilation rules
37vpath %.cc $(SUBDIRS)
38$(OBJ)/%.o: %.cc
39 echo Compiling $< to $@
40 $(CXX) -c $(INLINEDEPFLAG) $(CPPFLAGS) $(CXXFLAGS) -o $@ $<
41 $(DoDep)
42
43# Include the dependencies that are available
44The_DFiles = $(wildcard $($(LOCAL)-DEP))
45ifneq ($(words $(The_DFiles)),0)
46include $(The_DFiles)
47endif