# API version. When something changes, increment as appropriate. 
# Ignore at your own risk.
LIBAFSRPCMAJOR=1
LIBAFSRPCMINOR=4

# 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
#
# Portions Copyright (c) 2003 Apple Computer, Inc.

# This is a pthread safe library containing rx, rxkad and des.

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


MODULE_CFLAGS=-DRXDEBUG

SFLAGS=-P -I${TOP_INCDIR}

RX = $(srcdir)/../rx
RXKAD = $(srcdir)/../rxkad
RXSTAT = $(srcdir)/../rxstat
FSINT = $(srcdir)/../fsint
COMERR = $(srcdir)/../comerr
UTIL = $(srcdir)/../util
OPR = $(srcdir)/../opr
SYS = ${srcdir}/../sys
LWP = ${srcdir}/../lwp

SYSOBJS =\
	syscall.o

UTILOBJS =\
	assert.o \
	casestrcpy.o \
	base64.o \
	rbtree.o

COMERROBJS =\
	error_msg.o \
	et_name.o \
	com_err.o

XDROBJS =\
	xdr.o \
	xdr_array.o \
	xdr_arrayn.o \
	xdr_rx.o \
	xdr_mem.o \
	xdr_len.o \
	xdr_int32.o \
	xdr_int64.o \
	xdr_afsuuid.o \
	xdr_update.o \
	xdr_refernce.o \
	AFS_component_version_number.o

RXOBJS =\
	rx_event.o \
	rx_user.o \
	rx_pthread.o \
	rx.o \
	rx_null.o \
	rx_opaque.o \
	rx_conncache.o \
	rx_globals.o \
	rx_getaddr.o \
	rx_identity.o \
	rx_misc.o \
	rx_packet.o \
	rx_rdwr.o \
	rx_stats.o \
	rx_trace.o \
	rx_multi.o \
	rx_peer.o \
	rx_conn.o \
        rx_call.o

RXSTATOBJS =\
	rxstat.o \
	rxstat.ss.o \
	rxstat.xdr.o \
	rxstat.cs.o

FSINTOBJS =\
	afsint.cs.o \
	afsint.xdr.o \
	afscbint.cs.o \
	afscbint.xdr.o \
	afsaux.o

RXKADOBJS =\
	rxkad_client.o \
	rxkad_server.o \
	rxkad_common.o \
	ticket.o \
	ticket5.o \
	crc.o \
	fcrypt.o \
	crypt_conn.o

LWPOBJS = \
	fasttime.o

LIBOBJS = \
	${RXOBJS} \
	${XDROBJS} \
	${RXKADOBJS} \
	${COMERROBJS} \
	${UTILOBJS} \
	${SYSOBJS} \
	${RXSTATOBJS} \
	${LWPOBJS} \
	${FSINTOBJS}

LIBAFSRPC = libafsrpc.${SHLIB_SUFFIX}.${LIBAFSRPCMAJOR}.${LIBAFSRPCMINOR}

all: ${TOP_LIBDIR}/${LIBAFSRPC} ${TOP_LIBDIR}/libafsrpc_pic.a

${TOP_LIBDIR}/${LIBAFSRPC}: ${LIBAFSRPC}
	../config/shlib-install -d ${TOP_LIBDIR} \
		-l libafsrpc -M ${LIBAFSRPCMAJOR} -m ${LIBAFSRPCMINOR}

${TOP_LIBDIR}/libafsrpc_pic.a: libafsrpc_pic.a
	${INSTALL_DATA} libafsrpc_pic.a $@

install: ${LIBAFSRPC} libafsrpc_pic.a
	../config/shlib-install -d ${DESTDIR}${libdir} \
		-l libafsrpc -M ${LIBAFSRPCMAJOR} -m ${LIBAFSRPCMINOR}
	${INSTALL_DATA} libafsrpc_pic.a ${DESTDIR}${libdir}/libafsrpc_pic.a

dest: ${LIBAFSRPC} libafsrpc_pic.a
	../config/shlib-install -d ${DEST}/lib \
		-l libafsrpc -M ${LIBAFSRPCMAJOR} -m ${LIBAFSRPCMINOR}
	${INSTALL_DATA} libafsrpc_pic.a ${DEST}/lib/libafsrpc_pic.a

${LIBAFSRPC}: ${LIBOBJS} libafsrpc.map
	../config/shlib-build -d $(srcdir) -l libafsrpc \
		-M ${LIBAFSRPCMAJOR} -m ${LIBAFSRPCMINOR} -- \
		$(LDFLAGS_roken) $(LDFLAGS_hcrypto) \
		${LIBOBJS} $(LIB_hcrypto) $(LIB_roken) $(MT_LIBS)

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

rx_event.o: ${RX}/rx_event.c
	$(AFS_CCRULE) $(RX)/rx_event.c

