# 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

# Enable build+install of obsolete and insecure packages
# Set to anything other than YES, or comment out to disable the build
WITH_OBSOLETE=@WITH_OBSOLETE@

ENABLE_KERNEL_MODULE=@ENABLE_KERNEL_MODULE@

# To compile AFS from scratch in the src tree run "make".
#   This recursively calls "make install ..." and does not depend on the
#   existence of any non-standard programs.
# To compile for the kernel type "make blibafs".  This assumes install, 
#   rxgen, compile_et and others already exist and runs it with
#   "-argument kinstall".

COMPILE_PART1  = cd src && cd
COMPILE_PART2A = && $(MAKE)
COMPILE_PART2B = all
COMPILE_PART2  = ${COMPILE_PART2A} ${COMPILE_PART2B}
COMPILE_CLEAN  = ${COMPILE_PART2A} clean
COMPILE_DEPINSTALL  = ${COMPILE_PART2A} depinstall

all: force ${TOP_INCDIR} ${TOP_INCDIR}/afs ${TOP_LIBDIR}
	$(MAKE) build

all_nolibafs: force ${TOP_INCDIR} ${TOP_INCDIR}/afs ${TOP_LIBDIR}
	$(MAKE) build TARGET=finale_nolibafs

only_libafs: force ${TOP_INCDIR} ${TOP_INCDIR}/afs ${TOP_LIBDIR}
	$(MAKE) build TARGET=libafs

only_libafs_tree: force ${TOP_INCDIR} ${TOP_INCDIR}/afs ${TOP_LIBDIR}
	$(MAKE) build TARGET=libafs_tree

install: all install_dirs
	$(MAKE) build COMPILE_PART2B=install

install_nolibafs: all_nolibafs install_dirs
	$(MAKE) build TARGET=finale_nolibafs COMPILE_PART2B=install

install_only_libafs: only_libafs install_dirs
	$(MAKE) build TARGET=libafs COMPILE_PART2B=install

dest: all dest_dirs
	$(MAKE) build COMPILE_PART2B=dest
	-${INSTALL} ${srcdir}/src/LICENSE ${DEST}/LICENSE

dest_nolibafs: all_nolibafs dest_dirs
	$(MAKE) build TARGET=finale_nolibafs COMPILE_PART2B=dest
	-${INSTALL} ${srcdir}/src/LICENSE ${DEST}/LICENSE

dest_only_libafs: only_libafs dest_dirs
	$(MAKE) build TARGET=libafs COMPILE_PART2B=dest
	-${INSTALL} ${srcdir}/src/LICENSE ${DEST}/LICENSE

packages: dest
	@case ${SYS_NAME} in \
	*_darwin_* ) \
		${COMPILE_PART1} packaging/MacOS && sh ./buildpkg.sh ${DEST} ;; \
	hp_ux110 ) \
		${COMPILE_PART1} packaging/HP-UX && swpackage -s  psf-1.2.10-transarc-paths-11.00 ;; \
	hp_ux11i ) \
		${COMPILE_PART1} packaging/HP-UX && swpackage -s  psf-1.2.10-transarc-paths-11.11 ;; \
	ia64_hpux1122 ) \
		${COMPILE_PART1} packaging/HP-UX && swpackage -s  psf-1.2.10-transarc-paths-11.22 ;; \
	ia64_hpux1123 | hp_ux1123) \
		${COMPILE_PART1} packaging/HP-UX && swpackage -s  psf-1.2.10-transarc-paths-11.23 ;; \
	*) \
		echo Not building packages for ${SYS_NAME} ;; \
	esac

${TOP_INCDIR} ${TOP_INCDIR}/afs ${TOP_LIBDIR} ${TOP_JLIBDIR}:
	mkdir -p $@

install_dirs: force
	mkdir -p ${DESTDIR}${bindir}
	mkdir -p ${DESTDIR}${sbindir}
	mkdir -p ${DESTDIR}${libexecdir}/openafs
	mkdir -p ${DESTDIR}${libdir}/afs
	mkdir -p ${DESTDIR}${includedir}/afs
	mkdir -p ${DESTDIR}${includedir}/rx
	mkdir -p ${DESTDIR}${afskerneldir}
	mkdir -p ${DESTDIR}${afssrvbindir}
	mkdir -p ${DESTDIR}${afssrvsbindir}
	mkdir -p ${DESTDIR}${afssrvlibexecdir}

dest_dirs: force
	mkdir -p ${DEST}/bin
	mkdir -p ${DEST}/etc
	mkdir -p ${DEST}/lib/afs
	mkdir -p ${DEST}/include/afs
	mkdir -p ${DEST}/include/rx
	mkdir -p ${DEST}/root.client/usr/vice/etc/C
	mkdir -p ${DEST}/root.server/etc
	mkdir -p ${DEST}/root.server/usr/afs/bin

