config/debuginfod: do not include pkg.m4 directly
[deliverable/binutils-gdb.git] / libctf / configure.ac
1 dnl -*- Autoconf -*-
2 dnl Process this file with autoconf to produce a configure script.
3 dnl
4 dnl Copyright (C) 2019-2021 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
20
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_USE_SYSTEM_EXTENSIONS
28 AM_INIT_AUTOMAKE
29
30 # Checks for programs.
31 AC_PROG_MAKE_SET
32 AC_PROG_CC
33 AC_PROG_RANLIB
34 AM_PROG_AR
35 ZW_GNU_GETTEXT_SISTER_DIR
36
37 dnl Default to a non shared library. This may be overridden by the
38 dnl configure option --enable-shared.
39 AC_DISABLE_SHARED
40
41 LT_INIT
42 AC_SYS_LARGEFILE
43
44 MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing
45 AC_CHECK_PROGS([ACLOCAL], [aclocal], [$MISSING aclocal])
46 AC_CHECK_PROGS([AUTOCONF], [autoconf], [$MISSING autoconf])
47 AC_CHECK_PROGS([AUTOHEADER], [autoheader], [$MISSING autoheader])
48
49 # Figure out what compiler warnings we can enable.
50 # See config/warnings.m4 for details.
51
52 ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wno-narrowing -Wwrite-strings \
53 -Wmissing-format-attribute], [warn])
54 ACX_PROG_CC_WARNING_OPTS([-Wstrict-prototypes -Wmissing-prototypes \
55 -Wold-style-definition], [c_warn])
56 ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([-Wno-long-long])
57
58 # Only enable with --enable-werror-always until existing warnings are
59 # corrected.
60 ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual])
61
62 AM_MAINTAINER_MODE
63 AM_INSTALL_LIBBFD
64 ACX_PROG_CC_WARNING_OPTS([-Wall], [ac_libctf_warn_cflags])
65
66 AC_FUNC_MMAP
67 # Needed for BFD capability checks.
68 AC_SEARCH_LIBS(dlopen, dl)
69 AM_ZLIB
70
71 GCC_ENABLE([libctf-hash-debugging], [no], [], [Enable expensive debugging of CTF deduplication type hashing])
72 if test "${enable_libctf_hash_debugging}" = yes; then
73 AC_DEFINE(ENABLE_LIBCTF_HASH_DEBUGGING, 1, [Enable expensive debugging of CTF deduplication type hashing])
74 fi
75 AM_CONDITIONAL(ENABLE_LIBCTF_HASH_DEBUGGING, test "${enable_libctf_hash_debugging}" = yes)
76
77 # Similar to GDB_AC_CHECK_BFD.
78 OLD_CFLAGS=$CFLAGS
79 OLD_LDFLAGS=$LDFLAGS
80 OLD_LIBS=$LIBS
81 # Put the old CFLAGS/LDFLAGS last, in case the user's (C|LD)FLAGS
82 # points somewhere with bfd, with -I/foo/lib and -L/foo/lib. We
83 # always want our bfd.
84 CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
85 ZLIBDIR=`echo $zlibdir | sed 's,\$(top_builddir)/,,g'`
86 LDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS"
87 intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
88 LIBS="-lbfd -liberty -lz $intl $LIBS"
89 AC_CACHE_CHECK([for ELF support in BFD], ac_cv_libctf_bfd_elf,
90 [AC_TRY_LINK([#include <stdlib.h>
91 #include <string.h>
92 #include "bfd.h"
93 #include "elf-bfd.h"],
94 [(void) bfd_section_from_elf_index (NULL, 0);
95 return 0;],
96 [ac_cv_libctf_bfd_elf=yes],
97 [ac_cv_libctf_bfd_elf=no])])
98 CFLAGS=$OLD_CFLAGS
99 LDFLAGS=$OLD_LDFLAGS
100 LIBS=$OLD_LIBS
101
102 if test $ac_cv_libctf_bfd_elf = yes; then
103 AC_DEFINE([HAVE_BFD_ELF], 1,
104 [Whether libbfd was configured for an ELF target.])
105 fi
106
107 AC_C_BIGENDIAN
108 AC_CHECK_HEADERS(byteswap.h endian.h)
109 AC_CHECK_FUNCS(pread)
110
111 dnl Check for bswap_{16,32,64}
112 AC_CHECK_DECLS([bswap_16, bswap_32, bswap_64], [], [], [[#include <byteswap.h>]])
113 AC_CHECK_DECLS([asprintf, vasprintf, stpcpy])
114
115 dnl Check for qsort_r. (Taken from gnulib.)
116 AC_CHECK_FUNCS_ONCE([qsort_r])
117 if test $ac_cv_func_qsort_r = yes; then
118 AC_CACHE_CHECK([for qsort_r signature], [ac_cv_libctf_qsort_r_signature],
119 [AC_LINK_IFELSE(
120 [AC_LANG_PROGRAM([[#undef qsort_r
121 #include <stdlib.h>
122 void qsort_r (void *, size_t, size_t,
123 int (*) (void const *, void const *,
124 void *),
125 void *);
126 void (*p) (void *, size_t, size_t,
127 int (*) (void const *, void const *,
128 void *),
129 void *) = qsort_r;
130 ]])],
131 [ac_cv_libctf_qsort_r_signature=GNU],
132 [AC_LINK_IFELSE(
133 [AC_LANG_PROGRAM([[#undef qsort_r
134 #include <stdlib.h>
135 void qsort_r (void *, size_t, size_t, void *,
136 int (*) (void *,
137 void const *,
138 void const *));
139 void (*p) (void *, size_t, size_t, void *,
140 int (*) (void *, void const *,
141 void const *)) = qsort_r;
142 ]])],
143 [ac_cv_libctf_qsort_r_signature=BSD],
144 [ac_cv_libctf_qsort_r_signature=unknown])])])
145 fi
146
147 case x$ac_cv_libctf_qsort_r_signature in
148 xGNU) AC_DEFINE([HAVE_QSORT_R_ARG_LAST], 1,
149 [Whether a qsort_r exists with a void *arg as its last arg.]);;
150 xBSD) AC_DEFINE([HAVE_QSORT_R_COMPAR_LAST], 1,
151 [Whether a qsort_r exists with the compar function as its last arg.]);;
152 *) ac_cv_libctf_qsort_r_signature=unknown;;
153 esac
154
155 AM_CONDITIONAL(NEED_CTF_QSORT_R, test "${ac_cv_libctf_qsort_r_signature}" = unknown)
156
157 AC_CACHE_CHECK([for O_CLOEXEC], [ac_cv_libctf_macro_O_CLOEXEC],
158 [AC_LINK_IFELSE(
159 [AC_LANG_PROGRAM([[#include <fcntl.h>
160 #ifndef O_CLOEXEC
161 choke me;
162 #endif
163 ]],
164 [[return O_CLOEXEC;]])],
165 [ac_cv_libctf_macro_O_CLOEXEC=yes],
166 [ac_cv_libctf_macro_O_CLOEXEC=no])])
167
168 if test $ac_cv_libctf_macro_O_CLOEXEC = yes; then
169 AC_DEFINE([HAVE_O_CLOEXEC], 1,
170 [Whether the platform has a definition of O_CLOEXEC.])
171 fi
172
173 CTF_LIBADD="-L`pwd`/../libiberty -liberty"
174 SHARED_LDFLAGS=
175
176 # Horrible hacks to build DLLs on Windows and a shared library elsewhere.
177 if test "$enable_shared" = "yes"; then
178 # When building a shared libctf, link against the pic version of libiberty
179 # so that apps that use libctf won't need libiberty just to satisfy any
180 # libctf references. We can't do that if a pic libiberty is unavailable
181 # since including non-pic # code would insert text relocations into libctf.
182 # Note that linking against libbfd as we do here, which is itself linked
183 # against libiberty, may not satisfy all the libctf libiberty references
184 # since libbfd may not pull in the entirety of libiberty.
185 # Also, jam libintl into the right place in all of this: after libiberty,
186 # which uses it, but before -lcygwin, which it uses.
187 changequote(,)dnl
188 x=`sed -n -e 's/^[ ]*PICFLAG[ ]*=[ ]*//p' < ../libiberty/Makefile | sed -n '$p'`
189 changequote([,])dnl
190 if test -n "$x"; then
191 CTF_LIBADD="-L`pwd`/../libiberty/pic -liberty"
192 fi
193 fi
194
195 CTF_LIBADD="$CTF_LIBADD $LIBINTL"
196
197 if test "$enable_shared" = "yes"; then
198 case "${host}" in
199 # More hacks to build DLLs on Windows.
200 *-*-cygwin*)
201 SHARED_LDFLAGS="-no-undefined"
202 CTF_LIBADD="$CTF_LIBADD -lcygwin"
203 ;;
204 esac
205 fi
206 AC_SUBST(SHARED_LDFLAGS)
207 AC_SUBST(CTF_LIBADD)
208
209 AC_PATH_PROG([EXPECT], [expect])
210 AC_CACHE_CHECK([for Tcl supporting try/catch], [ac_cv_libctf_tcl_try],
211 [ac_cv_libctf_tcl_try=`if test -z $EXPECT; then echo no; else $EXPECT << EOF
212 if @<:@llength @<:@info commands try@:>@@:>@ then { puts yes } else { puts no }
213 EOF
214 fi`
215 ])
216 AM_CONDITIONAL(TCL_TRY, test "${ac_cv_libctf_tcl_try}" = yes)
217
218 # Use a version script, if possible, or an -export-symbols-regex otherwise.
219 VERSION_FLAGS='-export-symbols-regex ctf_.*'
220 if $LD --help 2>&1 | grep -- --version-script >/dev/null; then
221 VERSION_FLAGS="-Wl,--version-script='$srcdir/libctf.ver'"
222 fi
223 AC_SUBST(VERSION_FLAGS)
224
225 AC_CONFIG_FILES(Makefile)
226 AC_CONFIG_HEADERS(config.h)
227 AC_OUTPUT
228
229 GNU_MAKE_JOBSERVER
This page took 0.071676 seconds and 4 git commands to generate.