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

LDFLAGS = ${XLDFLAGS} ${ARCHFLAGS}

#
# What to make
#
all: afsd vsys @ENABLE_FUSE_CLIENT@

#
# Programs
#

AFSLIBS=${TOP_LIBDIR}/libauth.a ${TOP_LIBDIR}/libcmd.a ${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/util.a ${TOP_LIBDIR}/librx.a ${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/util.a
UAFSLIBS=${TOP_LIBDIR}/libuafs.a ${TOP_LIBDIR}/libdes.a ${TOP_LIBDIR}/libafsutil.a ${TOP_LIBDIR}/libcmd.a ${TOP_LIBDIR}/libafsutil.a

UAFS_CFLAGS=${CFLAGS} -I${TOP_SRCDIR}/afs -I${TOP_SRCDIR}/afs/UKERNEL -I${TOP_SRCDIR}/rx/UKERNEL -DUKERNEL @FUSE_CFLAGS@
UAFS_XLIBS=${XLIBS} @FUSE_LIBS@

afsd: afsd.o afsd_kernel.o $(AFSLIBS) $(AFSD_LIBS)
	${CC} ${CFLAGS} -o afsd afsd.o afsd_kernel.o $(NON_SHARED) $(LDFLAGS) $(AFSD_LDFLAGS) $(AFSLIBS) ${XLIBS} ${AFSD_LIBS}

afsd.fuse: afsd_fuse.o $(UAFSLIBS) $(AFSD_LIBS)
	${CC} ${UAFS_CFLAGS} -o afsd.fuse afsd_fuse.o $(NON_SHARED) $(LDFLAGS) $(AFSD_LDFLAGS) $(UAFSLIBS) ${UAFS_XLIBS} ${AFSD_LIBS}

vsys: vsys.o
	${CC} ${CFLAGS} -o vsys vsys.o ${TOP_LIBDIR}/libsys.a $(LDFLAGS) ${XLIBS}

#
# Objects
#
afsd.o: afsd.c AFS_component_version_number.c
	$(CC) $(CFLAGS) @CFLAGS_NOERROR@ -c ${srcdir}/afsd.c

afsd_kernel.o: afsd_kernel.c
	$(CC) $(CFLAGS) @CFLAGS_NOERROR@ -c ${srcdir}/afsd_kernel.c

afsd_fuse.o: afsd_fuse.c AFS_component_version_number.c
	$(CC) $(UAFS_CFLAGS) -c ${srcdir}/afsd_fuse.c

vsys.o: vsys.c AFS_component_version_number.c

clean:
	$(RM) -f *.o vsys afsd afsd.fuse core AFS_component_version_number.c

system: install

# XXX-INST: where to put the rc scripts?
install: afsd vsys @ENABLE_FUSE_CLIENT@
	${INSTALL} -d ${DESTDIR}${sbindir}
	${INSTALL} afsd ${DESTDIR}${sbindir}/afsd
	${INSTALL} vsys ${DESTDIR}${sbindir}/vsys
	set -e; if [ -n "@ENABLE_FUSE_CLIENT@" ] ; then \
	    ${INSTALL} afsd.fuse ${DESTDIR}${sbindir}/afsd.fuse; \
	fi

dest: afsd vsys @ENABLE_FUSE_CLIENT@
	${INSTALL} -d ${DEST}/root.client/usr/vice/etc
	${INSTALL} -d ${DEST}/etc
	${INSTALL} afsd ${DEST}/root.client/usr/vice/etc/afsd
	${INSTALL} vsys ${DEST}/etc/vsys
	set -e; if [ -n "@ENABLE_FUSE_CLIENT@" ] ; then \
	    ${INSTALL} afsd.fuse ${DEST}/root.client/usr/vice/etc/afsd.fuse; \
	fi
	case ${SYS_NAME} in \
		rs_aix*)  \
			${INSTALL} -d ${DEST}/root.client/usr/vice/etc/dkload ; \
			${INSTALL_SCRIPT} ${srcdir}/rc.afs.rs_aix ${DEST}/root.client/usr/vice/etc/dkload/rc.afs ; \
			${INSTALL_SCRIPT} ${srcdir}/rc.dkload.client.rs_aix ${DEST}/root.client/usr/vice/etc/dkload/rc.dkload.client ; \
			${INSTALL_SCRIPT} ${srcdir}/rc.dkload.server.rs_aix ${DEST}/root.client/usr/vice/etc/dkload/rc.dkload.server ;; \
		sgi_65 ) \
			${INSTALL} -d ${DEST}/root.client/usr/vice/etc/sgiload ; \
			${INSTALL} -d ${DEST}/root.server/etc/init.d ; \
			${INSTALL_SCRIPT} ${srcdir}/afs.rc.sgi_ipnos ${DEST}/root.client/usr/vice/etc/sgiload/afs.rc ;\
			${INSTALL_SCRIPT} ${srcdir}/afs.rc.sgi_ipnos ${DEST}/root.server/etc/init.d/afs.rc ;;\
		sgi_* ) \
			${INSTALL} -d ${DEST}/root.client/usr/vice/etc/sgiload ; \
			${INSTALL} -d ${DEST}/root.server/etc/init.d ; \
			${INSTALL_SCRIPT} ${srcdir}/afs.rc.sgi ${DEST}/root.client/usr/vice/etc/sgiload/afs.rc ;\
			${INSTALL_SCRIPT} ${srcdir}/afs.rc.sgi ${DEST}/root.server/etc/init.d/afs.rc ;\
			case ${SYS_NAME} in \
				sgi_53 | sgi_61 ) \
				${INSTALL_SCRIPT} ${srcdir}/afs_rtsymtab.pl.${SYS_NAME} ${DEST}/root.client/usr/vice/etc/sgiload/afs_rtsymtab.pl ;;\
			esac;; \
		sun4_52 | sun4_53 | sun4c_52 | sun4c_53 | sun4m_52 | sun4m_53 | sun4m_54 | sun4_54 | sun4c_54 | sunx86_54) \
			${INSTALL} -d ${DEST}/root.client/usr/vice/etc/modload ; \
			${INSTALL_SCRIPT} ${srcdir}/afs.rc.solaris ${DEST}/root.client/usr/vice/etc/modload/afs.rc ;;\
		sun*_57 ) \
			${INSTALL} -d ${DEST}/root.client/usr/vice/etc/modload ; \
			${INSTALL_SCRIPT} ${srcdir}/afs.rc.solaris.2.7 ${DEST}/root.client/usr/vice/etc/modload/afs.rc ;;\
		sun*_58 ) \
			${INSTALL} -d ${DEST}/root.client/usr/vice/etc/modload ; \
			${INSTALL_SCRIPT} ${srcdir}/afs.rc.solaris.2.8 ${DEST}/root.client/usr/vice/etc/modload/afs.rc ;;\
		sun*_59 | sun*_510 ) \
			${INSTALL} -d ${DEST}/root.client/usr/vice/etc/modload ; \
			${INSTALL_SCRIPT} ${srcdir}/afs.rc.solaris.2.9 ${DEST}/root.client/usr/vice/etc/modload/afs.rc ;;\
		sun*_511 ) \
			${INSTALL} -d ${DEST}/root.client/usr/vice/etc/modload ; \
			${INSTALL_SCRIPT} ${srcdir}/afs.rc.solaris.2.11 ${DEST}/root.client/usr/vice/etc/modload/afs.rc ;;\
                sun4x_5? ) \
			${INSTALL} -d ${DEST}/root.client/usr/vice/etc/modload ; \
			${INSTALL_SCRIPT} ${srcdir}/afs.rc.solaris.2_5 ${DEST}/root.client/usr/vice/etc/modload/afs.rc ;;\
		alpha_osf* ) \
			${INSTALL} -d ${DEST}/root.client/usr/vice/etc/dkload ; \
			${INSTALL_SCRIPT} ${srcdir}/afs.rc.alpha ${DEST}/root.client/usr/vice/etc/dkload/afs.rc ;;\
		hp_ux1122 ) \
			${INSTALL} -d ${DEST}/root.client/usr/vice/etc/dkload ; \
			${INSTALL_SCRIPT} ${srcdir}/afs.rc.hpux10 ${DEST}/root.client/usr/vice/etc/dkload/afs.rc ;\
			${INSTALL_DATA} ${srcdir}/afs.hpux1122.driver ${DEST}/root.client/usr/vice/etc/afs.driver ;;\
		hp_ux10? | hp_ux11? ) \
			${INSTALL} -d ${DEST}/root.client/usr/vice/etc/dkload ; \
			${INSTALL_SCRIPT} ${srcdir}/afs.rc.hpux10 ${DEST}/root.client/usr/vice/etc/dkload/afs.rc ;\
			${INSTALL_DATA} ${srcdir}/afs.hpux102.driver ${DEST}/root.client/usr/vice/etc/afs.driver ;;\
		alpha_dux* ) \
			${INSTALL} -d ${DEST}/root.client/usr/vice/etc/dkload ; \
			${INSTALL_SCRIPT} ${srcdir}/afs.rc.alpha_dux40 ${DEST}/root.client/usr/vice/etc/dkload/afs.rc ;;\
                hp?00_ux10? ) \
			${INSTALL} -d ${DEST}/root.client/usr/vice/etc/dkload ; \
			${INSTALL_SCRIPT} ${srcdir}/afs.rc.hpux10 ${DEST}/root.client/usr/vice/etc/dkload/afs.rc ;;\
		*linux* ) \
			${INSTALL} -d ${DEST}/root.client/usr/vice/etc ; \
			${INSTALL_SCRIPT} -m 755 ${srcdir}/afs.rc.linux ${DEST}/root.client/usr/vice/etc/afs.rc; \
			${INSTALL_DATA} ${srcdir}/afs.conf.linux ${DEST}/root.client/usr/vice/etc/afs.conf ;; \
		*_darwin*) \
			${INSTALL} -d ${DEST}/root.client/usr/vice/etc ; \
			${INSTALL_SCRIPT} -m 755 ${srcdir}/afs.rc.darwin ${DEST}/root.client/usr/vice/etc/afs.rc ; \
			${INSTALL_DATA} ${srcdir}/afs.rc.darwin.plist ${DEST}/root.client/usr/vice/etc/StartupParameters.plist ;; \
		*fbsd*) \
			${INSTALL} -d ${DEST}/root.client/usr/vice/etc ; \
			${INSTALL_SCRIPT} ${srcdir}/afs.rc.fbsd ${DEST}/root.client/usr/vice/etc/afs.rc.fbsd ;; \
		* )  \
			echo No rc scripts installed for ${SYS_NAME} ;; \
	esac

include ../config/Makefile.version
