]> pd.if.org Git - pdclib/blob - Makefile
Porting current working set from CVS.
[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 PROJDIRS := functions includes internals
5 SRCFILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.c")
6 HDRFILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.h")
7 INTFILES := atomax digits seed strtox_main strtox_prelim rename remove _Exit
8 OBJFILES := $(patsubst %.c,%.o,$(SRCFILES))
9 TSTFILES := $(patsubst %.c,%.t,$(SRCFILES))
10 REGFILES := $(filter-out $(patsubst %,functions/_PDCLIB/%.r,$(INTFILES)),$(patsubst %.c,%.r,$(SRCFILES)))
11 DEPFILES := $(patsubst %.c,%.d,$(SRCFILES))
12 ALLFILES := $(SRCFILES) $(HDRFILES) $(AUXFILES)
13
14 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
15
16 .PHONY: clean dist test testdrivers regtest
17
18 all: pdclib.a
19
20 pdclib.a: $(OBJFILES)
21         @ar r pdclib.a $?
22
23 test: testdrivers
24         -@rc=0; count=0; for file in $(TSTFILES); do ./$$file; rc=`expr $$rc + $$?`; count=`expr $$count + 1`; done; echo; echo "Tests executed (linking PDCLib): $$count  Tests failed: $$rc"
25
26 testdrivers: $(TSTFILES)
27
28 regtest: regtestdrivers
29         -@rc=0; count=0; for file in $(REGFILES); do ./$$file; rc=`expr $$rc + $$?`; count=`expr $$count + 1`; done; echo; echo "Tests executed (linking system libc): $$count  Tests failed: $$rc"
30
31 regtestdrivers: $(REGFILES)
32
33 -include $(DEPFILES)
34
35 clean:
36         @for file in $(OBJFILES) $(DEPFILES) $(TSTFILES) $(REGFILES) pdclib.a pdclib.tgz; do if [ -f $$file ]; then rm $$file; fi; done
37
38 dist:
39         @tar czf pdclib.tgz $(ALLFILES)
40
41 todolist:
42         -@for file in $(ALLFILES); do grep -H TODO $$file; done; true
43
44 %.o: %.c Makefile
45         @$(CC) $(CFLAGS) -Wall -DNDEBUG -MMD -MP -MT "$*.d $*.t" -g -std=c99 -I./includes -I./internals -c $< -o $@
46
47 %.t: %.c Makefile pdclib.a
48         @$(CC) $(CFLAGS) -DTEST -std=c99 -I./includes -I./internals $< pdclib.a -o $@
49
50 %.r: %.c Makefile
51         @$(CC) $(CFLAGS) -DTEST -DREGTEST -std=c99 -I./internals $< -o $@