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

UBIK=$(srcdir)/../ubik

INCLS=${TOP_INCDIR}/lwp.h ${TOP_INCDIR}/afs/afs_lock.h \
	${TOP_INCDIR}/rx/rx.h ${TOP_INCDIR}/rx/xdr.h \
	${TOP_INCDIR}/afs/afs_lock.h ubik.h ubik_int.h utst_int.h

LTLIBS=@TOP_OBJDIR@/src/util/liboafs_util.la \
       @TOP_OBJDIR@/src/ubik/liboafs_ubik.la \
       @TOP_OBJDIR@/src/cmd/liboafs_cmd.la

all: udebug utst_server utst_client

#
# insert comments here
#

utst_int.ss.o: utst_int.ss.c
utst_int.cs.o: utst_int.cs.c
utst_int.xdr.o: utst_int.xdr.c

utst_int.cs.c: ${UBIK}/utst_int.xg
	${RXGEN} -A -C -u -o $@ ${UBIK}/utst_int.xg

utst_int.ss.c: ${UBIK}/utst_int.xg
	${RXGEN} -A -S -o $@ ${UBIK}/utst_int.xg

utst_int.xdr.c: ${UBIK}/utst_int.xg
	${RXGEN} -A -c -o $@ ${UBIK}/utst_int.xg

utst_int.h: ${UBIK}/utst_int.xg
	${RXGEN} -A -h -u -o $@ ${UBIK}/utst_int.xg

utst_int.cs.c: utst_int.h
utst_int.ss.c: utst_int.h
utst_int.xdr.c: utst_int.h

utst_server.o: ${UBIK}/utst_server.c utst_int.h
	${AFS_CCRULE} ${UBIK}/utst_server.c

utst_client.o: ${UBIK}/utst_client.c utst_int.h
	${AFS_CCRULE} ${UBIK}/utst_client.c

utst_server: utst_server.o utst_int.ss.o utst_int.xdr.o $(LTLIBS)
	$(LT_LDRULE_static) utst_server.o utst_int.ss.o utst_int.xdr.o \
		$(LTLIBS) $(LIBS) $(LIB_hcrypto) $(LIB_roken)

utst_client: utst_client.o utst_int.cs.o utst_int.xdr.o $(LTLIBS)
	$(LT_LDRULE_static) utst_client.o utst_int.cs.o utst_int.xdr.o \
		$(LTLIBS) $(LIBS) $(LIB_hcrypto) $(LIB_roken)

udebug.o: ${UBIK}/udebug.c
	${AFS_CCRULE} ${UBIK}/udebug.c

udebug: udebug.o $(LTLIBS)
	$(LT_LDRULE_static) udebug.o \
		$(LTLIBS) $(LIBS) $(LIB_hcrypto) $(LIB_roken)

#
# Installation targets
#
test: all

install: udebug
	${INSTALL} -d ${DESTDIR}${bindir}
	${INSTALL} -d ${DESTDIR}${afssrvbindir}
	if [ "x$(ENABLE_PTHREADED_UBIK)" = "xyes" ] ; then                 \
	    $(LT_INSTALL_PROGRAM) udebug ${DESTDIR}${bindir}/udebug;          \
	    $(LT_INSTALL_PROGRAM) udebug ${DESTDIR}${afssrvbindir}/udebug;    \
	fi

dest: udebug
	${INSTALL} -d ${DEST}/root.server/usr/afs/bin
	if [ "x$(ENABLE_PTHREADED_UBIK)" = "xyes" ] ; then                    \
	    ${INSTALL_PROGRAM} udebug ${DEST}/bin/udebug;		      \
	    ${INSTALL_PROGRAM} udebug ${DEST}/root.server/usr/afs/bin/udebug; \
	fi
#
# Misc. targets
#
clean:
	$(LT_CLEAN)
	$(RM) -f *.o utst_server utst_client udebug *.a *.cs.c *.ss.c *.xdr.c
	$(RM) -f utst_int.h core AFS_component_version_number.c

include ../config/Makefile.version