project: cmd comerr 

tests: all 
	${COMPILE_PART1} tests ${COMPILE_PART2}

config: 
	${COMPILE_PART1} config ${COMPILE_PART2}

pinstall: config
	${COMPILE_PART1} pinstall ${COMPILE_PART2}

procmgmt: pinstall
	${COMPILE_PART1} procmgmt ${COMPILE_PART2}

util: procmgmt des lwp_depinstall
	${COMPILE_PART1} util ${COMPILE_PART2}

audit: util rx rxkad
	${COMPILE_PART1} audit ${COMPILE_PART2} #TODO

comerr: util
	${COMPILE_PART1} comerr ${COMPILE_PART2}

cmd: comerr
	@case ${SYS_NAME} in \
	sgi_6* | sun*_5[789] | sun*_51[01] | hp_ux11* | ia64_hpux* | sparc64_linux* | alpha_linux* ) \
		${COMPILE_PART1} cmd ${COMPILE_PART2}64 ;; \
	*) \
		${COMPILE_PART1} cmd ${COMPILE_PART2} ;; \
	esac

lwp: util lwp_depinstall
	${COMPILE_PART1} lwp ${COMPILE_PART2}

rxgen: pinstall 
	${COMPILE_PART1} rxgen ${COMPILE_PART2}

rx: pinstall lwp rxgen rx_depinstall
	${COMPILE_PART1} rx ${COMPILE_PART2}

rxstat: rx rxstat_depinstall
	${COMPILE_PART1} rxstat ${COMPILE_PART2}

rxtests: rxdebug
rxdebug: rx sys
	${COMPILE_PART1} rxdebug ${COMPILE_PART2}

fsint: cmd comerr rxgen rx lwp fsint_depinstall
	${COMPILE_PART1} fsint ${COMPILE_PART2}

export2: project 

export: 
	@case ${SYS_NAME} in \
	rs_aix*) \
		${MAKE} export_build ; \
	esac

export_build: fsint
	${COMPILE_PART1} export ${COMPILE_PART2}

afs: export pinstall comerr afs_depinstall
	${COMPILE_PART1} afs ${COMPILE_PART2}

des: config pinstall
	${COMPILE_PART1} des ${COMPILE_PART2} 

sys: cmd comerr afs des rx rxstat fsint sys_depinstall
	${COMPILE_PART1} sys ${COMPILE_PART2}

rxkad: cmd comerr sys des rx rxkad_depinstall
	${COMPILE_PART1} rxkad ${COMPILE_PART2}

auth: cmd comerr comerr des lwp rx sys rxkad audit auth_depinstall
	${COMPILE_PART1} auth ${COMPILE_PART2}

ubik: cmd comerr auth ubik_depinstall
	${COMPILE_PART1} ubik ${COMPILE_PART2}

ubiktests: ubik

ptserver: cmd comerr ubik cmd comerr auth audit ptserver_depinstall
	${COMPILE_PART1} ptserver ${COMPILE_PART2}

kauth: cmd comerr ubik cmd auth comerr ptserver audit libacl kauth_depinstall
	${COMPILE_PART1} kauth ${COMPILE_PART2}

dauth: cmd comerr ubik cmd auth kauth comerr
	${COMPILE_PART1} dauth ${COMPILE_PART2}

libacl: cmd comerr ptserver libacl_depinstall
	${COMPILE_PART1} libacl ${COMPILE_PART2}

dir: cmd comerr libacl dir_depinstall
	${COMPILE_PART1} dir ${COMPILE_PART2}

# Removed from sgi_* case below:
# ${COMPILE_PART1} sgiefs ${COMPILE_PART2};;
sgiefs:
	case ${SYS_NAME} in \
	sgi_*) \
                echo "SGI efs not supported" ;; \
	*) \
		echo No efs stuff for ${SYS_NAME};; \
	esac

vol: cmd comerr dir afs sgiefs
	${COMPILE_PART1} vol ${COMPILE_PART2}

vlserver: cmd comerr vol audit vlserver_depinstall
	${COMPILE_PART1} vlserver ${COMPILE_PART2}

viced: cmd comerr vlserver audit
	${COMPILE_PART1} viced ${COMPILE_PART2}

tviced: cmd comerr viced vlserver libafsrpc libafsauthent
	case ${SYS_NAME} in \
	alpha_dux*|sgi_*|sun*_5*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[of]bsd*|*nbsd[234]*) \
		${COMPILE_PART1} tviced ${COMPILE_PART2} ;; \
	*_darwin_[1-6][0-9]) \
		echo Not building MT viced for ${SYS_NAME} ;; \
	*_darwin_*) \
		${COMPILE_PART1} tviced  ${COMPILE_PART2} ;; \
	*) \
		echo Not building MT viced for ${SYS_NAME} ;; \
	esac

