aboutsummaryrefslogtreecommitdiff
path: root/libctf/configure.ac
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2019-07-20 14:45:12 +0100
committerNick Alcock <nick.alcock@oracle.com>2019-10-03 17:04:56 +0100
commit87279e3cef5b2c54f4a01962cf9dcea38664a336 (patch)
tree2f972035efea4b029156d1bcea5f37a4cdb8ef82 /libctf/configure.ac
parent1ff6de031241c59d0ff9fa01d3c0a4049b0e97c9 (diff)
downloadgdb-87279e3cef5b2c54f4a01962cf9dcea38664a336.zip
gdb-87279e3cef5b2c54f4a01962cf9dcea38664a336.tar.gz
gdb-87279e3cef5b2c54f4a01962cf9dcea38664a336.tar.bz2
libctf: installable libctf as a shared library
This lets other programs read and write CTF-format data. Two versioned shared libraries are created: libctf.so and libctf-nobfd.so. They contain identical content except that libctf-nobfd.so contains no references to libbfd and does not implement ctf_open, ctf_fdopen, ctf_bfdopen or ctf_bfdopen_ctfsect, so it can be used by programs that cannot use BFD, like readelf. The soname major version is presently .0 until the linker API stabilizes, when it will flip to .1 and hopefully never change again. New in v3. v4: libtoolize and turn into a pair of shared libraries. Drop --enable-install-ctf: now controlled by --enable-shared and --enable-install-libbfd, like everything else. v5: Add ../bfd to ACLOCAL_AMFLAGS and AC_CONFIG_MACRO_DIR. Fix tabdamage. * Makefile.def (host_modules): libctf is no longer no_install. * Makefile.in: Regenerated. libctf/ * configure.ac (AC_DISABLE_SHARED): New, like opcodes/. (LT_INIT): Likewise. (AM_INSTALL_LIBBFD): Likewise. (dlopen): Note why this is necessary in a comment. (SHARED_LIBADD): Initialize for possibly-PIC libiberty: derived from opcodes/. (SHARED_LDFLAGS): Likewise. (BFD_LIBADD): Likewise, for libbfd. (BFD_DEPENDENCIES): Likewise. (VERSION_FLAGS): Initialize, using a version script if ld supports one, or libtool -export-symbols-regex otherwise. (AC_CONFIG_MACRO_DIR): Add ../BFD. * Makefile.am (ACLOCAL_AMFLAGS): Likewise. (INCDIR): New. (AM_CPPFLAGS): Use $(srcdir), not $(top_srcdir). (noinst_LIBRARIES): Replace with... [INSTALL_LIBBFD] (lib_LTLIBRARIES): This, or... [!INSTALL_LIBBFD] (noinst_LTLIBRARIES): ... this, mentioning new libctf-nobfd.la as well. [INSTALL_LIBCTF] (include_HEADERS): Add the CTF headers. [!INSTALL_LIBCTF] (include_HEADERS): New, empty. (libctf_a_SOURCES): Rename to... (libctf_nobfd_la_SOURCES): ... this, all of libctf other than ctf-open-bfd.c. (libctf_la_SOURCES): Now derived from libctf_nobfd_la_SOURCES, with ctf-open-bfd.c added. (libctf_nobfd_la_LIBADD): New, using @SHARED_LIBADD@. (libctf_la_LIBADD): New, using @BFD_LIBADD@ as well. (libctf_la_DEPENDENCIES): New, using @BFD_DEPENDENCIES@. * Makefile.am [INSTALL_LIBCTF]: Use it. * aclocal.m4: Add ../bfd/acinclude.m4, ../config/acx.m4, and the libtool macros. * libctf.ver: New, everything is version LIBCTF_1.0 currently (even the unstable components). * Makefile.in: Regenerated. * config.h.in: Likewise. * configure: Likewise. binutils/ * Makefile.am (LIBCTF): Mention the .la file. (LIBCTF_NOBFD): New. (readelf_DEPENDENCIES): Use it. (readelf_LDADD): Likewise. * Makefile.in: Regenerated. ld/ * configure.ac (TESTCTFLIB): Set to the .so or .a, like TESTBFDLIB. * Makefile.am (TESTCTFLIB): Use it. (LIBCTF): Use the .la file. (check-DEJAGNU): Use it. * Makefile.in: Regenerated. * configure: Likewise. include/ * ctf-api.h: Note the instability of the ctf_link interfaces.
Diffstat (limited to 'libctf/configure.ac')
-rw-r--r--libctf/configure.ac66
1 files changed, 66 insertions, 0 deletions
diff --git a/libctf/configure.ac b/libctf/configure.ac
index 2a1a80b..aa40e4e 100644
--- a/libctf/configure.ac
+++ b/libctf/configure.ac
@@ -22,6 +22,7 @@ AC_PREREQ(2.64)
AC_INIT([libctf library], 1.2.0-pre)
AC_CONFIG_SRCDIR(ctf-impl.h)
AC_CONFIG_MACRO_DIR(../config)
+AC_CONFIG_MACRO_DIR(../bfd)
AC_USE_SYSTEM_EXTENSIONS
AM_INIT_AUTOMAKE
@@ -31,6 +32,11 @@ AC_PROG_CC
AC_PROG_RANLIB
AM_PROG_AR
+dnl Default to a non shared library. This may be overridden by the
+dnl configure option --enable-shared.
+AC_DISABLE_SHARED
+
+LT_INIT
AC_SYS_LARGEFILE
MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing
@@ -52,9 +58,11 @@ ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([-Wno-long-long])
ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual])
AM_MAINTAINER_MODE
+AM_INSTALL_LIBBFD
ACX_PROG_CC_WARNING_OPTS([-Wall], [ac_libctf_warn_cflags])
AC_FUNC_MMAP
+# Needed for BFD capability checks.
AC_SEARCH_LIBS(dlopen, dl)
AM_ZLIB
@@ -149,6 +157,64 @@ if test $ac_cv_libctf_macro_O_CLOEXEC = yes; then
[Whether the platform has a definition of O_CLOEXEC.])
fi
+# 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)
+
AC_CONFIG_FILES(Makefile)
AC_CONFIG_HEADERS(config.h)
AC_OUTPUT