# 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.lwp


LIBS=${TOP_LIBDIR}/libauth.a \
	${TOP_LIBDIR}/librxkad.a \
	${TOP_LIBDIR}/librx.a \
	${TOP_LIBDIR}/libsys.a \
	${TOP_LIBDIR}/librx.a \
	${TOP_LIBDIR}/liblwp.a \
	${TOP_LIBDIR}/libafscom_err.a \
	${TOP_LIBDIR}/util.a \
	${TOP_LIBDIR}/libopr.a \
	${TOP_LIBDIR}/libafsrfc3961.a \
	${TOP_LIBDIR}/libafshcrypto_lwp.a

all: upserver upclient

generated: update.cs.c update.ss.c update.xdr.c update.h

#
# Build targets
#
upclient: client.o update.cs.o utils.o ${LIBS}
	$(AFS_LDRULE) client.o update.cs.o utils.o \
		${LIBS} $(LIB_roken) ${XLIBS}

upserver: server.o utils.o update.ss.o ${LIBS}
	$(AFS_LDRULE) server.o utils.o update.ss.o \
		${LIBS} $(LIB_roken) ${XLIBS}

utils.o: utils.c update.h global.h

client.o server.o: update.h global.h AFS_component_version_number.c

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

update.ss.c: update.xg
	${RXGEN} -A -S -o $@ ${srcdir}/update.xg

update.xdr.c: update.xg
	${RXGEN} -A -c -o $@ ${srcdir}/update.xg

update.h: update.xg
	${RXGEN} -A -u -h -o $@ ${srcdir}/update.xg

update.cs.c: update.h
update.ss.c: update.h
update.er.c: update.h

#
# Installation targets
#
install: upserver upclient
	${INSTALL} -d ${DESTDIR}${afssrvlibexecdir}
	${INSTALL_PROGRAM} upserver ${DESTDIR}${afssrvlibexecdir}/upserver
	${INSTALL_PROGRAM} upclient ${DESTDIR}${afssrvlibexecdir}/upclient

dest: upserver upclient
	${INSTALL} -d ${DEST}/root.server/usr/afs/bin
	${INSTALL_PROGRAM} upserver ${DEST}/root.server/usr/afs/bin/upserver
	${INSTALL_PROGRAM} upclient ${DEST}/root.server/usr/afs/bin/upclient

#
# Misc. targets
#
clean:
	$(RM) -f *.o upclient upserver update.ss.c update.cs.c update.xdr.c update.h core \
	AFS_component_version_number.c

include ../config/Makefile.version