volser: cmd comerr tviced usd kauth audit
	${COMPILE_PART1} volser ${COMPILE_PART2}

tvolser: project tviced usd libafsrpc libafsauthent volser
	case ${SYS_NAME} in                                             \
	alpha_dux*|sgi_*|sun*_5*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*obsd*)   \
		${COMPILE_PART1} tvolser  ${COMPILE_PART2} ;;           \
	*_darwin_[1-6][0-9])                                            \
		echo Not building MT volser for ${SYS_NAME} ;;          \
	*_darwin_*)                                                     \
		${COMPILE_PART1} tvolser ${COMPILE_PART2} ;;            \
	*)                                                              \
		echo Not building MT volser for ${SYS_NAME} ;;          \
	esac

venus: cmd comerr volser ptserver
	${COMPILE_PART1} venus ${COMPILE_PART2}
	${COMPILE_PART1} venus/test ${COMPILE_PART2}

afsd: cmd comerr sys kauth
	${COMPILE_PART1} afsd ${COMPILE_PART2}

null: cmd comerr
	${COMPILE_PART1} null ${COMPILE_PART2}

${TOP_LIBDIR}/libtermlib.a: 
	$(RM) -f ${TOP_LIBDIR}/libtermlib.a
	case ${SYS_NAME} in \
	rs_aix* | sun4x_* | sunx86_* | sgi_6? | *linux* | *_darwin* | *fbsd* | ia64_hpux*) \
		ln -s libnull.a ${TOP_LIBDIR}/libtermlib.a ;; \
	*) \
		ln -s /usr/lib/libtermlib.a ${TOP_LIBDIR}/libtermlib.a ;; \
	esac

gtx: cmd comerr null auth kauth ${TOP_LIBDIR}/libtermlib.a
	${COMPILE_PART1} gtx ${COMPILE_PART2}

fsprobe: cmd comerr util fsint volser
	${COMPILE_PART1} fsprobe ${COMPILE_PART2}

scout: cmd comerr gtx fsprobe
	${COMPILE_PART1} scout ${COMPILE_PART2}

uss: des kauth cmd comerr rx vlserver vol volser
	${COMPILE_PART1} uss ${COMPILE_PART2}

bozo: cmd comerr audit auth kauth volser
	${COMPILE_PART1} bozo ${COMPILE_PART2}

vfsck:	vol
	set -x; \
	case ${SYS_NAME} in \
	sgi_* | *linux* | rs_aix* | *_darwin* | ia64_hpux* | *fbsd* | *_obsd* | *_nbsd* | sun*_4* ) \
		echo skip vfsck for ${SYS_NAME} ;; \
	 * ) \
		${COMPILE_PART1} vfsck ${COMPILE_PART2} ;; \
	esac

pam: cmd comerr kauth rxkad
	set -x; \
	if test "@HAVE_PAM@" = "yes"; then \
		${COMPILE_PART1} pam ${COMPILE_PART2} ; \
	else \
		echo Skipping pam for ${SYS_NAME} ; \
	fi

tsm41: cmd comerr kauth rxkad
	set -x; \
	case ${SYS_NAME} in \
	rs_aix* ) \
		${COMPILE_PART1} tsm41 ${COMPILE_PART2} ;; \
	* ) \
		echo Skipping tsm41 for ${SYS_NAME} ;; \
	esac

sia: cmd comerr kauth rxkad
	set -x; \
	case ${SYS_NAME} in \
	alpha_dux* ) \
		${COMPILE_PART1} sia ${COMPILE_PART2} ;; \
	* ) \
		echo Skipping sia for ${SYS_NAME} ;; \
	esac

sgistuff: cmd comerr kauth rxkad
	set -x; \
	case ${SYS_NAME} in \
	sgi_* ) \
		${COMPILE_PART1} sgistuff ${COMPILE_PART2} ;; \
	* ) \
		echo Skipping sgistuff for ${SYS_NAME} ;; \
	esac

aklog: comerr ptserver
	set -x; \
	if test "@BUILD_KRB5@" = "yes"; then \
		${COMPILE_PART1} aklog ${COMPILE_PART2} ; \
	else \
		echo Skipping aklog for ${SYS_NAME} ; \
	fi

platform: 
	${COMPILE_PART1} platform ${COMPILE_PART2}

login: cmd comerr kauth rxkad pam sia tsm41 sgistuff aklog
	set -x; \
	if test "@BUILD_LOGIN@" = "yes"; then \
		${COMPILE_PART1} login ${COMPILE_PART2} ; \
	else \
		echo Skipping login for ${SYS_NAME} ; \
	fi

