thisconfigdir=./..
myfulldir=lib/krb5/krb
mydir=krb
BUILDTOP=$(REL)$(U)$(S)$(U)$(S)$(U)
RUN_SETUP = @KRB5_RUN_ENV@
PROG_LIBPATH=-L$(TOPLIBD)
PROG_RPATH=$(KRB5_LIBDIR)

##DOS##BUILDTOP = ..\..\..
##DOS##PREFIXDIR=krb
##DOS##OBJFILE=..\$(OUTPRE)$(PREFIXDIR).lst
##WIN16##LIBNAME=..\krb5.lib

STLIBOBJS= \
	addr_comp.o	\
	addr_order.o	\
	addr_srch.o	\
	appdefault.o	\
	auth_con.o	\
	bld_pr_ext.o	\
	bld_princ.o	\
	chk_trans.o	\
	chpw.o		\
	conv_princ.o	\
	copy_addrs.o	\
	copy_auth.o	\
	copy_athctr.o	\
	copy_cksum.o    \
	copy_creds.o	\
	copy_data.o	\
	copy_key.o	\
	copy_princ.o	\
	copy_tick.o	\
	cp_key_cnt.o	\
	decode_kdc.o	\
	decrypt_tk.o	\
	deltat.o	\
        enc_helper.o	\
	encode_kdc.o	\
	encrypt_tk.o	\
	free_rtree.o	\
	fwd_tgt.o	\
	gc_frm_kdc.o	\
	gc_via_tkt.o	\
	gen_seqnum.o	\
	gen_subkey.o	\
	get_creds.o	\
	get_in_tkt.o	\
	gic_keytab.o	\
	gic_opt.o	\
	gic_pwd.o	\
	in_tkt_ktb.o	\
	in_tkt_pwd.o	\
	in_tkt_sky.o	\
	init_ctx.o	\
	kdc_rep_dc.o	\
	kfree.o		\
	mk_cred.o	\
	mk_error.o	\
	mk_priv.o	\
	mk_rep.o	\
	mk_req.o	\
	mk_req_ext.o	\
	mk_safe.o	\
	parse.o		\
	pr_to_salt.o	\
	preauth.o	\
	preauth2.o	\
	princ_comp.o	\
	rd_cred.o	\
	rd_error.o	\
	rd_priv.o	\
	rd_rep.o	\
	rd_req.o	\
	rd_req_dec.o	\
	rd_safe.o	\
	recvauth.o	\
	sendauth.o	\
	send_tgs.o	\
	ser_actx.o	\
	ser_adata.o	\
	ser_addr.o	\
	ser_auth.o	\
	ser_cksum.o	\
	ser_ctx.o	\
	ser_eblk.o	\
	ser_key.o	\
	ser_princ.o	\
	serialize.o	\
	set_realm.o	\
	srv_rcache.o	\
	str_conv.o	\
	tgtname.o	\
	unparse.o	\
	valid_times.o	\
	vfy_increds.o	\
	vic_opt.o	\
	walk_rtree.o

