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