# 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

DEST=@DEST@
TOP_INCDIR=@TOP_INCDIR@
TOP_LIBDIR=@TOP_LIBDIR@
bindir=@bindir@
sbindir=@sbindir@
libexecdir=@libexecdir@
libdir=@libdir@
includedir=@includedir@
mandir=@mandir@
sysconfdir=@sysconfdir@
localstatedir=@localstatedir@
COMPILE_ET=${TOP_SRCDIR}/comerr/compile_et
RXGEN=${TOP_SRCDIR}/rxgen/rxgen
TOP_SRCDIR=@TOP_SRCDIR@
SYS_NAME=@AFS_SYSNAME@
prefix=@prefix@
exec_prefix=@exec_prefix@
afsconfdir=@afsconfdir@
viceetcdir=@viceetcdir@
afssrvbindir=@afssrvbindir@
afssrvsbindir=@afssrvsbindir@
afssrvlibexecdir=@afssrvlibexecdir@
afsdbdir=@afsdbdir@
afslogsdir=@afslogsdir@
afslocaldir=@afslocaldir@
afsbackupdir=@afsbackupdir@
afsbosconfigdir=@afsbosconfigdir@

SHELL = /bin/sh

include ../config/Makefile.${SYS_NAME}

CFLAGS=${OPTMZ} -I${TOP_SRCDIR}/config -I. -I${TOP_INCDIR} ${XCFLAGS}
LDFLAGS = ${OPTMZ} ${XLDFLAGS}

objects = assert.o base64.o casestrcpy.o ktime.o volparse.o hostparse.o \
	 hputil.o kreltime.o isathing.o get_krbrlm.o uuid.o serverLog.o \
	 dirpath.o fileutil.o netutils.o flipbase64.o \
	 afs_atomlist.o afs_lhash.o snprintf.o ${REGEX_OBJ}

all: ukinstall kinstall \
	${TOP_INCDIR}/afs/dirpath.h \
	${TOP_INCDIR}/afs/pthread_nosigs.h \
	${TOP_INCDIR}/afs/assert.h \
	${TOP_INCDIR}/afs/errors.h \
	${TOP_INCDIR}/afs/vice.h \
	${TOP_INCDIR}/afs/remote.h \
	${TOP_INCDIR}/afs/ktime.h \
	${TOP_INCDIR}/afs/fileutil.h \
	${TOP_INCDIR}/afs/netutils.h \
	${TOP_INCDIR}/afs/packages.h \
	${TOP_INCDIR}/afs/afsutil.h \
	${TOP_INCDIR}/afs/pthread_glock.h \
	${TOP_INCDIR}/afs/afs_atomlist.h \
	${TOP_INCDIR}/afs/afs_lhash.h \
	${TOP_INCDIR}/potpourri.h \
	${TOP_LIBDIR}/util.a \
	${TOP_LIBDIR}/libafsutil.a \
	sys

dirpath.h: dirpath.hin Makefile
	( sed \
		-e "s+@afsconfdir+${afsconfdir}+" \
		-e "s+@viceetcdir+${viceetcdir}+" \
		-e "s+@afssrvbindir+${afssrvbindir}+" \
		-e "s+@afssrvsbindir+${afssrvsbindir}+" \
		-e "s+@afssrvlibexecdir+${afssrvlibexecdir}+" \
		-e "s+@afsdbdir+${afsdbdir}+" \
		-e "s+@afslogsdir+${afslogsdir}+" \
		-e "s+@afslocaldir+${afslocaldir}+" \
		-e "s+@afsbackupdir+${afsbackupdir}+" \
		-e "s+@afsbosconfigdir+${afsbosconfigdir}+" \
		dirpath.hin >dirpath.h.tmp && \
		mv dirpath.h.tmp dirpath.h )

util.a: ${objects} AFS_component_version_number.o
	$(RM) -f util.a
	$(AR) crv util.a ${objects} AFS_component_version_number.o
	$(RANLIB) util.a

volparse.o: volparse.c
	${CC} ${CFLAGS} -c volparse.c

snprintf.o: snprintf.c
	${CC} ${CFLAGS} -c snprintf.c

base64.o: base64.c
	${CC} ${CFLAGS} -c base64.c