OBJS=	$(OUTPRE)addr_comp.$(OBJEXT)	\
	$(OUTPRE)addr_order.$(OBJEXT)	\
	$(OUTPRE)addr_srch.$(OBJEXT)	\
	$(OUTPRE)appdefault.$(OBJEXT)	\
	$(OUTPRE)auth_con.$(OBJEXT)	\
	$(OUTPRE)bld_pr_ext.$(OBJEXT)	\
	$(OUTPRE)bld_princ.$(OBJEXT)	\
	$(OUTPRE)chk_trans.$(OBJEXT)	\
	$(OUTPRE)chpw.$(OBJEXT)		\
	$(OUTPRE)conv_princ.$(OBJEXT)	\
	$(OUTPRE)copy_addrs.$(OBJEXT)	\
	$(OUTPRE)copy_auth.$(OBJEXT)	\
	$(OUTPRE)copy_athctr.$(OBJEXT)	\
	$(OUTPRE)copy_cksum.$(OBJEXT)    \
	$(OUTPRE)copy_creds.$(OBJEXT)	\
	$(OUTPRE)copy_data.$(OBJEXT)	\
	$(OUTPRE)copy_key.$(OBJEXT)	\
	$(OUTPRE)copy_princ.$(OBJEXT)	\
	$(OUTPRE)copy_tick.$(OBJEXT)	\
	$(OUTPRE)cp_key_cnt.$(OBJEXT)	\
	$(OUTPRE)decode_kdc.$(OBJEXT)	\
	$(OUTPRE)decrypt_tk.$(OBJEXT)	\
	$(OUTPRE)deltat.$(OBJEXT)	\
        $(OUTPRE)enc_helper.$(OBJEXT)	\
	$(OUTPRE)encode_kdc.$(OBJEXT)	\
	$(OUTPRE)encrypt_tk.$(OBJEXT)	\
	$(OUTPRE)free_rtree.$(OBJEXT)	\
	$(OUTPRE)fwd_tgt.$(OBJEXT)	\
	$(OUTPRE)gc_frm_kdc.$(OBJEXT)	\
	$(OUTPRE)gc_via_tkt.$(OBJE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	\
	$(OUTPRE)ser_adata.$(OBJEXT)	\
	$(OUTPRE)ser_addr.$(OBJEXT)	\
	$(OUTPRE)ser_auth.$(OBJEXT)	\
	$(OUTPRE)ser_cksum.$(OBJEXT)	\
	$(OUTPRE)ser_ctx.$(OBJEXT)	\
	$(OUTPRE)ser_eblk.$(OBJEXT)	\
	$(OUTPRE)ser_key.$(OBJEXT)	\
	$(OUTPRE)ser_princ.$(OBJEXT)	\
	$(OUTPRE)serialize.$(OBJEXT)	\
	$(OUTPRE)set_realm.$(OBJEXT)	\
	$(OUTPRE)srv_rcache.$(OBJEXT)	\
	$(OUTPRE)str_conv.$(OBJEXT)	\
	$(OUTPRE)tgtname.$(OBJEXT)	\
	$(OUTPRE)unparse.$(OBJEXT)	\
	$(OUTPRE)valid_times.$(OBJEXT)	\
	$(OUTPRE)vfy_increds.$(OBJEXT)	\
	$(OUTPRE)vic_opt.$(OBJEXT)	\
	$(OUTPRE)walk_rtree.$(OBJEXT)

SRCS=	$(srcdir)/addr_comp.c	\
	$(srcdir)/addr_order.c	\
	$(srcdir)/addr_srch.c	\
	$(srcdir)/appdefault.c	\
	$(srcdir)/auth_con.c	\
	$(srcdir)/bld_pr_ext.c	\
	$(srcdir)/bld_princ.c	\
	$(srcdir)/brand.c	\
	$(srcdir)/chk_trans.c	\
	$(srcdir)/chpw.c	\
	$(srcdir)/conv_princ.c	\
	$(srcdir)/copy_addrs.c	\
	$(srcdir)/copy_auth.c	\
	$(srcdir)/copy_athctr.c	\
	$(srcdir)/copy_cksum.c   \
	$(srcdir)/copy_creds.c	\
	$(srcdir)/copy_data.c	\
	$(srcdir)/copy_key.c	\
	$(srcdir)/copy_princ.c	\
	$(srcdir)/copy_tick.c	\
	$(srcdir)/cp_key_cnt.c	\
	$(srcdir)/decode_kdc.c	\
	$(srcdir)/decrypt_tk.c	\
	$(srcdir)/deltat.c	\
	$(srcdir)/enc_helper.c	\
	$(srcdir)/encode_kdc.c	\
	$(srcdir)/encrypt_tk.c	\
	$(srcdir)/free_rtree.c	\
	$(srcdir)/fwd_tgt.c	\
	$(srcdir)/gc_frm_kdc.c	\
	$(srcdir)/gc_via_tkt.c	\
	$(srcdir)/gen_seqnum.c	\
	$(srcdir)/gen_subkey.c	\
	$(srcdir)/get_creds.c	\
	$(srcdir)/get_in_tkt.c	\
	$(srcdir)/gic_keytab.c	\
	$(srcdir)/gic_opt.c	\
	$(srcdir)/gic_pwd.c	\
	$(srcdir)/in_tkt_ktb.c	\
	$(srcdir)/in_tkt_pwd.c	\
	$(srcdir)/in_tkt_sky.c	\
	$(srcdir)/init_ctx.c	\
	$(srcdir)/kdc_rep_dc.c	\
	$(srcdir)/kfree.c	\
	$(srcdir)/mk_cred.c	\
	$(srcdir)/mk_error.c	\
	$(srcdir)/mk_priv.c	\
	$(srcdir)/mk_rep.c	\
	$(srcdir)/mk_req.c	\
	$(srcdir)/mk_req_ext.c	\
	$(srcdir)/mk_safe.c	\
	$(srcdir)/parse.c	\
	$(srcdir)/pr_to_salt.c	\
	$(srcdir)/preauth.c	\
	$(srcdir)/preauth2.c	\
	$(srcdir)/princ_comp.c	\
	$(srcdir)/rd_cred.c	\
	$(srcdir)/rd_error.c	\
	$(srcdir)/rd_priv.c	\
	$(srcdir)/rd_rep.c	\
	$(srcdir)/rd_req.c	\
	$(srcdir)/rd_req_dec.c	\
	$(srcdir)/rd_safe.c	\
	$(srcdir)/recvauth.c	\
	$(srcdir)/sendauth.c	\
	$(srcdir)/send_tgs.c	\
	$(srcdir)/ser_actx.c	\
	$(srcdir)/ser_adata.c	\
	$(srcdir)/ser_addr.c	\
	$(srcdir)/ser_auth.c	\
	$(srcdir)/ser_cksum.c	\
	$(srcdir)/ser_ctx.c	\
	$(srcdir)/ser_eblk.c	\
	$(srcdir)/ser_key.c	\
	$(srcdir)/ser_princ.c	\
	$(srcdir)/serialize.c	\
	$(srcdir)/set_realm.c	\
	$(srcdir)/srv_rcache.c	\
	$(srcdir)/str_conv.c	\
	$(srcdir)/tgtname.c	\
	$(srcdir)/unparse.c	\
	$(srcdir)/valid_times.c	\
	$(srcdir)/vfy_increds.c \
	$(srcdir)/vic_opt.c	\
	$(srcdir)/walk_rtree.c

# Someday, when we have a "maintainer mode", do this right:
BISON=bison
BISONFLAGS=-v # -v -> .output; -d -> .h
$(srcdir)/deltat.c : # x-deltat.y
	$(BISON) $(BISONFLAGS) -o $(srcdir)/deltat.c $(srcdir)/x-deltat.y

##DOS##LIBOBJS = $(OBJS)

all-unix:: all-libobjs
clean-unix:: clean-libobjs

COMERRLIB=$(TOPLIBD)/libcom_err.a

T_WALK_RTREE_OBJS= t_walk_rtree.o walk_rtree.o tgtname.o unparse.o \
	free_rtree.o bld_pr_ext.o 

T_KERB_OBJS= t_kerb.o conv_princ.o unparse.o set_realm.o str_conv.o

T_SER_OBJS= t_ser.o ser_actx.o ser_adata.o ser_addr.o ser_auth.o ser_cksum.o \
	ser_ctx.o ser_eblk.o ser_key.o ser_princ.o serialize.o 

T_DELTAT_OBJS= t_deltat.o deltat.o

t_walk_rtree: $(T_WALK_RTREE_OBJS) $(KDB5_DEPLIBS) $(KRB5_BASE_DEPLIBS)
	$(CC_LINK) -o t_walk_rtree $(T_WALK_RTREE_OBJS) \
		$(KDB5_LIBS) $(KRB5_BASE_LIBS)

t_kerb: $(T_KERB_OBJS) $(KDB5_DEPLIBS) $(KRB5_BASE_DEPLIBS)
	$(CC_LINK) -o t_kerb $(T_KERB_OBJS) \
		$(KDB5_LIBS) $(KRB5_BASE_LIBS)

t_ser: $(T_SER_OBJS) $(KDB5_DEPLIBS) $(KRB5_BASE_DEPLIBS)
	$(CC_LINK) -o t_ser $(T_SER_OBJS) \
		$(KDB5_LIBS) $(KRB5_BASE_LIBS)

t_deltat : $(T_DELTAT_OBJS)
	$(CC_LINK) -o t_deltat $(T_DELTAT_OBJS)

TEST_PROGS= t_walk_rtree t_kerb t_ser t_deltat

check-unix:: $(TEST_PROGS)
	KRB5_CONFIG=$(srcdir)/t_krb5.conf ; export KRB5_CONFIG ;\
	$(RUN_SETUP) ./t_kerb \
		parse_name tytso \
		parse_name tytso@SHAZAAM \
		parse_name tytso/root@VEGGIE.COM \
		parse_name tytso/tuber/carrot@VEGGIE.COM \
		parse_name tytso/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t \
		parse_name tytso/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t@FOO \
		parse_name tytso\\\\0/\\0@B\\n\\t\\\\GAG \
		parse_name tytso/\\n/\\b\\t@B\\0hacky-test \
		parse_name \\/slash/\\@atsign/octa\\/thorpe@\\/slash\\@at\\/sign \
		425_conv_principal rcmd e40-po ATHENA.MIT.EDU \
		425_conv_principal rcmd mit ATHENA.MIT.EDU \
		425_conv_principal rcmd lithium ATHENA.MIT.EDU \
		425_conv_principal rcmd tweedledumb CYGNUS.COM \
		425_conv_principal rcmd uunet UU.NET \
		425_conv_principal zephyr zephyr ATHENA.MIT.EDU \
		425_conv_principal kadmin ATHENA.MIT.EDU ATHENA.MIT.EDU \
		524_conv_principal host/e40-po.mit.edu@ATHENA.MIT.EDU \
		524_conv_principal host/foobar.stanford.edu@stanford.edu \
		set_realm marc@MIT.EDU CYGNUS.COM \
		> test.out
	cmp test.out $(srcdir)/t_ref_kerb.out
	$(RM) test.out
	KRB5_CONFIG=$(srcdir)/t_krb5.conf ; export KRB5_CONFIG ;\
		$(RUN_SETUP) ./t_ser
	./t_deltat

clean::
	$(RM) $(OUTPRE)t_walk_rtree$(EXEEXT) $(OUTPRE)t_walk_rtree.$(OBJEXT) \
		$(OUTPRE)t_kerb$(EXEEXT) $(OUTPRE)t_kerb.$(OBJEXT)	\
		$(OUTPRE)t_ser$(EXEEXT) $(OUTPRE)t_ser.$(OBJEXT)	\
		$(OUTPRE)t_deltat$(EXEEXT) $(OUTPRE)t_deltat.$(OBJEXT)
