-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
80 lines (54 loc) · 3.4 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
CC = gcc
COMP_FLAGS =
LOAD_FLAGS = $(COMP_FLAGS) -lfl -ldl -lm
HEADERS = $(wildcard src/cryml/*.h) $(wildcard src/cryml/stdlib/*.h) $(wildcard src/cryml/data/*.h)
CRYML_OBJECTS := $(patsubst %.c,%.o,$(wildcard src/cryml/*.c))
DATA_OBJECTS := $(patsubst %.c,%.o,$(wildcard src/cryml/stdlib/*.c))
STDLIB_OBJECTS := $(patsubst %.c,%.o,$(wildcard src/cryml/data/*.c))
CRYML_FILES := src/cryml/*.c
DATA_FILES := src/cryml/stdlib/*.c
STDLIB_FILES := src/cryml/data/*.c
SYNTACTIC_OBJECTS := src/generated/syntactic.o
default: parser
src/generated/lexical.c: $(HEADERS) src/grammar/cryml.lex folder_dependency
flex --outfile=src/generated/lexical.c src/grammar/cryml.lex
syntactic: src/generated/syntactic.c
src/generated/syntactic.c: src/grammar/cryml.bison folder_dependency
bison --report=state --graph --defines=src/generated/syntactic.h -o src/generated/syntactic.c src/grammar/cryml.bison
graph: syntactic
dot -Tpng src/generated/syntactic.dot -o src/generated/graph.png
dot -Tsvg src/generated/syntactic.dot -o src/generated/graph.svg
parser: bin/parser
bin/parser: bin/lib_example_functions.so $(HEADERS) src/generated/lexical.c $(CRYML_OBJECTS) $(DATA_OBJECTS) $(STDLIB_OBJECTS) $(SYNTACTIC_OBJECTS) src/parser.c
$(CC) -g $(CRYML_OBJECTS) $(DATA_OBJECTS) $(STDLIB_OBJECTS) $(SYNTACTIC_OBJECTS) src/parser.c -o bin/parser $(LOAD_FLAGS)
cryml: bin/cryml
bin/cryml: $(HEADERS) src/generated/lexical.c $(CRYML_OBJECTS) $(DATA_OBJECTS) $(STDLIB_OBJECTS) $(SYNTACTIC_OBJECTS) src/parser.c
$(CC) -g $(CRYML_OBJECTS) $(DATA_OBJECTS) $(STDLIB_OBJECTS) $(SYNTACTIC_OBJECTS) src/cryml.c -o bin/cryml $(LOAD_FLAGS)
debug_parser: $(HEADERS) src/generated/lexical.c $(CRYML_OBJECTS) $(DATA_OBJECTS) src/parser.c syntactic
$(CC) -g $(CRYML_OBJECTS) $(DATA_OBJECTS) $(STDLIB_OBJECTS) src/generated/syntactic.c src/parser.c -o bin/parser $(LOAD_FLAGS)
compile: $(HEADERS) src/generated/lexical.c $(CRYML_OBJECTS) $(DATA_OBJECTS) $(STDLIB_OBJECTS) src/cryml.c
$(CC) $(CRYML_OBJECTS) $(DATA_OBJECTS) $(STDLIB_OBJECTS) src/cryml.c -o bin/cryml $(LOAD_FLAGS)
bin/unit_test: $(HEADERS) src/generated/lexical.c $(CRYML_OBJECTS) $(DATA_OBJECTS) $(STDLIB_OBJECTS) test/unit/*.c test/unit.c syntactic
$(CC) -g $(CRYML_OBJECTS) $(DATA_OBJECTS) $(STDLIB_OBJECTS) test/unit/*.c test/unit.c src/generated/syntactic.c -lcunit -o bin/unit_test $(LOAD_FLAGS)
unit_test: $(HEADERS) src/generated/lexical.c $(CRYML_OBJECTS) $(DATA_OBJECTS) $(STDLIB_OBJECTS) test/unit/*.c test/unit.c bin/unit_test
./bin/unit_test
test: folder_dependency $(HEADERS) src/generated/lexical.c $(CRYML_OBJECTS) $(DATA_OBJECTS) test/unit/*.c test/unit.c bin/unit_test
./bin/unit_test
parsing_leaks: parser test/examples/simple.cryml
MallocStackLogging=1 ./bin/parser test/examples/simple.cryml
testing_leaks: unit_test
MallocStackLogging=1 ./bin/unit_test
bin/lib_example_functions.so: $(CRYML_FILES) $(DATA_FILES) $(STDLIB_FILES)
$(CC) -Wall -fPIC -c $(CRYML_FILES) $(DATA_FILES) $(STDLIB_FILES) test/lib_examples/lib_example_functions.c
$(CC) -shared -o bin/lib_example_functions.so *.o
rm *.o
bin/ray_tracing.so: $(CRYML_FILES) $(DATA_FILES) $(STDLIB_FILES)
$(CC) -Wall -fPIC -c $(CRYML_FILES) $(DATA_FILES) $(STDLIB_FILES) test/lib_examples/ray_tracing.c
$(CC) -shared -o bin/ray_tracing.so *.o
rm *.o
clean:
rm -rfv src/generated/* bin/* $(CRYML_OBJECTS) $(DATA_OBJECTS) $(STDLIB_OBJECTS) $(SYNTACTIC_OBJECTS)
folder_dependency:
mkdir -p src/generated
mkdir -p tmp
mkdir -p bin