]> pd.if.org Git - pdclib/blob - Makefile
Intermediate work while migrating CVS -> SVN.
[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 PROJDIRS := functions includes internals
7 SRCFILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.c")
8 HDRFILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.h")
9 INTFILES := _Exit atomax digits lengthmods print rename remove seed strtox_main strtox_prelim
10 OBJFILES := $(patsubst %.c,%.o,$(SRCFILES))
11 TSTFILES := $(patsubst %.c,%.t,$(SRCFILES))
12 REGFILES := $(filter-out $(patsubst %,functions/_PDCLIB/%.r,$(INTFILES)),$(patsubst %.c,%.r,$(SRCFILES)))
13 DEPFILES := $(patsubst %.c,%.d,$(SRCFILES))
14 ALLFILES := $(SRCFILES) $(HDRFILES) $(AUXFILES)
15
16 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
17
18 .PHONY: clean dist test testdrivers regtest
19
20 all: pdclib.a
21
22 pdclib.a: $(OBJFILES)
23         @ar r pdclib.a $?
24
25 test: testdrivers
26         -@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"
27
28 testdrivers: $(TSTFILES)
29
30 regtest: regtestdrivers
31         -@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"
32
33 regtestdrivers: $(REGFILES)
34
35 -include $(DEPFILES)
36
37 clean:
38         @for file in $(OBJFILES) $(DEPFILES) $(TSTFILES) $(REGFILES) pdclib.a pdclib.tgz; do if [ -f $$file ]; then rm $$file; fi; done
39
40 dist:
41         @tar czf pdclib.tgz $(ALLFILES)
42
43 todolist:
44         -@for file in $(ALLFILES); do grep -H TODO $$file; done; true
45
46 fixmelist:
47         -@for file in $(ALLFILES); do grep -H FIXME $$file; done; true
48
49 find:
50         @find functions/ includes/ internals/ platform/ -name "*\.[ch]" -type f | xargs grep $$FIND
51
52 %.o: %.c Makefile
53         @echo " CC      $@"
54         @$(CC) $(CFLAGS) -Wall -DNDEBUG -MMD -MP -MT "$*.d $*.t" -g -std=c99 -I./includes -I./internals -c $< -o $@
55
56 %.t: %.c Makefile pdclib.a
57         @echo " CC      $@"
58         @$(CC) $(CFLAGS) -DTEST -std=c99 -I./includes -I./internals $< pdclib.a -o $@
59
60 %.r: %.c Makefile
61         @echo " CC      $@"
62         @$(CC) $(CFLAGS) -DTEST -DREGTEST -std=c99 -I./internals $< -o $@