1# You probably want to take -DREDEBUG out of CFLAGS, and put something like
2# -O in, *after* testing (-DREDEBUG strengthens testing by enabling a lot of
3# internal assertion checking and some debugging facilities).
4# Put -Dconst= in for a pre-ANSI compiler.
5# Do not take -DPOSIX_MISTAKE out.
6# REGCFLAGS isn't important to you (it's for my use in some special contexts).
7CFLAGS=-I. -DPOSIX_MISTAKE -DREDEBUG $(REGCFLAGS)
8
9# If you have a pre-ANSI compiler, put -o into MKHFLAGS.  If you want
10# the Berkeley __P macro, put -b in.
11MKHFLAGS=
12
13# Flags for linking but not compiling, if any.
14LDFLAGS=
15
16# Extra libraries for linking, if any.
17LIBS=
18
19# Internal stuff, should not need changing.
20OBJPRODN=regcomp.o regexec.o regerror.o regfree.o
21OBJS=$(OBJPRODN) split.o debug.o main.o
22H=cclass.h cname.h regex2.h utils.h
23REGSRC=regcomp.c regerror.c regexec.c regfree.c
24ALLSRC=$(REGSRC) engine.c debug.c main.c split.c
25
26# Stuff that matters only if you're trying to lint the package.
27LINTFLAGS=-I. -Dstatic= -Dconst= -DREDEBUG
28LINTC=regcomp.c regexec.c regerror.c regfree.c debug.c main.c
29JUNKLINT=possible pointer alignment|null effect
30
31# arrangements to build forward-reference header files
32.SUFFIXES:	.ih .h
33.c.ih:
34	sh ./mkh $(MKHFLAGS) -p $< >$@
35
36default:	r
37
38lib:	purge $(OBJPRODN)
39	rm -f libregex.a
40	ar crv libregex.a $(OBJPRODN)
41
42purge:
43	rm -f *.o
44
45# stuff to build regex.h
46REGEXH=regex.h
47REGEXHSRC=regex2.h $(REGSRC)
48$(REGEXH):	$(REGEXHSRC) mkh
49	sh ./mkh $(MKHFLAGS) -i _REGEX_H_ $(REGEXHSRC) >regex.tmp
50	cmp -s regex.tmp regex.h 2>/dev/null || cp regex.tmp regex.h
51	rm -f regex.tmp
52
53# dependencies
54$(OBJPRODN) debug.o:	utils.h regex.h regex2.h
55regcomp.o:	cclass.h cname.h regcomp.ih
56regexec.o:	engine.c engine.ih
57regerror.o:	regerror.ih
58debug.o:	debug.ih
59main.o:	main.ih
60
61# tester
62re:	$(OBJS)
63	$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
64
65# regression test
66r:	re tests
67	./re <tests
68	./re -el <tests
69	./re -er <tests
70
71# 57 variants, and other stuff, for development use -- not useful to you
72ra:	./re tests
73	-./re <tests
74	-./re -el <tests
75	-./re -er <tests
76
77rx:	./re tests
78	./re -x <tests
79	./re -x -el <tests
80	./re -x -er <tests
81
82t:	./re tests
83	-time ./re <tests
84	-time ./re -cs <tests
85	-time ./re -el <tests
86	-time ./re -cs -el <tests
87
88l:	$(LINTC)
89	lint $(LINTFLAGS) -h $(LINTC) 2>&1 | egrep -v '$(JUNKLINT)' | tee lint
90
91fullprint:
92	ti README WHATSNEW notes todo | list
93	ti *.h | list
94	list *.c
95	list regex.3 regex.7
96
97print:
98	ti README WHATSNEW notes todo | list
99	ti *.h | list
100	list reg*.c engine.c
101
102
103mf.tmp:	Makefile
104	sed '/^REGEXH=/s/=.*/=regex.h/' Makefile | sed '/#DEL$$/d' >$@
105
106DTRH=cclass.h cname.h regex2.h utils.h
107PRE=COPYRIGHT README WHATSNEW
108POST=mkh regex.3 regex.7 tests $(DTRH) $(ALLSRC) fake/*.[ch]
109FILES=$(PRE) Makefile $(POST)
110DTR=$(PRE) Makefile=mf.tmp $(POST)
111dtr:	$(FILES) mf.tmp
112	makedtr $(DTR) >$@
113	rm mf.tmp
114
115cio:	$(FILES)
116	cio $(FILES)
117
118rdf:	$(FILES)
119	rcsdiff -c $(FILES) 2>&1 | p
120
121# various forms of cleanup
122tidy:
123	rm -f junk* core core.* *.core dtr *.tmp lint
124
125clean:	tidy
126	rm -f *.o *.s *.ih re libregex.a
127
128# don't do this one unless you know what you're doing
129spotless:	clean
130	rm -f mkh regex.h
131