-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
69 lines (49 loc) · 1.65 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
DISABLED_WARNINGS=switch
CFLAGS=-g -Wall $(patsubst %, -Wno-%, $(DISABLED_WARNINGS)) -std=gnu11 -Ilibcollect
LDFLAGS=-Llibcollect -lcollect
YACC=lemon/lemon
LEX=flex
NOWANTS=src/lexer.c src/gram.c src/hashmap.c src/stack.c
SOURCES=$(wildcard src/*.c) $(wildcard src/*.l) $(wildcard src/*.y)
OBJECTS=$(patsubst %.c, %.o, $(patsubst %.l, %.o, $(patsubst %.y, %.o, $(filter-out $(NOWANTS), $(SOURCES)))))
TEST_SOURCES=$(wildcard tests/*_tests.check)
TEST_OBJECTS=$(patsubst %.check, %.o, $(TEST_SOURCES)) \
$(patsubst %.check, %.c, $(TEST_SOURCES))
TESTS=$(patsubst %.check, bin/%, $(TEST_SOURCES))
.PRECIOUS: $(TESTS)
.PHONY: all parser lemon test clean dist-clean indent objects libcollect getexternals
all: bin/calculator
bin/calculator: $(OBJECTS) bin libcollect
$(CC) -o $@ $(OBJECTS) $(LDFLAGS)
src/calculator.o: src/calculator.c src/lexer.c
parser: src/gram.y lemon
$(YACC) $<
src/lexer.c: src/lexer.l parser
$(LEX) --header-file=src/lexer.h -o $@ $<
bin:
mkdir -p bin
bin/tests:
mkdir -p bin/tests
tests/%_tests.c: tests/%_tests.check
checkmk $< > $@
bin/tests/%_tests: tests/%_tests.c src/lexer.c libcollect bin/tests
$(CC) $(CFLAGS) `pkg-config --cflags --libs check` -o $@ $< src/gram.c src/ast.c src/ast_eval.c src/lexer.c $(LDFLAGS)
$@
libcollect:
@- make -C libcollect
lemon:
@- make -C lemon
test: $(TESTS)
objects:
@- echo $(OBJECTS)
clean:
rm -rf bin lib $(OBJECTS) src/gram.h src/gram.c src/gram.out src/lexer.c src/lexer.h
dist-clean:
@- make clean
@- make -C libcollect clean
@- make -C lemon clean
indent:
find . \( -iname "*.c" -o -iname "*.h" \) -exec astyle --style=linux {} \;
getexternals:
git submodule init
git submodule update