# 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

HELPER_SPLINT=@HELPER_SPLINT@
ENABLE_PTHREADED_UBIK=@ENABLE_PTHREADED_UBIK@

MODULE_CFLAGS=-DRXDEBUG -DFSSYNC_BUILD_CLIENT

VLSERVER=$(srcdir)/../vlserver
LWP=$(srcdir)/../lwp
LIBACL=$(srcdir)/../libacl
UTIL=$(srcdir)/../util
DIR=$(srcdir)/../dir
VOL=$(srcdir)/../vol
VOLSER=$(srcdir)/../volser
RX=$(srcdir)/../rx

VOLSEROBJS=volmain.o volprocs.o physio.o voltrans.o volerr.o volint.cs.o dumpstuff.o  volint.ss.o volint.xdr.o vscommon.o vol_split.o

VLSERVEROBJS=vldbint.cs.o vldbint.xdr.o vl_errors.o

VOSOBJS= vsprocs.o vsutils.o lockprocs.o volint.xdr.o volerr.o volint.cs.o

LWPOBJS=lock.o threadname.o

LIBACLOBJS=aclprocs.o netprocs.o

UTILOBJS=uuid.o serverLog.o fileutil.o netutils.o dirpath.o volparse.o flipbase64.o softsig.o pthread_threadname.o

DIROBJS=buffer.o dir.o salvage.o

VOLOBJS= vnode.o volume.o vutil.o partition.o fssync-client.o purge.o \
	 clone.o devname.o common.o ihandle.o listinodes.o \
	 namei_ops.o nuke.o salvsync-client.o daemon_com.o

RXOBJS=rx_pthread.o

objects= ${VOLSEROBJS} ${LWPOBJS} ${LIBACLOBJS} \
	 ${UTILOBJS} ${DIROBJS} ${VOLOBJS} ${RXOBJS}

vosobjects= ${VOSOBJS} ${VLSERVEROBJS} ${LIBACLOBJS} ${UTILOBJS} ${DIROBJS} \
	${VOLOBJS} ${RXOBJS}

LIBS=	${TOP_LIBDIR}/libcmd.a          \
	${TOP_LIBDIR}/libafsauthent.a   \
	${TOP_LIBDIR}/libafsutil.a      \
	${TOP_LIBDIR}/libusd.a          \
	${TOP_LIBDIR}/libafsrpc.a	\
	$(TOP_LIBDIR)/libopr.a

all: volserver vos

CFLAGS_rx_pthread.o = -DDPF_FSLOG
rx_pthread.o: ${RX}/rx_pthread.c
	$(AFS_CCRULE) $(RX)/rx_pthread.c

volmain.o: ${VOLSER}/volmain.c
	$(AFS_CCRULE) -I../volser $(VOLSER)/volmain.c

vol_split.o: ${VOLSER}/vol_split.c
	$(AFS_CCRULE) -I../volser $(VOLSER)/vol_split.c

volprocs.o: ${VOLSER}/volprocs.c
	$(AFS_CCRULE) -I../volser $(VOLSER)/volprocs.c

physio.o: ${VOLSER}/physio.c
	$(AFS_CCRULE) $(VOLSER)/physio.c

voltrans.o: ${VOLSER}/voltrans.c
	$(AFS_CCRULE) -I../volser $(VOLSER)/voltrans.c

volerr.o: ../volser/volerr.c
	$(AFS_CCRULE) ../volser/volerr.c

volint.cs.o: ../volser/volint.cs.c
	$(AFS_CCRULE) ../volser/volint.cs.c

dumpstuff.o: ${VOLSER}/dumpstuff.c
	$(AFS_CCRULE) -I../volser $(VOLSER)/dumpstuff.c

volint.ss.o: ../volser/volint.ss.c
	$(AFS_CCRULE) ../volser/volint.ss.c

volint.xdr.o: ../volser/volint.xdr.c
	$(AFS_CCRULE) ../volser/volint.xdr.c

vsprocs.o: ${VOLSER}/vsprocs.c
	$(AFS_CCRULE) $(VOLSER)/vsprocs.c

vsutils.o: ${VOLSER}/vsutils.c
	$(AFS_CCRULE) $(VOLSER)/vsutils.c

lockprocs.o: ${VOLSER}/lockprocs.c
	$(AFS_CCRULE) $(VOLSER)/lockprocs.c

uuid.o: ${UTIL}/uuid.c
	$(AFS_CCRULE) $(UTIL)/uuid.c

serverLog.o: ${UTIL}/serverLog.c
	$(AFS_CCRULE) $(UTIL)/serverLog.c

fileutil.o: ${UTIL}/fileutil.c
	$(AFS_CCRULE) $(UTIL)/fileutil.c

volparse.o: ${UTIL}/volparse.c
	$(AFS_CCRULE) $(UTIL)/volparse.c

flipbase64.o: ${UTIL}/flipbase64.c
	$(AFS_CCRULE) $(UTIL)/flipbase64.c

netutils.o: ${UTIL}/netutils.c
	$(AFS_CCRULE) -I../util $(UTIL)/netutils.c

dirpath.o: ${UTIL}/dirpath.c
	$(AFS_CCRULE) $(UTIL)/dirpath.c

softsig.o: ${UTIL}/softsig.c
	$(AFS_CCRULE) $(UTIL)/softsig.c

