# 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
DIR=$(srcdir)/../dir
VOL=$(srcdir)/../vol
VOLSER=$(srcdir)/../volser

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

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

objects= ${VOLSEROBJS} ${DIROBJS} ${VOLOBJS}

vosobjects= ${VLSERVEROBJS} ${DIROBJS} ${VOLOBJS}

LIBS_common = \
	$(top_builddir)/src/sys/liboafs_sys.la \
	$(top_builddir)/src/cmd/liboafs_cmd.la \
	$(top_builddir)/src/util/liboafs_util.la      \
	$(top_builddir)/src/usd/liboafs_usd.la		\
	$(top_builddir)/src/rx/liboafs_rx.la \
	$(top_builddir)/src/rxstat/liboafs_rxstat.la \
	$(top_builddir)/src/rxkad/liboafs_rxkad.la \
	$(top_builddir)/src/lwp/liboafs_lwpcompat.la \
	$(top_builddir)/src/opr/liboafs_opr.la

LIBS_client = \
	$(top_builddir)/src/ubik/liboafs_ubik.la \
	$(top_builddir)/src/volser/liboafs_volser.la \
	$(LIBS_common)

LIBS_server = \
	$(top_builddir)/src/lwp/liboafs_lwpcompat.la \
	$(top_builddir)/src/libacl/liboafs_acl.la \
	$(LIBS_common)

all: volserver vos

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: volerr.c
	$(AFS_CCRULE) 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

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

vl_errors.c: ${VLSERVER}/vl_errors.et
	${COMPILE_ET_C} -p ${VLSERVER} vl_errors

volerr.c: ${VOLSER}/volerr.et
	${COMPILE_ET_C} -p ${VOLSER} volerr

volser.h: ${VOLSER}/volerr.et ${VOLSER}/volser.p.h
	${COMPILE_ET_H} -p ${VOLSER} volerr -h volser

common.o: volser.h
dumpstuff.o: volser.h
lockprocs.o: volser.h
vol-dump.o.lo: volser.h
volmain.o: volser.h
volprocs.o: volser.h
vol_split.o: volser.h
voltrans.o: volser.h
vos.o: volser.h
vsprocs.o: volser.h
vsutils.o: volser.h

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) -I../volser $(VOLSER)/vos.c

vos: vos.o  ${VOSOBJS} ${VLSERVEROBJS} $(LIBS_client)
	$(LT_LDRULE_static) vos.o ${VOSOBJS} ${VLSERVEROBJS} $(LIBS_client) \
		$(LIB_hcrypto) $(LIB_roken) ${MT_LIBS}

volserver: ${objects} $(LIBS_server)
	$(LT_LDRULE_static) ${objects} $(LIBS_server) \
		$(LIB_hcrypto) $(LIB_roken) ${MT_LIBS}

install: volserver
	${INSTALL} -d ${DESTDIR}${afssrvlibexecdir}
	${LT_INSTALL_PROGRAM} volserver ${DESTDIR}${afssrvlibexecdir}/volserver
	if [ "x$(ENABLE_PTHREADED_UBIK)" = "xyes" ] ; then     \
	    $(LT_INSTALL_PROGRAM) vos ${DESTDIR}${afssrvsbindir}/vos;     \
	    $(LT_INSTALL_PROGRAM) 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:
	$(LT_CLEAN)
	$(RM) -f *.o vos volserver core AFS_component_version_number.c \
		vl_errors.c volerr.c volser.h

include ../config/Makefile.version
