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