hostparse.o: hostparse.c afsutil.h
	${CC} ${CFLAGS} -c hostparse.c

ktime.o: ktime.c
	${CC} ${CFLAGS} -c ktime.c

kreltime.o: kreltime.c
	${CC} ${CFLAGS} -c kreltime.c

get_krbrlm.o: get_krbrlm.c
	${CC} ${CFLAGS} -c get_krbrlm.c

uuid.o: uuid.c
	${CC} ${CFLAGS} -c uuid.c

sys.o: sys.c ${TOP_INCDIR}/afs/param.h AFS_component_version_number.c
	${CC} ${CFLAGS} -c sys.c

sys: sys.o 
	${CC} ${LDFLAGS} -o sys sys.o

isathing.o: isathing.c
	${CC} ${CFLAGS} -c isathing.c

serverLog.o: serverLog.c
	${CC} ${CFLAGS} -c serverLog.c

dirpath.o: dirpath.c dirpath.h
	${CC} ${CFLAGS} -c dirpath.c

fileutil.o: fileutil.c fileutil.h
	${CC} ${CFLAGS} -c fileutil.c

netutils.o: netutils.c netutils.h
	${CC} ${CFLAGS} -c netutils.c

afs_atomlist.o: afs_atomlist.c afs_atomlist.h
	${CC} ${CFLAGS} -c afs_atomlist.c

afs_lhash.o: afs_lhash.c afs_lhash.h afs_atomlist.h
	${CC} ${CFLAGS} -c afs_lhash.c

#
# Install targets
#
KDIR=../libafs/afs
UKDIR=../libuafs/afs

install: \
	${DESTDIR}${includedir}/afs/dirpath.h \
	${DESTDIR}${includedir}/afs/pthread_nosigs.h \
	${DESTDIR}${includedir}/afs/assert.h \
	${DESTDIR}${includedir}/afs/errors.h \
	${DESTDIR}${includedir}/afs/vice.h \
	${DESTDIR}${includedir}/afs/remote.h \
	${DESTDIR}${includedir}/afs/ktime.h \
	${DESTDIR}${includedir}/afs/fileutil.h \
	${DESTDIR}${includedir}/afs/netutils.h \
	${DESTDIR}${includedir}/afs/packages.h \
	${DESTDIR}${includedir}/afs/afsutil.h \
	${DESTDIR}${includedir}/afs/pthread_glock.h \
	${DESTDIR}${includedir}/afs/afs_atomlist.h \
	${DESTDIR}${includedir}/afs/afs_lhash.h \
	${DESTDIR}${includedir}/potpourri.h \
	${DESTDIR}${libdir}/afs/util.a \
	${DESTDIR}${libdir}/afs/libafsutil.a \
	${DESTDIR}${bindir}/sys

${TOP_INCDIR}/afs/dirpath.h: dirpath.h
	${INSTALL} $? $@

${TOP_INCDIR}/afs/pthread_nosigs.h: pthread_nosigs.h
	${INSTALL} $? $@

${TOP_INCDIR}/afs/assert.h: assert.h
	${INSTALL} $? $@

${TOP_INCDIR}/afs/errors.h: errors.h
	${INSTALL} $? $@

${TOP_INCDIR}/afs/vice.h: vice.h
	${INSTALL} $? $@

${TOP_INCDIR}/afs/remote.h: remote.h
	${INSTALL} $? $@

${TOP_INCDIR}/afs/ktime.h: ktime.h
	${INSTALL} $? $@

${TOP_INCDIR}/afs/fileutil.h: fileutil.h
	${INSTALL} $? $@

${TOP_INCDIR}/afs/netutils.h: netutils.h
	${INSTALL} $? $@

${TOP_INCDIR}/afs/packages.h: packages.h
	${INSTALL} $? $@

${TOP_INCDIR}/afs/afsutil.h: afsutil.h
	${INSTALL} $? $@

${TOP_INCDIR}/afs/pthread_glock.h: pthread_glock.h
	${INSTALL} $? $@

${TOP_INCDIR}/afs/afs_atomlist.h: afs_atomlist.h
	${INSTALL} $? $@

