1*869ffda3Schristosdnl -*- Autoconf -*- 2*869ffda3Schristosdnl Process this file with autoconf to produce a configure script. 3*869ffda3Schristosdnl 4*869ffda3Schristosdnl Copyright (C) 2019-2020 Free Software Foundation, Inc. 5*869ffda3Schristosdnl 6*869ffda3Schristosdnl This file is free software; you can redistribute it and/or modify 7*869ffda3Schristosdnl it under the terms of the GNU General Public License as published by 8*869ffda3Schristosdnl the Free Software Foundation; either version 2 of the License, or 9*869ffda3Schristosdnl (at your option) any later version. 10*869ffda3Schristosdnl 11*869ffda3Schristosdnl This program is distributed in the hope that it will be useful, 12*869ffda3Schristosdnl but WITHOUT ANY WARRANTY; without even the implied warranty of 13*869ffda3Schristosdnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*869ffda3Schristosdnl GNU General Public License for more details. 15*869ffda3Schristosdnl 16*869ffda3Schristosdnl You should have received a copy of the GNU General Public License 17*869ffda3Schristosdnl along with this program; see the file COPYING. If not see 18*869ffda3Schristosdnl <http://www.gnu.org/licenses/>. 19*869ffda3Schristosdnl 20*869ffda3Schristos 21*869ffda3SchristosAC_PREREQ(2.64) 22*869ffda3SchristosAC_INIT([libctf library], 1.2.0-pre) 23*869ffda3SchristosAC_CONFIG_SRCDIR(ctf-impl.h) 24*869ffda3SchristosAC_CONFIG_MACRO_DIR(../config) 25*869ffda3SchristosAC_CONFIG_MACRO_DIR(../bfd) 26*869ffda3SchristosAC_USE_SYSTEM_EXTENSIONS 27*869ffda3SchristosAM_INIT_AUTOMAKE 28*869ffda3Schristos 29*869ffda3Schristos# Checks for programs. 30*869ffda3SchristosAC_PROG_MAKE_SET 31*869ffda3SchristosAC_PROG_CC 32*869ffda3SchristosAC_PROG_RANLIB 33*869ffda3SchristosAM_PROG_AR 34*869ffda3Schristos 35*869ffda3Schristosdnl Default to a non shared library. This may be overridden by the 36*869ffda3Schristosdnl configure option --enable-shared. 37*869ffda3SchristosAC_DISABLE_SHARED 38*869ffda3Schristos 39*869ffda3SchristosLT_INIT 40*869ffda3SchristosAC_SYS_LARGEFILE 41*869ffda3Schristos 42*869ffda3SchristosMISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing 43*869ffda3SchristosAC_CHECK_PROGS([ACLOCAL], [aclocal], [$MISSING aclocal]) 44*869ffda3SchristosAC_CHECK_PROGS([AUTOCONF], [autoconf], [$MISSING autoconf]) 45*869ffda3SchristosAC_CHECK_PROGS([AUTOHEADER], [autoheader], [$MISSING autoheader]) 46*869ffda3Schristos 47*869ffda3Schristos# Figure out what compiler warnings we can enable. 48*869ffda3Schristos# See config/warnings.m4 for details. 49*869ffda3Schristos 50*869ffda3SchristosACX_PROG_CC_WARNING_OPTS([-W -Wall -Wno-narrowing -Wwrite-strings \ 51*869ffda3Schristos -Wmissing-format-attribute], [warn]) 52*869ffda3SchristosACX_PROG_CC_WARNING_OPTS([-Wstrict-prototypes -Wmissing-prototypes \ 53*869ffda3Schristos -Wold-style-definition], [c_warn]) 54*869ffda3SchristosACX_PROG_CC_WARNING_ALMOST_PEDANTIC([-Wno-long-long]) 55*869ffda3Schristos 56*869ffda3Schristos# Only enable with --enable-werror-always until existing warnings are 57*869ffda3Schristos# corrected. 58*869ffda3SchristosACX_PROG_CC_WARNINGS_ARE_ERRORS([manual]) 59*869ffda3Schristos 60*869ffda3SchristosAM_MAINTAINER_MODE 61*869ffda3SchristosAM_INSTALL_LIBBFD 62*869ffda3SchristosACX_PROG_CC_WARNING_OPTS([-Wall], [ac_libctf_warn_cflags]) 63*869ffda3Schristos 64*869ffda3SchristosAC_FUNC_MMAP 65*869ffda3Schristos# Needed for BFD capability checks. 66*869ffda3SchristosAC_SEARCH_LIBS(dlopen, dl) 67*869ffda3SchristosAM_ZLIB 68*869ffda3Schristos 69*869ffda3Schristos# Similar to GDB_AC_CHECK_BFD. 70*869ffda3SchristosOLD_CFLAGS=$CFLAGS 71*869ffda3SchristosOLD_LDFLAGS=$LDFLAGS 72*869ffda3SchristosOLD_LIBS=$LIBS 73*869ffda3Schristos# Put the old CFLAGS/LDFLAGS last, in case the user's (C|LD)FLAGS 74*869ffda3Schristos# points somewhere with bfd, with -I/foo/lib and -L/foo/lib. We 75*869ffda3Schristos# always want our bfd. 76*869ffda3SchristosCFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS" 77*869ffda3SchristosZLIBDIR=`echo $zlibdir | sed 's,\$(top_builddir)/,,g'` 78*869ffda3SchristosLDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS" 79*869ffda3Schristosintl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'` 80*869ffda3SchristosLIBS="-lbfd -liberty -lz $intl $LIBS" 81*869ffda3SchristosAC_CACHE_CHECK([for ELF support in BFD], ac_cv_libctf_bfd_elf, 82*869ffda3Schristos[AC_TRY_LINK([#include <stdlib.h> 83*869ffda3Schristos #include "bfd.h" 84*869ffda3Schristos #include "elf-bfd.h"], 85*869ffda3Schristos [(void) bfd_section_from_elf_index (NULL, 0); 86*869ffda3Schristos return 0;], 87*869ffda3Schristos [ac_cv_libctf_bfd_elf=yes], 88*869ffda3Schristos [ac_cv_libctf_bfd_elf=no])]) 89*869ffda3SchristosCFLAGS=$OLD_CFLAGS 90*869ffda3SchristosLDFLAGS=$OLD_LDFLAGS 91*869ffda3SchristosLIBS=$OLD_LIBS 92*869ffda3Schristos 93*869ffda3Schristosif test $ac_cv_libctf_bfd_elf = yes; then 94*869ffda3Schristos AC_DEFINE([HAVE_BFD_ELF], 1, 95*869ffda3Schristos [Whether libbfd was configured for an ELF target.]) 96*869ffda3Schristosfi 97*869ffda3Schristos 98*869ffda3SchristosAC_C_BIGENDIAN 99*869ffda3SchristosAC_CHECK_HEADERS(byteswap.h endian.h) 100*869ffda3SchristosAC_CHECK_FUNCS(pread) 101*869ffda3Schristos 102*869ffda3SchristosAC_CHECK_DECLS([asprintf]) 103*869ffda3Schristos 104*869ffda3Schristosdnl Check for qsort_r. (Taken from gnulib.) 105*869ffda3SchristosAC_CHECK_FUNCS_ONCE([qsort_r]) 106*869ffda3Schristosif test $ac_cv_func_qsort_r = yes; then 107*869ffda3Schristos AC_CACHE_CHECK([for qsort_r signature], [ac_cv_libctf_qsort_r_signature], 108*869ffda3Schristos [AC_LINK_IFELSE( 109*869ffda3Schristos [AC_LANG_PROGRAM([[#undef qsort_r 110*869ffda3Schristos #include <stdlib.h> 111*869ffda3Schristos void qsort_r (void *, size_t, size_t, 112*869ffda3Schristos int (*) (void const *, void const *, 113*869ffda3Schristos void *), 114*869ffda3Schristos void *); 115*869ffda3Schristos void (*p) (void *, size_t, size_t, 116*869ffda3Schristos int (*) (void const *, void const *, 117*869ffda3Schristos void *), 118*869ffda3Schristos void *) = qsort_r; 119*869ffda3Schristos ]])], 120*869ffda3Schristos [ac_cv_libctf_qsort_r_signature=GNU], 121*869ffda3Schristos [AC_LINK_IFELSE( 122*869ffda3Schristos [AC_LANG_PROGRAM([[#undef qsort_r 123*869ffda3Schristos #include <stdlib.h> 124*869ffda3Schristos void qsort_r (void *, size_t, size_t, void *, 125*869ffda3Schristos int (*) (void *, 126*869ffda3Schristos void const *, 127*869ffda3Schristos void const *)); 128*869ffda3Schristos void (*p) (void *, size_t, size_t, void *, 129*869ffda3Schristos int (*) (void *, void const *, 130*869ffda3Schristos void const *)) = qsort_r; 131*869ffda3Schristos ]])], 132*869ffda3Schristos [ac_cv_libctf_qsort_r_signature=BSD], 133*869ffda3Schristos [ac_cv_libctf_qsort_r_signature=unknown])])]) 134*869ffda3Schristosfi 135*869ffda3Schristos 136*869ffda3Schristoscase x$ac_cv_libctf_qsort_r_signature in 137*869ffda3Schristos xGNU) AC_DEFINE([HAVE_QSORT_R_ARG_LAST], 1, 138*869ffda3Schristos [Whether a qsort_r exists with a void *arg as its last arg.]);; 139*869ffda3Schristos xBSD) AC_DEFINE([HAVE_QSORT_R_COMPAR_LAST], 1, 140*869ffda3Schristos [Whether a qsort_r exists with the compar function as its last arg.]);; 141*869ffda3Schristos *) ac_cv_libctf_qsort_r_signature=unknown;; 142*869ffda3Schristosesac 143*869ffda3Schristos 144*869ffda3SchristosAM_CONDITIONAL(NEED_CTF_QSORT_R, test "${ac_cv_libctf_qsort_r_signature}" = unknown) 145*869ffda3Schristos 146*869ffda3SchristosAC_CACHE_CHECK([for O_CLOEXEC], [ac_cv_libctf_macro_O_CLOEXEC], 147*869ffda3Schristos [AC_LINK_IFELSE( 148*869ffda3Schristos [AC_LANG_PROGRAM([[#include <fcntl.h> 149*869ffda3Schristos #ifndef O_CLOEXEC 150*869ffda3Schristos choke me; 151*869ffda3Schristos #endif 152*869ffda3Schristos ]], 153*869ffda3Schristos [[return O_CLOEXEC;]])], 154*869ffda3Schristos [ac_cv_libctf_macro_O_CLOEXEC=yes], 155*869ffda3Schristos [ac_cv_libctf_macro_O_CLOEXEC=no])]) 156*869ffda3Schristos 157*869ffda3Schristosif test $ac_cv_libctf_macro_O_CLOEXEC = yes; then 158*869ffda3Schristos AC_DEFINE([HAVE_O_CLOEXEC], 1, 159*869ffda3Schristos [Whether the platform has a definition of O_CLOEXEC.]) 160*869ffda3Schristosfi 161*869ffda3Schristos 162*869ffda3Schristos# Horrible hacks to build DLLs on Windows and a shared library elsewhere. 163*869ffda3SchristosSHARED_LIBADD= 164*869ffda3SchristosSHARED_LDFLAGS= 165*869ffda3SchristosBFD_LIBADD= 166*869ffda3SchristosBFD_DEPENDENCIES= 167*869ffda3Schristosif test "$enable_shared" = "yes"; then 168*869ffda3Schristos# When building a shared libctf, link against the pic version of libiberty 169*869ffda3Schristos# so that apps that use libctf won't need libiberty just to satisfy any 170*869ffda3Schristos# libctf references. 171*869ffda3Schristos# We can't do that if a pic libiberty is unavailable since including non-pic 172*869ffda3Schristos# code would insert text relocations into libctf. 173*869ffda3Schristos# Note that linking against libbfd as we do here, which is itself linked 174*869ffda3Schristos# against libiberty, may not satisfy all the libctf libiberty references 175*869ffda3Schristos# since libbfd may not pull in the entirety of libiberty. 176*869ffda3Schristoschangequote(,)dnl 177*869ffda3Schristos x=`sed -n -e 's/^[ ]*PICFLAG[ ]*=[ ]*//p' < ../libiberty/Makefile | sed -n '$p'` 178*869ffda3Schristoschangequote([,])dnl 179*869ffda3Schristos if test -n "$x"; then 180*869ffda3Schristos SHARED_LIBADD="-L`pwd`/../libiberty/pic -liberty" 181*869ffda3Schristos fi 182*869ffda3Schristos 183*869ffda3Schristos case "${host}" in 184*869ffda3Schristos # More hacks to build DLLs on Windows. 185*869ffda3Schristos *-*-cygwin*) 186*869ffda3Schristos SHARED_LDFLAGS="-no-undefined" 187*869ffda3Schristos SHARED_LIBADD="-L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin" 188*869ffda3Schristos BFD_LIBADD="-L`pwd`/../bfd -lbfd" 189*869ffda3Schristos ;; 190*869ffda3Schristos 191*869ffda3Schristos *-*-darwin*) 192*869ffda3Schristos BFD_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.dylib" 193*869ffda3Schristos BFD_DEPENDENCIES="../bfd/libbfd.la" 194*869ffda3Schristos ;; 195*869ffda3Schristos *) 196*869ffda3Schristos case "$host_vendor" in 197*869ffda3Schristos hp) 198*869ffda3Schristos BFD_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.sl" 199*869ffda3Schristos ;; 200*869ffda3Schristos *) 201*869ffda3Schristos BFD_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.so" 202*869ffda3Schristos ;; 203*869ffda3Schristos esac 204*869ffda3Schristos BFD_DEPENDENCIES="../bfd/libbfd.la" 205*869ffda3Schristos ;; 206*869ffda3Schristos esac 207*869ffda3Schristosfi 208*869ffda3SchristosAC_SUBST(SHARED_LDFLAGS) 209*869ffda3SchristosAC_SUBST(SHARED_LIBADD) 210*869ffda3SchristosAC_SUBST(BFD_LIBADD) 211*869ffda3SchristosAC_SUBST(BFD_DEPENDENCIES) 212*869ffda3Schristos 213*869ffda3Schristos# Use a version script, if possible, or an -export-symbols-regex otherwise. 214*869ffda3SchristosVERSION_FLAGS='-export-symbols-regex ctf_.*' 215*869ffda3Schristosif $LD --help 2>&1 | grep -- --version-script >/dev/null; then 216*869ffda3Schristos VERSION_FLAGS="-Wl,--version-script='$srcdir/libctf.ver'" 217*869ffda3Schristosfi 218*869ffda3SchristosAC_SUBST(VERSION_FLAGS) 219*869ffda3Schristos 220*869ffda3SchristosAC_CONFIG_FILES(Makefile) 221*869ffda3SchristosAC_CONFIG_HEADERS(config.h) 222*869ffda3SchristosAC_OUTPUT 223