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

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

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

butc_errs.c: ${TOP_INCDIR}/afs/tcdata.h

butm_errs.c: ${TOP_INCDIR}/afs/butm.h

butm_errs.c butm.h: butm_errs.et butm.p.h
	$(RM) -f butm.h butm_errs.c
	${COMPILE_ET} -p ${srcdir} butm_errs -h butm

butc_errs.c tcdata.h: butc_errs.et tcdata.p.h butm.h
	$(RM) -f tcdata.h butc_errs.c
	${COMPILE_ET} -p ${srcdir} butc_errs -h tcdata

butx_errs.c butx.h: butx_errs.et
	$(RM) -f butx.h butx_errs.c
	${COMPILE_ET} -p ${srcdir} butx_errs -h butx

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