#### include configury here
BUILDTOP=..

SSRCS = kadm_server.c kadm_funcs.c admin_server.c kadm_ser_wrap.c
SOBJS = kadm_server.o kadm_funcs.o admin_server.o kadm_ser_wrap.o

PSRCS = kpasswd.c
POBJS = kpasswd.o

ASRCS = kadmin.c
AOBJS = kadmin.o kadmin_cmds.o

USRCS = ksrvutil.c
UOBJS = ksrvutil.o

GSRCS = get_srvtab.c
GOBJS = get_srvtab.o

SRCS = $(SSRCS) $(PSRCS) $(ASRCS) $(USRCS) 

CODE=$(SRCS) kadmin_cmds.ct kadm_server.h.sed

# util is for ss/ss.h
# . is for kadm_server.h
LOCALINCLUDE= -I$(SRCTOP)/util -I$(BUILDTOP)/util -I.

kadm_server.h:	kadm_server.h.sed
	$(RM) kadm_server.h
	sed -e 's*KDBDIR*$(KDBDIR)*g' < $(srcdir)/kadm_server.h.sed > kadm_server.h

all::

# make_cmds(kadmin_cmds)
kadmin_cmds.c: kadmin_cmds.ct
clean::
	$(RM) kadmin_cmds.c kadmin_cmds.o 

clean::
	rm -f kadm_server.h

depend:: kadm_server.h

all:: kpasswd kadmin ksrvutil kadmind get_srvtab build_pwfile

clean::
	$(RM) kpasswd kadmin ksrvutil kadmind build_pwfile

# program(kpasswd,$(POBJS),${COM_ERR_DEP} ${KADM_LIBDEP} ${KRB_LIBDEP} ${DES_LIBDEP},${COM_ERR} ${KADM_LIB} ${KRB_LIB} ${DES_LIB},${PROGDIR})
kpasswd: $(POBJS) ${COM_ERR_DEP} ${KADM_LIBDEP} ${KRB_LIBDEP} ${DES_LIBDEP}
	$(CC) $(CCFLAGS) -o $@ $(POBJS) ${COM_ERR} ${KADM_LIB} ${KRB_LIB} ${DES_LIB}

# program(kadmin,$(AOBJS),${SS_LIBDEP} ${COM_ERR_DEP} ${KADM_LIBDEP} ${KRB_LIBDEP} ${DES_LIBDEP},${SS_LIB} ${COM_ERR} ${KADM_LIB} ${KRB_LIB} ${DES_LIB},${PROGDIR})
kadmin: $(AOBJS) ${SS_LIBDEP} ${COM_ERR_DEP} ${KADM_LIBDEP} ${KRB_LIBDEP} ${DES_LIBDEP}
	$(CC) $(CCFLAGS) -o $@ $(AOBJS) ${SS_LIB} ${COM_ERR} ${KADM_LIB} ${KRB_LIB} ${DES_LIB}

# program(ksrvutil,$(UOBJS),${COM_ERR_DEP} ${KADM_LIBDEP} ${KRB_LIBDEP} ${DES_LIBDEP},${COM_ERR} ${KADM_LIB} ${KRB_LIB} ${DES_LIB},${PROGDIR})
ksrvutil: $(UOBJS) ${COM_ERR_DEP} ${KADM_LIBDEP} ${KRB_LIBDEP} ${DES_LIBDEP}
	$(CC) $(CCFLAGS) -o $@ $(UOBJS) ${COM_ERR} ${KADM_LIB} ${KRB_LIB} ${DES_LIB}

# program(kadmind,$(SOBJS),${HESIOD_LIBDEP} ${COM_ERR_DEP} ${ACL_LIBDEP} ${KADM_LIBDEP} ${KDB_LIBDEP} ${KRB_LIBDEP} ${DES_LIBDEP},${HESIOD_LIB} ${COM_ERR} ${ACL_LIB} ${KADM_LIB} ${KDB_LIB} ${KRB_LIB} ${DES_LIB},${DAEMDIR})
kadmind: $(SOBJS) ${HESIOD_LIBDEP} ${COM_ERR_DEP} ${ACL_LIBDEP} ${KADM_LIBDEP} ${KDB_LIBDEP} ${KRB_LIBDEP} ${DES_LIBDEP}
	$(CC) $(CCFLAGS) -o $@ $(SOBJS) ${HESIOD_LIB} ${COM_ERR} ${ACL_LIB} ${KADM_LIB} ${KDB_LIB} ${KRB_LIB} ${DES_LIB}

get_srvtab: $(GOBJS) ${COM_ERR_DEP} ${KADM_LIBDEP} ${KRB_LIBDEP} ${DES_LIBDEP}
	$(CC) $(CCFLAGS) -o $@ $(GOBJS) ${KADM_LIB} ${KRB_LIB} ${DES_LIB} ${COM_ERR}

# program(build_pwfile,build_pwfile.o,${DES_LIBDEP},${KDB_LIB} ${DES_LIB},${PROGDIR})
build_pwfile: build_pwfile.o ${KDB_LIBDEP} ${DES_LIBDEP}
	$(CC) $(CCFLAGS) -o $@ build_pwfile.o ${KDB_LIB} ${DES_LIB}

install::
	$(INSTALLPROG) kpasswd ${DESTDIR}$(PROGDIR)/kpasswd
	rm -f $(DESTDIR)$(PROGDIR)/passwd
	ln -s kpasswd $(DESTDIR)$(PROGDIR)/passwd
	$(INSTALLPROG) kadmin ${DESTDIR}$(PROGDIR)/kadmin
	$(INSTALLPROG) ksrvutil ${DESTDIR}$(PROGDIR)/ksrvutil
	$(INSTALLPROG) kadmind ${DESTDIR}$(DAEMDIR)/kadmind
	$(INSTALLPROG) get_srvtab ${DESTDIR}$(PROGDIR)/get_srvtab
	$(INSTALLPROG) build_pwfile ${DESTDIR}$(PROGDIR)/build_pwfile

depend:: ${CODE} 

