1# Makefile for regex testing.
2#
3# Copyright (C) 1992 Free Software Foundation, Inc.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2, or (at your option)
8# any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19CPPFLAGS =
20CFLAGS = -g
21LDFLAGS =
22
23srcdir = @srcdir@
24VPATH = @srcdir@:../@srcdir@
25
26CC = @CC@
27DEFS = @DEFS@
28LIBS = @LIBS@ $(LOADLIBES)
29
30ETAGS = etags
31SHELL = /bin/sh
32
33debug = -DDEBUG
34ALL_CPPFLAGS = -I. -I$(srcdir) -I../$(srcdir) $(DEFS) $(CPPFLAGS) $(debug)
35
36.c.o:
37	$(CC) $(ALL_CPPFLAGS) $(CFLAGS) -c $<
38
39
40# Define this as `../regex.o' to get the optimized version.
41regex_o = dregex.o
42test_h = test.h
43test_o = test.o bsd-interf.o other.o tregress.o psx-basic.o psx-extend.o \
44         psx-generic.o psx-group.o psx-interf.o psx-interv.o
45common_o = printchar.o upcase.o xmalloc.o $(malloc)
46
47# We have a lot of mallocs we can try when we run afoul of strange bugs.
48malloc = @ALLOCA@
49#malloc = # the libc malloc
50#malloc = g++malloc.o
51#malloc = debugmalloc.o
52#malloc = emacsmalloc.o
53emacsmallocflags = -Drcheck -Dbotch=abort -DUSG
54
55# default is to do nothing.
56default:
57
58all: regex syntax
59
60regex: $(regex_o) $(common_o) $(test_o) main.o
61	$(CC) -o $@ $(LDFLAGS) $^ $(LIBS)
62
63# As long as we're doing tests, we enable debugging.
64dregex.o: ../regex.c ../regex.h
65	rm -f $@
66	$(CC) $(ALL_CPPFLAGS) $(CFLAGS) -c ../$(srcdir)/regex.c
67	mv regex.o $@
68
69# iregex is the interactive regex.
70iregex: $(common_o) $(regex_o) iregex.o
71	$(CC) -o $@ $(LDFLAGS) $^ $(LIBS)
72
73# fileregex searches for an r.e. in every line of a given file.
74fileregex_o = fileregex.o printchar.o $(regex_o)
75fileregex: $(fileregex_o)
76	$(CC) -o $@ $(LDFLAGS) $(fileregex_o) $(LIBS)
77
78# cppregex is regex with a preprocessed regex.c.  Useful when the
79# problem is inside some macro.
80cppregex: regexcpp.o $(common_o) $(test_o) main.o
81	$(CC) -o $@ $(LDFLAGS) $^ $(LIBS)
82
83regexcpp.o: regexcpp.c
84
85regexcpp.c: regex.c regexcpp.sed
86	rm -f regexcpp.c
87	$(CC) -E $(ALL_CPPFLAGS) ../$(srcdir)/regex.c \
88          | egrep -v '^#|^ *$$' \
89          | sed -f regexcpp.sed \
90          > regexcpp.c
91	chmod a-w regexcpp.c
92
93# Have to give this malloc special flags.
94emacsmalloc.o: emacsmalloc.c
95	$(CC) -c $(CFLAGS) $(ALL_CPPFLAGS) $(emacsmallocflags) \
96	  ../$(srcdir)/test/emacsmalloc.c
97
98syntax: syntax.o
99	$(CC) $(CFLAGS) -o $@ syntax.o
100
101syntax.c: syntax.skel bits
102	sed '/\[\[\[replace.*\]\]\]/r bits' syntax.skel > $@
103
104bits: regex.h
105	sed -n 1,/RE_SYNTAX_EMACS/p ../$(srcdir)/regex.h \
106          | grep "#define RE_.*1" \
107          | sed 's/^#define \(RE_[A-Z_]*\) .*/  TEST_BIT (\1);/' > $@
108
109check: regex
110	./regex
111
112TAGS: regex.c regex.h *.h *.c
113	$(ETAGS) -t $^
114
115depend:
116	gcc -MM $(ALL_CPPFLAGS) *.c > /tmp/depend
117.PHONY: depend
118
119install:
120.PHONY: install
121
122clean mostlyclean:
123	rm -f *.o regex cppregex iregex fileregex regexcpp.c syntax
124
125distclean: clean
126	rm -f bits syntax.c Makefile
127
128extraclean: distclean
129	rm -f *~* *\#* patch* *.orig *.rej *.bak core a.out
130
131realclean: distclean
132	rm -f TAGS
133
134Makefile: Makefile.in ../config.status
135	(cd ..; sh config.status)
136
137# Prevent GNU make 3 from overflowing arg limit on system V.
138.NOEXPORT:
139
140# Assumes $(distdir) is the place to put our files.
141distfiles = ChangeLog TAGS *.in *.c *.h regexcpp.sed syntax.skel
142dist: Makefile TAGS
143	mkdir $(distdir)
144	ln $(distfiles) $(distdir)
145
146# Automatically-generated dependencies below here.
147alloca.o : alloca.c
148bsd-interf.o : bsd-interf.c
149debugmalloc.o : debugmalloc.c
150emacsmalloc.o : emacsmalloc.c getpagesize.h
151fileregex.o : fileregex.c .././regex.h
152g++malloc.o : g++malloc.c //usr/include/stdio.h getpagesize.h
153iregex.o : iregex.c .././regex.h
154main.o : main.c test.h .././regex.h
155malloc-test.o : malloc-test.c
156other.o : other.c test.h .././regex.h
157printchar.o : printchar.c
158psx-basic.o : psx-basic.c test.h .././regex.h
159psx-extend.o : psx-extend.c test.h .././regex.h
160psx-generic.o : psx-generic.c test.h .././regex.h
161psx-group.o : psx-group.c test.h .././regex.h
162psx-interf.o : psx-interf.c test.h .././regex.h
163psx-interv.o : psx-interv.c test.h .././regex.h
164syntax.o : syntax.c .././regex.h
165test.o : test.c test.h .././regex.h
166tregress.o : tregress.c test.h .././regex.h
167upcase.o : upcase.c
168xmalloc.o : xmalloc.c
169