# 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

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

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

RX=../rx
VICED=../viced
VLSERVER=../vlserver
LWP=../lwp
LIBACL=../libacl
UTIL=../util
DIR=../dir
VOL=../vol
FSINT=../fsint

VICEDOBJS=viced.o afsfileprocs.o host.o physio.o callback.o serialize_state.o	

VLSERVEROBJS=vldbint.cs.o vldbint.xdr.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-server.o \
	 clone.o devname.o common.o ihandle.o listinodes.o namei_ops.o \
	 fstab.o salvsync-client.o daemon_com.o

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

RXOBJS = rx_pthread.o 

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

SDBGOBJS = state_analyzer.o uuid.o dirpath.o fileutil.o ${TOP_LIBDIR}/util.a

LIBS=${TOP_LIBDIR}/libafsauthent.a ${TOP_LIBDIR}/libafsrpc.a ${TOP_LIBDIR}/util.a

all: fileserver state_analyzer

rx_pthread.o: ${RX}/rx_pthread.c
	${CCRULE} -DDPF_FSLOG

viced.o: ${VICED}/viced.c
	${CCRULE}

afsfileprocs.o: ${VICED}/afsfileprocs.c
	${CCRULE}

host.o: ${VICED}/host.c
	${CCRULE}

physio.o: ${VICED}/physio.c
	${CCRULE}

callback.o: ${VICED}/callback.c
	${CCRULE}

serialize_state.o: ./serialize_state.c
	${CCRULE}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

fssync-server.o: ${VOL}/fssync-server.c
	${CCRULE}

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

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

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

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

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

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

# only for darwin?
fstab.o: ${UTIL}/fstab.c
	${CCRULE}

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

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

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

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

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

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

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

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

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

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

state_analyzer.o: state_analyzer.c
	${CCRULE}

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

state_analyzer: ${SDBGOBJS}
	${CC} ${LDFLAGS} -o state_analyzer ${SDBGOBJS} ${MT_LIBS} ${XLIBS}

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

${DEST}/root.server/usr/afs/bin/state_analyzer: state_analyzer
	${INSTALL} $? $@

install: ${DESTDIR}${afssrvlibexecdir}/fileserver ${DESTDIR}${afssrvsbindir}/state_analyzer

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

include ../config/Makefile.version

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

${DESTDIR}${afssrvsbindir}/state_analyzer: state_analyzer
	${INSTALL} $? $@

dest: ${DEST}/root.server/usr/afs/bin/fileserver ${DEST}/root.server/usr/afs/bin/state_analyzer

