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