# 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.pthread


BUTMOBJS    =file_tm.o
BUTMLIBS    =libbutm.a
BUTMINCLS   =${TOP_INCDIR}/afs/com_err.h ${TOP_INCDIR}/afs/butm.h

MODULE_CFLAGS = @XBSA_CFLAGS@ -I${BUCOORD} -I${VOLSER} -I../bucoord -I../volser

BUTM    = ${srcdir}/../butm
BUTC    = ${srcdir}/../butc
BUCOORD = ${srcdir}/../bucoord
VOLSER  = ${srcdir}/../volser

BUCOORDOBJS=ubik_db_if.o ../bucoord/volstub.o ../bucoord/dlq.o \
	    status.o ../bucoord/bucoord_errs.o

VOLSEROBJS=vsprocs.o vsutils.o lockprocs.o

BUTCOBJS   =dbentries.o tcprocs.o lwps.o tcmain.o list.o recoverDb.o \
	    tcudbprocs.o dump.o tcstatus.o butc_xbsa.o afsxbsa.o \
            ${BUCOORDOBJS}

BUTCINCLS=${TOP_INCDIR}/afs/partition.h \
	    ${TOP_INCDIR}/afs/volume.h \
	    ${TOP_INCDIR}/afs/vlserver.h \
	    ${TOP_INCDIR}/rx/rx.h \
	    ${TOP_INCDIR}/rx/xdr.h \
	    ${TOP_INCDIR}/afs/keys.h \
	    ${TOP_INCDIR}/afs/cellconfig.h \
	    ${TOP_INCDIR}/ubik.h \
	    ${TOP_INCDIR}/afs/cmd.h \
	    ${TOP_INCDIR}/afs/butc.h \
	    ${TOP_INCDIR}/afs/tcdata.h \
	    ${TOP_INCDIR}/afs/bubasics.h \
	    ${TOP_INCDIR}/afs/butm.h

BUTCINCLUDE=-I. -I${TOP_INCDIR}
BUTCLIBS=${TOP_LIBDIR}/libbudb.a \
	    ${TOP_LIBDIR}/libbubasics.a \
            ${BUTMLIBS} \
	    $(top_builddir)/src/kauth/liboafs_kauth.la \
	    $(top_builddir)/src/volser/liboafs_volser.la \
	    $(top_builddir)/src/vlserver/liboafs_vldb.la \
	    $(top_builddir)/src/ubik/liboafs_ubik.la \
	    $(top_builddir)/src/rxkad/liboafs_rxkad.la \
            $(top_builddir)/src/cmd/liboafs_cmd.la \
	    $(top_builddir)/src/util/liboafs_util.la \
	    $(top_builddir)/src/opr/liboafs_opr.la \
	    $(top_builddir)/src/usd/liboafs_usd.la \
	    $(top_builddir)/src/lwp/liboafs_lwpcompat.la \
	    $(top_builddir)/src/sys/liboafs_sys.la \
	    ${TOP_LIBDIR}/libprocmgmt.a

#
# Build targets
#

all: butc

butc: ${BUTCOBJS} ${BUTCLIBS}
	$(LT_LDRULE_static) ${BUTCOBJS} ${BUTCLIBS} \
		$(LIB_hcrypto) $(LIB_roken) ${MT_LIBS}

libbutm.a: ${BUTMOBJS} AFS_component_version_number.o
	-$(RM) -f libbutm.a
	$(AR) crv libbutm.a $(BUTMOBJS) AFS_component_version_number.o
	${RANLIB} libbutm.a

afsxbsa.o: ${BUTC}/afsxbsa.c ${BUTC}/afsxbsa.h ${BUTCINCLS}
	$(AFS_CCRULE) ${BUTC}/afsxbsa.c

dbentries.o: ${BUTC}/dbentries.c ${BUTCINCLS}
	$(AFS_CCRULE) ${BUTC}/dbentries.c

tcprocs.o: ${BUTC}/tcprocs.c ${BUTCINCLS}
	$(AFS_CCRULE) ${BUTC}/tcprocs.c

lwps.o: ${BUTC}/lwps.c ${BUTCINCLS}
	$(AFS_CCRULE) ${BUTC}/lwps.c

tcmain.o: ${BUTC}/tcmain.c ${BUTCINCLS} AFS_component_version_number.c
	$(AFS_CCRULE) ${BUTC}/tcmain.c

list.o: ${BUTC}/list.c ${BUTCINCLS}
	$(AFS_CCRULE) ${BUTC}/list.c

recoverDb.o: ${BUTC}/recoverDb.c ${BUTCINCLS}
	$(AFS_CCRULE) ${BUTC}/recoverDb.c

CFLAGS_tcudbprocs.o=@CFLAGS_NOERROR@
tcudbprocs.o: ${BUTC}/tcudbprocs.c ${BUTCINCLS}
	$(AFS_CCRULE) ${BUTC}/tcudbprocs.c

dump.o: ${BUTC}/dump.c ${BUTCINCLS}
	$(AFS_CCRULE) ${BUTC}/dump.c

tcstatus.o: ${BUTC}/tcstatus.c ${BUTCINCLS}
	$(AFS_CCRULE) ${BUTC}/tcstatus.c

butc_xbsa.o: ${BUTC}/butc_xbsa.c ${BUTC}/butc_xbsa.h ${BUTCINCLS}
	$(AFS_CCRULE) ${BUTC}/butc_xbsa.c

ubik_db_if.o: ${BUCOORD}/ubik_db_if.c
	$(AFS_CCRULE) ${BUCOORD}/ubik_db_if.c

status.o: ${BUCOORD}/status.c
	$(AFS_CCRULE) ${BUCOORD}/status.c

vsutils.o: ${VOLSER}/vsutils.c
	$(AFS_CCRULE) ${VOLSER}/vsutils.c

vsprocs.o: ${VOLSER}/vsprocs.c
	$(AFS_CCRULE) ${VOLSER}/vsprocs.c

lockprocs.o: ${VOLSER}/lockprocs.c
	$(AFS_CCRULE) ${VOLSER}/lockprocs.c

file_tm.o: ${BUTM}/file_tm.c ${BUTMINCLS}
	$(AFS_CCRULE) ${BUTM}/file_tm.c

#
# Install targets
#
install: butc
	${INSTALL} -d ${DESTDIR}${sbindir}
	$(LT_INSTALL_PROGRAM) butc ${DESTDIR}${sbindir}/butc

dest: butc
	${INSTALL} -d ${DEST}/etc
	${INSTALL_PROGRAM} butc ${DEST}/etc/butc

#
# Misc targets
#
clean:
	$(LT_CLEAN)
	$(RM) -f *.o *.a core AFS_component_version_number.c butc

include ../config/Makefile.version
