# Where to find things 
# These might be overridden by definitions in the root Makefile.
P_INC	= -I../include
PFS_LIB	= ../lib/pfs/libpfs.a
SRV_LIB	= ../lib/psrv/libpsrv.a
RDP_LIB  = ../lib/ardp/libardp.a

#DB_LIBS= ../lib/psrv/archie2/libpsarchie.a 
#DB_LIBS= ../lib/psrv/archie3/libpsarchie.a ../lib/psrv/archie3/libparchie.a 

P_BINARIES = UNDEFINED
INSTALL = install
KRB_LIBS= 
OWNER   = pfs
GROUP   = pfs

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

CFILES	= \
	cvt_v1_ltype.c \
	create_link.c \
	create_obj.c \
	delete_link.c \
	dirsrv.c  \
	dirsrv_v1.c \
	edit_acl.c \
	ed_link_info.c \
	ed_obj_info.c \
	get_obj_info.c \
	forwarded.c \
	list.c \
	list_acl.c \
	parameter.c \
	pstart.c \
	restart_srv.c \
	shadowcvt.c \
	update.c \
	version.c

OBJECTS	= \
	shadowcvt.o \
	pstart.o \
	$(DIRSRV_OBJECTS)

DIRSRV_OBJECTS = \
	cvt_v1_ltype.o \
	create_link.o \
	create_obj.o \
	delete_link.o \
	dirsrv.o  \
	dirsrv_v1.o \
	edit_acl.o \
	ed_link_info.o \
	ed_obj_info.o \
	get_obj_info.o \
	forwarded.o \
	list.o \
	list_acl.o \
	parameter.o \
	restart_srv.o \
	update.o \
	version.o


PROGS	= dirsrv pstart
OTHERPROGS =  shadowcvt

CODE	= ${CFILES} Makefile

all:	${PROGS}

install:
	-for i in ${PROGS}; do \
	    (${INSTALL} -c -o ${OWNER} -g ${GROUP} $$i ${P_BINARIES}/$$i); \
    	done 
	-chmod 6755 ${P_BINARIES}/pstart 

clean:
	rm -f a.out core *~ tags TAGS *.o ${OBJECTS} ${PROGS} $(OTHERPROGS)

hide:
	-mkdir .hide
	-mv -f a.out core *~ tags TAGS *.o ${OBJECTS} ${PROGS} $(OTHERPROGS) .hide

