summaryrefslogtreecommitdiff
path: root/Makefile
blob: 87f541e945e98167a7e59dcd1fb46860f48ea6df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# The target
TARGET = casa-1.1b

# The compiler options
CC = g++
CFLAGS = \
    -Wredundant-decls -Wall -Werror -Wno-class-memaccess -g \
    -Icasa -Icommon -Icommon/utility -Iminisat/solver -Iminisat/include \
    -DSEARCH_PROGRESS
LFLAGS =
DFLAGS = -MM

#the .C files, without their extensions
COMBINATORICS_SOURCES = PascalTriangle Combinadic CombinadicIterator
MINISAT_SOURCES = Solver
SAT_SOURCES = SAT
IO_SOURCES = Usage SpecificationFile ConstraintFile OutputFile
STATE_SOURCES = CoveringArray CoveringArrayEntry CoveringArrayRow CoveringArraySubRow
SPACE_SOURCES = CoveringArraySpace SingleChangeSpace GraftSpace
BOOKKEEPING_SOURCES = Options
ANNEALING_SOURCES = Anneal AnnealingSuccess Bounds AnnealingPartitioner
ALGORITHM_SOURCES = BinarySearch
MAIN_SOURCES = Main
SOURCES = \
    $(COMBINATORICS_SOURCES:%=common/utility/%) \
    $(MINISAT_SOURCES:%=minisat/solver/%) \
    $(SAT_SOURCES:%=casa/sat/%) \
    $(IO_SOURCES:%=casa/io/%) \
    $(STATE_SOURCES:%=casa/covering/state/%) \
    $(SPACE_SOURCES:%=casa/covering/space/%) \
    $(BOOKKEEPING_SOURCES:%=casa/covering/bookkeeping/%) \
    $(ANNEALING_SOURCES:%=casa/annealing/%) \
    $(ALGORITHM_SOURCES:%=casa/algorithms/%) \
    $(MAIN_SOURCES:%=casa/%)

# The rules
all:	$(TARGET) TAGS

$(TARGET):	$(SOURCES:%=%.o)
	$(CC) -o $@ $(filter %.o,$^) $(LFLAGS)

$(SOURCES:%=%.o):	Makefile
	$(CC) -c -o $@ $(@:%.o=%.C) $(CFLAGS)

$(SOURCES:%=%.d):	%.d:%.C Makefile
	$(CC) $(DFLAGS) $(@:%.d=%.C) $(CFLAGS) | sed 's,.*\.o:,$(@:%.d=%.o) $@:	,g' > $@
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),distclean)
-include $(SOURCES:%=%.d)
endif
endif

Dependencies:	$(SOURCES:%=%.d)
	sed -e 's/://g' -e 's/[^ ][^ ]*\.d//g' -e 's/[^ ][^ ]*\.o//g' -e 's/[ 	\\][ 	\\]*/ /g' $(SOURCES:%=%.d) | tr ' ' "\n" | sort | uniq | tr "\n" ' ' | sed 's/^/ALL_INPUTS =/' > $@
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),distclean)
-include Dependencies
endif
endif

TAGS:	$(ALL_INPUTS)
	etags $^

clean:
	-$(RM) $(TARGET) $(SOURCES:%=%.o)

distclean:	clean
	-$(RM) $(SOURCES:%=%.d) Dependencies TAGS

.PHONY:	all clean distclean