man-pages:
	if test -d "doc/man-pages" ; then \
		cd doc/man-pages ${COMPILE_PART2} ; \
	fi

#
# _depinstall targets - only build and install headers/sources that are needed by libafs/libuafs
#
# encode dependencies within the _depinstall targets as required
#
lwp_depinstall: pinstall
	${COMPILE_PART1} lwp ${COMPILE_DEPINSTALL}

rx_depinstall: pinstall
	${COMPILE_PART1} rx ${COMPILE_DEPINSTALL}

rxkad_depinstall: pinstall comerr
	${COMPILE_PART1} rxkad ${COMPILE_DEPINSTALL}

ubik_depinstall: pinstall comerr rxgen
	${COMPILE_PART1} ubik ${COMPILE_DEPINSTALL}

vlserver_depinstall: pinstall rxgen ubik_depinstall auth_depinstall
	${COMPILE_PART1} vlserver ${COMPILE_DEPINSTALL}

auth_depinstall: pinstall comerr
	${COMPILE_PART1} auth ${COMPILE_DEPINSTALL}

fsint_depinstall: pinstall rxgen
	${COMPILE_PART1} fsint ${COMPILE_DEPINSTALL}

rxstat_depinstall: pinstall rxgen
	${COMPILE_PART1} rxstat ${COMPILE_DEPINSTALL}

libacl_depinstall: pinstall
	${COMPILE_PART1} libacl ${COMPILE_DEPINSTALL}

afs_depinstall: pinstall comerr
	${COMPILE_PART1} afs ${COMPILE_DEPINSTALL}

dir_depinstall: pinstall
	${COMPILE_PART1} dir ${COMPILE_DEPINSTALL}

sys_depinstall: pinstall
	${COMPILE_PART1} sys ${COMPILE_DEPINSTALL}

kauth_depinstall: pinstall rxgen comerr
	${COMPILE_PART1} kauth ${COMPILE_DEPINSTALL}

ptserver_depinstall: pinstall rxgen comerr
	${COMPILE_PART1} ptserver ${COMPILE_DEPINSTALL}


#
# libafs build targets
#
libafs_setup: config export
	src/config/config src/libafs/MakefileProto.${MKAFS_OSTYPE} src/libafs/Makefile ${SYS_NAME}

libafs: libafs_setup lwp_depinstall rx_depinstall vlserver_depinstall rxkad_depinstall fsint_depinstall \
		libacl_depinstall afs_depinstall dir_depinstall rxstat_depinstall sys_depinstall
	${COMPILE_PART1} libafs ${COMPILE_PART2}

libafs_tree: libafs_setup lwp_depinstall rx_depinstall vlserver_depinstall rxkad_depinstall fsint_depinstall \
		libacl_depinstall afs_depinstall dir_depinstall rxstat_depinstall sys_depinstall
	${TOP_SRCDIR}/config/make_libafs_tree.pl \
		-sn $(SYS_NAME) \
		-os $(MKAFS_OSTYPE) \
		-t @TOP_OBJDIR@/libafs_tree \
		-o @TOP_OBJDIR@ \
		-p @srcdir@

#
# libuafs build targets
#

UKERNELDIR= \
  des \
  afsweb 

libuafs_setup: config export
	src/config/config src/libuafs/MakefileProto.${MKAFS_OSTYPE} src/libuafs/Makefile ${SYS_NAME}

libuafs: libuafs_setup vlserver_depinstall rx_depinstall fsint_depinstall \
		auth_depinstall dir_depinstall libacl_depinstall rxkad_depinstall \
		ubik_depinstall afs_depinstall kauth_depinstall ptserver_depinstall \
		rxstat_depinstall lwp_depinstall sys_depinstall des
	set -x; \
	case ${SYS_NAME} in \
	hp_ux102* | *_obsd* | sun*_4* | *_nbsd*| hp_ux11i | hp_ux112* | ia64_hpux112*) \
		echo Skipping libuafs for ${SYS_NAME} ;; \
	* ) \
		${COMPILE_PART1} libuafs ${COMPILE_PART2} ;; \
	esac

afsweb: kauth dauth 
	${COMPILE_PART1} afsweb ${COMPILE_PART2}

update: cmd comerr auth
	${COMPILE_PART1} update ${COMPILE_PART2}

log: cmd comerr auth 
	${COMPILE_PART1} log ${COMPILE_PART2}

bu_utils: cmd comerr usd
	${COMPILE_PART1} bu_utils ${COMPILE_PART2}

usd: cmd comerr
	${COMPILE_PART1} usd ${COMPILE_PART2}

