#
# $Id: Makefile.in,v 1.74 1997/05/19 03:03:05 assar Exp $
#

# Under SunOS-5.x it is necessary to link with -ldes to be binary compatible.
LIBDES=`test -r /usr/lib/libkrb.so.1 && echo "-lresolv -L../des -ldes"; true`

SHELL = /bin/sh

srcdir = @srcdir@
VPATH = @srcdir@

CC = @CC@
AR = ar
RANLIB = @RANLIB@
LN_S = @LN_S@
DEFS = @DEFS@
CFLAGS = @CFLAGS@
LD_FLAGS = @LD_FLAGS@
EXECSUFFIX=@EXECSUFFIX@

INSTALL = @INSTALL@
INSTALL_DATA	= @INSTALL_DATA@
MKINSTALLDIRS = @top_srcdir@/mkinstalldirs

COMPILE_ET = ../../util/et/compile_et$(EXECSUFFIX) -language ansi-c 

prefix = @prefix@
exec_prefix = @exec_prefix@
libdir = @libdir@

PICFLAGS = @PICFLAGS@
 
PROGS = sizetest$(EXEC_SUFFIX)
LIBNAME = $(LIBPREFIX)krb
LIBEXT = @LIBEXT@
SHLIBEXT = @SHLIBEXT@
LIBPREFIX = @LIBPREFIX@
LDSHARED = @LDSHARED@
LIB = $(LIBNAME).$(LIBEXT)

SOURCES = cr_err_reply.c \
          create_auth_reply.c \
          create_ciph.c \
          create_death_packet.c \
          create_ticket.c \
          dest_tkt.c \
          get_in_tkt.c \
          get_svc_in_tkt.c \
          getrealm.c \
          k_localtime.c \
          krb_err_txt.c \
          krb_get_in_tkt.c \
          kuserok.c \
	  parse_name.c \
          kntoln.c \
	  mk_auth.c \
	  krb_check_auth.c \
          mk_err.c \
          mk_safe.c \
          rd_err.c \
          rd_safe.c \
          recvauth.c \
          mk_priv.c \
          rd_req.c \
          decomp_ticket.c \
          lifetime.c \
          month_sname.c \
	  stime.c \
          read_service_key.c \
          getst.c \
          sendauth.c \
          netread.c \
          netwrite.c \
          rd_priv.c \
          krb_equiv.c \
          str2key.c \
          get_ad_tkt.c \
          mk_req.c \
          get_cred.c \
          get_tf_realm.c \
          get_tf_fullname.c \
          one.c \
          save_credentials.c \
          send_to_kdc.c \
	  get_host.c \
          get_krbrlm.c \
          k_gethostname.c \
          tf_util.c \
          debug_decl.c \
          k_flock.c \
          tkt_string.c \
          getaddrs.c \
          k_getsockinst.c \
	  k_getport.c \
	  lsb_addr_comp.c \
	  name2name.c \
	  get_default_principal.c \
	  realm_parse.c \
	  verify_user.c \
	  rw.c \
	  kdc_reply.c \
	  encrypt_ktext.c \
	  swab.c \
	  gettimeofday.c \
	  check_time.c \
	  krb_err.c \
	  et_list.c \
	  resolve.c \
	  unparse_name.c \
	  logging.c \
	  k_concat.c

#	  these files reside in ../roken
#	  snprintf.c \
#	  strdup.c \
#	  strtok_r.c \
#	  strcasecmp.c

