# 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

LIBS=${TOP_LIBDIR}/libauth.a \
	${TOP_LIBDIR}/librxkad.a \
	${TOP_LIBDIR}/libdes.a \
	${TOP_LIBDIR}/librx.a \
	${TOP_LIBDIR}/liblwp.a \
	${TOP_LIBDIR}/libcom_err.a \
	${TOP_LIBDIR}/util.a \
	${TOP_LIBDIR}/libsys.a

all: upserver upclient

#
# Build targets
#
upclient: client.o update.cs.o utils.o ${LIBS} 
	${CC} ${CFLAGS} -o upclient client.o update.cs.o utils.o ${LIBS} ${XLIBS}

upserver: server.o utils.o update.ss.o ${LIBS}
	${CC} ${CFLAGS} -o upserver server.o utils.o update.ss.o ${LIBS} ${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} -u -C -o $@ ${srcdir}/update.xg

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

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

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

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

#
# Installation targets
#
install : ${DESTDIR}${afssrvlibexecdir}/upserver ${DESTDIR}${afssrvlibexecdir}/upclient

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

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

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

${DESTDIR}${afssrvlibexecdir}/upserver: upserver
	${INSTALL} $? $@

${DESTDIR}${afssrvlibexecdir}/upclient: upclient
	${INSTALL} $? $@

dest: ${DEST}/root.server/usr/afs/bin/upserver ${DEST}/root.server/usr/afs/bin/upclient

