# 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

srcdir=@srcdir@
include @TOP_OBJDIR@/src/config/Makefile.config
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@


#
# This must be built after inetd has built ta-rauth.o and after rsh
# XXX want these to end up in /usr/afsws ...
# Note that if afskauthlib.so gets installed on a client
# machine then that will be used ..
#
CFLAGS=${OPTIMIZE} -I${TOP_OBJDIR}/src/config -I${TOP_INCDIR} ${XCFLAGS} ${ARCHFLAGS}
LDFLAGS = ${OPTIMIZE} ${XLDFLAGS} ${ARCHFLAGS}
LIBDIR=${TOP_LIBDIR}/
AFSLIBS=${TOP_LIBDIR}/libkauth.a ${TOP_LIBDIR}/libprot.a ${LIBDIR}/libubik.a \
	  ${TOP_LIBDIR}/libauth.a ${TOP_LIBDIR}/librxkad.a ${TOP_LIBDIR}/libsys.a \
	  ${TOP_LIBDIR}/libdes.a ${LIBDIR}/librx.a ${LIBDIR}/liblwp.a \
          ${TOP_LIBDIR}/libcmd.a ${TOP_LIBDIR}/libafscom_err.a ${TOP_LIBDIR}/util.a
KAFSLIBS=${TOP_LIBDIR}/libkauth.krb.a ${TOP_LIBDIR}/libprot.a ${LIBDIR}/libubik.a \
	  ${TOP_LIBDIR}/libauth.krb.a ${TOP_LIBDIR}/librxkad.a ${TOP_LIBDIR}/libsys.a \
	  ${TOP_LIBDIR}/libdes.a ${LIBDIR}/librx.a ${LIBDIR}/liblwp.a \
          ${TOP_LIBDIR}/libcmd.a ${TOP_LIBDIR}/libafscom_err.a ${TOP_LIBDIR}/util.a
AUTHFILES=ta-rauth.o rcmd.o herror.o
AUTHLIBS=afsauthlib.so afskauthlib.so
TARGETS=$(AUTHLIBS) 

all: ${TOP_LIBDIR}/afsauthlib.so ${TOP_LIBDIR}/afskauthlib.so

${TOP_LIBDIR}/afsauthlib.so: afsauthlib.so
	${INSTALL_DATA} $? $@

${TOP_LIBDIR}/afskauthlib.so: afskauthlib.so
	${INSTALL_DATA} $? $@

install install.noversion: afsauthlib.so afskauthlib.so
	${INSTALL} -d ${DESTDIR}${libdir}
	${INSTALL_DATA} afsauthlib.so ${DESTDIR}${libdir}/afsauthlib.so
	${INSTALL_DATA} afskauthlib.so ${DESTDIR}${libdir}/afskauthlib.so

dest: afsauthlib.so afskauthlib.so
	${INSTALL} -d ${DEST}/root.client/usr/vice/etc
	${INSTALL_DATA} afsauthlib.so \
		${DEST}/root.client/usr/vice/etc/afsauthlib.so
	${INSTALL_DATA} afskauthlib.so \
		${DEST}/root.client/usr/vice/etc/afskauthlib.so

clean:
	$(RM) -f $(AUTHLIBS) $(AUTHFILES) 

afsauthlib.so: sgi_auth.o ${AFSLIBS} ${AUTHFILES}
	$(LD) ${LDFLAGS} -shared -all -o afsauthlib.so sgi_auth.o $(AFSLIBS) ${AUTHFILES}

afskauthlib.so: sgi_auth.o ${KAFSLIBS} ${AUTHFILES}
	$(LD) ${LDFLAGS} -shared -all -o afskauthlib.so sgi_auth.o $(KAFSLIBS) ${AUTHFILES}

ta-rauth.o: ta-rauth.c
	${CC} ${CFLAGS} -c ta-rauth.c

rcmd.o: rcmd.c
	${CC} ${CFLAGS} -c rcmd.c

herror.o: herror.c
	${CC} ${CFLAGS} -c herror.c

sgi_auth.o: sgi_auth.c
	${CC} ${CFLAGS} -c sgi_auth.c