bubasics: cmd comerr comerr rx
	${COMPILE_PART1} bubasics ${COMPILE_PART2}

butm: cmd comerr bubasics usd uss
	${COMPILE_PART1} butm ${COMPILE_PART2}

butc: cmd comerr bubasics butm budb bucoord cmd rxgen rx
	${COMPILE_PART1} butc ${COMPILE_PART2}

tbutc: cmd comerr bubasics butm budb bucoord cmd butc libadmin
	case ${SYS_NAME} in \
	alpha_dux*|sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*) \
		${COMPILE_PART1} tbutc ${COMPILE_PART2} ;; \
	*) \
		echo Not building MT butc for ${SYS_NAME} ;; \
	esac

budb: cmd comerr bubasics uss
	${COMPILE_PART1} budb ${COMPILE_PART2}

bucoord: cmd comerr bubasics budb volser
	${COMPILE_PART1} bucoord ${COMPILE_PART2}

xstat: cmd comerr fsint viced
	${COMPILE_PART1} xstat ${COMPILE_PART2}

afsmonitor: cmd comerr gtx xstat
	${COMPILE_PART1} afsmonitor ${COMPILE_PART2}

tests: rxtests ubiktests

# pthread based user space RX library
libafsrpc: rx rxkad des
	case ${SYS_NAME} in \
	alpha_dux*|sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[of]bsd*|*nbsd[234]*) \
	${COMPILE_PART1} libafsrpc ${COMPILE_PART2} ;; \
	*_darwin_[1-6][0-9]) \
		echo Not building MT libafsrpc for ${SYS_NAME} ;; \
	*_darwin_*) \
		${COMPILE_PART1} libafsrpc  ${COMPILE_PART2} ;; \
	*) \
		echo Not building MT libafsrpc for ${SYS_NAME} ;; \
	esac

libafsauthent: ubik auth kauth libafsrpc
	case ${SYS_NAME} in \
	alpha_dux*|sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[of]bsd*|*nbsd[234]*) \
	${COMPILE_PART1} libafsauthent ${COMPILE_PART2} ;; \
	*_darwin_[1-6][0-9]) \
		echo Not building MT libafsauthent for ${SYS_NAME} ;; \
	*_darwin_*) \
		${COMPILE_PART1} libafsauthent  ${COMPILE_PART2} ;; \
	*) \
		echo Not building MT libafsauthent for ${SYS_NAME} ;; \
	esac

# pthread based user space RX library
shlibafsrpc: rx rxkad des
	case ${SYS_NAME} in \
	amd64_linux24) \
		echo Skipping shlibafsrpc for amd64_linux24 ;; \
	alpha_dux*|sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*) \
	${COMPILE_PART1} shlibafsrpc ${COMPILE_PART2} ;; \
	*) \
		echo Not building shared libafsrpc for ${SYS_NAME} ;; \
	esac

shlibafsauthent: ubik auth kauth shlibafsrpc
	case ${SYS_NAME} in \
	amd64_linux24) \
		echo Skipping shlibafsauthent for amd64_linux24 ;; \
	alpha_dux*|sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*) \
	${COMPILE_PART1} shlibafsauthent ${COMPILE_PART2} ;; \
	*) \
		echo Not building shared libafsauthent for ${SYS_NAME} ;; \
	esac

libadmin_real: 
	${COMPILE_PART1} libadmin ${COMPILE_PART2}
	${COMPILE_PART1} libadmin/adminutil ${COMPILE_PART2}
	${COMPILE_PART1} libadmin/vos ${COMPILE_PART2}
	${COMPILE_PART1} libadmin/client ${COMPILE_PART2}
	${COMPILE_PART1} libadmin/kas ${COMPILE_PART2}
	${COMPILE_PART1} libadmin/pts ${COMPILE_PART2}
	${COMPILE_PART1} libadmin/bos ${COMPILE_PART2}
	${COMPILE_PART1} libadmin/cfg ${COMPILE_PART2}
	${COMPILE_PART1} libadmin/test ${COMPILE_PART2}
	${COMPILE_PART1} libadmin/samples ${COMPILE_PART2}

libadmin: libafsauthent bozo
	case ${SYS_NAME} in \
	alpha_dux*|sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*) \
			$(MAKE) libadmin_real ;; \
	*_darwin_[1-6][0-9]) \
		echo Not building MT libadmin for ${SYS_NAME} ;; \
	*_darwin_*) \
			$(MAKE) libadmin_real ;; \
	*) \
		echo Not building MT libadmin for ${SYS_NAME} ;; \
	esac

libjafs: libadmin
	case ${SYS_NAME} in \
	alpha_dux*|sgi_*|sun4x_*|rs_aix*|*linux*|hp_ux110) \
	${COMPILE_PART1} JAVA/libjafs  ${COMPILE_PART2} ;; \
	*) \
		echo Not building MT libjafs for ${SYS_NAME} ;; \
	esac

