# 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
include @TOP_OBJDIR@/src/config/Makefile.lwp



AFSLIBS = \
		${TOP_LIBDIR}/libkauth.a \
		${TOP_LIBDIR}/libprot.a \
		${TOP_LIBDIR}/libubik.a \
		${TOP_LIBDIR}/libauth.a \
		${TOP_LIBDIR}/librxkad.a \
		${TOP_LIBDIR}/libsys.a \
		${TOP_LIBDIR}/libafshcrypto_lwp.a \
		${TOP_LIBDIR}/librx.a \
		${TOP_LIBDIR}/liblwp.a \
		${TOP_LIBDIR}/libcmd.a \
		${TOP_LIBDIR}/libafscom_err.a \
		${TOP_LIBDIR}/util.a \
		${TOP_LIBDIR}/libopr.a \
		${TOP_LIBDIR}/libaudit.a

KAFSLIBS = \
		${TOP_LIBDIR}/libkauth.krb.a \
		${TOP_LIBDIR}/libprot.a \
		${TOP_LIBDIR}/libubik.a \
		${TOP_LIBDIR}/libauth.krb.a \
		${TOP_LIBDIR}/librxkad.a \
		${TOP_LIBDIR}/libsys.a \
		${TOP_LIBDIR}/libafshcrypto_lwp.a \
		${TOP_LIBDIR}/librx.a \
		${TOP_LIBDIR}/liblwp.a \
		${TOP_LIBDIR}/libcmd.a \
		${TOP_LIBDIR}/libafscom_err.a \
		${TOP_LIBDIR}/util.a \
		${TOP_LIBDIR}/libopr.a \
		${TOP_LIBDIR}/libaudit.a

AUTH_OBJS = \
		aix_auth.o \
		aix_ident.o \
		aix_auth_common.o \
		aix_ktc_null.o

AUTH_KRB5_OBJS = \
		aix_aklog.o 

AUTH_KRB_OBJS = \
		aix_auth.o \
		aix_ident.o \
		aix_auth_common.o \
		aix_ktc_krb.o \

AUTHLIBS= \
		afs_dynamic_auth afs_dynamic_kerbauth @MAKE_KRB5@ aklog_dynamic_auth

IMPORTS = -bI:/lib/aio.exp -bI:/lib/netinet.exp -bI:/lib/sockets.exp -bI:/lib/statcmd.exp 
LDFLAGS = -eafs_initialize ${IMPORTS} -lsys -lcsys -lc
AKLDFLAGS = -eaklog_initialize ${IMPORTS} -lsys -lcsys -lc

all: $(AUTHLIBS)

install install.noversion:

clean:
	$(RM) -f *.o $(AUTHLIBS) $(AUTHFILES) so_locations

aklog_dynamic_auth: ${AUTH_KRB5_OBJS} ${AFSLIBS} ${AUTHFILES}
	$(LD) -o $@ ${AUTH_KRB5_OBJS} $(AFSLIBS) ${AUTHFILES} \
		@KRB5_LIBS@ $(LDFLAGS_roken) $(LIB_roken) ${XLIBS} ${AKLDFLAGS}

afs_dynamic_auth: ${AUTH_OBJS} ${AFSLIBS} ${AUTHFILES}
	$(LD) -o $@ ${AUTH_OBJS} $(AFSLIBS) ${AUTHFILES} \
		$(LDFLAGS_roken) $(LIB_roken) ${XLIBS} ${LDFLAGS}

afs_dynamic_kerbauth: ${AUTH_KRB_OBJS} ${KAFSLIBS} ${AUTHFILES}
	$(LD) -o $@ ${AUTH_KRB_OBJS} $(KAFSLIBS) ${AUTHFILES} \
		$(LDFLAGS_roken) $(LIB_roken) ${XLIBS} ${LDFLAGS}

aix_auth_common.o: ${srcdir}/aix_auth_common.c

CFLAGS_aix_aklog.o = @KRB5_CPPFLAGS@
aix_aklog.o: ${srcdir}/aix_aklog.c

CFLAGS_aix_ktc_krb.o = -DAFS_KERBEROS_ENV
aix_ktc_krb.o: ${srcdir}/aix_ktc.c
	$(AFS_CCRULE) ${srcdir}/aix_ktc.c

aix_ktc_null.o: ${srcdir}/aix_ktc.c
	$(AFS_CCRULE) ${srcdir}/aix_ktc.c

aix_auth.o:
	@set -e; set -x; case "$(SYS_NAME)" in \
	rs_aix4*) \
		${CC} ${AFS_CFLAGS} -c ${srcdir}/aix41_auth.c -o $@ ;; \
	rs_aix5*) \
		${CC} ${AFS_CFLAGS} -c ${srcdir}/aix5_auth.c -o $@ ;; \
	rs_aix6*) \
		${CC} ${AFS_CFLAGS} -c ${srcdir}/aix5_auth.c -o $@ ;; \
	*) \
		echo "not building aix lam binary for ${SYS_NAME}" ;; \
	esac

# aix41_ident.c is a null source file for rs_aix5*
aix_ident.o: ${srcdir}/aix41_ident.c
	$(AFS_CCRULE) ${srcdir}/aix41_ident.c

dest: afs_dynamic_auth afs_dynamic_kerbauth @MAKE_KRB5@ aklog_dynamic_auth
	${INSTALL} -d ${DEST}/root.client/usr/vice/etc 
	${INSTALL_PROGRAM} afs_dynamic_auth \
		${DEST}/root.client/usr/vice/etc/afs_dynamic_auth
	${INSTALL_PROGRAM} afs_dynamic_kerbauth \
		${DEST}/root.client/usr/vice/etc/afs_dynamic_kerbauth
	@MAKE_KRB5@ ${INSTALL_PROGRAM} aklog_dynamic_auth ${DEST}/root.client/usr/vice/etc/aklog_dynamic_auth


