+# Horrible hacks to build DLLs on Windows and a shared library elsewhere.
+SHARED_LIBADD=
+SHARED_LDFLAGS=
+BFD_LIBADD=
+BFD_DEPENDENCIES=
+if test "$enable_shared" = "yes"; then
+# When building a shared libctf, link against the pic version of libiberty
+# so that apps that use libctf won't need libiberty just to satisfy any
+# libctf references.
+# We can't do that if a pic libiberty is unavailable since including non-pic
+# code would insert text relocations into libctf.
+# Note that linking against libbfd as we do here, which is itself linked
+# against libiberty, may not satisfy all the libctf libiberty references
+# since libbfd may not pull in the entirety of libiberty.
+changequote(,)dnl
+ x=`sed -n -e 's/^[ ]*PICFLAG[ ]*=[ ]*//p' < ../libiberty/Makefile | sed -n '$p'`
+changequote([,])dnl
+ if test -n "$x"; then
+ SHARED_LIBADD="-L`pwd`/../libiberty/pic -liberty"
+ fi
+
+ case "${host}" in
+ # More hacks to build DLLs on Windows.
+ *-*-cygwin*)
+ SHARED_LDFLAGS="-no-undefined"
+ SHARED_LIBADD="-L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin"
+ BFD_LIBADD="-L`pwd`/../bfd -lbfd"
+ ;;
+
+ *-*-darwin*)
+ BFD_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.dylib"
+ BFD_DEPENDENCIES="../bfd/libbfd.la"
+ ;;
+ *)
+ case "$host_vendor" in
+ hp)
+ BFD_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.sl"
+ ;;
+ *)
+ BFD_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.so"
+ ;;
+ esac
+ BFD_DEPENDENCIES="../bfd/libbfd.la"
+ ;;
+ esac
+fi
+AC_SUBST(SHARED_LDFLAGS)
+AC_SUBST(SHARED_LIBADD)
+AC_SUBST(BFD_LIBADD)
+AC_SUBST(BFD_DEPENDENCIES)
+
+# Use a version script, if possible, or an -export-symbols-regex otherwise.
+VERSION_FLAGS='-export-symbols-regex ctf_.*'
+if $LD --help 2>&1 | grep -- --version-script >/dev/null; then
+ VERSION_FLAGS="-Wl,--version-script='$srcdir/libctf.ver'"
+fi
+AC_SUBST(VERSION_FLAGS)
+