#
DESTDIR=
ADMDIR=	${DESTDIR}/usr/lib/admin
ADMBIN=	${DESTDIR}/usr/lib/admin/bin
ADMMISC=	${DESTDIR}/usr/lib/admin/misc
CFLAGS=	-O -20

# Programs that live in subdirectories, and have makefiles of their own.
#
SUBDIR=

# C programs that live in the current directory and do not need
# explicit make lines.
#
STD= create eat_input get_resp get_resp_x getegid geteuid getgid \
 getgrname getuid newpw printf

# C programs that live in the current directory and need explicit make lines.
#
NSTD=

# Shell scripts
#
SCRIPT= 

all:	${SUBDIR} ${STD} ${NSTD}

#${SUBDIR}: FRC
#	cd $@; make ${MFLAGS}

FRC:

${STD}:
	cc ${CFLAGS} -o $@ $@.c

# Files listed in ${NSTD} have explicit make lines given below.

install:	all
	-mkdir ${ADMDIR} ${ADMBIN} ${ADMMISC}
#	-for i in ${SUBDIR}; do \
#		(cd $$i; make ${MFLAGS} DESTDIR=${DESTDIR} install); done
	-for i in ${STD} ${NSTD}; do \
		(install -c -s $$i ${ADMBIN}/$$i); done
#	-for i in ${SCRIPT}; do \
#		(install -c -m 755 $$i.sh ${ADMBIN}/$$i); done

clean:
	rm -f a.out core *.s *.o
#	for i in ${SUBDIR}; do (cd $$i; make ${MFLAGS} clean); done
	rm -f ${STD} ${NSTD}

depend:
	cat </dev/null >x.c
	for i in ${STD} ${NSTD}; do \
		(echo $$i: $$i.c >>makedep; \
		/bin/grep '^#[ 	]*include' x.c $$i.c | sed \
			-e 's,<\(.*\)>,"/usr/include/\1",' \
			-e 's/:[^"]*"\([^"]*\)".*/: \1/' \
			-e 's/\.c//' >>makedep); done
	echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
	echo '$$r makedep' >>eddep
	echo 'w' >>eddep
	cp Makefile Makefile.bak
	ed - Makefile < eddep
	rm eddep makedep x.c
	echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
	echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
	echo '# see make depend above' >> Makefile

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

create: create.c
create: /usr/include/stdio.h
create: /usr/include/sys/types.h
create: /usr/include/sys/stat.h
create: /usr/include/sys/file.h
create: /usr/include/pwd.h
create: /usr/include/grp.h
eat_input: eat_input.c
eat_input: /usr/include/sys/ioctl.h
get_resp: get_resp.c
get_resp: /usr/include/sys/ioctl.h
get_resp_x: get_resp_x.c
get_resp_x: /usr/include/stdio.h
get_resp_x: /usr/include/sys/ioctl.h
getegid: getegid.c
geteuid: geteuid.c
getgid: getgid.c
getgrname: getgrname.c
getgrname: /usr/include/grp.h
getuid: getuid.c
newpw: newpw.c
newpw: /usr/include/stdio.h
newpw: /usr/include/pwd.h
printf: printf.c
printf: /usr/include/stdio.h
printf: /usr/include/sysexits.h
# DEPENDENCIES MUST END AT END OF FILE
# IF YOU PUT STUFF HERE IT WILL GO AWAY
# see make depend above
