# 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
#
# Portions Copyright (c) 2003 Apple Computer, Inc.

srcdir=@srcdir@
include @TOP_OBJDIR@/src/config/Makefile.config
include @TOP_OBJDIR@/src/config/Makefile.lwp


all: depinstall

generated: afs_trace.h afs_trace.msf unified_afs.c unified_afs.h

afs_trace.h: afs_trace.et
	${COMPILE_ET_H} -v 2 -p ${srcdir} afs_trace

afs_trace.msf: afs_trace.et
	${COMPILE_ET_C} -v 2 -p ${srcdir} afs_trace

unified_afs.h: unified_afs.et unified_afs.p.h
	${COMPILE_ET_H} -p ${srcdir} unified_afs -h unified_afs

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

afszcm.cat: afs_trace.msf
	-$(RM) -f afszcm.cat
	case ${SYS_NAME} in \
		sgi_* ) \
			${GENCAT} -m afszcm.cat afs_trace.msf ;; \
		*_linux* | *_umlinux* ) \
			${GENCAT} --new afszcm.cat afs_trace.msf ;; \
		*_darwin_* ) \
			${GENCAT} -new afszcm.cat afs_trace.msf ;; \
		* ) \
			${GENCAT} afszcm.cat afs_trace.msf ;; \
	esac

depinstall: afszcm.cat AFS_component_version_number.c \
	${TOP_INCDIR}/afs/afs_consts.h \
	${TOP_INCDIR}/afs/afs.h \
	${TOP_INCDIR}/afs/osi_inode.h \
	${TOP_INCDIR}/afs/afs_stats.h \
	${TOP_INCDIR}/afs/exporter.h \
	${TOP_INCDIR}/afs/nfsclient.h \
	${TOP_INCDIR}/afs/unified_afs.h \
	${TOP_INCDIR}/afs/sysctl.h \
	${TOP_INCDIR}/afs/afs_trace.h

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

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

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

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

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

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

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

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

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

install: unified_afs.h afs_trace.h
	${INSTALL} -d ${DESTDIR}${includedir}/afs
	${INSTALL_DATA} ${srcdir}/afs.h ${DESTDIR}${includedir}/afs/afs.h
	${INSTALL_DATA} ${srcdir}/afs_consts.h ${DESTDIR}${includedir}/afs/afs_consts.h
	${INSTALL_DATA} ${srcdir}/afs_stats.h ${DESTDIR}${includedir}/afs/afs_stats.h
	${INSTALL_DATA} ${srcdir}/exporter.h ${DESTDIR}${includedir}/afs/exporter.h
	${INSTALL_DATA} ${srcdir}/nfsclient.h ${DESTDIR}${includedir}/afs/nfsclient.h
	${INSTALL_DATA} ${srcdir}/${MKAFS_OSTYPE}/osi_inode.h \
	    ${DESTDIR}${includedir}/afs/osi_inode.h
	${INSTALL_DATA} ${srcdir}/sysctl.h ${DESTDIR}${includedir}/afs/sysctl.h
	${INSTALL_DATA} unified_afs.h ${DESTDIR}${includedir}/afs/unified_afs.h
	${INSTALL_DATA} afs_trace.h ${DESTDIR}${includedir}/afs/afs_trace.h
	${INSTALL_DATA} afszcm.cat ${DESTDIR}${afsdatadir}/C/afszcm.cat
	case ${SYS_NAME} in \
	    *linux*) \
		${INSTALL_DATA} ${srcdir}/${MKAFS_OSTYPE}/osi_vfs.h \
		    ${DESTDIR}${includedir}/afs/osi_vfs.h || true ;;\
	    *) \
		echo No vfs headers to install for ${SYS_NAME};; \
	esac

dest: unified_afs.h afs_trace.h
	${INSTALL} -d ${DEST}/include/afs
	${INSTALL_DATA} ${srcdir}/afs.h ${DEST}/include/afs/afs.h
	${INSTALL_DATA} ${srcdir}/afs_consts.h ${DEST}/include/afs/afs_consts.h
	${INSTALL_DATA} ${srcdir}/afs_stats.h ${DEST}/include/afs/afs_stats.h
	${INSTALL_DATA} ${srcdir}/exporter.h ${DEST}/include/afs/exporter.h
	${INSTALL_DATA} ${srcdir}/nfsclient.h ${DEST}/include/afs/nfsclient.h
	${INSTALL_DATA} ${srcdir}/${MKAFS_OSTYPE}/osi_inode.h ${DEST}/include/afs/osi_inode.h
	${INSTALL_DATA} ${srcdir}/sysctl.h ${DEST}/include/afs/sysctl.h
	${INSTALL_DATA} unified_afs.h ${DEST}/include/afs/unified_afs.h
	${INSTALL_DATA} afs_trace.h ${DEST}/include/afs/afs_trace.h
	${INSTALL_DATA} afszcm.cat ${DEST}/root.client/usr/vice/etc/C/afszcm.cat
	case ${SYS_NAME} in \
	    *linux*) \
		${INSTALL_DATA} ${srcdir}/${MKAFS_OSTYPE}/osi_vfs.h \
		    ${DEST}/include/afs/osi_vfs.h || true ;;\
	    *) \
		echo No vfs headers to install for ${SYS_NAME};; \
	esac

clean:
	-$(RM) -f *.o core AFS_component_version_number.c afs_trace.h afs_trace.msf afszcm.cat
	-$(RM) -f unified_afs.c unified_afs.h

include ../config/Makefile.version