rx_user.o: ${RX}/rx_user.c
	$(AFS_CCRULE) $(RX)/rx_user.c

rx_pthread.o: ${RX}/rx_pthread.c
	$(AFS_CCRULE) $(RX)/rx_pthread.c

rx.o: ${RX}/rx.c
	$(AFS_CCRULE) $(RX)/rx.c

rx_conncache.o: ${RX}/rx_conncache.c
	$(AFS_CCRULE) $(RX)/rx_conncache.c

rx_call.o: ${RX}/rx_call.c
	$(AFS_CCRULE) $(RX)/rx_call.c

rx_conn.o: ${RX}/rx_conn.c
	$(AFS_CCRULE) $(RX)/rx_conn.c

rx_peer.o: ${RX}/rx_peer.c
	$(AFS_CCRULE) $(RX)/rx_peer.c

rx_null.o: ${RX}/rx_null.c
	$(AFS_CCRULE) $(RX)/rx_null.c

rx_opaque.o: ${RX}/rx_opaque.c
	$(AFS_CCRULE) $(RX)/rx_opaque.c

rx_globals.o: ${RX}/rx_globals.c 
	$(AFS_CCRULE) $(RX)/rx_globals.c

rx_identity.o: ${RX}/rx_identity.c
	$(AFS_CCRULE) $(RX)/rx_identity.c

rx_getaddr.o: ${RX}/rx_getaddr.c
	$(AFS_CCRULE) $(RX)/rx_getaddr.c

rx_misc.o: ${RX}/rx_misc.c
	$(AFS_CCRULE) $(RX)/rx_misc.c

rx_packet.o: ${RX}/rx_packet.c
	$(AFS_CCRULE) $(RX)/rx_packet.c

rx_stats.o: ${RX}/rx_stats.c
	$(AFS_CCRULE) $(RX)/rx_stats.c

rx_rdwr.o: ${RX}/rx_rdwr.c
	$(AFS_CCRULE) $(RX)/rx_rdwr.c

rx_trace.o: ${RX}/rx_trace.c
	$(AFS_CCRULE) $(RX)/rx_trace.c

rx_multi.o: ${RX}/rx_multi.c
	$(AFS_CCRULE) $(RX)/rx_multi.c

rxkad_client.o: ${RXKAD}/rxkad_client.c
	$(AFS_CCRULE) -I../rxkad $(RXKAD)/rxkad_client.c

rxkad_server.o: ${RXKAD}/rxkad_server.c
	$(AFS_CCRULE) -I../rxkad $(RXKAD)/rxkad_server.c

rxkad_common.o: ${RXKAD}/rxkad_common.c
	$(AFS_CCRULE) -I../rxkad $(RXKAD)/rxkad_common.c

ticket.o: ${RXKAD}/ticket.c
	$(AFS_CCRULE) -I../rxkad $(RXKAD)/ticket.c

CFLAGS_ticket5.o = @CFLAGS_NOERROR@
ticket5.o: ${RXKAD}/ticket5.c
	$(AFS_CCRULE) -I../rxkad -I$(RXKAD) $(RXKAD)/ticket5.c

crc.o: ${RXKAD}/crc.c
	$(AFS_CCRULE) -I../rxkad $(RXKAD)/crc.c

fcrypt.o: ${RXKAD}/fcrypt.c
	$(AFS_CCRULE) -I../rxkad $(RXKAD)/fcrypt.c

crypt_conn.o: ${RXKAD}/crypt_conn.c
	$(AFS_CCRULE) -I../rxkad $(RXKAD)/crypt_conn.c

AFS_component_version_number.o: ${TOP_OBJDIR}/src/rx/AFS_component_version_number.c
	$(AFS_CCRULE) ${TOP_OBJDIR}/src/rx/AFS_component_version_number.c

xdr.o: ${RX}/xdr.c
	$(AFS_CCRULE) $(RX)/xdr.c

xdr_int32.o: ${RX}/xdr_int32.c
	$(AFS_CCRULE) $(RX)/xdr_int32.c

xdr_int64.o: ${RX}/xdr_int64.c
	$(AFS_CCRULE) $(RX)/xdr_int64.c

xdr_array.o: ${RX}/xdr_array.c
	$(AFS_CCRULE) $(RX)/xdr_array.c

xdr_arrayn.o: ${RX}/xdr_arrayn.c
	$(AFS_CCRULE) $(RX)/xdr_arrayn.c

xdr_float.o: ${RX}/xdr_float.c
	$(AFS_CCRULE) $(RX)/xdr_float.c

xdr_len.o: ${RX}/xdr_len.c
	$(AFS_CCRULE) $(RX)/xdr_len.c

xdr_mem.o: ${RX}/xdr_mem.c
	$(AFS_CCRULE) $(RX)/xdr_mem.c

xdr_rec.o: ${RX}/xdr_rec.c
	$(AFS_CCRULE) $(RX)/xdr_rec.c