libjafsadm: libjafs

jafs: libjafs

jafsadm: libjafsadm

finale: project cmd comerr afsd butc tbutc @ENABLE_KERNEL_MODULE@ libuafs audit kauth log package \
	ptserver scout bu_utils ubik uss bozo vfsck volser tvolser \
	venus update xstat afsmonitor dauth rxdebug libafsrpc \
	libafsauthent shlibafsrpc shlibafsauthent libadmin login man-pages \
	platform
	${COMPILE_PART1} finale ${COMPILE_PART2}

finale_nolibafs: project cmd comerr afsd butc tbutc libuafs audit kauth log package \
	ptserver scout bu_utils ubik uss bozo vfsck volser tvolser \
	venus update xstat afsmonitor dauth rxdebug libafsrpc \
	libafsauthent shlibafsrpc shlibafsauthent libadmin login man-pages \
	platform
	${COMPILE_PART1} finale ${COMPILE_PART2}

# Use washtool to ensure MakefileProto is current and obj/libafs exists.

force:

TARGET=finale
build: force
	$(MAKE) $(TARGET) DEST=$(DEST) COMPILE_PART2B=$(COMPILE_PART2B) DESTDIR=$(DESTDIR)

kupdate: updatekdir libafs_setup libuafs_setup

blibafs:
	$(MAKE) libafs

blibuafs:
	$(MAKE) libuafs

bwebafs: sys
	$(MAKE) libuafs

clean:
	$(MAKE) clean2

