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