#
# password changing suite
#
# entry points:
#	make all
#		to make everything
#	make passwd
#		to make the program
#  Author:
#	Matt Bishop
#	Research Institute for Advanced Computer Science
#	NASA Ames Research Center
#	Moffett Field, CA  94035
#
#	mab@riacs.edu, ...!{ihnp4!ames,decvax!decwrl}!riacs!mab
#
#  Copyright:
#	(c) 1988 by the Research Institute for Advanced Computer
#		 Science and Matt Bishop
#
# parameters; these will change from system to system
# PWFILE is the full path name of the password file
# PWTEST is the full path name of the password testing file
# PWLOG is the full path name of the password log file
# PWEXEC is the full path name of the password changing program
# COPTS is a set of flags to be passed to the C compiler
# DESLIB is the library containing the crypt(3) or shc_crypt(3) routine
# DESLINT is the lint library corresponding to DESLIB
# MANDIR is the directory where the manual pages go
# PATTYPE is the type of pattern matcher used
# CHFN indicates if chfn should be made; set to D if so, U if not
# CHSH indicates if chsh should be made; set to D if so, U if not
SYSTYPE	= SUN
PATTYPE = BSD4
#PWEXEC	= /bin/passwd
#PWFILE	= /etc/passwd
#PWTEST	= /etc/passwd.test
#PWLOG	= /usr/adm/passwd.log
PWEXEC	= ./passwd
PWFILE	= ./passwd.data
PWTEST	= ./passwd.test
PWLOG	= ./passwd.log
PWTYPE	= BSD4_2
COPTS	=
DESLIB	=
DESLINT	=
MANDIR	= /usr/man/man1
# make this -lrpcsvc if you intend to define YPPASSWD
LIBS	= -lrpcsvc
# compile-time options
# CFLAGS is the list of flags passed to cc(1)
# LTFLAGS is the list of flags passed to lint(1)
CFLAGS	= -O ${COPTS} -D${SYSTYPE} #-D${PWTYPE}
LTFLAGS	= -phbac
SED	= sed 's,%%PWFILE%%,${PWFILE},g' |\
		sed 's,%%PWTEST%%,${PWTEST},g' |\
			sed 's,%%PWLOG%%,${PWLOG},g'
SHELL	= /bin/sh

# programs
EXEC	= passwd
OBJECTS	= chfn.o chsh.o load.o log.o main.o pat${PATTYPE}.o prog.o pwd.o \
		sig.o test.o util.o verify.o
SOURCES	= chfn.c chsh.c load.c log.c main.c pat${PATTYPE}.c prog.c pwd.c \
		sig.c test.c util.c verify.c
# manual pages
MAN	= passwd.1
ROFF	= qtroff

# make everything but don't install it all:
all:	passwd.h ${EXEC}

# install the cookies
install:	passwd.h ${EXEC} ${MAN}
	cp ${EXEC} ${PWEXEC}
	-cp ${MAN} ${MANDIR}
	echo '*****'
	echo '***** remember to set up your test file ${PWTEST}'
	echo '***** (use pwsample in this directory as an example)'
	echo '***** the log file will be ${PWLOG}'
	echo '*****'

pat.o:
	cp pat${PATTYPE}.c pat.c
	${CC} ${CFLAGS} -c pat.c

${OBJECTS}:	passwd.h sys.h

# make the programs
passwd.h:
	< passwd.H ${SED} > passwd.h

passwd:	${OBJECTS} passwd.h
	( LIBS=`/bin/sh genlib.sh ${SYSTYPE}`;\
		${CC} ${CFLAGS} -o passwd ${OBJECTS} ${DESLIB} ${LIBS} )

# print manual pages
passwd.1:
	/lib/cpp -D${PWTYPE} passwd.1.man | ${SED} | sed '/^#/d' |\
		sed '/^[ 	]*$$/d' > passwd.1

man:	passwd.1
	${ROFF} -man passwd.1
	
# lint the programs
lint:	test.c
	( LIBS=`/bin/sh genlib.sh ${SYSTYPE}`;\
		lint ${LTFLAGS} ${COPTS} -D${SYSTYPE} -D${PWTYPE} ${SOURCES} \
				${DESLINT} ${LIBS} )

# clean up
clean:
	rm -f ${OBJECTS}

clobber:
	rm -f ${EXEC} ${OBJECTS} a.out core passwd.h passwd.1