clean2:
	-${COMPILE_PART1} config ${COMPILE_CLEAN}
	-${COMPILE_PART1} pinstall ${COMPILE_CLEAN}
	-${COMPILE_PART1} procmgmt ${COMPILE_CLEAN}
	-${COMPILE_PART1} util ${COMPILE_CLEAN}
	-${COMPILE_PART1} audit ${COMPILE_CLEAN}
	-${COMPILE_PART1} comerr ${COMPILE_CLEAN}
	-${COMPILE_PART1} cmd ${COMPILE_CLEAN}
	-${COMPILE_PART1} lwp ${COMPILE_CLEAN}
	-${COMPILE_PART1} rxgen ${COMPILE_CLEAN}
	-${COMPILE_PART1} rx ${COMPILE_CLEAN}
	-${COMPILE_PART1} rxstat ${COMPILE_CLEAN}
	-${COMPILE_PART1} fsint ${COMPILE_CLEAN}
	-${COMPILE_PART1} export ${COMPILE_CLEAN}
	-${COMPILE_PART1} afs ${COMPILE_CLEAN}
	-${COMPILE_PART1} des ${COMPILE_CLEAN}
	-${COMPILE_PART1} sys ${COMPILE_CLEAN}
	-${COMPILE_PART1} rxkad ${COMPILE_CLEAN}
	-${COMPILE_PART1} auth ${COMPILE_CLEAN}
	-${COMPILE_PART1} ubik ${COMPILE_CLEAN}
	-${COMPILE_PART1} ptserver ${COMPILE_CLEAN}
	-${COMPILE_PART1} kauth ${COMPILE_CLEAN}
	-${COMPILE_PART1} dauth ${COMPILE_CLEAN}
	-${COMPILE_PART1} libacl ${COMPILE_CLEAN}
	-${COMPILE_PART1} dir ${COMPILE_CLEAN}
	-${COMPILE_PART1} vol ${COMPILE_CLEAN}
	-${COMPILE_PART1} vlserver ${COMPILE_CLEAN}
	-${COMPILE_PART1} viced ${COMPILE_CLEAN}
	-${COMPILE_PART1} tviced ${COMPILE_CLEAN}
	-${COMPILE_PART1} volser ${COMPILE_CLEAN}
	-${COMPILE_PART1} tvolser ${COMPILE_CLEAN}
	-${COMPILE_PART1} venus ${COMPILE_CLEAN}
	-${COMPILE_PART1} venus/test ${COMPILE_CLEAN}
	-${COMPILE_PART1} afsd ${COMPILE_CLEAN}
	-${COMPILE_PART1} null ${COMPILE_CLEAN}
	-${COMPILE_PART1} gtx ${COMPILE_CLEAN}
	-${COMPILE_PART1} fsprobe ${COMPILE_CLEAN}
	-${COMPILE_PART1} scout ${COMPILE_CLEAN}
	-${COMPILE_PART1} uss ${COMPILE_CLEAN}
	-${COMPILE_PART1} bozo ${COMPILE_CLEAN}
	-${COMPILE_PART1} vfsck ${COMPILE_CLEAN}
	-${COMPILE_PART1} sgistuff ${COMPILE_CLEAN}
	-${COMPILE_PART1} tsm41 ${COMPILE_CLEAN}
	-${COMPILE_PART1} sia ${COMPILE_CLEAN}
	-${COMPILE_PART1} aklog ${COMPILE_CLEAN}
	-${COMPILE_PART1} login ${COMPILE_CLEAN}
	-${COMPILE_PART1} pam ${COMPILE_CLEAN}
	-${COMPILE_PART1} afsweb ${COMPILE_CLEAN}
	-${COMPILE_PART1} update ${COMPILE_CLEAN}
	-${COMPILE_PART1} log ${COMPILE_CLEAN}
	-${COMPILE_PART1} bu_utils ${COMPILE_CLEAN}
	-${COMPILE_PART1} usd ${COMPILE_CLEAN}
	-${COMPILE_PART1} bubasics ${COMPILE_CLEAN}
	-${COMPILE_PART1} butm ${COMPILE_CLEAN}
	-${COMPILE_PART1} butc ${COMPILE_CLEAN}
	-${COMPILE_PART1} tbutc ${COMPILE_CLEAN}
	-${COMPILE_PART1} budb ${COMPILE_CLEAN}
	-${COMPILE_PART1} bucoord ${COMPILE_CLEAN}
	-${COMPILE_PART1} xstat ${COMPILE_CLEAN}
	-${COMPILE_PART1} afsmonitor ${COMPILE_CLEAN}
	-${COMPILE_PART1} tests ${COMPILE_CLEAN}
	-${COMPILE_PART1} rxdebug ${COMPILE_CLEAN}
	-${COMPILE_PART1} libafsrpc ${COMPILE_CLEAN}
	-${COMPILE_PART1} libafsauthent ${COMPILE_CLEAN}
	-${COMPILE_PART1} shlibafsrpc ${COMPILE_CLEAN}
	-${COMPILE_PART1} shlibafsauthent ${COMPILE_CLEAN}
	-${COMPILE_PART1} platform ${COMPILE_CLEAN}
	-${COMPILE_PART1} libadmin ${COMPILE_CLEAN}
	-${COMPILE_PART1} libadmin/adminutil ${COMPILE_CLEAN}
	-${COMPILE_PART1} libadmin/client ${COMPILE_CLEAN}
	-${COMPILE_PART1} libadmin/vos ${COMPILE_CLEAN}
	-${COMPILE_PART1} libadmin/kas ${COMPILE_CLEAN}
	-${COMPILE_PART1} libadmin/pts ${COMPILE_CLEAN}
	-${COMPILE_PART1} libadmin/bos ${COMPILE_CLEAN}
	-${COMPILE_PART1} libadmin/cfg ${COMPILE_CLEAN}
	-${COMPILE_PART1} libadmin/test ${COMPILE_CLEAN}
	-${COMPILE_PART1} libadmin/samples ${COMPILE_CLEAN}
	-${COMPILE_PART1} JAVA/libjafs ${COMPILE_CLEAN}
	-${COMPILE_PART1} finale ${COMPILE_CLEAN}
	-${COMPILE_PART1} mpp ${COMPILE_CLEAN}
	-${COMPILE_PART1} package ${COMPILE_CLEAN}
	-${COMPILE_PART1} libafs ${COMPILE_CLEAN}
	-${COMPILE_PART1} libuafs ${COMPILE_CLEAN}
	-${COMPILE_PART1} tests ${COMPILE_CLEAN}
	-(cd src/libafs; /bin/rm -rf afs afsint config rx)
	-(cd src/libuafs; /bin/rm -rf afs afsint config rx des)
	-/bin/rm -rf ${TOP_INCDIR} ${TOP_LIBDIR} ${TOP_JLIBDIR}
	-/bin/rm -rf libafs_tree ${SYS_NAME}

 
