##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
include @TOP_OBJDIR@/src/config/Makefile.pthread


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

#
# Programs
#

AFSLIBS=$(top_builddir)/src/auth/liboafs_auth.la \
	$(top_builddir)/src/cmd/liboafs_cmd.la \
	$(top_builddir)/src/sys/liboafs_sys.la \
	$(top_builddir)/src/util/liboafs_util.la \
	$(top_builddir)/src/opr/liboafs_opr.la

UAFSLIBS=$(top_builddir)/src/cmd/liboafs_cmd.la \
	 ${TOP_LIBDIR}/libuafs.a \
	 $(top_builddir)/src/cmd/liboafs_cmd.la \
	 $(top_builddir)/src/util/liboafs_util.la \
	 $(top_builddir)/src/opr/liboafs_opr.la

FUSE_LIBS=@FUSE_LIBS@

LDFLAGS_afsd = $(AFSD_LDFLAGS)
afsd: afsd.o afsd_kernel.o $(AFSLIBS) $(AFSD_LIBS)
	$(LT_LDRULE_static) afsd.o afsd_kernel.o $(NON_SHARED) \
		$(AFSLIBS) ${AFSD_LIBS} $(LIB_hcrypto) $(LIB_roken) $(MT_LIBS)

LDFLAGS_afsd.fuse = $(AFSD_LDFLAGS)
afsd.fuse: afsd_fuse.o $(UAFSLIBS) $(AFSD_LIBS)
	$(LT_LDRULE_static) afsd_fuse.o $(NON_SHARED) \
		$(UAFSLIBS) $(LIB_hcrypto) $(LIB_roken) $(MT_LIBS) $(LIB_crypt) \
		${FUSE_LIBS} ${AFSD_LIBS}

vsys: vsys.o
	${AFS_LDRULE} vsys.o ${TOP_LIBDIR}/libsys.a \
		$(LIB_roken) $(MT_LIBS)

#
# Objects
#
CFLAGS_afsd_fuse.o   = -I${TOP_SRCDIR}/afs -I${TOP_SRCDIR}/afs/UKERNEL \
		       -I${TOP_SRCDIR}/rx/UKERNEL -DUKERNEL @FUSE_CFLAGS@

afsd.o: afsd.c AFS_component_version_number.c

afsd_fuse.o: afsd_fuse.c AFS_component_version_number.c
	${AFS_CCRULE} -c ${srcdir}/afsd_fuse.c

vsys.o: vsys.c AFS_component_version_number.c

clean:
	$(LT_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;; \
		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 ;;\
		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 ;;\
	        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
