# 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


all: ${TOP_LIBDIR}/libbubasics.a ${TOP_INCDIR}/afs/bumon.h ${TOP_INCDIR}/afs/butc.h ${TOP_INCDIR}/afs/bubasics.h ${TOP_INCDIR}/afs/butx.h \
		${TOP_INCDIR}/afs/tcdata.h ${TOP_INCDIR}/afs/butm.h

generated: \
	butc.ss.c butc.cs.c butc.xdr.c butc.h \
	bumon.ss.c bumon.cs.c bumon.xdr.c bumon.h \
	butc_errs.c tcdata.h \
	butm_errs.c butm.h \
	butx_errs.c butx.h

OBJS=butc.ss.o butc.cs.o butc.xdr.o bumon.ss.o bumon.cs.o bumon.xdr.o butc_errs.o butm_errs.o butx_errs.o

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

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

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

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

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

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

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

libbubasics.a: $(OBJS) AFS_component_version_number.o
	-$(RM) -f libbubasics.a
	ar r libbubasics.a ${OBJS} AFS_component_version_number.o
	${RANLIB} libbubasics.a

butc.xdr.c: butc.xg
	${RXGEN} -A -c -o $@ ${srcdir}/butc.xg

butc.ss.c: butc.xg
	${RXGEN} -A -S -o $@ ${srcdir}/butc.xg

butc.cs.c: butc.xg
	${RXGEN} -A -C -o $@ ${srcdir}/butc.xg

butc.h: butc.xg
	${RXGEN} -A -h -o $@ ${srcdir}/butc.xg

butc.xdr.c: butc.h
butc.cs.c: butc.h
butc.ss.c: butc.h

bumon.xdr.c: bumon.xg
	${RXGEN} -A -c -o $@ ${srcdir}/bumon.xg

bumon.ss.c: bumon.xg
	${RXGEN} -A -S -o $@ ${srcdir}/bumon.xg

bumon.cs.c: bumon.xg
	${RXGEN} -A -C -o $@ ${srcdir}/bumon.xg

bumon.h: bumon.xg
	${RXGEN} -A -h -o $@ ${srcdir}/bumon.xg

bumon.xdr.c: bumon.h
bumon.ss.c: bumon.h
bumon.cs.c: bumon.h

butm.h: butm_errs.et butm.p.h
	${COMPILE_ET_H} -p ${srcdir} butm_errs -h butm

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

tcdata.h: butc_errs.et tcdata.p.h butm.h
	${COMPILE_ET_H} -p ${srcdir} butc_errs -h tcdata

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

butx.h: butx_errs.et
	${COMPILE_ET_H} -p ${srcdir} butx_errs -h butx

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

#
# Installation targets
#
install: libbubasics.a bumon.h butc.h bubasics.h tcdata.h butm.h butx.h
	${INSTALL} -d ${DESTDIR}${libdir}/afs
	${INSTALL} -d ${DESTDIR}${includedir}/afs
	${INSTALL_DATA} libbubasics.a ${DESTDIR}${libdir}/afs/libbubasics.a
	${INSTALL_DATA} bumon.h ${DESTDIR}${includedir}/afs/bumon.h
	${INSTALL_DATA} butc.h ${DESTDIR}${includedir}/afs/butc.h
	${INSTALL_DATA} ${srcdir}/bubasics.h ${DESTDIR}${includedir}/afs/bubasics.h
	${INSTALL_DATA} tcdata.h ${DESTDIR}${includedir}/afs/tcdata.h
	${INSTALL_DATA} butm.h ${DESTDIR}${includedir}/afs/butm.h
	${INSTALL_DATA} butx.h ${DESTDIR}${includedir}/afs/butx.h

dest: libbubasics.a bumon.h butc.h bubasics.h tcdata.h butm.h butx.h
	${INSTALL} -d ${DEST}/lib/afs
	${INSTALL} -d ${DEST}/include/afs
	${INSTALL_DATA} libbubasics.a ${DEST}/lib/afs/libbubasics.a
	${INSTALL_DATA} bumon.h ${DEST}/include/afs/bumon.h
	${INSTALL_DATA} butc.h ${DEST}/include/afs/butc.h
	${INSTALL_DATA} ${srcdir}/bubasics.h ${DEST}/include/afs/bubasics.h
	${INSTALL_DATA} tcdata.h ${DEST}/include/afs/tcdata.h
	${INSTALL_DATA} butm.h ${DEST}/include/afs/butm.h
	${INSTALL_DATA} butx.h ${DEST}/include/afs/butx.h

#
# Common targets
#

clean:
	$(RM) -f *.o *.a *.xdr.c *.ss.c *.cs.c butc.h butx.h butm.h bumon.h tcdata.h \
		butc_errs.c butx_errs.c butm_errs.c core AFS_component_version_number.c

include ../config/Makefile.version