pthread_threadname.o: ${UTIL}/pthread_threadname.c
	$(AFS_CCRULE) $(UTIL)/pthread_threadname.c

lock.o: ${LWP}/lock.c
	$(AFS_CCRULE) $(LWP)/lock.c

threadname.o: ${LWP}/threadname.c
	$(AFS_CCRULE) $(LWP)/threadname.c

aclprocs.o: ${LIBACL}/aclprocs.c
	$(AFS_CCRULE) $(LIBACL)/aclprocs.c

netprocs.o: ${LIBACL}/netprocs.c
	$(AFS_CCRULE) $(LIBACL)/netprocs.c

vlserver.h vl_errors.c: ${VLSERVER}/vl_errors.et ${VLSERVER}/vlserver.p.h
	$(RM) -f vlserver.h vl_errors.c; ${COMPILE_ET} -p ${VLSERVER} vl_errors -h vlserver


vldbint.cs.o: ../vlserver/vldbint.cs.c
	$(AFS_CCRULE) -I$(VLSERVER) ../vlserver/vldbint.cs.c

vldbint.xdr.o: ../vlserver/vldbint.xdr.c
	$(AFS_CCRULE) -I$(VLSERVER) ../vlserver/vldbint.xdr.c

buffer.o: ${DIR}/buffer.c
	$(AFS_CCRULE) $(DIR)/buffer.c

dir.o: ${DIR}/dir.c
	$(AFS_CCRULE) $(DIR)/dir.c

salvage.o: ${DIR}/salvage.c
	$(AFS_CCRULE) $(DIR)/salvage.c

vnode.o: ${VOL}/vnode.c
	$(AFS_CCRULE) $(VOL)/vnode.c

volume.o: ${VOL}/volume.c
	$(AFS_CCRULE) $(VOL)/volume.c

vutil.o: ${VOL}/vutil.c
	$(AFS_CCRULE) $(VOL)/vutil.c

partition.o: ${VOL}/partition.c
	$(AFS_CCRULE) $(VOL)/partition.c

nuke.o: ${VOL}/nuke.c
	$(AFS_CCRULE) $(VOL)/nuke.c

fssync-client.o: ${VOL}/fssync-client.c
	$(AFS_CCRULE) $(VOL)/fssync-client.c

salvsync-client.o: ${VOL}/salvsync-client.c
	$(AFS_CCRULE) $(VOL)/salvsync-client.c

daemon_com.o: ${VOL}/daemon_com.c
	$(AFS_CCRULE) $(VOL)/daemon_com.c

purge.o: ${VOL}/purge.c
	$(AFS_CCRULE) $(VOL)/purge.c

clone.o: ${VOL}/clone.c
	$(AFS_CCRULE) $(VOL)/clone.c

devname.o: ${VOL}/devname.c
	$(AFS_CCRULE) $(VOL)/devname.c

common.o: ${VOL}/common.c
	$(AFS_CCRULE) $(VOL)/common.c

vscommon.o: ${VOLSER}/common.c
	$(AFS_CCRULE) $(VOLSER)/common.c

listinodes.o: ${VOL}/listinodes.c
	$(AFS_CCRULE) $(VOL)/listinodes.c

ihandle.o: ${VOL}/ihandle.c
	$(AFS_CCRULE) $(VOL)/ihandle.c

namei_ops.o: ${VOL}/namei_ops.c
	$(AFS_CCRULE) $(VOL)/namei_ops.c

vos.o: ${VOLSER}/vos.c
	$(AFS_CCRULE) $(VOLSER)/vos.c

vos: vos.o  ${VOSOBJS} ${VLSERVEROBJS} ${LIBS} ${TOP_LIBDIR}/libubik_pthread.a
	$(AFS_LDRULE) vos.o ${VOSOBJS} ${VLSERVEROBJS} ${LIBS} \
		${TOP_LIBDIR}/libubik_pthread.a \
		$(LIB_hcrypto) $(LIB_roken) ${MT_LIBS} ${XLIBS}

volserver: ${objects} ${LIBS}
	$(AFS_LDRULE) ${objects} \
		${LIBS} $(LIB_hcrypto) $(LIB_roken) ${MT_LIBS} ${XLIBS}

install: volserver
	${INSTALL} -d ${DESTDIR}${afssrvlibexecdir}
	${INSTALL} volserver ${DESTDIR}${afssrvlibexecdir}/volserver
	if [ "x$(ENABLE_PTHREADED_UBIK)" = "xyes" ] ; then     \
	    ${INSTALL} vos ${DESTDIR}${afssrvsbindir}/vos;     \
	    ${INSTALL} vos ${DESTDIR}${sbindir}/vos;           \
	fi

dest: volserver
	${INSTALL} -d ${DEST}/root.server/usr/afs/bin
	${INSTALL} volserver ${DEST}/root.server/usr/afs/bin/volserver
	if [ "x$(ENABLE_PTHREADED_UBIK)" = "xyes" ] ; then      \
	    ${INSTALL} vos ${DEST}/root.server/usr/afs/bin/vos; \
	    ${INSTALL} vos ${DEST}/etc/vos; 			\
	fi

clean:
	$(RM) -f *.o volserver core AFS_component_version_number.c

include ../config/Makefile.version
