# Copyright (c) 2012 Your File System Inc.
# All rights reserved.
#
# This file is released under the terms of the two clause BSD
# License. For details, see the LICENSE file at the top level of
# this distribution.

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

# Increment these according to libtool's versioning rules (look them up!)
# The library output looks like libafsrpc.so.<current - age>.<revision>
LT_current = 2
LT_revision = 0
LT_age = 0

LT_objs = \
	$(top_builddir)/src/fsint/libfsint_pic.la \
	$(top_builddir)/src/rx/librx_pic.la \
	$(top_builddir)/src/rxkad/librxkad_pic.la \
	$(top_builddir)/src/crypto/rfc3961/librfc3961_pic.la \
	$(top_builddir)/src/comerr/libcomerr_pic.la \
	$(top_builddir)/src/util/libafsrpc_util.la \
	$(top_builddir)/src/rxstat/librxstat_pic.la \
	$(top_builddir)/src/sys/libafsrpc_sys.la \
	$(top_builddir)/src/lwp/liblwpcompat_pic.la \
	$(top_builddir)/src/opr/libopr_pic.la

LT_deps =

LT_libs = $(LIB_hcrypto) $(LIB_roken) $(MT_LIBS)

all: libafsrpc.la libafsrpc.a libafsrpc_pic.la \
	$(TOP_LIBDIR)/libafsrpc.a \
	$(TOP_LIBDIR)/libafsrpc_pic.a

# On AIX, we need to pull in the syscall import list from afsl.exp. Sadly
# there doesn't seem to be any way to get libtool to remember this requirement
# when it links the libafsrpc_sys.la convenience library.

libafsrpc.la: libafsrpc.la.sym $(LT_objs) $(LT_deps) libafsrpc_pic.la
	@set -e; set -x; case "$(SYS_NAME)" in \
	rs_aix*) \
	    $(LT_LDLIB_shlib) -Wl,-bI:../sys/afsl.exp \
		$(LT_objs) $(LT_deps) $(LT_libs) ;; \
	*) \
	    $(LT_LDLIB_shlib) $(LT_objs) $(LT_deps) $(LT_libs);; \
	esac

libafsrpc_pic.la: $(LT_objs)
	$(LT_LDLIB_pic) $(LT_objs)

# AIX needs libafsrpc to also be linked against the syscall import list
# On most platforms, libtool will make shared and static libraries at the
# same time, but not on AIX, so we need separate rules.
libafsrpc.a: $(LT_objs) libafsrpc.la
	$(LT_LDLIB_static) $(LT_objs)
	@set -e; set -x; case "${SYS_NAME}" in \
	    rs_aix*) \
		$(AR) crv $@ ../sys/afsl.exp;; \
	esac

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

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

install: libafsrpc.la libafsrpc.a libafsrpc_pic.la
	${INSTALL} -d ${DESTDIR}${libdir}
	$(LT_INSTALL_DATA) libafsrpc.la $(DESTDIR)$(libdir)/libafsrpc.la
	$(RM) $(DESTDIR)$(libdir)/libafsrpc.la
	$(INSTALL_DATA) libafsrpc.a $(DESTDIR)$(libdir)/libafsrpc.a
	$(INSTALL_DATA) .libs/libafsrpc_pic.a $(DESTDIR)$(libdir)/libafsrpc_pic.a

dest: libafsrpc.la libafsrpc.a
	${INSTALL} -d ${DEST}/lib
	${LT_INSTALL_DATA} libafsrpc.la ${DEST}/lib/libafsrpc.la
	${RM} ${DEST}/lib/libafsrpc.la
	${INSTALL_DATA} libafsrpc.a ${DEST}/lib/libafsrpc.a
	${INSTALL_DATA} .libs/libafsrpc_pic.a ${DEST}/lib/libafsrpc_pic.a

clean:
	$(LT_CLEAN)
	$(RM) -f *.o libafsrpc.a
