blob: 0d34b98d05facbf34bc6dea8a61cfbbae275d9e8 (
plain)
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
|
TARGET := get-uctypes
# All source files of the project
SRCFILES := $(wildcard *.c)
# All header files of the project
HDRFILES := $(wildcard *.h)
# All object files in the project
OBJFILES := $(patsubst %.c,%.o,$(SRCFILES))
# All test drivers (_t)
TSTFILES := $(patsubst %.c,%_t,$(SRCFILES))
# All dependency files (.d)
DEPFILES := $(patsubst %.c,%.d,$(SRCFILES))
# All test driver dependency files (_t.d)
TSTDEPFILES := $(patsubst %,%.d,$(TSTFILES))
# All test driver dependency files (_t.d)
WARNINGS := -Wall -Wextra -pedantic -Wno-unused-parameter -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-long-long -Wuninitialized -Wstrict-prototypes -Wdeclaration-after-statement
CFLAGS := -g -std=c99 $(WARNINGS) $(USERFLAGS) -I.
.PHONY: all clean tests
all: $(TARGET)
$(TARGET): $(OBJFILES)
@echo " CC $@"
@$(CC) $^ -o $@
@echo
tests: testdrivers
-@rc=0; count=0; failed=""; for file in $(TSTFILES); do echo " TST $$file"; ./$$file; test=$$?; if [ $$test != 0 ]; then rc=`expr $$rc + $$test`; failed="$$failed $$file"; fi; count=`expr $$count + 1`; done; echo; echo "Tests executed: $$count Tests failed: $$rc"; echo; for file in $$failed; do echo "Failed: $$file"; done; echo
testdrivers: $(TSTFILES)
@echo
-include $(DEPFILES) $(TSTDEPFILES)
clean:
-@$(RM) $(wildcard $(OBJFILES) $(DEPFILES) $(TSTFILES) $(TSTDEPFILES) $(TARGET) aux.a)
%.o: %.c Makefile
@echo " CC $@"
@$(CC) $(CFLAGS) -MMD -MP -c $< -o $@
%_t: %.c Makefile aux.a
@echo " CC $@"
@$(CC) $(CFLAGS) -MMD -MP -DTEST $< aux.a -o $@
aux.a: $(OBJFILES)
@ar rc $@ $^
|