Add a note to the binutils/NEWS file about DCO signed contributions.
[binutils-gdb.git] / libctf / configure.ac
blob2e2ccf4b624fe95162925d30a996f746d232e9c6
1 dnl                                            -*- Autoconf -*-
2 dnl Process this file with autoconf to produce a configure script.
3 dnl
4 dnl   Copyright (C) 2019-2022 Free Software Foundation, Inc.
5 dnl
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.
10 dnl
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.
15 dnl
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/>.
19 dnl
21 AC_PREREQ(2.64)
22 AC_INIT([libctf], 1.2.0)
23 AC_CONFIG_SRCDIR(ctf-impl.h)
24 AC_CONFIG_MACRO_DIR(..)
25 AC_CONFIG_MACRO_DIR(../config)
26 AC_CONFIG_MACRO_DIR(../bfd)
27 AC_CANONICAL_BUILD
28 AC_CANONICAL_HOST
29 AC_CANONICAL_TARGET
30 AC_USE_SYSTEM_EXTENSIONS
31 AM_INIT_AUTOMAKE
32 AM_SILENT_RULES([yes])
34 # Checks for programs.
35 AC_PROG_MAKE_SET
36 AC_PROG_CC
37 AC_PROG_RANLIB
38 AM_PROG_AR
39 ZW_GNU_GETTEXT_SISTER_DIR
41 dnl Default to a non shared library.  This may be overridden by the
42 dnl configure option --enable-shared.
43 AC_DISABLE_SHARED
45 LT_INIT
46 AC_SYS_LARGEFILE
48 MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing
49 AC_CHECK_PROGS([ACLOCAL], [aclocal], [$MISSING aclocal])
50 AC_CHECK_PROGS([AUTOCONF], [autoconf], [$MISSING autoconf])
51 AC_CHECK_PROGS([AUTOHEADER], [autoheader], [$MISSING autoheader])
53 # Figure out what compiler warnings we can enable.
54 # See config/warnings.m4 for details.
56 ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wno-narrowing -Wwrite-strings \
57                           -Wmissing-format-attribute], [warn])
58 ACX_PROG_CC_WARNING_OPTS([-Wstrict-prototypes -Wmissing-prototypes \
59                           -Wold-style-definition], [c_warn])
60 ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([-Wno-long-long])
62 # Only enable with --enable-werror-always until existing warnings are
63 # corrected.
64 ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual])
66 AM_MAINTAINER_MODE
67 AM_INSTALL_LIBBFD
68 ACX_PROG_CC_WARNING_OPTS([-Wall], [ac_libctf_warn_cflags])
70 AC_FUNC_MMAP
71 # Needed for BFD capability checks.
72 AC_SEARCH_LIBS(dlsym, dl)
73 AM_ZLIB
74 AC_ZSTD
76 GCC_ENABLE([libctf-hash-debugging], [no], [], [Enable expensive debugging of CTF deduplication type hashing])
77 if test "${enable_libctf_hash_debugging}" = yes; then
78     AC_DEFINE(ENABLE_LIBCTF_HASH_DEBUGGING, 1, [Enable expensive debugging of CTF deduplication type hashing])
80 AM_CONDITIONAL(ENABLE_LIBCTF_HASH_DEBUGGING, test "${enable_libctf_hash_debugging}" = yes)
82 # Similar to GDB_AC_CHECK_BFD.
83 OLD_CFLAGS=$CFLAGS
84 OLD_LDFLAGS=$LDFLAGS
85 OLD_LIBS=$LIBS
86 # Put the old CFLAGS/LDFLAGS last, in case the user's (C|LD)FLAGS
87 # points somewhere with bfd, with -I/foo/lib and -L/foo/lib.  We
88 # always want our bfd.
89 CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
90 ZLIBDIR=`echo $zlibdir | sed 's,\$(top_builddir)/,,g'`
91 LDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS"
92 intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
93 LIBS="-lbfd -liberty -lz $ZSTD_LIBS $intl $LIBS"
94 AC_CACHE_CHECK([for ELF support in BFD], ac_cv_libctf_bfd_elf,
95 [AC_TRY_LINK([#include <stdlib.h>
96              #include <string.h>
97              #include "bfd.h"
98              #include "elf-bfd.h"],
99             [(void) bfd_section_from_elf_index (NULL, 0);
100              return 0;],
101             [ac_cv_libctf_bfd_elf=yes],
102             [ac_cv_libctf_bfd_elf=no])])
103 CFLAGS=$OLD_CFLAGS
104 LDFLAGS=$OLD_LDFLAGS
105 LIBS=$OLD_LIBS
107 if test $ac_cv_libctf_bfd_elf = yes; then
108   AC_DEFINE([HAVE_BFD_ELF], 1,
109             [Whether libbfd was configured for an ELF target.])
112 AC_C_BIGENDIAN
113 AC_CHECK_HEADERS(byteswap.h endian.h)
114 AC_CHECK_FUNCS(pread)
116 dnl Check for bswap_{16,32,64}
117 AC_CHECK_DECLS([bswap_16, bswap_32, bswap_64], [], [], [[#include <byteswap.h>]])
118 AC_CHECK_DECLS([asprintf, vasprintf, stpcpy])
120 dnl Check for qsort_r.  (Taken from gnulib.)
121 AC_CHECK_FUNCS_ONCE([qsort_r])
122 if test $ac_cv_func_qsort_r = yes; then
123   AC_CACHE_CHECK([for qsort_r signature], [ac_cv_libctf_qsort_r_signature],
124     [AC_LINK_IFELSE(
125        [AC_LANG_PROGRAM([[#undef qsort_r
126                           #include <stdlib.h>
127                           void qsort_r (void *, size_t, size_t,
128                                         int (*) (void const *, void const *,
129                                                  void *),
130                                         void *);
131                           void (*p) (void *, size_t, size_t,
132                                      int (*) (void const *, void const *,
133                                               void *),
134                                      void *) = qsort_r;
135                         ]])],
136        [ac_cv_libctf_qsort_r_signature=GNU],
137        [AC_LINK_IFELSE(
138           [AC_LANG_PROGRAM([[#undef qsort_r
139                              #include <stdlib.h>
140                              void qsort_r (void *, size_t, size_t, void *,
141                                            int (*) (void *,
142                                                     void const *,
143                                                     void const *));
144                              void (*p) (void *, size_t, size_t, void *,
145                                         int (*) (void *, void const *,
146                                                  void const *)) = qsort_r;
147                            ]])],
148           [ac_cv_libctf_qsort_r_signature=BSD],
149           [ac_cv_libctf_qsort_r_signature=unknown])])])
152 case x$ac_cv_libctf_qsort_r_signature in
153   xGNU)     AC_DEFINE([HAVE_QSORT_R_ARG_LAST], 1,
154              [Whether a qsort_r exists with a void *arg as its last arg.]);;
155   xBSD)     AC_DEFINE([HAVE_QSORT_R_COMPAR_LAST], 1,
156              [Whether a qsort_r exists with the compar function as its last arg.]);;
157   *) ac_cv_libctf_qsort_r_signature=unknown;;
158 esac
160 AM_CONDITIONAL(NEED_CTF_QSORT_R, test "${ac_cv_libctf_qsort_r_signature}" = unknown)
162 AC_CACHE_CHECK([for O_CLOEXEC], [ac_cv_libctf_macro_O_CLOEXEC],
163   [AC_LINK_IFELSE(
164     [AC_LANG_PROGRAM([[#include <fcntl.h>
165                        #ifndef O_CLOEXEC
166                          choke me;
167                        #endif
168                      ]],
169                      [[return O_CLOEXEC;]])],
170     [ac_cv_libctf_macro_O_CLOEXEC=yes],
171     [ac_cv_libctf_macro_O_CLOEXEC=no])])
173 if test $ac_cv_libctf_macro_O_CLOEXEC = yes; then
174   AC_DEFINE([HAVE_O_CLOEXEC], 1,
175             [Whether the platform has a definition of O_CLOEXEC.])
178 build_info=
179 makeinfo_too_old=
180 AC_CHECK_PROGS([MAKEINFO], makeinfo, [$MISSING makeinfo])
181 case " $build_configdirs " in
182   *" texinfo "*) MAKEINFO='$$r/$(BUILD_SUBDIR)/texinfo/makeinfo/makeinfo' ;;
183 esac
184 changequote(,)
185     # We require texinfo to be 6.3 or later, for a working synindex
186     # and validatemenus: otherwise we fall back to /bin/true.
187     if ${MAKEINFO} --version \
188        | egrep 'texinfo[^0-9]*(6\.[3-9]|[7-9][0-9])' >/dev/null 2>&1; then
189       build_info=yes
190     else
191         build_info=
192         makeinfo_too_old=t
193     fi
194 changequote([,])
195 if test -n "$makeinfo_too_old"; then
196     AC_MSG_WARN([
197 *** Makeinfo is too old. Info documentation will not be built.])
199 AC_SUBST(MAKEINFO)
200 AM_CONDITIONAL(BUILD_INFO, test "${build_info}" = yes)
202 CTF_LIBADD="-L`pwd`/../libiberty -liberty"
203 SHARED_LDFLAGS=
205 # Horrible hacks to build DLLs on Windows and a shared library elsewhere.
206 if test "$enable_shared" = "yes"; then
207 # When building a shared libctf, link against the pic version of libiberty
208 # so that apps that use libctf won't need libiberty just to satisfy any
209 # libctf references.  We can't do that if a pic libiberty is unavailable
210 # since including non-pic # code would insert text relocations into libctf.
211 # Note that linking against libbfd as we do here, which is itself linked
212 # against libiberty, may not satisfy all the libctf libiberty references
213 # since libbfd may not pull in the entirety of libiberty.
214 # Also, jam libintl into the right place in all of this: after libiberty,
215 # which uses it, but before -lcygwin, which it uses.
216 changequote(,)dnl
217   x=`sed -n -e 's/^[    ]*PICFLAG[      ]*=[    ]*//p' < ../libiberty/Makefile | sed -n '$p'`
218 changequote([,])dnl
219   if test -n "$x"; then
220     CTF_LIBADD="-L`pwd`/../libiberty/pic -liberty"
221   fi
224 CTF_LIBADD="$CTF_LIBADD $LIBINTL"
226 if test "$enable_shared" = "yes"; then
227   case "${host}" in
228   # More hacks to build DLLs on Windows.
229     *-*-cygwin*)
230       SHARED_LDFLAGS="-no-undefined"
231       CTF_LIBADD="$CTF_LIBADD -lcygwin"
232       ;;
233   esac
235 AC_SUBST(SHARED_LDFLAGS)
236 AC_SUBST(CTF_LIBADD)
238 AC_PATH_PROG([EXPECT], [expect])
239 AC_CACHE_CHECK([for Tcl supporting try/catch], [ac_cv_libctf_tcl_try],
240   [ac_cv_libctf_tcl_try=`if test -z $EXPECT; then echo no; else $EXPECT << EOF
241 if @<:@llength @<:@info commands try@:>@@:>@ then { puts yes } else { puts no }
245 AM_CONDITIONAL(TCL_TRY, test "${ac_cv_libctf_tcl_try}" = yes)
247 # Use a version script, if possible, or an -export-symbols-regex otherwise.
248 decommented_version_script=
249 AC_CACHE_CHECK([for linker versioning flags], [ac_cv_libctf_version_script],
250   [echo 'FOO { global: mai*; local: ctf_fo*; };' > conftest.ver
251    old_LDFLAGS="$LDFLAGS"
252    old_CFLAGS="$CFLAGS"
253    LDFLAGS="$LDFLAGS -shared -Wl,--version-script=conftest.ver"
254    CFLAGS="$CFLAGS -fPIC"
255    AC_LINK_IFELSE([AC_LANG_SOURCE([[int ctf_foo (void) { return 0; }
256                                     int main (void) { return ctf_foo(); }]])],
257                   [ac_cv_libctf_version_script="-Wl,--version-script='$srcdir/libctf.ver'"],
258                   [])
259    LDFLAGS="$old_LDFLAGS"
261    if test -z "$ac_cv_libctf_version_script"; then
262      LDFLAGS="$LDFLAGS -shared -Wl,-B,local -Wl,-z,gnu-version-script=conftest.ver"
263      AC_LINK_IFELSE([AC_LANG_SOURCE([[int ctf_foo (void) { return 0; }
264                                       int main (void) { return ctf_foo(); }]])],
265                     [ac_cv_libctf_version_script="-Wl,-B,local -Wl,-z,gnu-version-script"
266                      decommented_version_script=t],
267                     [])
268      LDFLAGS="$old_LDFLAGS"
269    fi
270    CFLAGS="$old_CFLAGS"
272    if test -z "$ac_cv_libctf_version_script"; then
273      ac_cv_libctf_version_script='-export-symbols-regex ctf_.*'
274    fi
275    rm -f conftest.ver])
276 if test -n "$decommented_version_script"; then
277    # Solaris's version scripts use shell-style comments rather than the C-style
278    # used by GNU ld.  Use cpp to strip the comments out.  (cpp exists under this
279    # name on all platforms that support ld -z gnu-version-script.)
280    # Also ensure that no symbols exist in the version script for libctf-nobfd.so
281    # that do not exist in the shared library itself, since some linkers add such
282    # symbols with type NOTYPE.
283    /lib/cpp < $srcdir/libctf.ver > libctf-decommented.ver
284    grep -v 'libctf only' $srcdir/libctf.ver | /lib/cpp > libctf-nobfd-decommented.ver
285    VERSION_FLAGS="$ac_cv_libctf_version_script='libctf-decommented.ver'"
286    VERSION_FLAGS_NOBFD="$ac_cv_libctf_version_script='libctf-nobfd-decommented.ver'"
287 else
288    VERSION_FLAGS="$ac_cv_libctf_version_script"
289    VERSION_FLAGS_NOBFD="$ac_cv_libctf_version_script"
291 AC_SUBST(VERSION_FLAGS)
292 AC_SUBST(VERSION_FLAGS_NOBFD)
294 AC_CONFIG_FILES(Makefile)
295 AC_CONFIG_HEADERS(config.h)
296 AC_OUTPUT
298 GNU_MAKE_JOBSERVER