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