-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
150 lines (110 loc) · 3.25 KB
/
Makefile
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# Debug or release build?
BUILD_TYPE=DEBUG
# With or without coverage flags?
WITH_COVERAGE=NO
# Include gprof support?
WITH_GPROF=NO
# Include OpenMP support?
WITH_OPENMP=YES
#-----------------------------------------------------------------------------
# Root directory we do all compilation in.
BUILD_ROOT=./build
# Where all the source files are.
SRC_ROOT=./src/c
# Parser generated files
FLEX_IN=$(SRC_ROOT)/parser/sat-expression-scanner.l
FLEX_COUT=$(BUILD_ROOT)/sat-expression-scanner.c
FLEX_HOUT=$(BUILD_ROOT)/sat-expression-scanner.h
BISON_IN=$(SRC_ROOT)/parser/sat-expression-parser.y
BISON_OUT=$(BUILD_ROOT)/sat-expression-parser.c
INC_DIRS=-I$(SRC_ROOT) -I$(BUILD_ROOT)
# Executable Source Files.
SRC_FILES=$(FLEX_COUT) \
$(BISON_OUT) \
$(BUILD_ROOT)/queue.c \
$(BUILD_ROOT)/sat-expression.c \
$(BUILD_ROOT)/imp-matrix.c \
$(BUILD_ROOT)/main.c
OBJ_FILES=$(SRC_FILES:.c=.o)
# Executable output file
BIN_FILE=$(BUILD_ROOT)/sats
CC=gcc
CFLAGS+=-Wall $(INC_DIRS)
# The default test file to run when using the 'run-test' target.
TEST=tests/and.txt
#-----------------------------------------------------------------------------
# Building for debug or release?
ifeq ("$(BUILD_TYPE)" , "DEBUG")
CFLAGS+=-g -O0
else ifeq ("$(BUILD_TYPE)" , "RELEASE")
CFLAGS+=-O2
else
$(error BUILD_TYPE must be 'DEBUG' or 'RELEASE'. Got '$(BUILD_TYPE)')
endif
# Build with coverage collection support?
ifeq ("$(WITH_COVERAGE)" , "YES")
CFLAGS+=--coverage -O0
else ifeq ("$(WITH_COVERAGE)" , "NO")
else
$(error WITH_COVERAGE must be 'YES' or 'NO'. Got '$(WITH_COVERAGE)')
endif
# Build with OpenMP Support?
ifeq ("$(WITH_OPENMP)" , "YES")
CFLAGS+=-fopenmp
else ifeq ("$(WITH_OPENMP)" , "NO")
else
$(error WITH_OPENMP must be 'YES' or 'NO'. Got '$(WITH_OPENMP)')
endif
# Build with profiling support?
ifeq ("$(WITH_GPROF)" , "YES")
CFLAGS+=-pg
else ifeq ("$(WITH_GPROF)" , "NO")
else
$(error WITH_GPROF must be 'YES' or 'NO'. Got '$(WITH_GPROF)')
endif
#-----------------------------------------------------------------------------
all: $(FLEX_HOUT) $(FLEX_COUT) $(BISON_OUT) $(OBJ_FILES) $(BIN_FILE)
setup:
mkdir -p $(BUILD_ROOT)
clean: clean-tests
rm -rf ./build* gmon.out
#-----------------------------------------------------------------------------
#
# Rule: Builds C source files from flex input files.
#
$(FLEX_HOUT) $(FLEX_COUT) : $(FLEX_IN)
flex -o $(FLEX_COUT) --header-file=$(FLEX_HOUT) $(FLEX_IN)
#
# Rule: Builds C source files from bison input files.
#
$(BISON_OUT) : $(BISON_IN) $(FLEX_HOUT)
bison -o $@ $<
#
# Rule: Copy files from source folder to build folder.
#
build/%.c : src/c/%.c
cp $< $@
#
# Rule: Build object file from C source file.
#
%.o : %.c
$(CC) $(CFLAGS) -c -o $@ $< -lm
#
# Rule: Link object files into executable.
#
$(BIN_FILE) : $(OBJ_FILES)
$(CC) $(CFLAGS) -o $@ $(OBJ_FILES) -lm
#-----------------------------------------------------------------------------
docs:
doxygen doxyfile
#-----------------------------------------------------------------------------
run-test: $(BIN_FILE)
$(BIN_FILE) $(TEST)
clean-tests:
rm -rf ./build/test_logs
run-regression: $(BIN_FILE)
./bin/run-tests.sh
gen-random-tests:
./bin/test-gen.py
run-random-tests:
./bin/run-random.sh