# 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@

PROGRAMS=	unlog tokens tokens.krb

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

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

unlog: unlog.o ${LIBRARIES}
	${CC} -o unlog unlog.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: unlog tokens tokens.krb
	${INSTALL} -d ${DESTDIR}${bindir}
	${INSTALL} -d ${DESTDIR}${afssrvbindir}
	${INSTALL} -d ${DESTDIR}${sbindir}
	${INSTALL_PROGRAM} unlog ${DESTDIR}${bindir}/unlog
	${INSTALL_PROGRAM} tokens ${DESTDIR}${bindir}/tokens
	${INSTALL_PROGRAM} tokens.krb ${DESTDIR}${bindir}/tokens.krb
	${INSTALL_PROGRAM} tokens ${DESTDIR}${afssrvbindir}/tokens
	${INSTALL_PROGRAM} tokens.krb ${DESTDIR}${afssrvbindir}/tokens.krb

dest: unlog tokens tokens.krb
	${INSTALL} -d ${DEST}/bin
	${INSTALL} -d ${DEST}/root.server/usr/afs/bin
	${INSTALL} -d ${DEST}/etc
	${INSTALL_PROGRAM} unlog ${DEST}/bin/unlog
	${INSTALL_PROGRAM} tokens ${DEST}/bin/tokens
	${INSTALL_PROGRAM} tokens.krb ${DEST}/bin/tokens.krb
	${INSTALL_PROGRAM} tokens ${DEST}/root.server/usr/afs/bin/tokens
	${INSTALL_PROGRAM} tokens.krb ${DEST}/root.server/usr/afs/bin/tokens.krb

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

test:
	cd test; $(MAKE)

include ../config/Makefile.version
