dnl CF__ADD_SHLIB_RULES version: 5 updated: 2015/05/10 19:52:14
dnl -------------------
dnl Append rules for creating, installing, uninstalling and cleaning library.
dnl In particular, this is needed for shared libraries since there are symbolic
dnl links which depend on configuration choices.
dnl
dnl The logic is controlled by these cache variables:
dnl $cf_cv_do_symlinks
dnl $cf_cv_shlib_version
dnl
dnl The macro uses variables set by CF__DEFINE_SHLIB_VARS
dnl
dnl $1 = makefile to append to
dnl $2 = model (static, shared, libtool)
dnl $3 = objects (dependencies)
dnl $4 = additional libraries needed to link the shared library
define([CF__ADD_SHLIB_RULES],[

CF__DEFINE_LIB_TARGET

case x$2 in
(xlibtool|xshared)
	cf_libdeps="ifelse($4,,,[$4])"
	;;
(x*)
	cf_libdeps=
	;;
esac

cat >>$1 <<CF_EOF

# generated by CF__ADD_SHLIB_RULES
# libmodel: $2
# symlinks: $cf_cv_do_symlinks
# shlibver: $cf_cv_shlib_version

CF_EOF

cat >>$1 <<CF_EOF
$cf_libname :: \\
CF_EOF

cat >>$1 <<CF_EOF
		$3
	@echo linking \[$]@
	\$(LIBTOOL_CREATE) $3 $cf_libdeps
CF_EOF

if test "x$cf_cv_do_symlinks" = xyes
then
cat >>$1 <<CF_EOF
	\$(LN_S) $cf_libname $cf_liblink
	\$(LN_S) $cf_liblink $cf_libroot
CF_EOF
fi

cat >>$1 <<CF_EOF

install \\
install.libs :: \$(DESTDIR)\$(libdir)/$cf_libname

\$(DESTDIR)\$(libdir)/$cf_libname :: \\
		\$(DESTDIR)\$(libdir) \\
		$3
	@echo linking \[$]@
	\$(LIBTOOL_CREATE) $3 $cf_libdeps
CF_EOF

if test "x$cf_cv_do_symlinks" = xyes
then
cat >>$1 <<CF_EOF
	cd \$(DESTDIR)\$(libdir) && (\$(LN_S) $cf_libname $cf_liblink; \$(LN_S) $cf_liblink $cf_libroot; )
CF_EOF
fi

if test x$2 = xshared
then
cat >>$1 <<CF_EOF
	- test -z "\$(DESTDIR)" && /sbin/ldconfig
CF_EOF
fi

cat >>$1 <<CF_EOF

uninstall \\
uninstall.libs ::
	@echo uninstalling \$(DESTDIR)\$(libdir)/$cf_libname
CF_EOF

if test "x$cf_cv_do_symlinks" = xyes
then
cat >>$1 <<CF_EOF
	-rm -f \$(DESTDIR)\$(libdir)/$cf_libroot
	-rm -f \$(DESTDIR)\$(libdir)/$cf_liblink
CF_EOF
fi

cat >>$1 <<CF_EOF
	-rm -f \$(DESTDIR)\$(libdir)/$cf_libname

clean \\
clean.libs ::
CF_EOF

if test "x$cf_cv_do_symlinks" = xyes
then
cat >>$1 <<CF_EOF
	-rm -f $cf_libroot
	-rm -f $cf_liblink
CF_EOF
fi

cat >>$1 <<CF_EOF
	-rm -f $cf_libname

mostlyclean::
	-rm -f $3
# end generated by CF__ADD_SHLIB_RULES
CF_EOF
])dnl
