# Where to find things and to put things
P_BINARIES= UNDEFINED
P_INC	= -I../../include
# K_INC will be defined in the top-level makefile if we're using KERBEROS.
# #define it here too if we're doing heavy development.
# Maybe the "include" feature of more advanced Make programs would be useful, 
# but we'll continue to be developing manually for now.
#K_INC	= /nfs/kerberos/v5/src/include
INCS	= ${P_INC} ${K_INC}

# libraries should be relative to this dir, not SRC
SRV_LIB	= libpsrv.a
# if using the Archie database, uncomment one of these definitions of SUBDIR
# SUBDIR=archie2.dir
# SUBDIR=archie3.dir
# if reading a locally stored Gopher database, uncomment this definition.
# This is not currently supported.  Use GOPHER-GW instead.
# SUBDIR=gopher.dir
# If you want this prospero server to act as a gateway to the Gopher
# protocol (GOPHER-GW), uncomment this definition of SUBDIR
# SUBDIR=gopher_gw.dir

CC	= gcc
CFLAGS  = -g
F_CC	= $(CFLAGS) -c
F_CPP	= ${INCS} ${MACHDEF}

CFILES = \
	ad2l_atr.c \
	at_delete.c \
	change_acl.c \
	check_acl.c \
	check_nfs.c \
	chk_krb_auth.c \
	chk_localpth.c \
	dsdir.c \
	dsrfinfo.c \
	dswfinfo.c \
	error_reply.c \
	optparse.c \
	plog.c \
	ppasswd.c \
	replyf.c \
	retrieve_fp.c \
	srv_qoprintf.c

OBJECTS	= \
	ad2l_atr.o \
	at_delete.o \
	change_acl.o \
	check_acl.o \
	check_nfs.o \
	chk_krb_auth.o \
	chk_localpth.o \
	dsdir.o \
	dsrfinfo.o \
	dswfinfo.o \
	error_reply.o \
	optparse.o \
	plog.o \
	ppasswd.o \
	replyf.o \
	retrieve_fp.o \
	srv_qoprintf.o 


CODE	= ${CFILES} Makefile

all:	${SRV_LIB} $(SUBDIR)

gopher.dir:
	cd gopher; \
	${MAKE} ${PASTHRU} all 2>&1 | sed -e '/^[a-z_\/]*\.[ch]:/s/^/gopher\//'

gopher_gw.dir:
	cd gopher_gw; \
	${MAKE} ${PASTHRU} all 2>&1 | sed -e '/^[a-z_\/]*\.[ch]:/s/^/gopher_gw\//'

archie2.dir:
	cd archie2; \
	${MAKE} ${PASTHRU} all 2>&1 | sed -e '/^[a-z_\/]*\.[ch]:/s/^/archie2\//'

archie3.dir:
	cd archie3; \
	${MAKE} ${PASTHRU} all 2>&1 | sed -e '/^[a-z_\/]*\.[ch]:/s/^/archie3\//'

install:
	cp ${SRV_LIB} ${P_BINARIES}/${SRV_LIB}
	ranlib ${P_BINARIES}/${SRV_LIB}

clean:
	rm -f a.out core *~ tags TAGS
	rm -f ${OBJECTS} ${SRV_LIB} 

hide:
	-mkdir .hide
	-mv -f a.out core *~ tags TAGS ${OBJECTS} ${SRV_LIB} .hide
	-for i in `echo ${SUBDIR} | sed -e 's/.dir$$//'`; do (cd $$i; ${MAKE} hide); done

unhide:
	-mv .hide/* .hide/.??* .
	-rmdir .hide
	-for i in `echo ${SUBDIR} | sed -e 's/.dir$$//'` ; do (cd $$i; ${MAKE} unhide); done



src:	${CODE}

${CODE}:
	co -q $@

${OBJECTS}:
	${CC} ${F_CC} ${F_CPP} $*.c

${SRV_LIB}: ${OBJECTS}
	rm -f ${SRV_LIB}
	ar r${AR_FLAGS} ${SRV_LIB} ${OBJECTS}
	ranlib ${SRV_LIB}

# Dependencies
ad2l_atr.o : \
  ../../include/pfs.h \
  ../../include/ardp.h \
  ../../include/list_macros.h 
at_delete.o : ../../include/pfs.h \
  ../../include/ardp.h \
  ../../include/list_macros.h \
  ../../include/psrv.h ../../include/pparse.h 
change_acl.o : \
  ../../include/ardp.h \
  ../../include/list_macros.h ../../include/pfs.h \
  ../../include/psite.h ../../include/pprot.h \
  ../../include/plog.h \
  ../../include/pmachine.h ../../include/psrv.h ../../include/pparse.h 
check_acl.o : \
  ../../include/ardp.h \
  ../../include/list_macros.h ../../include/pfs.h \
  ../../include/pserver.h ../../include/pprot.h \
  ../../include/plog.h \
  ../../include/pmachine.h ../../include/psrv.h ../../include/pparse.h 
check_nfs.o : \
  ../../include/pfs.h \
  ../../include/ardp.h \
  ../../include/list_macros.h \
  ../../include/pmachine.h 
chk_krb_auth.o : ../../include/psite.h \
  ../../include/pfs.h ../../include/ardp.h \
  ../../include/list_macros.h \
  ../../include/psrv.h ../../include/pparse.h \
  ../../include/pserver.h 
chk_localpth.o : \
  ../../include/pmachine.h ../../include/pserver.h 
dsdir.o : \
  ../../include/pserver.h ../../include/ardp.h \
  ../../include/list_macros.h ../../include/pfs.h ../../include/plog.h \
  ../../include/pprot.h ../../include/perrno.h ../../include/pmachine.h ../../include/pparse.h 
dsrfinfo.o : \
  ../../include/ardp.h \
  ../../include/list_macros.h \
  ../../include/pfs.h ../../include/plog.h \
  ../../include/pprot.h ../../include/perrno.h ../../include/pmachine.h ../../include/pparse.h 
dswfinfo.o : ../../include/pfs.h \
  ../../include/ardp.h \
  ../../include/list_macros.h \
  ../../include/pparse.h \
  ../../include/psrv.h ../../include/perrno.h ../../include/plog.h 
error_reply.o : ../../include/ardp.h \
  ../../include/list_macros.h ../../include/psrv.h ../../include/pparse.h \
  ../../include/pfs.h \
  ../../include/plog.h ../../include/pprot.h 
optparse.o : ../../include/pfs.h \
  ../../include/ardp.h \
  ../../include/list_macros.h \
  ../../include/pparse.h \
  ../../include/psrv.h ../../include/perrno.h 
plog.o : \
  ../../include/ardp.h \
  ../../include/list_macros.h ../../include/pfs.h ../../include/pserver.h ../../include/plog.h \
  ../../include/pmachine.h 
ppasswd.o : \
  ../../include/pfs.h \
  ../../include/ardp.h \
  ../../include/list_macros.h ../../include/pserver.h \
  ../../include/ppasswd.h 
replyf.o : \
  ../../include/ardp.h \
  ../../include/list_macros.h ../../include/pfs.h \
  ../../include/plog.h \
  ../../include/pprot.h 
retrieve_fp.o : \
  ../../include/pfs.h ../../include/ardp.h \
  ../../include/list_macros.h \
  ../../include/perrno.h 
srv_qoprintf.o : \
  ../../include/ardp.h \
  ../../include/list_macros.h ../../include/pfs.h ../../include/pparse.h \
  ../../include/psrv.h 
