srcdir=@srcdir@
include @TOP_OBJDIR@/src/config/Makefile.config
include @TOP_OBJDIR@/src/config/Makefile.pthread

#for debugging:
#CFLAGS += -DAFSCP_DEBUG
KRB5CPPFLAGS = @KRB5_CPPFLAGS@

LIBOBJS = \
	afscp_callback.o \
	afscp_server.o \
	afscp_fid.o \
	afscp_volume.o \
	afscp_file.o \
	afscp_dir.o \
	afscp_init.o \
	afscp_util.o \
	afscp_dirops.o \
	afscp_acl.o

all: \
	${TOP_LIBDIR}/libafscp.a \
	depinstall

#
# Build targets
#
${TOP_LIBDIR}/libafscp.a: libafscp.a
	${INSTALL_DATA} $? $@

libafscp.a: ${LIBOBJS} AFS_component_version_number.o
	$(RM) -f $@
	$(AR) crv $@ ${LIBOBJS} AFS_component_version_number.o
	$(RANLIB) $@

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

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

CPPFLAGS_afscp_util.o = $(KRB5CPPFLAGS)
CPPFLAGS_afscp_server.o = $(KRB5CPPFLAGS)

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

dest: all
	${INSTALL} -d ${DEST}/lib
	${INSTALL} -d ${DEST}/include/afs
	${INSTALL_DATA} libafscp.a ${DEST}/lib/libafscp.a
	${INSTALL_DATA} ${srcdir}/afscp.h ${DEST}/include/afs/afscp.h

#
# Misc targets
#
clean:
	$(RM) -f *.o *.a *.gch libafscp* core AFS_component_version_number.c

include ../config/Makefile.version
