-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
103 lines (81 loc) · 2.74 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
CC=gcc
SRC=./
BIN=./bin/
OBJ=./obj/
DEPENDENCIES_FILE=dependencies.mk
CFLAGS=-std=c89
LFLAGS=
INSTALL_PATH=/usr/local/bin/
TESTERS_PATH=testers/
BIN_TESTERS=$(BIN)$(TESTERS_PATH)
OBJ_TESTERS=$(OBJ)$(TESTERS_PATH)
DEVELOPMENT ?= 0
ifeq ($(DEVELOPMENT), 1)
CFLAGS+=-g -Wall -O0
else
CFLAGS+=-O3 -DNDEBUG
endif
TESTERS=tokenizer-tester tokenizer-special-mode-tester parser-tester compiler-tester
PROGRAM=jcunit
SAMPLE_FILE=./examples/base.test
vpath %.c $(SRC)
vpath %.c $(HEADERS)
all: build
OBJECTS+=main.o
OBJECTS+=tokenizer.o
OBJECTS+=bytes-allocator.o
OBJECTS+=object-allocator.o
OBJECTS+=string.o
OBJECTS+=list.o
OBJECTS+=ast.o
OBJECTS+=parse.o
OBJECTS+=runner.o
OBJECTS+=child-process.o
OBJECTS+=show-result.o
OBJECTS+=util.o
OBJECTS+=fs.o
OBJECTS+=version.o
OBJECTS+=test-iterator.o
OBJECTS+=compiler.o
OBJECTS+=source.o
OBJECTS+=options.o
OBJECTS+=application.o
OBJECTS+=errors.o
ifeq ($(DEVELOPMENT), 1)
OBJECTS+=print.o
endif
OBJECTS_TOKENIZER_TESTER=$(TESTERS_PATH)tokenizer-tester.o print.o tokenizer.o bytes-allocator.o object-allocator.o string.o util.o options.o \
errors.o
OBJECTS_TOKENIZER_SPECIAL_MODE_TESTER=$(TESTERS_PATH)tokenizer-special-mode-tester.o print.o tokenizer.o bytes-allocator.o \
object-allocator.o string.o util.o options.o errors.o
OBJECTS_PARSER_TESTER=$(TESTERS_PATH)parser-tester.o print.o tokenizer.o bytes-allocator.o object-allocator.o string.o util.o options.o parse.o \
ast.o list.o errors.o
OBJECTS_COMPILER_TESTER=$(TESTERS_PATH)compiler-tester.o print.o tokenizer.o bytes-allocator.o object-allocator.o string.o util.o options.o \
parse.o ast.o list.o compiler.o errors.o application.o fs.o source.o show-result.o test-iterator.o runner.o \
child-process.o
build: $(addprefix $(OBJ), $(OBJECTS)) | dependencies
$(CC) $(LFLAGS) $^ -o $(BIN)$(PROGRAM)
tokenizer-tester: $(addprefix $(OBJ), $(OBJECTS_TOKENIZER_TESTER))
$(CC) $(LFLAGS) $^ -o $(BIN_TESTERS)tokenizer-tester
tokenizer-special-mode-tester: $(addprefix $(OBJ), $(OBJECTS_TOKENIZER_SPECIAL_MODE_TESTER))
$(CC) $(LFLAGS) $^ -o $(BIN_TESTERS)tokenizer-special-mode-tester
parser-tester: $(addprefix $(OBJ), $(OBJECTS_PARSER_TESTER))
$(CC) $(LFLAGS) $^ -o $(BIN_TESTERS)parser-tester
compiler-tester: $(addprefix $(OBJ), $(OBJECTS_COMPILER_TESTER))
$(CC) $(LFLAGS) $^ -o $(BIN_TESTERS)compiler-tester
dependencies:
@rm -rf $(DEPENDENCIES_FILE)
@$(foreach file, $(OBJECTS), $(CC) -MT $(OBJ)$(file) -MM $(patsubst %.o, %.c, $(file)) >> $(DEPENDENCIES_FILE);)
testers: $(TESTERS)
install: build
cp $(BIN)$(PROGRAM) $(INSTALL_PATH)$(PROGRAM)
uninstall:
rm -rfv $(INSTALL_PATH)$(PROGRAM)
clean:
rm -rfv $(BIN)$(PROGRAM)
rm -rfv $(OBJ)*.o
rm -rfv $(OBJ_TESTERS)*.o
rm -rfv $(BIN_TESTERS)*
$(OBJ)%.o: %.c
$(CC) $(CFLAGS) -c $(SRC)$*.c -o $@
-include $(DEPENDENCIES_FILE)