# 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: config mkvers \
	${TOP_INCDIR}/afs/param.h \
	${TOP_INCDIR}/afs/stds.h \
	${TOP_INCDIR}/afs/afs_sysnames.h \
	${TOP_INCDIR}/afs/afs_args.h \
	${TOP_INCDIR}/afs/icl.h \
	${TOP_INCDIR}/afs/venus.h \
	${TOP_INCDIR}/afs/vioc.h

generated_clean:
	${RM} -f ${TOP_INCDIR}/afs/param.h

buildtools: \
	config \
	mkvers \
	${TOP_INCDIR}/afs/param.h \
	${TOP_INCDIR}/afs/afs_sysnames.h \
	${TOP_INCDIR}/afs/stds.h

Makefile.version: Makefile.version-CML Makefile.version-NOCML
	$(RM) -f Makefile.version
	if	[ -r @TOP_SRCDIR@/CML/state ] ; \
	then	$(CP) Makefile.version-CML Makefile.version ; \
	else	$(CP) Makefile.version-NOCML Makefile.version ; \
	fi

#
# AFS component version string file generation targets
#
AFS_component_version_number.c: Makefile.version
	$(MAKE) -f Makefile.version AFS_component_version_number.c

#
# App build/install targets
#
config: config.o mc.o
	$(AFS_LDRULE) config.o mc.o

mkvers: mkvers.c
	$(CC) $(AFS_CPPFLAGS) $(AFS_CFLAGS) $(AFS_LDFLAGS) \
		-o mkvers ${srcdir}/mkvers.c

config.o: config.c AFS_component_version_number.c

#
# Include installation targets
#

param.h.new: ${srcdir}/param.${SYS_NAME}.h ${AFS_PARAM_COMMON}
	if [ "X${AFS_PARAM_COMMON}" != "X" ] ; then \
		cat ${srcdir}/${AFS_PARAM_COMMON} ${srcdir}/param.${SYS_NAME}.h > param.h.new ; \
	else \
		cat ${srcdir}/param.${SYS_NAME}.h > param.h.new ; \
	fi

${DEST}/include/afs/param.h ${DESTDIR}${includedir}/afs/param.h ${TOP_INCDIR}/afs/param.h: param.h.new
	${INSTALL_DATA} $? $@

${DEST}/include/afs/afs_sysnames.h ${DESTDIR}${includedir}/afs/afs_sysnames.h ${TOP_INCDIR}/afs/afs_sysnames.h: ${srcdir}/afs_sysnames.h
	${INSTALL_DATA} $? $@

${DEST}/include/afs/stds.h ${DESTDIR}${includedir}/afs/stds.h ${TOP_INCDIR}/afs/stds.h: ${srcdir}/stds.h
	${INSTALL_DATA} $? $@

${DEST}/include/afs/icl.h ${DESTDIR}${includedir}/afs/icl.h ${TOP_INCDIR}/afs/icl.h: ${srcdir}/icl.h
	${INSTALL_DATA} $? $@

${DEST}/include/afs/afs_args.h ${DESTDIR}${includedir}/afs/afs_args.h ${TOP_INCDIR}/afs/afs_args.h: ${srcdir}/afs_args.h
	${INSTALL_DATA} $? $@

${DEST}/include/afs/venus.h ${DESTDIR}${includedir}/afs/venus.h ${TOP_INCDIR}/afs/venus.h: ${srcdir}/venus.h
	${INSTALL_DATA} $? $@

${DEST}/include/afs/vioc.h ${DESTDIR}${includedir}/afs/vioc.h ${TOP_INCDIR}/afs/vioc.h: ${srcdir}/vioc.h
	${INSTALL_DATA} $? $@

# these are needed to compile the kernel.  Config is necessary to
# convert the MakefileProto in libafs and the kernel links provide the
# kernel include environment.  param.h is, well, param.h.  The afs_sysnames.h
# file is needed by param.h to create unique identifiers for each SYS_TYPE.

install: ${DESTDIR}${includedir}/afs/param.h \
	${DESTDIR}${includedir}/afs/stds.h \
	${DESTDIR}${includedir}/afs/afs_sysnames.h \
	${DESTDIR}${includedir}/afs/afs_args.h \
	${DESTDIR}${includedir}/afs/icl.h \
	${DESTDIR}${includedir}/afs/venus.h \
	${DESTDIR}${includedir}/afs/vioc.h

clean:
	$(RM) -f *.o config mkvers core xprt AFS_component_version_number.c param.h.new Makefile.version.in

dest: ${DEST}/include/afs/param.h \
	${DEST}/include/afs/stds.h \
	${DEST}/include/afs/afs_sysnames.h \
	${DEST}/include/afs/afs_args.h \
	${DEST}/include/afs/icl.h \
	${DEST}/include/afs/venus.h \
	${DEST}/include/afs/vioc.h

