# @(#)Makefile	3.2  DeltaDate 8/11/90   ExtrDate 10/6/90

# Variables to define your environment:
#   Define what kind of regular expression routines you have
#	BSD_RE		use re_comp()/re_exec()
#	SYSV_RE		use recmp()/regex()
#	PD_RE		use Henry Spencer's public domain routines
#			regcomp()/regexec()
#	NO_RE		no regular expressions
#
#   Define what flavor of curses you have
#	TERMCAP		use the original (BSD) curses
#	TERMINFO	use the SYSV rewrite of curses
#
#   Define what tty driver you have
#	SYSV_TTY
#	BSD_TTY
#
#   Define which string library you have
#	BSD_STRING	unprotected tolower(), index()
#	SYSV_STRING	safe tolower(), strchr()
#
#   Define which signal library you have
#	BSD_SIG		system calls are continued after interrupt
#	SYSV_SIG	system call returns error if interrupted
#
# Pick one from each of the five lists above.
#
# SIGRTN defines the return type of the signal functions, normally
#	an integer prior to SysV.3, void in SysV.3 and after
# DEBUG defines the level of debug output, normally not defined

# These are for compiling on the Sun 4.0
#CC	=	cc
#CCP	=	ccp
#LINT	=	lint
#DEFINES =	-DTERMCAP -DBSD_RE -DBSD_STRING -DSYSV_TTY -DSIGRTN=void -DBSD_SIG
#CC	=	/usr/5bin/cc
#CCP	=	/usr/5bin/ccp
#LINT	=	/usr/5bin/lint
#DEFINES =	-DTERMINFO -DBSD_RE -DBSD_STRING -DSYSV_TTY -DSIGRTN=void -DSYSV_SIG

# These are for System V
CC	=	cc
CPP	=	/lib/cpp
LINT	=	lint
DEFINES	=	-DTERMINFO -DSYSV_RE -DSYSV_STRING -DSYSV_TTY -DSIGRTN=int -DSYSV_SIG


# The PW library is where the regular expression subroutines regcmp, and
#	regex are kept. If you use -DNO_RE or if your libraries are
#	different change it.
LIBS	=	-lPW -lcurses
#LIBS	=	-lcurses -ltermcap

BINDIR	=	/usr/local/bin/
MANDIR	=	/usr/man/man1/

#CFLAGS	=	-g -DDEBUG $(DEFINES)
CFLAGS	=	-g $(DEFINES)

#
# Nothing past here should need changing
#

.SUFFIXES:	.1 .1~ .man .man~
.c~.c:
		$(GET) $(GFLAGS) $<

.man~.man:
		$(GET) $(GFLAGS) $<


SHAR	=	shar
SHARFLAGS =	-c -V -l62 -n cardfile -a -x -o cardfile

DOC	=	cardfile.1
DOCS	=	cardfile.man

HDRS	=	ascii.h cardfile.h

SRC	=	\
		cardfile.c \
		add.c \
		change.c \
		common.c \
		compress.c \
		define.c \
		delete.c \
		dumpdb.c \
		extract.c \
		find.c \
		findrcds.c \
		fmt_chk.c \
		getkey.c \
		keymatch.c \
		maint.c \
		menu.c \
		printdb.c \
		putrcd.c \
		rawio.c \
		rbuildak.c \
		screen.c \
		setupkeys.c \
		updak.c \
		$(NULL)

OBJ	=	\
		cardfile.o \
		add.o \
		change.o \
		common.o \
		compress.o \
		define.o \
		delete.o \
		dumpdb.o \
		extract.o \
		find.o \
		findrcds.o \
		fmt_chk.o \
		getkey.o \
		keymatch.o \
		maint.o \
		menu.o \
		printdb.o \
		putrcd.o \
		rawio.o \
		rbuildak.o \
		screen.o \
		setupkeys.o \
		updak.o \
		$(NULL)

TESTDB	=	\
		library.def \
		library.db \
		library.ak0 \
		library.ak1 \
		library.ak2 \
		library.ak3 \
		$(NULL)

###############################################################################
#
#	Make targets
#
###############################################################################

all:		cardfile cardfile.1

cardfile:	$(OBJ)
		$(CC) -o cardfile $(OBJ) $(LIBS)

install:	all
		cp cardfile $(BINDIR)cardfile
		strip $(BINDIR)cardfile
		cp cardfile.1 $(MANDIR)cardfile.1

clean:
		rm -f *.o cardfile cardfile.1
		for f in $(DOCS) $(SRC) $(HDRS) Makefile ; \
		do \
			if [ -f $$f -a -f s.$$f -a ! -f p.$$f ] ; \
			then \
				rm -f $$f ; \
			fi ; \
		done


print:		prt_src prt_docs

prt_src:	$(HDRS) $(SRC) Makefile
		cpr -w96 -l88 $(HDRS) $(SRC) Makefile |  \
		lp -o-v8 -o-t -o-h12

prt_docs:	$(DOC)
		nroff -man cardfile.1 | lp -o-qc

cardfile.1:	cardfile.man
		$(CPP) -C -P cardfile.man | sed -e '/^$$/d' >cardfile.1

shar:		$(HDRS) $(SRC) $(DOCS) Makefile $(TESTDB)
		$(SHAR) $(SHARFLAGS) README $(DOCS) Makefile \
			$(SRC) $(HDRS) $(TESTDB)

lint:		$(HDRS) $(SRC)
		$(LINT) $(DEFINES) $(SRC)

###############################################################################
#
#	Object dependencies
#
###############################################################################

add.o:		cardfile.h ascii.h
cardfile.o:	cardfile.h ascii.h
change.o:	cardfile.h ascii.h
common.o:	cardfile.h ascii.h
compress.o:	cardfile.h
define.o:	cardfile.h ascii.h
delete.o:	cardfile.h ascii.h
dumpdb.o:	cardfile.h ascii.h
extract.o:	cardfile.h ascii.h
find.o:		cardfile.h ascii.h
findrcds.o:	cardfile.h ascii.h
getkey.o:	cardfile.h
keymatch.o:	cardfile.h
maint.o:	cardfile.h
menu.o:		cardfile.h
printdb.o:	cardfile.h ascii.h
putrcd.o:	cardfile.h
rbuildak.o:	cardfile.h
screen.o:	cardfile.h ascii.h
setupkeys.o:	cardfile.h ascii.h
updak.o:	cardfile.h ascii.h
