#
# rh:
# >>>> VERSION: 2 <<<<
# Written by: Ken Stauffer
# VERSION 2.8
# Enhancements and bug fixes by Rick Ohnemus
#
# Place one of the following -D's onto the end of
# the definition of CFLAGS.
#
# -DSYSV
#	- System V/III like OS (including Xenix)
#
# -DBSD
#	- BSD like OS (including SunOS and Ultrix)
#
# Also, place one of the following -D's onto the end of
# the definition of CFLAGS if you have an operating system
# in the specified subclass of the classes listed above.
#
# -DSUNOS_4
#    - SunOS 4.x (subclass of BSD)
#
# -DSYSVR3
#    - System V Release 3.x (subclass of SYSV)
#
# -DULTRIX
#    - Ultrix Version 3.x or higher (subclass of BSD)
#
# -Dvoid=int
#    - for systems that don't like void
#
# -DNEED_STRSTR
#    - Some systems are missing strstr() or have bad
#      (or even extremely bad in Sun's case)
#      implementations of strstr().
#

#CPPFLAGS= -DSYSV -DSYSVR3
#CPPFLAGS= -DBSD -DULTRIX -DNEED_STRSTR
CPPFLAGS= -DBSD -DSUNOS_4 -DNEED_STRSTR
CPP= /usr/lib/cpp

CFLAGS= -O -pipe
#CFLAGS= $(CPPFLAGS) -O -pipe
#CFLAGS= $(CPPFLAGS) -O

YACC= byacc
YFLAGS= -t

#LINTFLAGS= $(CPPFLAGS) -ah
LINTFLAGS= $(CPPFLAGS) -bhx

#EXTRA_SRC=strdup.c strstr.c
EXTRA_SRC=strstr.c
#EXTRA_OBJ=strdup.o strstr.o
EXTRA_OBJ=strstr.o

SRCS= rhcmds.c rh.c rhparse.c rhdir.c rhdata.c wildmat.c \
      rhcache.c resname.c getdate.c $(EXTRA_SRC)

OBJS= rhcmds.o rh.o rhparse.o rhdir.o rhdata.o wildmat.o \
      rhcache.o resname.o getdate.o $(EXTRA_OBJ)

rh: $(OBJS)
	$(CC) $(CFLAGS) $(OBJS) -o rh

purify: $(OBJS)
	purify $(CC) $(CFLAGS) $(OBJS) -o rh

lint: $(SRCS)
	lint $(LINTFLAGS) $(SRCS)

saber_src: $(SRCS)
	#load $(CPPFLAGS) $(SRCS)

clean:
	rm -f rh core *.o *~ mon.out getdate.c y.output \
		Makefile.bak purify.out mem.leak

depend: $(SRCS)
	sed -n -e '1,/^### DO NOT DELETE THIS LINE/p' < Makefile \
	   | sed -e '/^### DO NOT DELETE THIS LINE/d' > Makefile.new
	echo "### DO NOT DELETE THIS LINE - make depend needs it" >> Makefile.new
	echo >> Makefile.new
	for fl in $(SRCS) ; \
	do \
	   $(CPP) $(CPPFLAGS) -M $$fl | grep -v ': /usr/include/' >> Makefile.new ; \
	   echo >> Makefile.new ; \
	done
	mv Makefile Makefile.bak
	mv Makefile.new Makefile

### DO NOT DELETE THIS LINE - make depend needs it

rhcmds.o: rhcmds.c
rhcmds.o: ./rh.h

rh.o: rh.c
rh.o: ./rh.h

rhparse.o: rhparse.c
rhparse.o: ./rh.h

rhdir.o: rhdir.c
rhdir.o: ./rh.h

rhdata.o: rhdata.c
rhdata.o: ./rh.h

wildmat.o: wildmat.c

rhcache.o: rhcache.c
rhcache.o: ./rh.h

resname.o: resname.c

getdate.o: getdate.c

strstr.o: strstr.c

