]> pd.if.org Git - pdclib/blob - Makefile
Removed redundant -Wall.
[pdclib] / Makefile
1 # $Id$
2
3 # This is a list of all non-source files that are part of the distribution.
4 AUXFILES := Makefile Readme.txt
5
6 # Directories belonging to the project
7 PROJDIRS := functions includes internals
8 # All source files of the project
9 SRCFILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.c")
10 # All header files of the project
11 HDRFILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.h")
12 # All .c files in functions/_PDCLIB that do not have a regression test driver
13 INTFILES := _Exit atomax digits print rename remove seed strtox_main strtox_prelim
14 # All object files in the library
15 OBJFILES := $(patsubst %.c,%.o,$(SRCFILES))
16 # All test drivers (.t)
17 TSTFILES := $(patsubst %.c,%.t,$(SRCFILES))
18 # All regression test drivers (.r)
19 REGFILES := $(filter-out $(patsubst %,functions/_PDCLIB/%.r,$(INTFILES)),$(patsubst %.c,%.r,$(SRCFILES)))
20 # All dependency files (.d)
21 DEPFILES := $(patsubst %.c,%.d,$(SRCFILES))
22 # All files belonging to the source distribution
23 ALLFILES := $(SRCFILES) $(HDRFILES) $(AUXFILES)
24
25 # All files in platform/example/functions/_PDCLIB (for development only)
26 PATCHFILES1 := $(shell ls platform/example/functions/_PDCLIB/*.c)
27 # All files in platform/example/functions/stdlib (for development only)
28 PATCHFILES2 := $(shell ls platform/example/functions/stdlib/*.c)
29
30 CFLAGS := -Wall -pedantic -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-long-long -Wconversion -Wstrict-prototypes
31
32 .PHONY: all clean dist tests testdrivers regtests regtestdrivers todos fixmes find links unlink help
33
34 all: pdclib.a
35
36 pdclib.a: $(OBJFILES)
37         @ar r pdclib.a $?
38
39 tests: testdrivers
40         -@rc=0; count=0; for file in $(TSTFILES); do echo " TST $$file"; ./$$file; rc=`expr $$rc + $$?`; count=`expr $$count + 1`; done; echo; echo "Tests executed (linking PDCLib): $$count  Tests failed: $$rc"
41
42 testdrivers: $(TSTFILES)
43
44 regtests: regtestdrivers
45         -@rc=0; count=0; for file in $(REGFILES); do echo " RTST        $$file"; ./$$file; rc=`expr $$rc + $$?`; count=`expr $$count + 1`; done; echo; echo "Tests executed (linking system libc): $$count  Tests failed: $$rc"
46
47 regtestdrivers: $(REGFILES)
48
49 -include $(DEPFILES)
50
51 clean:
52         @for file in $(OBJFILES) $(DEPFILES) $(TSTFILES) $(REGFILES) pdclib.a pdclib.tgz; do if [ -f $$file ]; then rm $$file; fi; done
53
54 dist:
55         @tar czf pdclib.tgz $(ALLFILES)
56
57 todos:
58         -@for file in $(ALLFILES); do grep -H TODO $$file; done; true
59
60 fixmes:
61         -@for file in $(ALLFILES); do grep -H FIXME $$file; done; true
62
63 find:
64         @find functions/ includes/ internals/ platform/ -name "*\.[ch]" -type f | xargs grep $$FIND
65
66 links:
67         @echo "Linking platform/example..."
68         @cd internals && ln -s ../platform/example/internals/_PDCLIB_config.h
69         @cd includes && ln -s ../platform/example/includes/float.h
70         @cd functions/_PDCLIB && for file in $(PATCHFILES1); do basfile=`basename $$file`; if [ ! -f $$basfile ]; then ln -s `ls ../../$$file` .; fi; done
71         @cd functions/stdlib && for file in $(PATCHFILES2); do basfile=`basename $$file`; if [ ! -f $$basfile ]; then ln -s `ls ../../$$file` .; fi; done
72
73 unlink:
74         @echo "Unlinking platform files..."
75         @if [ -f internals/_PDCLIB_config.h ]; then rm internals/_PDCLIB_config.h; fi
76         @if [ -f includes/float.h ]; then rm includes/float.h; fi
77         @cd functions/_PDCLIB && for file in $(PATCHFILES1); do basfile=`basename $$file`; if [ -f $$basfile ]; then rm $$basfile; fi; done
78         @cd functions/stdlib && for file in $(PATCHFILES2); do basfile=`basename $$file`; if [ -f $$basfile ]; then rm $$basfile; fi; done
79
80 help:
81         @echo "Available make targets:"
82         @echo
83         @echo "all              - build pdclib.a"
84         @echo "clean            - remove all object files, dependency files and test drivers"
85         @echo "dist             - build pdclib.tgz (source tarball)"
86         @echo "tests            - build and run test drivers (link pdclib.a)"
87         @echo "  testdrivers    - build but do not run test drivers"
88         @echo "regtests         - build and run regression test drivers (link system clib)"
89         @echo "  regtestdrivers - build but do not run regression test drivers"
90         @echo "todos            - list all TODO comments in the sources"
91         @echo "fixmes           - list all FIXME comments in the sources"
92         @echo "find             - find a phrase in the sources (Usage: FIND=\"phrase\" make find)"
93         @echo "links            - link example platform files (development only)"
94         @echo "unlink           - remove links to example platform files (development only)"
95         @echo "%.o              - build an individual object file"
96         @echo "%.t              - build an individual test driver"
97         @echo "%.r              - build an individual regression test driver"
98         @echo "help             - print this list"
99
100 %.o: %.c Makefile
101         @echo " CC      $@"
102         @$(CC) $(CFLAGS) -DNDEBUG -MMD -MP -MT "$*.d $*.t" -g -std=c99 -I./includes -I./internals -c $< -o $@
103
104 %.t: %.c Makefile pdclib.a
105         @echo " CC      $@"
106         @$(CC) $(CFLAGS) -DTEST -std=c99 -I./includes -I./internals $< pdclib.a -o $@
107
108 %.r: %.c Makefile
109         @echo " CC      $@"
110         @$(CC) $(CFLAGS) -DTEST -DREGTEST -std=c99 -I./internals $< -o $@