-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (49 loc) · 3.54 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
#–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
# CONFIGURATION
#–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
override \
CFLAGS += -funsigned-char \
-W -Wall -Wextra -Werror \
-Wno-unknown-warning -Wno-unknown-warning-option -Wno-padded \
-Wno-parentheses -Wno-c99-compat -Wno-unused-function \
-Isrc -Itemplib \
-DBUILDSTAMP=$(shell date +"%Y%m%d.%H%M%S")
ifdef STACKDEBUG
override CFLAGS += -O1 -ggdb3 -DulNEEDTRACE
else ifdef DEBUG
override CFLAGS += -O1 -ggdb3
else
override CFLAGS += -Ofast -DNDEBUG
endif
FORCEPREP := $(shell mkdir -p templib && find . -iregex ".*src/.*\.[ch].*" -exec cp -a {} templib/ \;)
VPATH = templib
#–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
# TARGETS
#–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
.PHONY: clean test
all: test
%.o : %.c
@$(CC) $(CFLAGS) -c $<
clean:
@rm -fr .DS_Store Thumbs.db core *.dSYM *.o
@rm -fr */.DS_Store */Thumbs.db */core */*.dSYM */*.o
-@$(foreach dir,$(shell find modules -type d -depth 1 2>/dev/null),$(MAKE) clean -C $(dir) 2>/dev/null;)
@rm -fr $(TESTEXE) templib
#–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
# TEST HARNESS
#–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
TESTEXE = ./testprog
TESTSTART = printf "%s %-36s" "Testing" $(subst test_,,$@...)
TESTEND = printf "\342\234\205 OK\n" || printf "\342\235\214\033[1;31m FAILED!!!\033[m\n"
TESTCC = $(CC) $(CFLAGS) -o $(TESTEXE)
test: testbegin testsuite testfinish
testbegin: ; @printf "RUNNING TEST SUITE\n——————————————————\n"
testfinish: ; @rm -fr $(TESTEXE) templib temp.rtf test/latepartial-output.rtf test/letter-output.rtf
#–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
# SPECIFIC TESTS
#–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
testsuite: test_regexes
test_regexes: trex.o TEST/testtrex.c
@$(TESTSTART)
@$(TESTCC) trex.o TEST/testtrex.c -o $(TESTEXE)
@$(TESTEXE) && $(TESTEND)