# 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

# Makefile for the module providing the client side of the File Server
# and Cache Manager extended statistics gathering.

srcdir=@srcdir@
include @TOP_OBJDIR@/src/config/Makefile.config
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@

RPCINCLS=${TOP_INCDIR}/lwp.h ${TOP_INCDIR}/rx/rx.h

LIBS=${TOP_LIBDIR}/libafsint.a \
	${TOP_LIBDIR}/libcmd.a \
	${TOP_LIBDIR}/librx.a \
	${TOP_LIBDIR}/liblwp.a \
	${TOP_LIBDIR}/libsys.a \
	${TOP_LIBDIR}/util.a

all: \
	${TOP_INCDIR}/afs/xstat_fs.h \
	${TOP_INCDIR}/afs/xstat_cm.h \
	${TOP_LIBDIR}/libxstat_fs.a \
	${TOP_LIBDIR}/libxstat_cm.a \
	xstat_fs_test \
	xstat_cm_test

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

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

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

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

#
# File Server data collection
#
FSINCLS=xstat_fs.h ${RPCINCLS}

libxstat_fs.a: xstat_fs.o xstat_fs_callback.o AFS_component_version_number.o
	-$(RM) -f $@
	$(AR) crv $@ xstat_fs.o xstat_fs_callback.o AFS_component_version_number.o
	$(RANLIB) $@

xstat_fs.o: xstat_fs.c ${FSINCLS}

xstat_fs_callback.o: xstat_fs_callback.c ${FSINCLS}

xstat_fs_test.o: xstat_fs_test.c ${FSINCLS} AFS_component_version_number.c

xstat_fs_test: xstat_fs_test.o libxstat_fs.a ${LIBS}
	${CC} ${CFLAGS} -o xstat_fs_test xstat_fs_test.o libxstat_fs.a ${LIBS} ${XLIBS}

#
# Cache Manager data collection
#
CMINCLS=xstat_cm.h ${RPCINCLS}

libxstat_cm.a: xstat_cm.o AFS_component_version_number.o
	-$(RM) -f libxstat_cm.a
	$(AR) crv libxstat_cm.a xstat_cm.o AFS_component_version_number.o
	$(RANLIB) libxstat_cm.a

xstat_cm.o: xstat_cm.c ${CMINCLS}

xstat_cm_test.o: xstat_cm_test.c ${CMINCLS} AFS_component_version_number.c

xstat_cm_test: xstat_cm_test.o libxstat_cm.a ${LIBS}
	${CC} ${CFLAGS} -o xstat_cm_test xstat_cm_test.o libxstat_cm.a ${LIBS} ${XLIBS}

#
# Installation targets
#
install: xstat_fs.h xstat_cm.h libxstat_fs.a libxstat_cm.a xstat_fs_test \
		xstat_cm_test
	${INSTALL} -d ${DESTDIR}${includedir}/afs
	${INSTALL} -d ${DESTDIR}${libdir}/afs
	${INSTALL} -d ${DESTDIR}${bindir}
	${INSTALL_DATA} xstat_fs.h ${DESTDIR}${includedir}/afs/xstat_fs.h
	${INSTALL_DATA} xstat_cm.h ${DESTDIR}${includedir}/afs/xstat_cm.h
	${INSTALL_DATA} libxstat_fs.a ${DESTDIR}${libdir}/afs/libxstat_fs.a
	${INSTALL_DATA} libxstat_cm.a ${DESTDIR}${libdir}/afs/libxstat_cm.a
	${INSTALL_PROGRAM} xstat_fs_test ${DESTDIR}${bindir}/xstat_fs_test
	${INSTALL_PROGRAM} xstat_cm_test ${DESTDIR}${bindir}/xstat_cm_test

dest: xstat_fs.h xstat_cm.h libxstat_fs.a libxstat_cm.a xstat_fs_test \
		xstat_cm_test
	${INSTALL} -d ${DEST}/include/afs
	${INSTALL} -d ${DEST}/lib/afs
	${INSTALL} -d ${DEST}/bin
	${INSTALL_DATA} xstat_fs.h ${DEST}/include/afs/xstat_fs.h
	${INSTALL_DATA} xstat_cm.h ${DEST}/include/afs/xstat_cm.h
	${INSTALL_DATA} libxstat_fs.a ${DEST}/lib/afs/libxstat_fs.a
	${INSTALL_DATA} libxstat_cm.a ${DEST}/lib/afs/libxstat_cm.a
	${INSTALL_PROGRAM} xstat_fs_test ${DEST}/bin/xstat_fs_test
	${INSTALL_PROGRAM} xstat_cm_test ${DEST}/bin/xstat_cm_test

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

include ../config/Makefile.version