distclean: clean
	/bin/rm -rf lib include
	/bin/rm -f config.log config.cache config.status \
	src/config/afsconfig.h src/config/stamp-h1 \
	Makefile \
	src/afs/Makefile \
	src/afsd/Makefile \
	src/afsd/afs.ppc_darwin.plist \
	src/afsmonitor/Makefile \
	src/afsweb/Makefile \
	src/aklog/Makefile \
	src/audit/Makefile \
	src/auth/test/Makefile \
	src/auth/Makefile \
	src/bozo/test/Makefile \
	src/bozo/Makefile \
	src/bu_utils/Makefile \
	src/bubasics/Makefile \
	src/bucoord/Makefile \
	src/budb/Makefile \
	src/butc/Makefile \
	src/butm/Makefile \
	src/cmd/test/Makefile \
	src/cmd/Makefile \
	src/comerr/test/Makefile \
	src/comerr/Makefile \
	src/config/Makefile \
	src/config/Makefile.version \
	src/config/Makefile.version-NOCML \
	src/config/Makefile.config \
	src/dauth/Makefile \
	src/des/test/Makefile \
	src/des/Makefile \
	src/des_stub/Makefile \
	src/dir/test/Makefile \
	src/dir/Makefile \
	src/export/Makefile \
	src/finale/Makefile \
	src/fsint/Makefile \
	src/fsprobe/Makefile \
	src/gtx/Makefile \
	src/kauth/test/Makefile \
	src/kauth/Makefile \
	src/libacl/test/Makefile \
	src/libacl/Makefile \
	src/libadmin/adminutil/Makefile \
	src/libadmin/Makefile \
	src/libadmin/bos/Makefile \
	src/libadmin/cfg/test/Makefile \
	src/libadmin/cfg/Makefile \
	src/libadmin/client/Makefile \
	src/libadmin/kas/Makefile \
	src/libadmin/pts/Makefile \
	src/libadmin/samples/Makefile \
	src/libadmin/test/Makefile \
	src/libadmin/vos/Makefile \
	src/JAVA/libjafs/Makefile \
	src/libafs/Makefile \
	src/libafs/Makefile.common \
	src/libafs/MakefileProto.${MKAFS_OSTYPE} \
	src/libafs/afs.${MKAFS_OSTYPE}.plist \
	src/libafsauthent/Makefile \
	src/libafsrpc/Makefile \
	src/libuafs/Makefile \
	src/libuafs/Makefile.common \
	src/libuafs/MakefileProto.${MKAFS_OSTYPE} \
	src/log/test/Makefile \
	src/log/Makefile \
	src/login/Makefile \
	src/lwp/test/Makefile \
	src/lwp/Makefile \
	src/mpp/Makefile \
	src/null/Makefile \
	src/package/Makefile \
	src/pam/Makefile \
	src/pinstall/test/Makefile \
	src/pinstall/Makefile \
	src/platform/Makefile \
	src/platform/${MKAFS_OSTYPE}/Makefile \
	src/procmgmt/Makefile \
	src/procmgmt/test/Makefile \
	src/ptserver/Makefile \
	src/rx/Makefile \
	src/rx/bulk.example/Makefile \
	src/rx/bulktest/Makefile \
	src/rx/multi.example/Makefile \
	src/rx/simple.example/Makefile \
	src/rx/test/Makefile \
	src/rxdebug/Makefile \
	src/rxgen/Makefile \
	src/rxkad/Makefile \
	src/rxkad/test/Makefile \
	src/rxstat/Makefile \
	src/scout/Makefile \
	src/sgistuff/Makefile \
	src/shlibafsauthent/Makefile \
	src/shlibafsrpc/Makefile \
	src/sia/Makefile \
	src/sys/Makefile \
	src/tbutc/Makefile \
	src/tests/Makefile \
	src/tests/run-tests \
	src/tsm41/Makefile \
	src/tviced/Makefile \
	src/tvolser/Makefile \
	src/ubik/Makefile \
	src/update/Makefile \
	src/usd/test/Makefile \
	src/usd/Makefile \
	src/uss/Makefile \
	src/util/Makefile \
	src/util/test/Makefile \
	src/venus/test/Makefile \
	src/venus/Makefile \
	src/vfsck/Makefile \
	src/viced/Makefile \
	src/vlserver/Makefile \
	src/vol/Makefile \
	src/vol/test/Makefile \
	src/volser/Makefile \
	src/wsadmin.src/Makefile \
	src/xstat/Makefile  \
	src/helper-splint.sh
	if test -d doc/man-pages ; then \
	    rm -f doc/man-pages/Makefile doc/man-pages/install-man ; \
	fi

pristine: distclean
	/bin/rm -f src/config/afsconfig.h.in configure configure-libafs aclocal.m4

maintainer-clean: pristine

#
# Below targets are all deprecated, obsolete, 
# see README.OBSOLETE for more info
#

mpp: project
	@case ${WITH_OBSOLETE} in \
	YES) 	${COMPILE_PART1} mpp ${COMPILE_PART2} ;; \
	*)	echo skipping deprecated target: mpp ;; \
	esac

package: project mpp
	@case ${WITH_OBSOLETE} in \
	YES) 	${COMPILE_PART1} package ${COMPILE_PART2} ;; \
	*)	echo skipping deprecated target: package ;; \
	esac

package.files: package
	@case ${WITH_OBSOLETE} in \
	YES) 	${DESTDIR}/bin/makepkgfiles afs.dev ;; \
	*)	echo skipping deprecated target: package.files ;; \
	esac

