#
# $Id: Makefile.in,v 1.113 1999/11/25 05:26:26 assar Exp $
#
SHELL = /bin/sh

srcdir = @srcdir@
VPATH = @srcdir@

CC = @CC@
LINK = @LINK@
AR = ar
RANLIB = @RANLIB@
LN_S = @LN_S@
DEFS = @DEFS@ -DROKEN_RENAME
CFLAGS = @CFLAGS@ $(WFLAGS)
WFLAGS = @WFLAGS@
LD_FLAGS = @LD_FLAGS@
EXECSUFFIX=@EXECSUFFIX@

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

COMPILE_ET = ../com_err/compile_et

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

includedir = @includedir@

incdir = $(includedir)
inc_DATA = krb_err.h
idir = $(top_builddir)/include

PICFLAGS = @PICFLAGS@

# Under SunOS-5.x it is necessary to link with -ldes to be binary compatible.

LIBDES=`test -r /usr/lib/libkrb.so.1 && echo "@LD_FLAGS@ -L../des -ldes"; true`

LIB_DEPS = @lib_deps_yes@ `echo @LIB_res_search@ @LIB_dn_expand@ | sort | uniq` $(LIBDES) -lc
build_symlink_command   = @build_symlink_command@
install_symlink_command = @install_symlink_command@
 
PROGS = sizetest$(EXECSUFFIX)
LIBNAME = $(LIBPREFIX)krb
LIBEXT = @LIBEXT@
SHLIBEXT = @SHLIBEXT@
LIBPREFIX = @LIBPREFIX@
LDSHARED = @LDSHARED@
LIB = $(LIBNAME).$(LIBEXT)

SOURCES = \
	check_time.c \
	cr_err_reply.c \
	create_auth_reply.c \
	create_ciph.c \
	create_death_packet.c \
	create_ticket.c \
	debug_decl.c \
	decomp_ticket.c \
	defaults.c \
	dest_tkt.c \
	encrypt_ktext.c \
	extra.c \
	get_ad_tkt.c \
	getfile.c \
	get_cred.c \
	get_default_principal.c \
	get_host.c \
	get_in_tkt.c \
	get_krbrlm.c \
	get_svc_in_tkt.c \
	get_tf_fullname.c \
	get_tf_realm.c \
	getaddrs.c \
	getrealm.c \
	getst.c \
	k_getport.c \
	k_getsockinst.c \
	k_localtime.c \
	kdc_reply.c \
	kntoln.c \
	krb_check_auth.c \
	krb_equiv.c \
	krb_err.c \
	krb_err_txt.c \
	krb_get_in_tkt.c \
	kuserok.c \
	lifetime.c \
	logging.c \
	lsb_addr_comp.c \
	mk_auth.c \
	mk_err.c \
	mk_priv.c \
	mk_req.c \
	mk_safe.c \
	month_sname.c \
	name2name.c \
	krb_net_read.c \
	krb_net_write.c \
	one.c \
	parse_name.c \
	rd_err.c \
	rd_priv.c \
	rd_req.c \
	rd_safe.c \
	read_service_key.c \
	realm_parse.c \
	recvauth.c \
	rw.c \
	save_credentials.c \
	send_to_kdc.c \
	sendauth.c \
	solaris_compat.c \
	stime.c \
	str2key.c \
	tf_util.c \
	time.c \
	tkt_string.c \
	unparse_name.c \
	verify_user.c \
	krb_ip_realm.c

# these files reside in ../roken or ../com_err/
EXTRA_SOURCE = \
	base64.c \
	concat.c \
	flock.c \
	gethostname.c \
	gettimeofday.c \
	getuid.c \
	resolve.c \
	snprintf.c \
	strcasecmp.c \
	strlcat.c \
	strlcpy.c \
	strdup.c \
	strncasecmp.c \
	strnlen.c \
	strtok_r.c \
	swab.c

SHLIB_EXTRA_SOURCE = \
	com_err.c \
	error.c
  
OBJECTS = \
	check_time.o \
	cr_err_reply.o \
	create_auth_reply.o \
	create_ciph.o \
	create_death_packet.o \
	create_ticket.o \
	debug_decl.o \
	decomp_ticket.o \
	defaults.o \
	dest_tkt.o \
	encrypt_ktext.o \
	extra.o \
	get_ad_tkt.o \
	getfile.o \
	get_cred.o \
	get_default_principal.o \
	get_host.o \
	get_in_tkt.o \
	get_krbrlm.o \
	get_svc_in_tkt.o \
	get_tf_fullname.o \
	get_tf_realm.o \
	getaddrs.o \
	getrealm.o \
	getst.o \
	k_getport.o \
	k_getsockinst.o \
	k_localtime.o \
	kdc_reply.o \
	kntoln.o \
	krb_check_auth.o \
	krb_equiv.o \
	krb_err.o \
	krb_err_txt.o \
	krb_get_in_tkt.o \
	kuserok.o \
	lifetime.o \
	logging.o \
	lsb_addr_comp.o \
	mk_auth.o \
	mk_err.o \
	mk_priv.o \
	mk_req.o \
	mk_safe.o \
	month_sname.o \
	name2name.o \
	krb_net_read.o \
	krb_net_write.o \
	one.o \
	parse_name.o \
	rd_err.o \
	rd_priv.o \
	rd_req.o \
	rd_safe.o \
	read_service_key.o \
	realm_parse.o \
	recvauth.o \
	rw.o \
	save_credentials.o \
	send_to_kdc.o \
	sendauth.o \
	solaris_compat.o \
	stime.o \
	str2key.o \
	tf_util.o \
	time.o \
	tkt_string.o \
	unparse_name.o \
	verify_user.o \
	krb_ip_realm.o \
	$(LIBADD)

