# 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
HELPER_SPLINT=@HELPER_SPLINT@

CC=${MT_CC}
CFLAGS=${COMMON_CFLAGS} -I.. -DNINTERFACE ${MT_CFLAGS} -DRXDEBUG -DFSSYNC_BUILD_CLIENT

CCRULE=${CC} ${CFLAGS} -c $?

VICED=../viced
VLSERVER=../vlserver
LWP=../lwp
LIBACL=../libacl
UTIL=../util
DIR=../dir
VOL=../vol
FSINT=../fsint
VOLSER=../volser
RX=../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

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=assert.o uuid.o serverLog.o fileutil.o netutils.o dirpath.o volparse.o flipbase64.o softsig.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

FSINTOBJS=# afsaux.o afscbint.cs.o afsint.ss.o afsint.xdr.o

RXOBJS=rx_pthread.o

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

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

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

all: volserver 

all_vos: vos
	
COMPILE=${CC} ${CFLAGS} -c $?

rx_pthread.o: ${RX}/rx_pthread.c
	${COMPILE} -DDPF_FSLOG
volmain.o: ${VOLSER}/volmain.c
	${COMPILE}
volprocs.o: ${VOLSER}/volprocs.c
	${COMPILE}
physio.o: ${VOLSER}/physio.c
	${COMPILE}
voltrans.o: ${VOLSER}/voltrans.c
	${COMPILE}
volerr.o: ${VOLSER}/volerr.c
	${COMPILE}
volint.cs.o: ${VOLSER}/volint.cs.c
	${COMPILE}
dumpstuff.o: ${VOLSER}/dumpstuff.c
	${COMPILE}
volint.ss.o: ${VOLSER}/volint.ss.c
	${COMPILE}
volint.xdr.o: ${VOLSER}/volint.xdr.c
	${COMPILE}
vsprocs.o: ${VOLSER}/vsprocs.c
	${COMPILE}
vsutils.o: ${VOLSER}/vsutils.c
	${COMPILE}
lockprocs.o: ${VOLSER}/lockprocs.c
	${COMPILE}

assert.o: ${UTIL}/assert.c
	${COMPILE}

uuid.o: ${UTIL}/uuid.c
	${COMPILE}

serverLog.o: ${UTIL}/serverLog.c
	${COMPILE}

fileutil.o: ${UTIL}/fileutil.c
	${COMPILE}

volparse.o: ${UTIL}/volparse.c
	${COMPILE}

flipbase64.o: ${UTIL}/flipbase64.c
	${COMPILE}

netutils.o: ${UTIL}/netutils.c
	${COMPILE}

dirpath.o: ${UTIL}/dirpath.c
	${COMPILE}

softsig.o: ${UTIL}/softsig.c
	${COMPILE}

lock.o: ${LWP}/lock.c
	${COMPILE}

threadname.o: ${LWP}/threadname.c
	${COMPILE}

aclprocs.o: ${LIBACL}/aclprocs.c
	${COMPILE}

netprocs.o: ${LIBACL}/netprocs.c
	${COMPILE}

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

vl_errors.o: vl_errors.c
	${COMPILE}

vldbint.cs.o: ${VLSERVER}/vldbint.cs.c
	${COMPILE}

vldbint.xdr.o: ${VLSERVER}/vldbint.xdr.c
	${COMPILE}

buffer.o: ${DIR}/buffer.c
	${COMPILE}

dir.o: ${DIR}/dir.c
	${COMPILE}

salvage.o: ${DIR}/salvage.c
	${COMPILE}

vnode.o: ${VOL}/vnode.c
	${COMPILE}

volume.o: ${VOL}/volume.c
	${COMPILE}

vutil.o: ${VOL}/vutil.c
	${COMPILE}

partition.o: ${VOL}/partition.c
	${COMPILE}

nuke.o: ${VOL}/nuke.c
	${COMPILE}

fssync-client.o: ${VOL}/fssync-client.c
	${COMPILE}

salvsync-client.o: ${VOL}/salvsync-client.c
	${COMPILE}

daemon_com.o: ${VOL}/daemon_com.c
	${COMPILE}

purge.o: ${VOL}/purge.c
	${COMPILE}

clone.o: ${VOL}/clone.c
	${COMPILE}

devname.o: ${VOL}/devname.c
	${COMPILE}

common.o: ${VOL}/common.c
	${COMPILE}

vscommon.o: ${VOLSER}/common.c
	${COMPILE} -o vscommon.o

listinodes.o: ${VOL}/listinodes.c
	${COMPILE}

ihandle.o: ${VOL}/ihandle.c
	${COMPILE}

namei_ops.o: ${VOL}/namei_ops.c
	${COMPILE}

afsaux.o: ${FSINT}/afsaux.c
	${COMPILE}

afscbint.cs.o: ${FSINT}/afscbint.cs.c
	${COMPILE}

afscbint.ss.o: ${FSINT}/afscbint.ss.c
	${COMPILE}

afsint.cs.o: ${FSINT}/afsint.cs.c
	${COMPILE}

afsint.ss.o: ${FSINT}/afsint.ss.c
	${COMPILE}

afsint.xdr.o: ${FSINT}/afsint.xdr.c
	${COMPILE}

vos.o: ${VOLSER}/vos.c
	${COMPILE}


vos: vos.o  ${VOSOBJS} ${VLSERVEROBJS} ${LIBS} ${TOP_LIBDIR}/libubik_pthread.a
	${CC} ${LDFLAGS} -o vos vos.o ${VOSOBJS} ${VLSERVEROBJS} ${LIBS} ${TOP_LIBDIR}/libubik_pthread.a ${MT_LIBS} ${XLIBS}

volserver: ${objects} ${LIBS}
	${CC} ${LDFLAGS} -o volserver ${objects} ${LIBS} ${MT_LIBS} ${XLIBS}

${DEST}/root.server/usr/afs/bin/volserver: volserver
	${INSTALL} -ns $? $@

${DEST}/root.server/usr/afs/bin/vos: vos
	${INSTALL} -ns $? $@

install: ${DESTDIR}${afssrvlibexecdir}/volserver 
install_vos: ${DESTDIR}${afssrvsbindir}/vos

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

include ../config/Makefile.version

${DESTDIR}${afssrvlibexecdir}/volserver: volserver
	${INSTALL} -ns $? $@

${DESTDIR}${afssrvsbindir}/vos: vos
	${INSTALL} -ns $? $@

dest: ${DEST}/root.server/usr/afs/bin/volserver 
dest_vos: ${DEST}/root.server/usr/afs/bin/vos

