1 | # This makefile is adapted from Peter Miller's article |
---|
2 | # "Recursive Make Considered Harmful" |
---|
3 | # |
---|
4 | # http://www.pcug.org.au/~millerp/rmch/recu-make-cons-harm.html |
---|
5 | |
---|
6 | MODULES := Common Parser SynTree SymTab ResolvExpr CodeGen ControlStruct GenPoly Tuples InitTweak Designators #Try ArgTweak Explain |
---|
7 | TARGET := cfa-cpp |
---|
8 | |
---|
9 | all: $(TARGET) |
---|
10 | |
---|
11 | # look for include files in each of the modules |
---|
12 | CXX := @CXX@ |
---|
13 | CXXFLAGS += -Wno-deprecated -Wall -g -DDEBUG_ALL -I. -I Common -MMD |
---|
14 | INSTALL=@INSTALL@ |
---|
15 | |
---|
16 | # this is the back-end compiler, used to compile libcfa & builtins to link with user code |
---|
17 | BACKEND_CC := @BACKEND_CC@ |
---|
18 | |
---|
19 | # uncomment the definition of this variable to enable purify |
---|
20 | # (do a "purerun" first) |
---|
21 | #PURIFY := purify --cache-dir=$(HOME)/tmp |
---|
22 | |
---|
23 | # extra libraries if required |
---|
24 | LIBS := |
---|
25 | |
---|
26 | # each module will add to this |
---|
27 | SRC := main.cc MakeLibCfa.cc |
---|
28 | |
---|
29 | # other things that ought to be cleaned up |
---|
30 | EXTRA_OUTPUT := core |
---|
31 | |
---|
32 | # include the description for each module |
---|
33 | include $(patsubst %,%/module.mk,$(MODULES)) |
---|
34 | |
---|
35 | # determine the object files |
---|
36 | OBJ := $(patsubst %.cc,%.o,$(filter %.cc,$(SRC))) \ |
---|
37 | $(patsubst %.y,%.tab.o,$(filter %.y,$(SRC))) \ |
---|
38 | $(patsubst %.l,%.yy.o,$(filter %.l,$(SRC))) |
---|
39 | |
---|
40 | # include the C include dependencies |
---|
41 | DEPS := $(OBJ:.o=.d) |
---|
42 | -include $(DEPS) |
---|
43 | |
---|
44 | # link the program |
---|
45 | $(TARGET): $(OBJ) |
---|
46 | $(PURIFY) $(CXX) -o $@ $(OBJ) $(LIBS) |
---|
47 | |
---|
48 | #installing |
---|
49 | install: $(TARGET) |
---|
50 | $(INSTALL) -d @CFA_LIBDIR@ |
---|
51 | $(INSTALL) $(TARGET) @CFA_LIBDIR@ |
---|
52 | |
---|
53 | # clean-up rule |
---|
54 | clean: |
---|
55 | rm -f $(OBJ) $(DEPS) $(TARGET) tags $(EXTRA_OUTPUT) |
---|
56 | find . -name "Expected*" -prune -o \( -name "*.tst" -o -name "report" \) -print | xargs rm -f |
---|
57 | find . -name "core*" -print | xargs rm -f |
---|
58 | |
---|
59 | distclean: clean |
---|