# 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


all: \
	${TOP_LIBDIR}/libdir.a \
	depinstall \
	test

depinstall: \
	${TOP_INCDIR}/afs/dir.h

${TOP_INCDIR}/afs/dir.h: dir.h
	${INSTALL_DATA} $? $@

${TOP_LIBDIR}/libdir.a: libdir.a
	${INSTALL_DATA} $? $@

libdir.a: buffer.o dir.o salvage.o AFS_component_version_number.o
	$(RM) -f $@
	$(AR) crv $@ buffer.o dir.o salvage.o  AFS_component_version_number.o
	$(RANLIB) $@

.PHONY: test
test: ${TOP_LIBDIR}/libdir.a
	cd test && $(MAKE) all

buffer.o: buffer.c dir.h

dir.o: dir.c dir.h

salvage.o: salvage.c dir.h


#
# Install targets
#
install: libdir.a dir.h
	${INSTALL} -d ${DESTDIR}${libdir}/afs
	${INSTALL} -d ${DESTDIR}${includedir}/afs
	${INSTALL_DATA} libdir.a ${DESTDIR}${libdir}/afs/libdir.a
	${INSTALL_DATA} ${srcdir}/dir.h ${DESTDIR}${includedir}/afs/dir.h

dest: libdir.a dir.h
	${INSTALL} -d ${DEST}/lib/afs
	${INSTALL} -d ${DEST}/include/afs
	${INSTALL_DATA} libdir.a ${DEST}/lib/afs/libdir.a
	${INSTALL_DATA} ${srcdir}/dir.h ${DEST}/include/afs/dir.h

#
# Misc. targets
#
clean:
	$(RM) -f *.o *.a core AFS_component_version_number.c
	cd test && $(MAKE) clean

include ../config/Makefile.version
