# 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

PROGRAMS=	unlog tokens tokens.krb kseal

INCLS=${TOP_INCDIR}/afs/auth.h ${TOP_INCDIR}/rx/rx.h \
${TOP_INCDIR}/rx/xdr.h ${TOP_INCDIR}/des.h ${TOP_INCDIR}/rx/rxkad.h \
${TOP_INCDIR}/afs/cellconfig.h

LIBRARIES=${TOP_LIBDIR}/libauth.a \
		${TOP_LIBDIR}/librxkad.a \
		${TOP_LIBDIR}/libdes.a \
		${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/librx.a \
		${TOP_LIBDIR}/libsys.a \
	        ${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/libcmd.a \
	        ${TOP_LIBDIR}/util.a
KLIBRARIES=${TOP_LIBDIR}/libauth.krb.a \
		${TOP_LIBDIR}/librxkad.a \
		${TOP_LIBDIR}/libdes.a \
		${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/librx.a \
		${TOP_LIBDIR}/libsys.a \
	        ${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/libcmd.a \
	        ${TOP_LIBDIR}/util.a

#
# Main targets
#
all: unlog tokens tokens.krb kseal

#
# Build targets
#
kseal: kseal.o ${LIBRARIES}
	${CC} -o kseal kseal.o ${LIBRARIES} ${XLIBS} ${CFLAGS}

log: log.o ${LIBRARIES}
	${CC} -o log log.o ${LIBRARIES} ${XLIBS} ${CFLAGS}

unlog: unlog.o ${LIBRARIES}
	${CC} -o unlog unlog.o ${LIBRARIES} ${XLIBS} ${CFLAGS}

passwd:	passwd.o ${LIBRARIES}
	${CC} -o passwd passwd.o ${LIBRARIES} ${XLIBS} ${CFLAGS}

tokens: tokens.o ${LIBRARIES}
	${CC} -o tokens tokens.o ${LIBRARIES} ${XLIBS} ${CFLAGS}

tokens.krb: tokens.o ${KLIBRARIES}
	${CC} -o tokens.krb tokens.o ${KLIBRARIES} ${XLIBS} ${CFLAGS}

kseal.o: kseal.c ${INCLS} AFS_component_version_number.c
unlog.o: unlog.c AFS_component_version_number.c
tokens.o: tokens.c ${TOP_INCDIR}/rx/xdr.h AFS_component_version_number.c

#
# Install targets
#
install: \
	${DESTDIR}${bindir}/unlog \
	${DESTDIR}${bindir}/tokens \
	${DESTDIR}${bindir}/tokens.krb \
	${DESTDIR}${afssrvbindir}/tokens \
	${DESTDIR}${afssrvbindir}/tokens.krb \
	${DESTDIR}${sbindir}/kseal

${DEST}/bin/unlog: unlog
	${INSTALL} $? $@

${DEST}/bin/tokens: tokens
	${INSTALL} $? $@

${DEST}/bin/tokens.krb: tokens.krb
	${INSTALL} $? $@

${DEST}/root.server/usr/afs/bin/tokens: tokens
	${INSTALL} $? $@

${DEST}/root.server/usr/afs/bin/tokens.krb: tokens.krb
	${INSTALL} $? $@

${DEST}/etc/kseal: kseal
	${INSTALL} $? $@

#
# Misc. targets
#
clean:	
	$(RM) -f *.o log passwd unlog tokens kseal core AFS_component_version_number.c tokens.krb

test:
	cd test; $(MAKE)

include ../config/Makefile.version

${DESTDIR}${bindir}/unlog: unlog
	${INSTALL} $? $@

${DESTDIR}${bindir}/tokens: tokens
	${INSTALL} $? $@

${DESTDIR}${bindir}/tokens.krb: tokens.krb
	${INSTALL} $? $@

${DESTDIR}${afssrvbindir}/tokens: tokens
	${INSTALL} $? $@

${DESTDIR}${afssrvbindir}/tokens.krb: tokens.krb
	${INSTALL} $? $@

${DESTDIR}${sbindir}/kseal: kseal
	${INSTALL} $? $@

dest: \
	${DEST}/bin/unlog \
	${DEST}/bin/tokens \
	${DEST}/bin/tokens.krb \
	${DEST}/root.server/usr/afs/bin/tokens \
	${DEST}/root.server/usr/afs/bin/tokens.krb \
	${DEST}/etc/kseal

