2 dnl Process this file with autoconf to produce a configure script.
4 dnl Copyright (C) 2019 Free Software Foundation, Inc.
6 dnl This file is free software; you can redistribute it and/or modify
7 dnl it under the terms of the GNU General Public License as published by
8 dnl the Free Software Foundation; either version 2 of the License, or
9 dnl (at your option) any later version.
11 dnl This program is distributed in the hope that it will be useful,
12 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 dnl GNU General Public License for more details.
16 dnl You should have received a copy of the GNU General Public License
17 dnl along with this program; see the file COPYING. If not see
18 dnl <http://www.gnu.org/licenses/>.
22 AC_INIT([libctf library], 1.2.0-pre)
23 AC_CONFIG_SRCDIR(ctf-impl.h)
24 AC_CONFIG_MACRO_DIR(../config)
25 AC_USE_SYSTEM_EXTENSIONS
28 # Checks for programs.
36 MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing
37 AC_CHECK_PROGS([ACLOCAL], [aclocal], [$MISSING aclocal])
38 AC_CHECK_PROGS([AUTOCONF], [autoconf], [$MISSING autoconf])
39 AC_CHECK_PROGS([AUTOHEADER], [autoheader], [$MISSING autoheader])
41 # Figure out what compiler warnings we can enable.
42 # See config/warnings.m4 for details.
44 ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wno-narrowing -Wwrite-strings \
45 -Wmissing-format-attribute], [warn])
46 ACX_PROG_CC_WARNING_OPTS([-Wstrict-prototypes -Wmissing-prototypes \
47 -Wold-style-definition], [c_warn])
48 ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([-Wno-long-long])
50 # Only enable with --enable-werror-always until existing warnings are
52 ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual])
55 ACX_PROG_CC_WARNING_OPTS([-Wall], [ac_libctf_warn_cflags])
58 AC_SEARCH_LIBS(dlopen, dl)
61 # Similar to GDB_AC_CHECK_BFD.
65 # Put the old CFLAGS/LDFLAGS last, in case the user's (C|LD)FLAGS
66 # points somewhere with bfd, with -I/foo/lib and -L/foo/lib. We
67 # always want our bfd.
68 CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
69 ZLIBDIR=`echo $zlibdir | sed 's,\$(top_builddir)/,,g'`
70 LDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS"
71 intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
72 LIBS="-lbfd -liberty -lz $intl $LIBS"
73 AC_CACHE_CHECK([for ELF support in BFD], ac_cv_libctf_bfd_elf,
74 [AC_TRY_LINK([#include <stdlib.h>
76 #include "elf-bfd.h"],
77 [(void) bfd_section_from_elf_index (NULL, 0);
79 [ac_cv_libctf_bfd_elf=yes],
80 [ac_cv_libctf_bfd_elf=no])])
85 if test $ac_cv_libctf_bfd_elf = yes; then
86 AC_DEFINE([HAVE_BFD_ELF], 1,
87 [Whether libbfd was configured for an ELF target.])
91 AC_CHECK_HEADERS(byteswap.h endian.h)
94 dnl Check for qsort_r. (Taken from gnulib.)
95 AC_CHECK_FUNCS_ONCE([qsort_r])
96 if test $ac_cv_func_qsort_r = yes; then
97 AC_CACHE_CHECK([for qsort_r signature], [ac_cv_libctf_qsort_r_signature],
99 [AC_LANG_PROGRAM([[#undef qsort_r
101 void qsort_r (void *, size_t, size_t,
102 int (*) (void const *, void const *,
105 void (*p) (void *, size_t, size_t,
106 int (*) (void const *, void const *,
110 [ac_cv_libctf_qsort_r_signature=GNU],
112 [AC_LANG_PROGRAM([[#undef qsort_r
114 void qsort_r (void *, size_t, size_t, void *,
118 void (*p) (void *, size_t, size_t, void *,
119 int (*) (void *, void const *,
120 void const *)) = qsort_r;
122 [ac_cv_libctf_qsort_r_signature=BSD],
123 [ac_cv_libctf_qsort_r_signature=unknown])])])
126 case x$ac_cv_libctf_qsort_r_signature in
127 xGNU) AC_DEFINE([HAVE_QSORT_R_ARG_LAST], 1,
128 [Whether a qsort_r exists with a void *arg as its last arg.]);;
129 xBSD) AC_DEFINE([HAVE_QSORT_R_COMPAR_LAST], 1,
130 [Whether a qsort_r exists with the compar function as its last arg.]);;
131 *) ac_cv_libctf_qsort_r_signature=unknown;;
134 AM_CONDITIONAL(NEED_CTF_QSORT_R, test "${ac_cv_libctf_qsort_r_signature}" = unknown)
136 AC_CONFIG_FILES(Makefile)
137 AC_CONFIG_HEADERS(config.h)