unhide:
	-mv .hide/* .hide/.??* .
	-rmdir .hide

src:	${CODE}

${CODE}:
	co -q $@

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

dirsrv: $(DIRSRV_OBJECTS) ${SRV_LIB} ${PFS_LIB} ${RDP_LIB} ${DB_LIBS}
	${CC} ${F_CCL} -o $@ $(DIRSRV_OBJECTS) ${DB_LIBS} ${SRV_LIB} ${PFS_LIB} ${KRB_LIBS} ${LIBS} ${RDP_LIB}
#	ld -o $@ $(DIRSRV_OBJECTS) ${SRV_LIB} ${DB_LIBS} ${PFS_LIB} ${LIBS}

pstart: pstart.o ${SRV_LIB} ${PFS_LIB}
	${CC} ${F_CCL} -o $@ $@.o ${SRV_LIB} ${PFS_LIB} ${LIBS}

# KRB_LIBS must be included because shadowcvt refers to files which refer to 
# files which in turn are included by the kerberos stuff.
shadowcvt: shadowcvt.o cvt_v1_ltype.o ${SRV_LIB} ${PFS_LIB} ${RDP_LIB}
	${CC} ${F_CCL} -o $@ $@.o cvt_v1_ltype.o ${SRV_LIB} ${PFS_LIB} $(KRB_LIBS) ${LIBS} ${RDP_LIB}

# Dependencies
cvt_v1_ltype.o : ../include/pserver.h \
  ../include/pfs.h ../include/ardp.h \
  ../include/list_macros.h 
create_link.o : \
  ../include/ardp.h \
  ../include/list_macros.h ../include/pfs.h ../include/plog.h \
  ../include/psrv.h ../include/pparse.h ../include/perrno.h ../include/pmachine.h \
  dirsrv.h 
create_obj.o : \
  ../include/ardp.h \
  ../include/list_macros.h ../include/pfs.h ../include/plog.h \
  ../include/psrv.h ../include/pparse.h ../include/perrno.h ../include/pmachine.h \
  dirsrv.h 
delete_link.o : \
  ../include/ardp.h \
  ../include/list_macros.h ../include/pfs.h ../include/pparse.h \
  ../include/plog.h ../include/psrv.h ../include/perrno.h ../include/pmachine.h \
  dirsrv.h 
dirsrv.o : \
  ../include/ardp.h \
  ../include/list_macros.h ../include/pfs.h ../include/pserver.h ../include/plog.h \
  ../include/pprot.h \
  ../include/psrv.h ../include/pparse.h ../include/perrno.h ../include/pmachine.h \
  dirsrv.h 
dirsrv_v1.o : \
  ../include/pserver.h ../include/ardp.h \
  ../include/list_macros.h ../include/pfs.h ../include/psrv.h ../include/pparse.h \
  ../include/plog.h \
  ../include/pprot.h ../include/perrno.h ../include/pmachine.h dirsrv.h 
edit_acl.o : \
  ../include/ardp.h \
  ../include/list_macros.h ../include/pfs.h ../include/psrv.h ../include/pparse.h \
  ../include/plog.h \
  ../include/perrno.h ../include/pmachine.h dirsrv.h 
ed_link_info.o : \
  ../include/ardp.h \
  ../include/list_macros.h ../include/pfs.h ../include/plog.h \
  ../include/psrv.h ../include/pparse.h ../include/perrno.h ../include/pmachine.h \
  dirsrv.h 
ed_obj_info.o : ../include/ardp.h \
  ../include/list_macros.h ../include/pfs.h \
  ../include/perrno.h ../include/plog.h \
  ../include/pparse.h ../include/pprot.h \
  ../include/psrv.h dirsrv.h 
get_obj_info.o : \
  ../include/ardp.h \
  ../include/list_macros.h ../include/pfs.h ../include/pparse.h \
  ../include/psrv.h ../include/plog.h ../include/pprot.h ../include/perrno.h ../include/pmachine.h \
  dirsrv.h 
forwarded.o : \
  ../include/ardp.h \
  ../include/list_macros.h ../include/pfs.h ../include/plog.h \
  ../include/psrv.h ../include/pparse.h ../include/perrno.h ../include/pmachine.h \
  dirsrv.h 
list.o : \
  ../include/ardp.h \
  ../include/list_macros.h ../include/pfs.h ../include/pparse.h \
  ../include/pserver.h ../include/psrv.h ../include/plog.h ../include/pprot.h \
  ../include/perrno.h ../include/pmachine.h dirsrv.h 
list_acl.o : ../include/ardp.h \
  ../include/list_macros.h ../include/pfs.h \
  ../include/plog.h \
  ../include/psrv.h ../include/pparse.h ../include/perrno.h ../include/pprot.h \
  ../include/pmachine.h dirsrv.h 
parameter.o : ../include/ardp.h \
  ../include/list_macros.h ../include/pfs.h \
  ../include/pprot.h \
  ../include/plog.h \
  ../include/psrv.h ../include/pparse.h dirsrv.h 
pstart.o : \
  ../include/pserver.h ../include/pprot.h ../include/pmachine.h 
restart_srv.o : \
  ../include/ardp.h \
  ../include/list_macros.h ../include/pfs.h ../include/pserver.h ../include/plog.h \
  ../include/pmachine.h \
  ../include/pparse.h dirsrv.h 
shadowcvt.o : ../include/pfs.h \
  ../include/ardp.h \
  ../include/list_macros.h \
  ../include/pserver.h ../include/pprot.h \
  ../include/pparse.h 
update.o : \
  ../include/ardp.h \
  ../include/list_macros.h ../include/pfs.h \
  ../include/plog.h \
  ../include/perrno.h ../include/psrv.h ../include/pparse.h ../include/pprot.h \
  dirsrv.h 
version.o : ../include/ardp.h \
  ../include/list_macros.h ../include/pfs.h \
  ../include/plog.h \
  ../include/pprot.h \
  ../include/pparse.h dirsrv.h 
