]> pd.if.org Git - pdclib/blob - Makefile
Some filename cleanup in functions/_PDCLIB.
[pdclib] / Makefile
1 # This is a list of all non-source files that are part of the distribution.
2 AUXFILES := Makefile Readme.txt
3
4 # Directories belonging to the project
5 PROJDIRS := functions includes internals platform/example
6 # All source files of the project
7 SRCFILES := $(shell find -L $(PROJDIRS) -type f -name "*.c")
8 # All header files of the project
9 HDRFILES := $(shell find -L $(PROJDIRS) -type f -name "*.h")
10 # All object files in the library
11 OBJFILES := $(patsubst %.c,%.o,$(SRCFILES))
12 # All test drivers (.t)
13 TSTFILES := $(patsubst %.c,%_t,$(SRCFILES))
14 # All regression test drivers (.r)
15 REGFILES := $(patsubst %.c,%_r,$(SRCFILES))
16 # All library dependency files (.d)
17 DEPFILES := $(patsubst %.c,%.d,$(SRCFILES))
18 # All test driver dependency files (_t.d)
19 TSTDEPFILES := $(patsubst %,%.d,$(TSTFILES))
20 # All regression test driver dependency files (_r.d)
21 REGDEPFILES := $(patsubst %,%.d,$(REGFILES))
22 # All files belonging to the source distribution
23 ALLFILES := $(SRCFILES) $(HDRFILES) $(AUXFILES)
24
25 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
26 CFLAGS := -fno-builtin -g -std=c99 -I./internals -I./testing -I./platform/example/include -I./platform/example/internals $(WARNINGS) $(USERFLAGS)
27
28 .PHONY: all clean srcdist tests testdrivers regtests regtestdrivers todos fixmes help
29
30 all: pdclib.a testdrivers regtestdrivers
31         @echo
32         @echo "========================"
33         @echo "Executing library tests:"
34         @echo "========================"
35         @echo
36         @$(MAKE) tests | grep -v "^ TST" | grep -v "^Failed"
37         @echo
38         @echo "==========================="
39         @echo "Executing regression tests:"
40         @echo "==========================="
41         @echo
42         @$(MAKE) regtests | grep -v "^ RTST" | grep -v "^Failed"
43         @echo
44         @echo "========"
45         @echo "FIXME's:"
46         @echo "========"
47         @echo
48         @$(MAKE) fixmes
49         @echo
50         @echo "======="
51         @echo "TODO's:"
52         @echo "======="
53         @echo
54         @$(MAKE) todos | head
55         @echo "..."
56
57 pdclib.a: $(OBJFILES)
58         @echo " AR      $@"
59         @ar rc pdclib.a $?
60         @echo
61
62 tests: testdrivers
63         -@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 (linking PDCLib): $$count  Tests failed: $$rc"; echo; for file in $$failed; do echo "Failed: $$file"; done; echo
64
65 testdrivers: $(TSTFILES)
66         @echo
67
68 regtests: regtestdrivers
69         -@rc=0; count=0; failed=""; for file in $(REGFILES); do echo " RTST     $$file"; ./$$file; test=$$?; if [ $$test != 0 ]; then rc=`expr $$rc + $$test`; failed="$$failed $$file"; fi; count=`expr $$count + 1`; done; echo; echo "Tests executed (linking system libc): $$count  Tests failed: $$rc"; echo; for file in $$failed; do echo "Failed: $$file"; done; echo
70
71 regtestdrivers: $(REGFILES)
72         @echo
73
74 -include $(DEPFILES) $(TSTDEPFILES) $(REGDEPFILES)
75
76 clean:
77         -@$(RM) $(wildcard $(OBJFILES) $(DEPFILES) $(TSTFILES) $(TSTDEPFILES) $(REGFILES) $(REGDEPFILES) pdclib.a pdclib.tgz scanf_testdata_*)
78
79 srcdist:
80         @tar czf pdclib.tgz $(ALLFILES)
81
82 todos:
83         -@for file in $(ALLFILES:Makefile=); do grep -H TODO $$file; done; true
84
85 fixmes:
86         -@for file in $(ALLFILES:Makefile=); do grep -H FIXME $$file; done; true
87
88 help:
89         @echo "Available make targets:"
90         @echo
91         @echo "all              - build pdclib.a"
92         @echo "clean            - remove all object files, dependency files and test drivers"
93         @echo "srcdist          - build pdclib.tgz (source tarball)"
94         @echo "tests            - build and run test drivers (link pdclib.a)"
95         @echo "  testdrivers    - build but do not run test drivers"
96         @echo "regtests         - build and run regression test drivers (link system clib)"
97         @echo "  regtestdrivers - build but do not run regression test drivers"
98         @echo "todos            - list all TODO comments in the sources"
99         @echo "fixmes           - list all FIXME comments in the sources"
100         @echo "%.o              - build an individual object file"
101         @echo "%.t              - build an individual test driver"
102         @echo "%.r              - build an individual regression test driver"
103         @echo "help             - print this list"
104         @echo
105         @echo "Any additional compiler flags you want to use can be passed as USERFLAGS"
106         @echo "(Usage: USERFLAGS=\"flags\" make [...])."
107
108 %.o: %.c Makefile
109         @echo " CC      $(patsubst functions/%,%,$@)"
110         @$(CC) $(CFLAGS) -MMD -MP -I./includes -c $< -o $@
111
112 %_t: %.c Makefile pdclib.a
113         @echo " CC      $(patsubst functions/%,%,$@)"
114         @$(CC) $(CFLAGS) -MMD -MP -DTEST -I./includes $< pdclib.a -o $@
115
116 %_r: %.c Makefile
117         @echo " CC      $(patsubst functions/%,%,$@)"
118         @$(CC) $(CFLAGS) -Wno-deprecated-declarations -Wno-format -MMD -MP -DTEST -DREGTEST $< -o $@