xdr_refernce.o: ${RX}/xdr_refernce.c
	$(AFS_CCRULE) $(RX)/xdr_refernce.c

xdr_rx.o: ${RX}/xdr_rx.c
	$(AFS_CCRULE) $(RX)/xdr_rx.c

xdr_update.o: ${RX}/xdr_update.c
	$(AFS_CCRULE) $(RX)/xdr_update.c

xdr_afsuuid.o: ${RX}/xdr_afsuuid.c
	$(AFS_CCRULE) $(RX)/xdr_afsuuid.c

error_msg.o: ${COMERR}/error_msg.c
	$(AFS_CCRULE) $(COMERR)/error_msg.c

et_name.o: ${COMERR}/et_name.c
	$(AFS_CCRULE) $(COMERR)/et_name.c

com_err.o: ${COMERR}/com_err.c
	$(AFS_CCRULE) $(COMERR)/com_err.c

casestrcpy.o: ${OPR}/casestrcpy.c
	$(AFS_CCRULE) $(OPR)/casestrcpy.c

assert.o: ${OPR}/assert.c
	$(AFS_CCRULE) $(OPR)/assert.c

rbtree.o: ${OPR}/rbtree.c
	$(AFS_CCRULE) $(OPR)/rbtree.c

base64.o: ${UTIL}/base64.c
	$(AFS_CCRULE) $(UTIL)/base64.c

fasttime.o: ${LWP}/fasttime.c
	$(AFS_CCRULE) $(LWP)/fasttime.c

syscall.o: ${SYS}/syscall.s
	case "$(SYS_NAME)" in \
	     sun4x_5* | sunx86_5*) \
		$(PATH_CPP)  ${SFLAGS} ${SYS}/syscall.s > syscall.ss; \
		as -o syscall.o syscall.ss;		\
		$(RM) syscall.ss;;				\
	 arm_darwin_* ) \
		touch syscall.c ; \
	        ${CC} ${AFS_CFLAGS} -c syscall.c;; \
	 sgi_* | *_darwin_* ) \
	        ${CC} ${AFS_CFLAGS} -c ${SYS}/syscall.s;;          \
	 alpha_dux?? ) \
		${AS} -P ${AFS_CFLAGS} -D_NO_PROTO -DMACH -DOSF -nostdinc -traditional -DASSEMBLER ${SYS}/syscall.s; \
		${AS} -o syscall.o syscall.i; \
		$(RM) -f syscall.ss syscall.i;; \
	 *fbsd* ) \
		touch syscall.c ; \
	        ${CC} ${AFS_CFLAGS} -c syscall.c;; \
	 *) \
		$(PATH_CPP) ${SFLAGS} ${SYS}/syscall.s > syscall.ss; \
		as $(ASFLAGS) -o syscall.o syscall.ss;		\
		$(RM) syscall.ss;;				\
	esac

rxstat.o: ${RXSTAT}/rxstat.c
	$(AFS_CCRULE) $(RXSTAT)/rxstat.c

rxstat.cs.o: ${TOP_OBJDIR}/src/rxstat/rxstat.cs.c
	$(AFS_CCRULE) ${TOP_OBJDIR}/src/rxstat/rxstat.cs.c

rxstat.ss.o: ${TOP_OBJDIR}/src/rxstat/rxstat.ss.c
	$(AFS_CCRULE) ${TOP_OBJDIR}/src/rxstat/rxstat.ss.c

rxstat.xdr.o: ${TOP_OBJDIR}/src/rxstat/rxstat.xdr.c
	$(AFS_CCRULE) ${TOP_OBJDIR}/src/rxstat/rxstat.xdr.c

afsint.cs.o: ${TOP_OBJDIR}/src/fsint/afsint.cs.c
	$(AFS_CCRULE) ${TOP_OBJDIR}/src/fsint/afsint.cs.c

afsint.xdr.o: ${TOP_OBJDIR}/src/fsint/afsint.xdr.c
	$(AFS_CCRULE) ${TOP_OBJDIR}/src/fsint/afsint.xdr.c

afscbint.cs.o: ${TOP_OBJDIR}/src/fsint/afscbint.cs.c
	$(AFS_CCRULE) ${TOP_OBJDIR}/src/fsint/afscbint.cs.c

afscbint.xdr.o: ${TOP_OBJDIR}/src/fsint/afscbint.xdr.c
	$(AFS_CCRULE) ${TOP_OBJDIR}/src/fsint/afscbint.xdr.c

afsaux.o: ${FSINT}/afsaux.c
	$(AFS_CCRULE) -I../fsint ${FSINT}/afsaux.c

clean:
	$(RM) -f *.o libafsrpc.a* libafsrpc.sl* libafsrpc.so* \
		libafsrpc_pic.a libafsrpc.dylib.* libafsrpc.exp
