# 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
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@

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

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

RX=../rx
VICED=../viced
TVICED=../tviced
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 vg_cache.o vg_scan.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: dafileserver 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: ${TVICED}/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} -I../util

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} -I${srcdir}/../vlserver

vldbint.xdr.o: ${VLSERVER}/vldbint.xdr.c
	${CCRULE} -I${srcdir}/../vlserver

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}

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

vg_scan.o: ${VOL}/vg_scan.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} -I../fsint

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: ${TVICED}/state_analyzer.c
	${CCRULE}

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

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

install: dafileserver state_analyzer
	${INSTALL} -d ${DESTDIR}${afssrvlibexecdir}
	${INSTALL} -d ${DESTDIR}${afssrvsbindir}
	${INSTALL} dafileserver \
		${DESTDIR}${afssrvlibexecdir}/dafileserver
	${INSTALL_PROGRAM} state_analyzer \
		${DESTDIR}${afssrvsbindir}/state_analyzer

dest: dafileserver state_analyzer
	${INSTALL} -d ${DEST}/root.server/usr/afs/bin
	${INSTALL} dafileserver \
		${DEST}/root.server/usr/afs/bin/dafileserver
	${INSTALL_PROGRAM} state_analyzer \
		${DEST}/root.server/usr/afs/bin/state_analyzer

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

include ../config/Makefile.version
