-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
116 lines (78 loc) · 3.33 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
#
# File: Makefile
# Author: Dominik Horky
# Date: 2020-11-18
#
# compiler, flags
CC=gcc
CCFLAGS=-std=c99 -Wall -Wextra -Werror -g -I $(SRC) -I $(TEST)
# executable name
OUT=compilerIFJ2020
# main module
MAIN=ifj2020
# source and test folder
SRC=src/
TEST=tests/
#
# MAKE
#
make: src $(MAIN)
# PARTS
scanner.o: $(SRC)scanner.c $(SRC)scanner.h $(SRC)str.h
$(CC) $(CCFLAGS) -c $< -o $(SRC)scanner.o
parser.o: $(SRC)parser.c $(SRC)parser.h $(SRC)symtable.h $(SRC)str.h $(SRC)returns.h $(SRC)semantic.h
$(CC) $(CCFLAGS) -c $< -o $(SRC)parser.o
returns.o: $(SRC)returns.c $(SRC)returns.h
$(CC) $(CCFLAGS) -c $< -o $(SRC)returns.o
str.o: $(SRC)str.c $(SRC)str.h
$(CC) $(CCFLAGS) -c $< -o $(SRC)str.o
symtable.o: $(SRC)symtable.c $(SRC)symtable.h $(SRC)str.h
$(CC) $(CCFLAGS) -c $< -o $(SRC)symtable.o
precedent.o: $(SRC)precedent.c $(SRC)precedent.h $(SRC)scanner.h $(SRC)symstack.h $(SRC)returns.h $(SRC)str.h
$(CC) $(CCFLAGS) -c $< -o $(SRC)precedent.o
symstack.o: $(SRC)symstack.c $(SRC)symstack.h $(SRC)symtable.h $(SRC)scanner.h
$(CC) $(CCFLAGS) -c $< -o $(SRC)symstack.o
generator.o: $(SRC)generator.c $(SRC)generator.h
$(CC) $(CCFLAGS) -c $< -o $(SRC)generator.o
semantic.o: $(SRC)semantic.c $(SRC)semantic.h
$(CC) $(CCFLAGS) -c $< -o $(SRC)semantic.o
# MAIN
$(MAIN).o: $(MAIN).c $(MAIN).h $(SRC)scanner.h $(SRC)str.h $(SRC)symtable.h $(SRC)parser.h $(SRC)returns.h $(SRC)generator.h $(SRC)semantic.h
$(CC) $(CCFLAGS) -c $<
$(MAIN): $(MAIN).o $(SRC)scanner.o $(SRC)str.o $(SRC)symtable.o $(SRC)parser.o $(SRC)returns.o $(SRC)precedent.o $(SRC)symstack.o $(SRC)generator.o $(SRC)semantic.o
$(CC) $(CCFLAGS) $(MAIN).o $(SRC)scanner.o $(SRC)str.o $(SRC)symtable.o $(SRC)parser.o $(SRC)returns.o $(SRC)precedent.o $(SRC)symstack.o $(SRC)generator.o $(SRC)semantic.o -o $(OUT)
#
# ADDITIONAL FEATURES
#
# ENABLE DEBUG MESSAGES
debug: $(MAIN)-d
$(SRC)scanner-d.o: $(SRC)scanner.c $(SRC)scanner.h $(SRC)str.h
$(CC) $(CCFlAGS) -DDEBUG -c $< -o $(SRC)scanner-d.o
$(SRC)parser-d.o: $(SRC)parser.c $(SRC)parser.h $(SRC)symtable.h $(SRC)str.h $(SRC)returns.h
$(CC) $(CCFlAGS) -DDEBUG -c $< -o $(SRC)parser-d.o
$(MAIN)-d: $(MAIN).o $(SRC)scanner-d.o $(SRC)str.o $(SRC)symtable.o $(SRC)returns.o $(SRC)parser-d.o $(SRC)precedent.o $(SRC)symstack.o $(SRC)generator.o $(SRC)semantic.o
$(CC) $(CCFLAGS) -DDEBUG $(MAIN).o $(SRC)scanner-d.o $(SRC)str.o $(SRC)symtable.o $(SRC)returns.o $(SRC)parser-d.o $(SRC)precedent.o $(SRC)symstack.o $(SRC)generator.o $(SRC)semantic.o -o $(OUT)
# CLEAN MAKE OUTPUT(S)
clean:
rm -rf src/*.o tests/*.o t-* *.o $(OUT) vgcore.*
# HELP
help:
@printf "Usage of this Makefile:\n"
@printf " make \tStandard project compilation.\n"
@printf " make debug\tCompile with DEBUG defined. Executable will output debug messages to stdout/stderr.\n"
@printf " make clean\tRemove all makefile outputs. (executables, *.o files)\n"
@printf " make test\tCompile and run (all) tests.\n"
@printf " make test-c\tCompile only (all) tests.\n"
#
# COMPILE AND RUN TESTS
#
test-c: symtest
# SYMTABLE TEST
$(TEST)symtest.o: $(TEST)symtest.c $(SRC)symtable.h $(SRC)returns.h $(SRC)str.h
$(CC) $(CCFLAGS) -c $< -o $(TEST)symtest.o
symtest: $(TEST)symtest.o $(SRC)symtable.o $(SRC)returns.o $(SRC)str.o
$(CC) $(CCFLAGS) $(TEST)symtest.o $(SRC)symtable.o $(SRC)returns.o $(SRC)str.o -o t-symtable
# RUN TESTS
test: test-c runtests
runtests:
./t-*