OBJECTS = cr_err_reply.o \
          create_auth_reply.o \
          create_ciph.o \
          create_death_packet.o \
          create_ticket.o \
          dest_tkt.o \
          get_in_tkt.o \
          get_svc_in_tkt.o \
          getrealm.o \
          k_localtime.o \
          krb_err_txt.o \
          krb_get_in_tkt.o \
          kuserok.o \
	  parse_name.o \
          kntoln.o \
	  mk_auth.o \
	  krb_check_auth.o \
          mk_err.o \
          mk_safe.o \
          rd_err.o \
          rd_safe.o \
          recvauth.o \
          mk_priv.o \
          rd_req.o \
          decomp_ticket.o \
          lifetime.o \
          month_sname.o \
	  stime.o \
          read_service_key.o \
          getst.o \
          sendauth.o \
          netread.o \
          netwrite.o \
          rd_priv.o \
          krb_equiv.o \
          str2key.o \
          get_ad_tkt.o \
          mk_req.o \
          get_cred.o \
          get_tf_realm.o \
          get_tf_fullname.o \
          one.o \
          save_credentials.o \
          send_to_kdc.o \
	  get_host.o \
          get_krbrlm.o \
          k_gethostname.o \
          tf_util.o \
          debug_decl.o \
          k_flock.o \
          tkt_string.o \
          getaddrs.o \
          k_getsockinst.o \
	  k_getport.o \
	  lsb_addr_comp.o \
	  name2name.o \
	  get_default_principal.o \
	  realm_parse.o \
	  verify_user.o \
	  rw.o \
	  kdc_reply.o \
	  encrypt_ktext.o \
	  swab.o \
	  gettimeofday.o \
	  check_time.o \
	  krb_err.o \
	  resolve.o \
	  unparse_name.o \
	  logging.o \
	  k_concat.o \
	  snprintf.o \
	  strdup.o \
	  strtok_r.o \
	  strcasecmp.o

# This is only needed by some shared library implementations
LDOBJ = et_list.o

all: $(LIB) $(PROGS)

Wall:
		make CFLAGS="-g -Wall -Wno-comment -Wmissing-prototypes -Wmissing-declarations -D__USE_FIXED_PROTOTYPES__"

.c.o:
	$(CC) -c $(CPPFLAGS) $(DEFS) -I../../include -I$(srcdir) $(CFLAGS) $(PICFLAGS) $<

install: all
	$(MKINSTALLDIRS) $(libdir)
	$(INSTALL_DATA) -m 0555 $(LIB) $(libdir)

uninstall:
	rm -f $(libdir)/$(LIB)

TAGS: $(SOURCES)
	etags $(SOURCES)

sizetest.o: sizetest.c
	$(CC) -c $(CPPFLAGS) $(DEFS) -I../../include -I$(srcdir) $(CFLAGS) $<

sizetest$(EXECSUFFIX): sizetest.o
	$(CC) $(LD_FLAGS) $(LDFLAGS) -o $@ sizetest.o

check: sizetest$(EXECSUFFIX)
	./sizetest$(EXECSUFFIX)

clean:
	rm -f $(LIB) *.o *.a krb_err.c krb_err.h $(PROGS) 

mostlyclean: clean

distclean: clean
	rm -f Makefile *.tab.c *~

realclean: distclean
	rm -f TAGS

dist: $(DISTFILES)
	for file in $(DISTFILES); do \
	  ln $$file ../`cat ../.fname`/lib \
	    || cp -p $$file ../`cat ../.fname`/lib; \
	done

$(LIBNAME).a: $(OBJECTS)
	rm -f $@
	$(AR) cr $@ $(OBJECTS)
	-$(RANLIB) $@

$(LIBNAME).$(SHLIBEXT): $(OBJECTS) $(LDOBJ)
	rm -f $@
	$(LDSHARED) -o $@ $(OBJECTS) $(LDOBJ) $(LIBDES)

krb_err.c krb_err.h: krb_err.et
	test -r krb_err.et || (rm -f krb_err.et && $(LN_S) $(srcdir)/krb_err.et .)
	$(COMPILE_ET) krb_err.et

snprintf.c:
	$(LN_S) $(srcdir)/../roken/snprintf.c .

strdup.c:
	$(LN_S) $(srcdir)/../roken/strdup.c .

strtok_r.c:
	$(LN_S) $(srcdir)/../roken/strtok_r.c .

strcasecmp.c:
	$(LN_S) $(srcdir)/../roken/strcasecmp.c .

$(OBJECTS): ../../include/config.h
$(OBJECTS): krb_locl.h krb.h krb_err.h
one.o: ../../include/version.h