${TOP_INCDIR}/afs/afs_lhash.h: afs_lhash.h
	${INSTALL} $? $@

${TOP_INCDIR}/potpourri.h: potpourri.h
	${INSTALL} $? $@


${TOP_LIBDIR}/util.a: util.a
	${INSTALL} $? $@

${TOP_LIBDIR}/libafsutil.a: util.a
	${INSTALL} $? $@


${DESTDIR}${includedir}/afs/dirpath.h: dirpath.h
	${INSTALL} $? $@

${DESTDIR}${includedir}/afs/pthread_nosigs.h: pthread_nosigs.h
	${INSTALL} $? $@

${DESTDIR}${includedir}/afs/assert.h: assert.h
	${INSTALL} $? $@

${DESTDIR}${includedir}/afs/errors.h: errors.h
	${INSTALL} $? $@

${DESTDIR}${includedir}/afs/vice.h: vice.h
	${INSTALL} $? $@

${DESTDIR}${includedir}/afs/remote.h: remote.h
	${INSTALL} $? $@

${DESTDIR}${includedir}/afs/ktime.h: ktime.h
	${INSTALL} $? $@

${DESTDIR}${includedir}/afs/fileutil.h: fileutil.h
	${INSTALL} $? $@

${DESTDIR}${includedir}/afs/netutils.h: netutils.h
	${INSTALL} $? $@

${DESTDIR}${includedir}/afs/packages.h: packages.h
	${INSTALL} $? $@

${DESTDIR}${includedir}/afs/afsutil.h: afsutil.h
	${INSTALL} $? $@

${DESTDIR}${includedir}/afs/pthread_glock.h: pthread_glock.h
	${INSTALL} $? $@

${DESTDIR}${includedir}/afs/afs_atomlist.h: afs_atomlist.h
	${INSTALL} $? $@

${DESTDIR}${includedir}/afs/afs_lhash.h: afs_lhash.h
	${INSTALL} $? $@

${DESTDIR}${includedir}/potpourri.h: potpourri.h
	${INSTALL} $? $@


${DESTDIR}${libdir}/afs/util.a: util.a
	${INSTALL} $? $@

${DESTDIR}${libdir}/afs/libafsutil.a: util.a
	${INSTALL} $? $@


${DESTDIR}${bindir}/sys: sys
	${INSTALL} $? $@


${DEST}/include/afs/dirpath.h: dirpath.h
	${INSTALL} $? $@

${DEST}/include/afs/pthread_nosigs.h: pthread_nosigs.h
	${INSTALL} $? $@

${DEST}/include/afs/assert.h: assert.h
	${INSTALL} $? $@

${DEST}/include/afs/errors.h: errors.h
	${INSTALL} $? $@

${DEST}/include/afs/vice.h: vice.h
	${INSTALL} $? $@

${DEST}/include/afs/remote.h: remote.h
	${INSTALL} $? $@

${DEST}/include/afs/ktime.h: ktime.h
	${INSTALL} $? $@

${DEST}/include/afs/fileutil.h: fileutil.h
	${INSTALL} $? $@

${DEST}/include/afs/netutils.h: netutils.h
	${INSTALL} $? $@

${DEST}/include/afs/packages.h: packages.h
	${INSTALL} $? $@

${DEST}/include/afs/afsutil.h: afsutil.h
	${INSTALL} $? $@

${DEST}/include/afs/pthread_glock.h: pthread_glock.h
	${INSTALL} $? $@

${DEST}/include/afs/afs_atomlist.h: afs_atomlist.h
	${INSTALL} $? $@

${DEST}/include/afs/afs_lhash.h: afs_lhash.h
	${INSTALL} $? $@

${DEST}/include/potpourri.h: potpourri.h
	${INSTALL} $? $@


${DEST}/lib/afs/util.a: util.a
	${INSTALL} $? $@

${DEST}/lib/afs/libafsutil.a: util.a
	${INSTALL} $? $@


${DEST}/bin/sys: sys
	${INSTALL} $? $@


kinstall: ${KDIR}/vice.h \
	${KDIR}/afs_base64.c \
	${KDIR}/afs_uuid.c \
	${KDIR}/afs_atomlist.c \
	${KDIR}/afs_atomlist.h \
	${KDIR}/afs_lhash.c \
	${KDIR}/afs_lhash.h

