-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
70 lines (49 loc) · 1.73 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
.POSIX:
.SUFFIXES: .o .c
CFLAGS = -g3 -Og -Wall -Wextra -pedantic -I./lib
BIN = lexer parser analyzer mapper c0 gen
all: $(BIN)
GEN_OBJ = fatarena.o map.o token.o lex.o parser.o analyzer.o gen.o
gen: $(GEN_OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) main-c0gen.c -o $@ $(GEN_OBJ)
MAIN_ANALYZER_OBJ = fatarena.o token.o map.o lex.o parser.o analyzer.o
analyzer: $(MAIN_ANALYZER_OBJ) main-analyzer.c
$(CC) $(CFLAGS) $(LDFLAGS) main-analyzer.c -o analyzer $(MAIN_ANALYZER_OBJ)
analyzer.o: analyzer.c
$(CC) $(CFLAGS) -c analyzer.c -o analyzer.o
MAIN_PARSER_OBJ = fatarena.o token.o map.o lex.o parser.o
parser: $(MAIN_PARSER_OBJ) main-parser.c
$(CC) $(CFLAGS) $(LDFLAGS) main-parser.c -o parser $(MAIN_PARSER_OBJ)
parser.o: parser.c
$(CC) $(CFLAGS) -c parser.c -o parser.o
LEXER_OBJS = map.o lexer.o lex.o fatarena.o token.o
lexer: $(LEXER_OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(LEXER_OBJS)
MAPPER_OBJS = mapper.o fatarena.o map.o
mapper: $(MAPPER_OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(MAPPER_OBJS)
token.o: lib/token.c
$(CC) $(CFLAGS) -c lib/token.c -o $@
fatarena.o: lib/fatarena.c
$(CC) $(CFLAGS) -c lib/fatarena.c -o $@
map.o: lib/map.c
$(CC) $(CFLAGS) -c lib/map.c -o $@
.c.o:
$(CC) $(CFLAGS) -c $<
format:
astyle -q -Z -n -A3 -t8 -p -xg -H -j -xB *.[ch]
astyle -q -Z -n -A3 -t8 -p -xg -H -j -xB lib/*.[ch]
clean:
rm -f $(BIN)
rm -f *.o
rm -f tests/*.err
rm -f tests/*.res
tests: $(BIN)
sh tests/test.sh ./lexer tests/tests-lexer
sh tests/test.sh ./parser tests/tests-parser
sh tests/test.sh ./analyzer tests/tests-analyzer
rebuild-test:
sh tests/build-test.sh ./lexer tests/tests-lexer
sh tests/build-test.sh ./parser tests/tests-parser
sh tests/build-test.sh ./analyzer tests/tests-analyzer
.PHONY: all clean format rebuild-test