LIBADD = \
	base64.o \
	concat.o \
	flock.o \
	gethostname.o \
	gettimeofday.o \
	getuid.o \
	net_read.o \
	net_write.o \
	resolve.o \
	snprintf.o \
	strcasecmp.o \
	strlcat.o \
	strlcpy.o \
	strdup.o \
	strncasecmp.o \
	strnlen.o \
	strtok_r.o \
	swab.o

SHLIB_LIBADD = \
	com_err.o \
	error.o

all: $(LIB) $(PROGS) all-local

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

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

install: all
	$(MKINSTALLDIRS) $(DESTDIR)$(libdir)
	$(INSTALL_DATA) -m 0555 $(LIB) $(DESTDIR)$(libdir)/$(LIB)
	@install_symlink_command@
	$(MKINSTALLDIRS) $(DESTDIR)$(includedir)
	@for i in $(inc_DATA); do \
	echo "  $(INSTALL_DATA) $$i $(DESTDIR)$(incdir)/$$i";\
	$(INSTALL_DATA) $$i $(DESTDIR)$(incdir)/$$i; done

uninstall:
	rm -f $(DESTDIR)$(libdir)/$(LIB)
	@for i in $(inc_DATA); do \
	echo "  rm -f $(DESTDIR)$(incdir)/$$i";\
	rm -f $(DESTDIR)$(incdir)/$$i; done

TAGS: $(SOURCES)
	etags $(SOURCES)

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

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

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

clean:
	rm -f $(LIB) *.o *.a *.so *.so.* so_locations \
	 krb_err.c krb_err.h $(PROGS)  $(EXTRA_SOURCE) $(SHLIB_EXTRA_SOURCE)

mostlyclean: clean

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

realclean: distclean
	rm -f TAGS

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

$(LIBNAME).$(SHLIBEXT): $(OBJECTS) $(SHLIB_LIBADD)
	rm -f $@
	$(LDSHARED) -o $@ $(OBJECTS) $(SHLIB_LIBADD) $(LIB_DEPS)
	@build_symlink_command@

krb_err.c krb_err.h: krb_err.et
	$(COMPILE_ET) $(srcdir)/krb_err.et

# this doesn't work with parallel makes
#$(EXTRA_SOURCE):
#	for i in $(EXTRA_SOURCE); do \
#	  test -f $$i || $(LN_S) $(srcdir)/../roken/$$i .; \
#	done

base64.c:
	$(LN_S) $(srcdir)/../roken/base64.c .
concat.c:
	$(LN_S) $(srcdir)/../roken/concat.c .
flock.c:
	$(LN_S) $(srcdir)/../roken/flock.c .
gethostname.c:
	$(LN_S) $(srcdir)/../roken/gethostname.c .
gettimeofday.c:
	$(LN_S) $(srcdir)/../roken/gettimeofday.c .
getuid.c:
	$(LN_S) $(srcdir)/../roken/getuid.c .
snprintf.c:
	$(LN_S) $(srcdir)/../roken/snprintf.c .
strcasecmp.c:
	$(LN_S) $(srcdir)/../roken/strcasecmp.c .
strlcat.c:
	$(LN_S) $(srcdir)/../roken/strlcat.c .
strlcpy.c:
	$(LN_S) $(srcdir)/../roken/strlcpy.c .
strncasecmp.c:
	$(LN_S) $(srcdir)/../roken/strncasecmp.c .
strnlen.c:
	$(LN_S) $(srcdir)/../roken/strnlen.c .
strdup.c:
	$(LN_S) $(srcdir)/../roken/strdup.c .
strtok_r.c:
	$(LN_S) $(srcdir)/../roken/strtok_r.c .
swab.c:
	$(LN_S) $(srcdir)/../roken/swab.c .
resolve.c:
	$(LN_S) $(srcdir)/../roken/resolve.c .
net_read.c:
	$(LN_S) $(srcdir)/../roken/net_read.c .
net_write.c:
	$(LN_S) $(srcdir)/../roken/net_write.c .
com_err.c:
	$(LN_S) $(srcdir)/../com_err/com_err.c .
error.c:
	$(LN_S) $(srcdir)/../com_err/error.c .


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

all-local: $(inc_DATA)
	@for i in $(inc_DATA); do \
		if cmp -s  $$i $(idir)/$$i 2> /dev/null ; then :; else\
			echo " $(INSTALL_DATA) $$i $(idir)/$$i"; \
			$(INSTALL_DATA) $$i $(idir)/$$i; \
		fi ; \
	done

.PHONY: all Wall install uninstall check clean mostlyclean distclean realclean all-local