${KDIR}/vice.h: vice.h
	${INSTALL} $? $@

${KDIR}/afs_base64.c: base64.c
	${INSTALL} $? $@

${KDIR}/afs_uuid.c: uuid.c
	${INSTALL} $? $@

${KDIR}/afs_atomlist.c: afs_atomlist.c
	${INSTALL} $? $@

${KDIR}/afs_atomlist.h: afs_atomlist.h
	${INSTALL} $? $@

${KDIR}/afs_lhash.c: afs_lhash.c
	${INSTALL} $? $@

${KDIR}/afs_lhash.h: afs_lhash.h
	${INSTALL} $? $@

ukinstall: \
	${UKDIR}/afs_uuid.c \
	${UKDIR}/afs_atomlist.c \
	${UKDIR}/afs_atomlist.h \
	${UKDIR}/afs_lhash.c \
	${UKDIR}/afs_lhash.h \
	${UKDIR}/pthread_glock.h \
	${UKDIR}/vice.h \
	${UKDIR}/errors.h \
	${UKDIR}/afsutil.h \
	${UKDIR}/dirpath.h \
	${UKDIR}/dirpath.c \
	${UKDIR}/fileutil.h \
	${UKDIR}/fileutil.c \
	${UKDIR}/netutils.h \
	${UKDIR}/netutils.c \
	${UKDIR}/casestrcpy.c \
	${UKDIR}/hostparse.c 

${UKDIR}/errors.h: errors.h
	${INSTALL} $? $@

${UKDIR}/afsutil.h: afsutil.h
	${INSTALL} $? $@

${UKDIR}/dirpath.h: dirpath.h
	${INSTALL} $? $@

${UKDIR}/dirpath.c: dirpath.c
	${INSTALL} $? $@

${UKDIR}/fileutil.h: fileutil.h
	${INSTALL} $? $@

${UKDIR}/fileutil.c: fileutil.c
	${INSTALL} $? $@

${UKDIR}/netutils.h: netutils.h
	${INSTALL} $? $@

${UKDIR}/netutils.c: netutils.c
	${INSTALL} $? $@

${UKDIR}/casestrcpy.c: casestrcpy.c
	${INSTALL} $? $@

${UKDIR}/hostparse.c: hostparse.c
	${INSTALL} $? $@

${UKDIR}/pthread_glock.h: pthread_glock.h
	${INSTALL} $? $@

${UKDIR}/vice.h: vice.h
	${INSTALL} $? $@

${UKDIR}/afs_uuid.c: uuid.c
	${INSTALL} $? $@

${UKDIR}/afs_atomlist.c: afs_atomlist.c
	${INSTALL} $? $@

${UKDIR}/afs_atomlist.h: afs_atomlist.h
	${INSTALL} $? $@

${UKDIR}/afs_lhash.c: afs_lhash.c
	${INSTALL} $? $@

${UKDIR}/afs_lhash.h: afs_lhash.h
	${INSTALL} $? $@

#
# Misc targets
#

clean:
	$(RM) -f ${objects} sys dirpath.h
	$(RM) -f util.a *.o core AFS_component_version_number.c

test:
	cd test; $(MAKE)

include ../config/Makefile.version

dest: \
	${DEST}/include/afs/dirpath.h \
	${DEST}/include/afs/pthread_nosigs.h \
	${DEST}/include/afs/assert.h \
	${DEST}/include/afs/errors.h \
	${DEST}/include/afs/vice.h \
	${DEST}/include/afs/remote.h \
	${DEST}/include/afs/ktime.h \
	${DEST}/include/afs/fileutil.h \
	${DEST}/include/afs/netutils.h \
	${DEST}/include/afs/packages.h \
	${DEST}/include/afs/afsutil.h \
	${DEST}/include/afs/pthread_glock.h \
	${DEST}/include/afs/afs_atomlist.h \
	${DEST}/include/afs/afs_lhash.h \
	${DEST}/include/potpourri.h \
	${DEST}/lib/afs/util.a \
	${DEST}/lib/afs/libafsutil.a \
	${DEST}/bin/sys

