# 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


LIBS=${TOP_LIBDIR}/libbudb.a ${TOP_LIBDIR}/libbubasics.a \
        ${TOP_LIBDIR}/libbutm.a ${TOP_LIBDIR}/libvolser.a \
        ${TOP_LIBDIR}/libvldb.a  ${TOP_LIBDIR}/vlib.a \
        ${TOP_LIBDIR}/libkauth.a ${TOP_LIBDIR}/libubik.a \
        ${TOP_LIBDIR}/libauth.a  ${TOP_LIBDIR}/librxkad.a \
        ${TOP_LIBDIR}/libsys.a \
        ${TOP_LIBDIR}/librx.a  ${TOP_LIBDIR}/libsys.a \
        ${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/libcmd.a \
        ${TOP_LIBDIR}/libafscom_err.a \
	${TOP_LIBDIR}/util.a \
	$(TOP_LIBDIR)/libopr.a \
	${TOP_LIBDIR}/libafsrfc3961.a \
	${TOP_LIBDIR}/libafshcrypto_lwp.a

all: ${TOP_LIBDIR}/libbxdb.a ${TOP_INCDIR}/afs/bucoord_prototypes.h ${TOP_INCDIR}/afs/bc.h backup

generated: bucoord_errs.c bc.h

${TOP_LIBDIR}/libbxdb.a: libbxdb.a
	${INSTALL_DATA} $? $@

${TOP_INCDIR}/afs/bucoord_prototypes.h: bucoord_prototypes.h
	${INSTALL_DATA} $? $@

${TOP_INCDIR}/afs/bc.h: bc.h
	${INSTALL_DATA} $? $@

libbxdb.a: dsstub.o ubik_db_if.o status.o dlq.o bucoord_errs.o volstub.o AFS_component_version_number.o
	-$(RM) -f $@
	$(AR) crv $@ dsstub.o ubik_db_if.o status.o dlq.o bucoord_errs.o volstub.o AFS_component_version_number.o
	$(RANLIB) $@

ttest: ttest.o ${TOP_LIBDIR}/librx.a ${TOP_LIBDIR}/liblwp.a libbxdb.a
	$(AFS_LDRULE) ttest.o libbxdb.a ${TOP_LIBDIR}/libbubasics.a \
		${TOP_LIBDIR}/librx.a ${TOP_LIBDIR}/liblwp.a

ttest.o: AFS_component_version_number.c

btest: btest.o ${TOP_LIBDIR}/libbubasics.a ${TOP_LIBDIR}/librx.a ${TOP_LIBDIR}/liblwp.a
	$(AFS_LDRULE) btest.o ${TOP_LIBDIR}/libbubasics.a \
		${TOP_LIBDIR}/librx.a ${TOP_LIBDIR}/liblwp.a

btest.o: AFS_component_version_number.c

BACKSRCS = main.c config.c dsstub.c volstub.c commands.c server.c \
	dsvs.c dump.c restore.c ubik_db_if.c 				  \
	dump_sched.c vol_sets.c tape_hosts.c				  \
	bc_status.c status.c dlq.c

BACKOBJS = main.o config.o dsstub.o volstub.o commands.o server.o \
	dsvs.o dump.o restore.o ubik_db_if.o dump_sched.o vol_sets.o	\
	tape_hosts.o bucoord_errs.o bc_status.o status.o dlq.o

main.o: AFS_component_version_number.c

$(BACKOBJS): bc.h ${TOP_INCDIR}/afs/butc.h

backup:  $(BACKOBJS) ${LIBS}
	$(AFS_LDRULE) $(BACKOBJS) ${LIBS} $(LIB_roken) ${XLIBS}

bucoord_errs.c: bucoord_errs.et
	${COMPILE_ET_C} -p ${srcdir} bucoord_errs

bc.h: bucoord_errs.et bc.p.h
	${COMPILE_ET_H} -p ${srcdir} bucoord_errs -h bc

bc_status.o: bc.h
btest.o: bc.h
commands.o: bc.h
config.o: bc.h
dlq.o: bc.h
dsstub.o: bc.h
dsvs.o: bc.h
dump.o: bc.h
dump_sched.o: bc.h
main.o: bc.h
restore.o: bc.h
status.o: bc.h
tape_hosts.o: bc.h
ttest.o: bc.h
ubik_db_if.o: bc.h
vol_sets.o: bc.h
volstub.o: bc.h

#
# Errors
#
CFLAGS_commands.o=@CFLAGS_NOERROR@

#
# Install targets
#

install: libbxdb.a backup
	${INSTALL} -d ${DESTDIR}${libdir}/afs
	${INSTALL} -d ${DESTDIR}${sbindir}
	${INSTALL_DATA} libbxdb.a ${DESTDIR}${libdir}/afs/libbxdb.a
	${INSTALL_PROGRAM} backup ${DESTDIR}${sbindir}/backup

dest: libbxdb.a backup
	${INSTALL} -d ${DEST}/lib/afs
	${INSTALL} -d ${DEST}/etc
	${INSTALL_DATA} libbxdb.a ${DEST}/lib/afs/libbxdb.a
	${INSTALL_PROGRAM} backup ${DEST}/etc/backup

#
# Misc targets
#

clean:
	$(RM) -f *.o backup convert *.ss.c *.cs.c *.xdr.c *.a core btest ttest AFS_component_version_number.c bc.h bucoord_errs.c

include ../config/Makefile.version
