# Copyright 2000, International Business Machines Corporation and others.
# All Rights Reserved.
# 
# This software has been released under the terms of the IBM Public
# License.  For details, see the LICENSE file in the top-level source
# directory or online at http://www.openafs.org/dl/license10.html

# */

DEST=@DEST@
TOP_INCDIR=@TOP_INCDIR@
TOP_LIBDIR=@TOP_LIBDIR@
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
sbindir=@sbindir@
libexecdir=@libexecdir@
libdir=@libdir@
includedir=@includedir@
mandir=@mandir@
afssrvbindir=@afssrvbindir@
afssrvsbindir=@afssrvsbindir@
afssrvlibexecdir=@afssrvlibexecdir@
COMPILE_ET=${TOP_SRCDIR}/comerr/compile_et
RXGEN=${TOP_SRCDIR}/rxgen/rxgen
TOP_SRCDIR=@TOP_SRCDIR@
SYS_NAME=@AFS_SYSNAME@

SHELL = /bin/sh

DEBUG = 
#UNRESOLVED = -expect_unresolved \*
UNRESOLVED =
include ../config/Makefile.${SYS_NAME}

LIBS1=${TOP_LIBDIR}/libubik.a        ${TOP_LIBDIR}/libprot.a
LIBS2=${TOP_LIBDIR}/librxkad.a       ${TOP_LIBDIR}/libaudit.a \
	${TOP_LIBDIR}/librx.a          ${TOP_LIBDIR}/liblwp.a \
	${TOP_LIBDIR}/libdes.a         ${TOP_LIBDIR}/libcmd.a \
	${TOP_LIBDIR}/libcom_err.a ${TOP_LIBDIR}/util.a \
	${TOP_LIBDIR}/libsys.a

LIBS=${TOP_LIBDIR}/libkauth.a ${LIBS1} ${TOP_LIBDIR}/libauth.a ${LIBS2}
KLIBS=${TOP_LIBDIR}/libkauth.krb.a ${LIBS1} ${TOP_LIBDIR}/libauth.krb.a ${LIBS2}

all: ${TOP_LIBDIR}/libafssiad.so ${TOP_LIBDIR}/libafssiad.krb.so

clean:
	$(RM) -f test-reauth libafssiad.so libafssiad.krb.so *.s *.o *.b core *~ *.com *.ld AFS_component_version_number.c

CFLAGS=$(DEBUG) -I${TOP_SRCDIR}/config -I${TOP_INCDIR} ${XCFLAGS}

${DEST}/lib/afs/libafssiad.so: libafssiad.so
	${INSTALL} $? $@

${DEST}/lib/afs/libafssiad.krb.so: libafssiad.krb.so
	${INSTALL} $? $@

siad.o: siad.c
	$(CC) $(CFLAGS) -c -g siad.c -o siad.o

siad_krb.o: siad.c
	$(CC) $(CFLAGS) -DAFS_KERBEROS_ENV -c -g siad.c -o siad_krb.o

libafssiad.so: siad.o
	$(LD) $(LDFLAGS) -g -shared -no_archive -o libafssiad.so \
		 ${UNRESOLVED} siad.o ${LIBS} -none -lc

libafssiad.krb.so: siad_krb.o
	$(LD) $(LDFLAGS) -g -shared -no_archive -o libafssiad.krb.so \
		 ${UNRESOLVED} siad_krb.o ${KLIBS} ${LIBS} -none -lc

test-reauth: test-reauth.o
	$(CC) $(CFLAGS) -g -o test-reauth test-reauth.o -lc

install: ${DESTDIR}${libdir}/afs/libafssiad.so ${DESTDIR}${libdir}/afs/libafssiad.krb.so

${DESTDIR}${libdir}/afs/libafssiad.so: libafssiad.so
	${INSTALL} $? $@

${TOP_LIBDIR}/libafssiad.so: libafssiad.so
	${INSTALL} $? $@

${DESTDIR}${libdir}/afs/libafssiad.krb.so: libafssiad.krb.so
	${INSTALL} $? $@

${TOP_LIBDIR}/libafssiad.krb.so: libafssiad.krb.so
	${INSTALL} $? $@

dest: ${DEST}/lib/afs/libafssiad.so ${DEST}/lib/afs/libafssiad.krb.so

