##
##  Apache Makefile, automatically generated by Configure script.
##  Hand-edited changes will be lost if the Configure script is re-run.
##  Sources: - ../Makefile.config (via Configuration.apaci)
##           - ./Makefile.tmpl
##

##
##  Inherited Makefile options from Configure script
##  (Begin of automatically generated section)
##
SRCDIR=..
MWOS=/mwos
EXTRA_CFLAGS=`$(SRCDIR)/apaci`
EXTRA_LDFLAGS=
EXTRA_LIBS=
EXTRA_INCLUDES=
EXTRA_DEPS=
OSDIR=$(SRCDIR)/os/os9
INCDIR=$(SRCDIR)/include
INCLUDES0=-v$(OSDIR) -v$(INCDIR)
SHELL=/bin/sh
OS=OS9
CC=xcc
TARGET=httpd
OPTIM=
CFLAGS1= -DOS9 -v$(SRCDIR)/lib/expat-lite
INCLUDES1= -v$(MWOS)/src/defs/spf/bsd
LIBS_SHLIB=
LDFLAGS1=
REGLIB=regex/libregex.l
EXPATLIB=lib/expat-lite/libexpat.l
RANLIB=merge
LIBS1=
##
##  (End of automatically generated section)
##


# You probably want to take -DREDEBUG out of CFLAGS, and put something like
# -O in, *after* testing (-DREDEBUG strengthens testing by enabling a lot of
# internal assertion checking and some debugging facilities).
# Put -Dconst= in for a pre-ANSI compiler.
# Do not take -DPOSIX_MISTAKE out.
# REGCFLAGS isn't important to you (it's for my use in some special contexts).
INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
CFLAGS=-v. $(INCLUDES) $(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS) -DPOSIX_MISTAKE

# If you have a pre-ANSI compiler, put -o into MKHFLAGS.  If you want
# the Berkeley __P macro, put -b in.
MKHFLAGS=

# Flags for linking but not compiling, if any.
LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS) -sl=$(SRCDIR)/ap

# Extra libraries for linking, if any.
LIBS=$(EXTRA_LIBS) $(LIBS1) -llibap.l

# Internal stuff, should not need changing.
OBJPRODN=regcomp.r regexec.r regerror.r regfree.r
OBJS=$(OBJPRODN) split.r debug.r main.r
H=cclass.h cname.h regex2.h utils.h
REGSRC=regcomp.c regerror.c regexec.c regfree.c
ALLSRC=$(REGSRC) engine.c debug.c main.c split.c

# Stuff that matters only if you're trying to lint the package.
LINTFLAGS=-v. -Dstatic= -Dconst= -DREDEBUG
LINTC=regcomp.c regexec.c regerror.c regfree.c debug.c main.c
JUNKLINT=possible pointer alignment|null effect

# arrangements to build forward-reference header files
.SUFFIXES:	.ih .h
.c.ih:
#	sh ./mkh $(MKHFLAGS) -p $< >$@
	echo sh ./mkh $(MKHFLAGS) -p $< to $@

.c.r:
	$(CC) -eas $(INCLUDES) $(CFLAGS) $<

all lib: libregex.l

libregex.l: $(OBJPRODN)
	rm -f libregex.l
	$(RANLIB) -o=libregex.l $(OBJPRODN) 

default:	r

purge:
	rm -f *.r

# stuff to build regex.h
REGEXH=../include/hsregex.h
REGEXHSRC=regex2.h $(REGSRC)
$(REGEXH):	$(REGEXHSRC) mkh
	sh ./mkh $(MKHFLAGS) -i _REGEX_H_ $(REGEXHSRC) > $(REGEXH)

#	cmp -s regex.tmp regex.h 2>/dev/null || cp regex.tmp regex.h
#	rm -f regex.tmp

# no automatic dependencies here
depend:

# dependencies
$(OBJPRODN) debug.r:	utils.h $(REGEXH) regex2.h
regcomp.r:	cclass.h cname.h regcomp.ih
regexec.r:	engine.c engine.ih
regerror.r:	regerror.ih
debug.r:	debug.ih
main.r:	main.ih
 
# tester - just compile... do not link
re-nolink: $(OBJS)
	$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -eas

# tester
re:	$(OBJS)
	$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -fd=$@

# regression test
r:	re tests
	./re <tests
	./re -el <tests
	./re -er <tests

# 57 variants, and other stuff, for development use -- not useful to you
ra:	./re tests
	-./re <tests
	-./re -el <tests
	-./re -er <tests

rx:	./re tests
	./re -x <tests
	./re -x -el <tests
	./re -x -er <tests

t:	./re tests
	-time ./re <tests
	-time ./re -cs <tests
	-time ./re -el <tests
	-time ./re -cs -el <tests

l:	$(LINTC)
	lint $(LINTFLAGS) -h $(LINTC) 2>&1 | egrep -v '$(JUNKLINT)' | tee lint

fullprint:
	ti README WHATSNEW notes todo | list
	ti *.h | list
	list *.c
	list regex.3 regex.7

print:
	ti README WHATSNEW notes todo | list
	ti *.h | list
	list reg*.c engine.c


mf.tmp:	Makefile
	sed '/^REGEXH=/s/=.*/=..\/include\\hsregex.h/' Makefile \
	| sed '/#DEL$$/d' >$@

DTRH=cclass.h cname.h regex2.h utils.h
PRE=COPYRIGHT README WHATSNEW
POST=mkh regex.3 regex.7 tests $(DTRH) $(ALLSRC) fake/*.[ch]
FILES=$(PRE) Makefile $(POST)
DTR=$(PRE) Makefile=mf.tmp $(POST)
dtr:	$(FILES) mf.tmp
	makedtr $(DTR) >$@
	rm mf.tmp

cio:	$(FILES)
	cio $(FILES)

rdf:	$(FILES)
	rcsdiff -c $(FILES) 2>&1 | p

# various forms of cleanup
tidy:
	rm -f junk* core core.* *.core dtr *.tmp lint

clean:	tidy
	rm -f *.r *.s re libregex.a

distclean: clean
	-rm -f Makefile

# don't do this one unless you know what you're doing
spotless:	clean
	rm -f mkh ../include/hsregex.h
