blob: ff9581d222c83e3fefed5b1748b668555f388e7e [file] [log] [blame]
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00001dnl Process this file with autoconf to produce a configure script.
2dnl Configure input file for elfutils. -*-autoconf-*-
3dnl
Frank Ch. Eiglere27e30c2019-10-28 13:29:26 -04004dnl Copyright (C) 1996-2019 Red Hat, Inc.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00005dnl
Mark Wielaardde2ed972012-06-05 17:15:16 +02006dnl This file is part of elfutils.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00007dnl
Mark Wielaardde2ed972012-06-05 17:15:16 +02008dnl This file is free software; you can redistribute it and/or modify
9dnl it under the terms of the GNU General Public License as published by
10dnl the Free Software Foundation; either version 3 of the License, or
11dnl (at your option) any later version.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000012dnl
Mark Wielaardde2ed972012-06-05 17:15:16 +020013dnl elfutils is distributed in the hope that it will be useful, but
14dnl WITHOUT ANY WARRANTY; without even the implied warranty of
15dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16dnl GNU General Public License for more details.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000017dnl
Mark Wielaardde2ed972012-06-05 17:15:16 +020018dnl You should have received a copy of the GNU General Public License
19dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
Mark Wielaard983e86f2021-11-10 16:26:07 +010020AC_INIT([elfutils],[0.186],[https://sourceware.org/bugzilla],[elfutils],[http://elfutils.org/])
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000021
Mark Wielaard34b037b2017-01-12 11:43:30 +010022dnl Workaround for older autoconf < 2.64
23m4_ifndef([AC_PACKAGE_URL],
24 [AC_DEFINE([PACKAGE_URL], ["http://elfutils.org/"],
25 [Define to home page for this package])
26 AC_SUBST([PACKAGE_URL], ["http://elfutils.org/"])])
27
Dmitry V. Levinfc5e8082020-12-09 03:12:53 +030028LIBDEBUGINFOD_SONAME=libdebuginfod.so.1
29AC_SUBST([LIBDEBUGINFOD_SONAME])
30
Mark Wielaard9ba24582016-03-02 15:04:43 +010031# We want eu- as default program prefix if none was given by the user.
32# But if the user explicitly provided --program-prefix="" then pretend
33# it wasn't set at all (NONE). We want to test this really early before
34# configure has a chance to use the value.
35
36if test "x$program_prefix" = "xNONE"; then
37 AC_MSG_NOTICE([No --program-prefix given, using "eu-"])
38 program_prefix="eu-"
39elif test "x$program_prefix" = "x"; then
40 AC_MSG_NOTICE([Using no program-prefix])
41 program_prefix=NONE
42fi
43
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000044AC_CONFIG_AUX_DIR([config])
45AC_CONFIG_FILES([config/Makefile])
46
Mark Wielaardae057382021-02-05 22:55:10 +010047AC_COPYRIGHT([Copyright (C) 1996-2021 The elfutils developers.])
Ulrich Drepperdb12f162009-09-21 08:04:38 -070048AC_PREREQ(2.63) dnl Minimum Autoconf version required.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000049
Roland McGrath9aa8ef72007-05-18 08:59:43 +000050dnl We use GNU make extensions; automake 1.10 defaults to -Wportability.
Mark Wielaard86be7922013-04-26 23:44:25 +020051AM_INIT_AUTOMAKE([gnits 1.11 -Wno-portability dist-bzip2 no-dist-gzip parallel-tests])
Roland McGrathc373d852006-10-10 00:25:21 +000052AM_MAINTAINER_MODE
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000053
Mark Wielaardc04f4912015-10-07 13:37:56 +020054AM_SILENT_RULES([yes])
55
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000056AC_CONFIG_SRCDIR([libelf/libelf.h])
57AC_CONFIG_FILES([Makefile])
58AC_CONFIG_HEADERS([config.h])
59
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000060dnl The RPM spec file. We substitute a few values in the file.
61AC_CONFIG_FILES([elfutils.spec:config/elfutils.spec.in])
62
Aaron Merey288f6b12019-10-28 13:29:26 -040063dnl debuginfo-server client & server parts.
Dmitry V. Levinfc5e8082020-12-09 03:12:53 +030064AC_CONFIG_FILES([debuginfod/Makefile debuginfod/debuginfod.h])
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000065
66AC_CANONICAL_HOST
67
Roland McGrath3284b792012-01-20 12:51:46 -080068AC_ARG_ENABLE(deterministic-archives,
69[AS_HELP_STRING([--enable-deterministic-archives],
70 [ar and ranlib default to -D behavior])], [
71if test "${enableval}" = no; then
72 default_ar_deterministic=false
73else
74 default_ar_deterministic=true
75fi], [default_ar_deterministic=false])
76AC_DEFINE_UNQUOTED(DEFAULT_AR_DETERMINISTIC, $default_ar_deterministic,
77 [Should ar and ranlib use -D behavior by default?])
78
Ulrich Drepper7e678fa2009-01-10 18:02:05 -080079AC_ARG_ENABLE([thread-safety],
Mark Wielaard09c9bb92013-11-06 12:21:32 +010080AS_HELP_STRING([--enable-thread-safety],
81 [enable thread safety of libraries EXPERIMENTAL]),
82 use_locks=$enableval, use_locks=no)
Ulrich Drepper7e678fa2009-01-10 18:02:05 -080083AM_CONDITIONAL(USE_LOCKS, test "$use_locks" = yes)
84AS_IF([test "$use_locks" = yes], [AC_DEFINE(USE_LOCKS)])
Mark Wielaard09c9bb92013-11-06 12:21:32 +010085AS_IF([test "$use_locks" = yes],
86 [AC_MSG_WARN([thread-safety is EXPERIMENTAL tests might fail.])])
Ulrich Drepperd56e2322008-08-16 03:09:13 +000087
Ulrich Drepper7e678fa2009-01-10 18:02:05 -080088AH_TEMPLATE([USE_LOCKS], [Defined if libraries should be thread-safe.])
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000089
Adrian Ratiu6eb991a2021-08-30 18:43:13 +030090AC_PROG_CC_C99
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000091AC_PROG_RANLIB
92AC_PROG_YACC
93AM_PROG_LEX
Michael Forneya45c8042013-11-01 00:51:04 -070094# Only available since automake 1.12
95m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
96AC_CHECK_TOOL([READELF], [readelf])
97AC_CHECK_TOOL([NM], [nm])
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000098
Ulf Hermann11274702017-08-18 13:06:36 +020099AC_CACHE_CHECK([whether gcc supports __attribute__((visibility()))],
100 ac_cv_visibility, [dnl
101save_CFLAGS="$CFLAGS"
102CFLAGS="$save_CFLAGS -Werror"
103AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl
104int __attribute__((visibility("hidden")))
105foo (int a)
106{
107 return a;
108}])], ac_cv_visibility=yes, ac_cv_visibility=no)
109CFLAGS="$save_CFLAGS"])
110if test "$ac_cv_visibility" = "yes"; then
111 AC_DEFINE([HAVE_VISIBILITY], [1],
112 [Defined if __attribute__((visibility())) is supported])
113fi
114
Ulf Hermann17d71942017-08-18 14:05:10 +0200115AC_CACHE_CHECK([whether gcc supports __attribute__((gcc_struct))],
116 ac_cv_gcc_struct, [dnl
117save_CFLAGS="$CFLAGS"
118CFLAGS="$save_CFLAGS -Werror"
119AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl
120struct test { int x; } __attribute__((gcc_struct));
121])], ac_cv_gcc_struct=yes, ac_cv_gcc_struct=no)
122CFLAGS="$save_CFLAGS"])
123if test "$ac_cv_gcc_struct" = "yes"; then
124 AC_DEFINE([HAVE_GCC_STRUCT], [1],
125 [Defined if __attribute__((gcc_struct)) is supported])
126fi
127
Ulf Hermann07737582017-08-18 12:41:11 +0200128AC_CACHE_CHECK([whether gcc supports -fPIC], ac_cv_fpic, [dnl
129save_CFLAGS="$CFLAGS"
130CFLAGS="$save_CFLAGS -fPIC -Werror"
131AC_COMPILE_IFELSE([AC_LANG_SOURCE()], ac_cv_fpic=yes, ac_cv_fpic=no)
132CFLAGS="$save_CFLAGS"
133])
134if test "$ac_cv_fpic" = "yes"; then
135 fpic_CFLAGS="-fPIC"
136else
137 fpic_CFLAGS=""
138fi
139AC_SUBST([fpic_CFLAGS])
140
141AC_CACHE_CHECK([whether gcc supports -fPIE], ac_cv_fpie, [dnl
142save_CFLAGS="$CFLAGS"
143CFLAGS="$save_CFLAGS -fPIE -Werror"
144AC_COMPILE_IFELSE([AC_LANG_SOURCE()], ac_cv_fpie=yes, ac_cv_fpie=no)
145CFLAGS="$save_CFLAGS"
146])
147if test "$ac_cv_fpie" = "yes"; then
148 fpie_CFLAGS="-fPIE"
149else
150 fpie_CFLAGS=""
151fi
152AC_SUBST([fpie_CFLAGS])
153
154dso_LDFLAGS="-shared"
155
156ZDEFS_LDFLAGS="-Wl,-z,defs"
157AC_CACHE_CHECK([whether gcc supports $ZDEFS_LDFLAGS], ac_cv_zdefs, [dnl
158save_LDFLAGS="$LDFLAGS"
159LDFLAGS="$ZDEFS_LDFLAGS $save_LDFLAGS"
160AC_LINK_IFELSE([AC_LANG_PROGRAM()], ac_cv_zdefs=yes, ac_cv_zdefs=no)
161LDFLAGS="$save_LDFLAGS"
162])
163if test "$ac_cv_zdefs" = "yes"; then
164 dso_LDFLAGS="$dso_LDFLAGS $ZDEFS_LDFLAGS"
165fi
166
Mark Wielaardcf1b5fe2019-12-06 17:20:00 +0100167# We really want build-ids. Warn and force generating them if gcc was
168# configure without --enable-linker-build-id
169AC_CACHE_CHECK([whether the compiler generates build-ids], ac_cv_buildid, [dnl
Sergei Trofimovich9698a392020-06-14 20:28:07 +0100170AC_LINK_IFELSE([AC_LANG_PROGRAM()],[ac_cv_buildid=yes; $READELF -n conftest$EXEEXT | grep -q NT_GNU_BUILD_ID || ac_cv_buildid=no],AC_MSG_FAILURE([unexpected compile failure]))])
Mark Wielaardcf1b5fe2019-12-06 17:20:00 +0100171if test "$ac_cv_buildid" = "no"; then
172 AC_MSG_WARN([compiler doesn't generate build-id by default])
173 LDFLAGS="$LDFLAGS -Wl,--build-id"
174fi
175
Ulf Hermann07737582017-08-18 12:41:11 +0200176ZRELRO_LDFLAGS="-Wl,-z,relro"
177AC_CACHE_CHECK([whether gcc supports $ZRELRO_LDFLAGS], ac_cv_zrelro, [dnl
178save_LDFLAGS="$LDFLAGS"
179LDFLAGS="$ZRELRO_LDFLAGS $save_LDFLAGS"
180AC_LINK_IFELSE([AC_LANG_PROGRAM()], ac_cv_zrelro=yes, ac_cv_zrelro=no)
181LDFLAGS="$save_LDFLAGS"
182])
183if test "$ac_cv_zrelro" = "yes"; then
184 dso_LDFLAGS="$dso_LDFLAGS $ZRELRO_LDFLAGS"
185fi
186
187AC_SUBST([dso_LDFLAGS])
188
Roland McGrath81817392009-01-23 03:23:02 -0800189AC_CACHE_CHECK([for __thread support], ac_cv_tls, [dnl
Roland McGrathe72bf152009-01-23 14:27:39 -0800190# Use the same flags that we use for our DSOs, so the test is representative.
191# Some old compiler/linker/libc combinations fail some ways and not others.
192save_CFLAGS="$CFLAGS"
193save_LDFLAGS="$LDFLAGS"
Ulf Hermann07737582017-08-18 12:41:11 +0200194CFLAGS="$fpic_CFLAGS $CFLAGS"
195LDFLAGS="$dso_LDFLAGS $LDFLAGS"
Roland McGrath81817392009-01-23 03:23:02 -0800196AC_LINK_IFELSE([dnl
Mark Wielaard0a35e3a2015-03-13 23:51:40 +0100197AC_LANG_PROGRAM([[#include <stdlib.h>
198#undef __thread
Roland McGrathe72bf152009-01-23 14:27:39 -0800199static __thread int a; int foo (int b) { return a + b; }]],
Roland McGrath81817392009-01-23 03:23:02 -0800200 [[exit (foo (0));]])],
Roland McGrathe72bf152009-01-23 14:27:39 -0800201 ac_cv_tls=yes, ac_cv_tls=no)
202CFLAGS="$save_CFLAGS"
203LDFLAGS="$save_LDFLAGS"])
Ulrich Drepper7e678fa2009-01-10 18:02:05 -0800204AS_IF([test "x$ac_cv_tls" != xyes],
Roland McGrath81817392009-01-23 03:23:02 -0800205 AC_MSG_ERROR([__thread support required]))
Ulrich Drepper7e678fa2009-01-10 18:02:05 -0800206
Dmitry V. Levin98b69a92020-12-12 19:52:49 +0300207dnl Before 4.9 gcc doesn't ship stdatomic.h, but the necessary atomics are
Jonathon Anderson77b66a72019-08-25 10:01:51 -0500208dnl available by (at least) 4.7. So if the system doesn't have a stdatomic.h we
209dnl fall back on one copied from FreeBSD that handles the difference.
210AC_CACHE_CHECK([whether gcc provides stdatomic.h], ac_cv_has_stdatomic,
211 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdatomic.h>]])],
212 ac_cv_has_stdatomic=yes, ac_cv_has_stdatomic=no)])
213AM_CONDITIONAL(HAVE_STDATOMIC_H, test "x$ac_cv_has_stdatomic" = xyes)
214AS_IF([test "x$ac_cv_has_stdatomic" = xyes], [AC_DEFINE(HAVE_STDATOMIC_H)])
215
216AH_TEMPLATE([HAVE_STDATOMIC_H], [Define to 1 if `stdatomic.h` is provided by the
217 system, 0 otherwise.])
218
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000219dnl This test must come as early as possible after the compiler configuration
220dnl tests, because the choice of the file model can (in principle) affect
221dnl whether functions and headers are available, whether they work, etc.
222AC_SYS_LARGEFILE
223
Mark Wielaardee225022016-11-23 20:51:35 +0100224dnl Older glibc had a broken fts that didn't work with Large File Systems.
225dnl We want the version that can handler LFS, but include workaround if we
226dnl get a bad one. Add define to CFLAGS (not AC_DEFINE it) since we need to
227dnl check it before including config.h (which might define _FILE_OFFSET_BITS).
228AC_CACHE_CHECK([whether fts.h is bad when included (with LFS)], ac_cv_bad_fts,
229 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <fts.h>]])],
230 ac_cv_bad_fts=no, ac_cv_bad_fts=yes)])
Mark Wielaardad7036f2020-07-18 01:53:29 +0200231AS_IF([test "x$ac_cv_bad_fts" = "xyes"],
232 [CFLAGS="$CFLAGS -DBAD_FTS=1" CXXFLAGS="$CXXFLAGS -DBAD_FTS=1"])
Mark Wielaardee225022016-11-23 20:51:35 +0100233
Mark Wielaard01b994e2017-02-09 21:09:54 +0100234# See if we can add -D_FORTIFY_SOURCE=2. Don't do it if it is already
235# (differently) defined or if it generates warnings/errors because we
236# don't use the right optimisation level (string.h will warn about that).
237AC_MSG_CHECKING([whether to add -D_FORTIFY_SOURCE=2 to CFLAGS])
238case "$CFLAGS" in
239 *-D_FORTIFY_SOURCE=2*)
240 AC_MSG_RESULT([no, already there])
241 ;;
242 *)
243 save_CFLAGS="$CFLAGS"
Omar Sandovalc435a332019-12-11 16:23:27 -0800244 CFLAGS="-D_FORTIFY_SOURCE=2 $CFLAGS -Werror"
Mark Wielaard01b994e2017-02-09 21:09:54 +0100245 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
246 #include <string.h>
247 int main() { return 0; }
248 ]])], [ AC_MSG_RESULT([yes])
249 CFLAGS="-D_FORTIFY_SOURCE=2 $save_CFLAGS" ],
250 [ AC_MSG_RESULT([no])
251 CFLAGS="$save_CFLAGS"])
252 ;;
253esac
254
Ulrich Drepper3cbdd382008-01-02 17:44:39 +0000255dnl enable debugging of branch prediction.
Ulrich Drepper28a0c612008-01-21 18:57:48 +0000256AC_ARG_ENABLE([debugpred],
Ulrich Drepperdb12f162009-09-21 08:04:38 -0700257AS_HELP_STRING([--enable-debugpred],[build binaries with support to debug branch prediction]),
Mike Frysinger8f3002e2011-10-08 15:09:15 -0700258[use_debugpred=$enableval], [use_debugpred=no])
259case $use_debugpred in
Mark Wielaard7702a3c2015-05-01 09:23:57 +0200260 yes) use_debugpred_val=1 ;;
261 *) use_debugpred_val=0 ;;
Mike Frysinger8f3002e2011-10-08 15:09:15 -0700262esac
Mark Wielaard7702a3c2015-05-01 09:23:57 +0200263AC_SUBST([DEBUGPRED], $use_debugpred_val)
Ulrich Drepper3cbdd382008-01-02 17:44:39 +0000264
Dmitry V. Levin98b69a92020-12-12 19:52:49 +0300265dnl Enable gprof support.
Ulrich Drepper47be7952005-08-07 04:41:39 +0000266AC_ARG_ENABLE([gprof],
Mike Frysinger8f3002e2011-10-08 15:09:15 -0700267AS_HELP_STRING([--enable-gprof],[build binaries with gprof support]), [use_gprof=$enableval], [use_gprof=no])
Ulrich Drepper47be7952005-08-07 04:41:39 +0000268if test "$use_gprof" = yes; then
269 CFLAGS="$CFLAGS -pg"
270 LDFLAGS="$LDFLAGS -pg"
271fi
272AM_CONDITIONAL(GPROF, test "$use_gprof" = yes)
Ulrich Drepperfbe998a2005-08-29 16:27:10 +0000273
Dmitry V. Levin98b69a92020-12-12 19:52:49 +0300274# Enable gcov support.
Ulrich Drepperfbe998a2005-08-29 16:27:10 +0000275AC_ARG_ENABLE([gcov],
Mike Frysinger8f3002e2011-10-08 15:09:15 -0700276AS_HELP_STRING([--enable-gcov],[build binaries with gcov support]), [use_gcov=$enableval], [use_gcov=no])
Ulrich Drepperfbe998a2005-08-29 16:27:10 +0000277if test "$use_gcov" = yes; then
278 CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
Mark Wielaard3f81dbd2019-11-26 08:56:44 +0100279 CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage"
Ulrich Drepperfbe998a2005-08-29 16:27:10 +0000280 LDFLAGS="$LDFLAGS -fprofile-arcs"
Dmitry V. Levin2a16a0f2021-01-12 08:00:00 +0000281 AC_CHECK_PROG([GCOV], [gcov], [gcov])
282 AC_CHECK_PROG([LCOV], [lcov], [lcov])
283 AC_CHECK_PROG([GENHTML], [genhtml], [genhtml])
Ulrich Drepperfbe998a2005-08-29 16:27:10 +0000284fi
Ulrich Drepper39cec7a2005-08-30 01:22:01 +0000285AM_CONDITIONAL(GCOV, test "$use_gcov" = yes)
Ulrich Drepperfbe998a2005-08-29 16:27:10 +0000286
Mark Wielaard2b250b72015-05-21 23:36:51 +0200287AC_ARG_ENABLE([sanitize-undefined],
288 AS_HELP_STRING([--enable-sanitize-undefined],
289 [Use gcc undefined behaviour sanitizer]),
290 [use_undefined=$enableval], [use_undefined=no])
291if test "$use_undefined" = yes; then
292 old_CFLAGS="$CFLAGS"
293 old_CXXFLAGS="$CXXFLAGS"
294 # We explicitly use unaligned access when possible (see ALLOW_UNALIGNED)
295 # We want to fail immediately on first error, don't try to recover.
Mark Wielaard170f1bb2015-05-31 22:37:19 +0200296 CFLAGS="$CFLAGS -fsanitize=undefined -fno-sanitize-recover"
297 CXXFLAGS="$CXXFLAGS -fsanitize=undefined -fno-sanitize-recover"
298 AC_LINK_IFELSE([AC_LANG_SOURCE([int main (int argc, char **argv) { return 0; }])], use_undefined=yes, use_undefined=no)
Mark Wielaard2b250b72015-05-21 23:36:51 +0200299 AS_IF([test "x$use_undefined" != xyes],
300 AC_MSG_WARN([gcc undefined behaviour sanitizer not available])
301 CFLAGS="$old_CFLAGS" CXXFLAGS="$old_CXXFLAGS")
302fi
Mark Wielaard170f1bb2015-05-31 22:37:19 +0200303case $use_undefined in
304 yes) check_undefined_val=1 ;;
305 *) check_undefined_val=0 ;;
306esac
307AC_DEFINE_UNQUOTED(CHECK_UNDEFINED, $check_undefined_val,
308 [Building with -fsanitize=undefined or not])
Mark Wielaard2b250b72015-05-21 23:36:51 +0200309
Mark Wielaarde3e3ee22012-10-01 16:14:12 +0200310AC_ARG_ENABLE([valgrind],
311AS_HELP_STRING([--enable-valgrind],[run all tests under valgrind]),
312[use_valgrind=$enableval], [use_valgrind=no])
313if test "$use_valgrind" = yes; then
314 AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no)
315 if test "$HAVE_VALGRIND" = "no"; then
316 AC_MSG_ERROR([valgrind not found])
317 fi
318fi
319AM_CONDITIONAL(USE_VALGRIND, test "$use_valgrind" = yes)
320
Jonathon Anderson5e2a8e22019-08-25 09:53:50 -0500321AC_ARG_WITH([valgrind],
322AS_HELP_STRING([--with-valgrind],[include directory for Valgrind headers]),
323[with_valgrind_headers=$withval], [with_valgrind_headers=no])
324if test "x$with_valgrind_headers" != xno; then
325 save_CFLAGS="$CFLAGS"
326 CFLAGS="$CFLAGS -I$with_valgrind_headers"
327 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
328 #include <valgrind/valgrind.h>
329 int main() { return 0; }
330 ]])], [ HAVE_VALGRIND_HEADERS="yes"
331 CFLAGS="$save_CFLAGS -I$with_valgrind_headers" ],
332 [ AC_MSG_ERROR([invalid valgrind include directory: $with_valgrind_headers]) ])
333fi
334
335AC_ARG_ENABLE([valgrind-annotations],
336AS_HELP_STRING([--enable-valgrind-annotations],[insert extra annotations for better valgrind support]),
337[use_vg_annotations=$enableval], [use_vg_annotations=no])
338if test "$use_vg_annotations" = yes; then
339 if test "x$HAVE_VALGRIND_HEADERS" != "xyes"; then
340 AC_MSG_CHECKING([whether Valgrind headers are available])
341 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
342 #include <valgrind/valgrind.h>
343 int main() { return 0; }
344 ]])], [ AC_MSG_RESULT([yes]) ],
345 [ AC_MSG_ERROR([valgrind annotations requested but no headers are available]) ])
346 fi
347fi
348AM_CONDITIONAL(USE_VG_ANNOTATIONS, test "$use_vg_annotations" = yes)
349
Mark Wielaardb63007e2019-01-18 14:18:22 +0100350AC_ARG_ENABLE([install-elfh],
351AS_HELP_STRING([--enable-install-elfh],[install elf.h in include dir]),
352 [install_elfh=$enableval], [install_elfh=no])
353AM_CONDITIONAL(INSTALL_ELFH, test "$install_elfh" = yes)
354
Ulrich Drepper47be7952005-08-07 04:41:39 +0000355AM_CONDITIONAL(BUILD_STATIC, [dnl
Mark Wielaard32324792014-04-13 17:39:57 +0200356test "$use_gprof" = yes -o "$use_gcov" = yes])
Ulrich Drepper47be7952005-08-07 04:41:39 +0000357
Roland McGrath1b8b4462005-11-16 01:33:38 +0000358AC_ARG_ENABLE([tests-rpath],
Ulrich Drepperdb12f162009-09-21 08:04:38 -0700359AS_HELP_STRING([--enable-tests-rpath],[build $ORIGIN-using rpath into tests]),
Mike Frysinger8f3002e2011-10-08 15:09:15 -0700360 [tests_use_rpath=$enableval], [tests_use_rpath=no])
Roland McGrath1b8b4462005-11-16 01:33:38 +0000361AM_CONDITIONAL(TESTS_RPATH, test "$tests_use_rpath" = yes)
362
Mark Wielaard528cb452015-10-16 23:07:12 +0200363dnl zlib is mandatory.
Roland McGrathbca43152009-01-05 23:59:32 -0800364save_LIBS="$LIBS"
365LIBS=
Roland McGrath24169642009-08-26 02:26:34 -0700366eu_ZIPLIB(zlib,ZLIB,z,gzdirect,gzip)
Mike Frysinger2d703bf2016-01-14 13:46:18 -0500367AS_IF([test "x$with_zlib" = xno], [AC_MSG_ERROR([zlib not found but is required])])
Mark Wielaard528cb452015-10-16 23:07:12 +0200368LIBS="$save_LIBS"
369
Mark Wielaard52536d72020-09-18 12:49:29 +0200370dnl Test for bzlib and xz/lzma/zstd, gives BZLIB/LZMALIB/ZSTD .am
371dnl conditional and config.h USE_BZLIB/USE_LZMALIB/USE_ZSTD #define.
Mark Wielaard528cb452015-10-16 23:07:12 +0200372save_LIBS="$LIBS"
373LIBS=
Roland McGrath24169642009-08-26 02:26:34 -0700374eu_ZIPLIB(bzlib,BZLIB,bz2,BZ2_bzdopen,bzip2)
Mark Wielaard0aa60ac2016-01-04 21:41:52 +0100375# We need this since bzip2 doesn't have a pkgconfig file.
376BZ2_LIB="$LIBS"
377AC_SUBST([BZ2_LIB])
Roland McGrath24169642009-08-26 02:26:34 -0700378eu_ZIPLIB(lzma,LZMA,lzma,lzma_auto_decoder,[LZMA (xz)])
Mark Wielaard0aa60ac2016-01-04 21:41:52 +0100379AS_IF([test "x$with_lzma" = xyes], [LIBLZMA="liblzma"], [LIBLZMA=""])
380AC_SUBST([LIBLZMA])
Mark Wielaard52536d72020-09-18 12:49:29 +0200381eu_ZIPLIB(zstd,ZSTD,zstd,ZSTD_decompress,[ZSTD (zst)])
382AS_IF([test "x$with_zstd" = xyes], [LIBZSTD="libzstd"], [LIBLZSTD=""])
383AC_SUBST([LIBZSTD])
Roland McGrathbca43152009-01-05 23:59:32 -0800384zip_LIBS="$LIBS"
385LIBS="$save_LIBS"
386AC_SUBST([zip_LIBS])
387
Akihiko Odakia24d52a2016-10-13 09:16:48 +0900388AC_CHECK_DECLS([memrchr, rawmemchr],[],[],
389 [#define _GNU_SOURCE
390 #include <string.h>])
391AC_CHECK_DECLS([powerof2],[],[],[#include <sys/param.h>])
Ulf Hermannb3248e62017-02-16 10:10:30 +0100392AC_CHECK_DECLS([mempcpy],[],[],
393 [#define _GNU_SOURCE
394 #include <string.h>])
Mark Wielaard1a13c352021-07-28 16:46:36 +0200395AC_CHECK_DECLS([reallocarray],[],[],
396 [#define _GNU_SOURCE
397 #include <stdlib.h>])
Akihiko Odakia24d52a2016-10-13 09:16:48 +0900398
Mark Wielaardafffdff2018-03-18 00:24:08 +0100399AC_CHECK_FUNCS([process_vm_readv])
400
Saleem Abdulrasool76c84c12021-08-20 20:28:23 +0000401AC_CHECK_HEADERS([error.h])
402AC_CHECK_HEADERS([err.h])
403
Érico Rolim8db222e2021-02-01 21:16:56 -0300404old_CFLAGS="$CFLAGS"
405CFLAGS="$CFLAGS -D_GNU_SOURCE"
406AC_FUNC_STRERROR_R()
407CFLAGS="$old_CFLAGS"
408
Ulrich Drepperb4a16cf2011-10-02 08:33:19 -0400409AC_CHECK_LIB([stdc++], [__cxa_demangle], [dnl
410AC_DEFINE([USE_DEMANGLE], [1], [Defined if demangling is enabled])])
Max Filippov1ce4a452015-05-03 21:14:09 +0300411AM_CONDITIONAL(DEMANGLE, test "x$ac_cv_lib_stdcpp___cxa_demangle" = "xyes")
412AS_IF([test "x$ac_cv_lib_stdcpp___cxa_demangle" = "xyes"],
Mark Wielaarde6e80da2015-05-01 10:31:36 +0200413 [enable_demangler=yes],[enable_demangler=no])
Ulrich Drepperb4a16cf2011-10-02 08:33:19 -0400414
Mark Wielaard805ec832014-11-27 23:53:30 +0100415AC_ARG_ENABLE([textrelcheck],
416AS_HELP_STRING([--disable-textrelcheck],
417 [Disable textrelcheck being a fatal error]))
418AM_CONDITIONAL(FATAL_TEXTREL, [test "x$enable_textrelcheck" != "xno"])
Mark Wielaard7702a3c2015-05-01 09:23:57 +0200419AS_IF([test "x$enable_textrelcheck" != "xno"],
420 [enable_textrelcheck=yes],[enable_textrelcheck=no])
Mark Wielaard805ec832014-11-27 23:53:30 +0100421
Max Filippovbafacac2015-04-23 20:46:59 +0200422AC_ARG_ENABLE([symbol-versioning],
423AS_HELP_STRING([--disable-symbol-versioning],
424 [Disable symbol versioning in shared objects]))
Ulf Hermann4a3330a2017-08-18 15:50:42 +0200425
426AC_CACHE_CHECK([whether symbol versioning is supported], ac_cv_symbol_versioning, [dnl
427AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl
428#define NEW_VERSION(name, version) \
429 asm (".symver " #name "," #name "@@@" #version);
430int foo(int x) { return x + 1; }
431NEW_VERSION (foo, ELFUTILS_12.12)
432])], ac_cv_symbol_versioning=yes, ac_cv_symbol_versioning=no)])
433if test "$ac_cv_symbol_versioning" = "no"; then
434 if test "x$enable_symbol_versioning" != "xno"; then
435 AC_MSG_ERROR([Symbol versioning is not supported.
436 Use --disable-symbol-versioning to build without.])
437 fi
438fi
439
Max Filippovbafacac2015-04-23 20:46:59 +0200440AM_CONDITIONAL(SYMBOL_VERSIONING, [test "x$enable_symbol_versioning" != "xno"])
441AS_IF([test "x$enable_symbol_versioning" = "xno"],
Mark Wielaard7702a3c2015-05-01 09:23:57 +0200442 [AC_MSG_WARN([Disabling symbol versioning breaks ABI compatibility.])
443 enable_symbol_versioning=no],[enable_symbol_versioning=yes])
Max Filippovbafacac2015-04-23 20:46:59 +0200444
Mark Wielaard4b7953d2015-06-09 00:28:13 +0200445AC_CACHE_CHECK([whether gcc accepts -Wstack-usage], ac_cv_stack_usage, [dnl
446old_CFLAGS="$CFLAGS"
Filipe Brandenburger239cd482016-05-02 13:26:13 -0700447CFLAGS="$CFLAGS -Wstack-usage=262144 -Werror"
Mark Wielaard4b7953d2015-06-09 00:28:13 +0200448AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
449 ac_cv_stack_usage=yes, ac_cv_stack_usage=no)
450CFLAGS="$old_CFLAGS"])
451AM_CONDITIONAL(ADD_STACK_USAGE_WARNING, [test "x$ac_cv_stack_usage" != "xno"])
452
Mark Wielaard8bc14232016-02-09 16:10:22 +0100453# -Wlogical-op was too fragile in the past, make sure we get a sane one.
454AC_CACHE_CHECK([whether gcc has a sane -Wlogical-op], ac_cv_logical_op, [dnl
455old_CFLAGS="$CFLAGS"
456CFLAGS="$CFLAGS -Wlogical-op -Werror"
457AC_COMPILE_IFELSE([AC_LANG_SOURCE(
458 [#define FLAG 1
459 int f (int r, int f) { return (r && (FLAG || (FLAG & f))); }])],
460 ac_cv_logical_op=yes, ac_cv_logical_op=no)
461CFLAGS="$old_CFLAGS"])
462AM_CONDITIONAL(SANE_LOGICAL_OP_WARNING,
463 [test "x$ac_cv_logical_op" != "xno"])
464
465# -Wduplicated-cond was added by GCC6
466AC_CACHE_CHECK([whether gcc accepts -Wduplicated-cond], ac_cv_duplicated_cond, [dnl
467old_CFLAGS="$CFLAGS"
Filipe Brandenburger239cd482016-05-02 13:26:13 -0700468CFLAGS="$CFLAGS -Wduplicated-cond -Werror"
Mark Wielaard8bc14232016-02-09 16:10:22 +0100469AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
470 ac_cv_duplicated_cond=yes, ac_cv_duplicated_cond=no)
471CFLAGS="$old_CFLAGS"])
472AM_CONDITIONAL(HAVE_DUPLICATED_COND_WARNING,
473 [test "x$ac_cv_duplicated_cond" != "xno"])
474
Mark Wielaard6993d402016-02-13 19:10:00 +0100475# -Wnull-dereference was added by GCC6
476AC_CACHE_CHECK([whether gcc accepts -Wnull-dereference], ac_cv_null_dereference, [dnl
477old_CFLAGS="$CFLAGS"
Filipe Brandenburger239cd482016-05-02 13:26:13 -0700478CFLAGS="$CFLAGS -Wnull-dereference -Werror"
Mark Wielaard6993d402016-02-13 19:10:00 +0100479AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
480 ac_cv_null_dereference=yes, ac_cv_null_dereference=no)
481CFLAGS="$old_CFLAGS"])
482AM_CONDITIONAL(HAVE_NULL_DEREFERENCE_WARNING,
483 [test "x$ac_cv_null_dereference" != "xno"])
484
Mark Wielaarda3cc8182016-11-02 13:29:26 +0100485# -Wimplicit-fallthrough was added by GCC7
486AC_CACHE_CHECK([whether gcc accepts -Wimplicit-fallthrough], ac_cv_implicit_fallthrough, [dnl
487old_CFLAGS="$CFLAGS"
488CFLAGS="$CFLAGS -Wimplicit-fallthrough -Werror"
489AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
490 ac_cv_implicit_fallthrough=yes, ac_cv_implicit_fallthrough=no)
491CFLAGS="$old_CFLAGS"])
492AM_CONDITIONAL(HAVE_IMPLICIT_FALLTHROUGH_WARNING,
493 [test "x$ac_cv_implicit_fallthrough" != "xno"])
494
Timm Bäderd6c85cf2021-02-17 10:27:06 +0100495# Check whether the compiler additionally accepts -Wimplicit-fallthrough=5
496# GCC accepts this and 5 means "don't parse any fallthrough comments and
497# only accept the fallthrough attribute"
498AC_CACHE_CHECK([whether the compiler accepts -Wimplicit-fallthrough=5], ac_cv_implicit_fallthrough_5, [dnl
499old_CFLAGS="$CFLAGS"
500CFLAGS="$CFLAGS -Wimplicit-fallthrough=5 -Werror"
501AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
502 ac_cv_implicit_fallthrough_5=yes, ac_cv_implicit_fallthrough_5=no)
503CFLAGS="$old_CFLAGS"])
504AM_CONDITIONAL(HAVE_IMPLICIT_FALLTHROUGH_5_WARNING,
505 [test "x$ac_cv_implicit_fallthrough_5" != "xno"])
506
Joshua Watt555e15e2018-02-09 10:27:18 -0600507# Assume the fallthrough attribute is supported if -Wimplict-fallthrough is supported
508if test "$ac_cv_implicit_fallthrough" = "yes"; then
509 AC_DEFINE([HAVE_FALLTHROUGH], [1],
510 [Defined if __attribute__((fallthrough)) is supported])
511fi
512
Timm Bäder00d92d02021-02-17 10:27:07 +0100513AC_CACHE_CHECK([whether the compiler accepts -Wtrampolines], ac_cv_trampolines, [dnl
514old_CFLAGS="$CFLAGS"
515CFLAGS="$CFLAGS -Wtrampolines -Werror"
516AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
517 ac_cv_trampolines=yes, ac_cv_trampolines=no)
518CFLAGS="$old_CFLAGS"])
519AM_CONDITIONAL(HAVE_TRAMPOLINES_WARNING,
520 [test "x$ac_cv_trampolines" != "xno"])
521
Timm Bäder1645d4a2021-02-17 10:27:08 +0100522AC_CACHE_CHECK([whether the compiler accepts -Wno-packed-not-aligned], ac_cv_no_packed_not_aligned, [dnl
523old_CFLAGS="$CFLAGS"
524CFLAGS="$CFLAGS -Wno-packed-not-aligned -Werror"
525AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
526 ac_cv_no_packed_not_aligned=yes, ac_cv_no_packed_not_aligned=no)
527CFLAGS="$old_CFLAGS"])
528AM_CONDITIONAL(HAVE_NO_PACKED_NOT_ALIGNED_WARNING,
529 [test "x$ac_cv_no_packed_not_aligned" != "xno"])
530
Dmitry V. Levinbe084cc2020-12-11 03:59:40 +0300531saved_LIBS="$LIBS"
532AC_SEARCH_LIBS([argp_parse], [argp])
533LIBS="$saved_LIBS"
534case "$ac_cv_search_argp_parse" in
535 no) AC_MSG_FAILURE([failed to find argp_parse]) ;;
536 -l*) argp_LDADD="$ac_cv_search_argp_parse" ;;
537 *) argp_LDADD= ;;
538esac
Anthony G. Basile1ab3c2b2015-05-04 02:25:39 +0300539AC_SUBST([argp_LDADD])
540
Érico Rolimda855fc2020-11-01 21:48:50 -0300541saved_LIBS="$LIBS"
542AC_SEARCH_LIBS([fts_close], [fts])
543LIBS="$saved_LIBS"
544case "$ac_cv_search_fts_close" in
545 no) AC_MSG_FAILURE([failed to find fts_close]) ;;
546 -l*) fts_LIBS="$ac_cv_search_fts_close" ;;
547 *) fts_LIBS= ;;
548esac
549AC_SUBST([fts_LIBS])
550
551saved_LIBS="$LIBS"
552AC_SEARCH_LIBS([_obstack_free], [obstack])
553LIBS="$saved_LIBS"
554case "$ac_cv_search__obstack_free" in
Dmitry V. Levin8ffada52020-12-11 03:59:00 +0300555 no) AC_MSG_FAILURE([failed to find _obstack_free]) ;;
Érico Rolimda855fc2020-11-01 21:48:50 -0300556 -l*) obstack_LIBS="$ac_cv_search__obstack_free" ;;
557 *) obstack_LIBS= ;;
558esac
559AC_SUBST([obstack_LIBS])
560
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000561dnl The directories with content.
562
563dnl Documentation.
Ben Woodardf0a51762019-08-23 13:42:06 -0700564AC_CONFIG_FILES([doc/Makefile])
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000565
566dnl Support library.
567AC_CONFIG_FILES([lib/Makefile])
568
569dnl ELF library.
Ulrich Drepper2c9ee4f2007-06-06 02:49:30 +0000570AC_CONFIG_FILES([libelf/Makefile])
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000571
572dnl Higher-level ELF support library.
573AC_CONFIG_FILES([libebl/Makefile])
574
Mark Wielaard93802972014-04-11 23:52:47 +0200575dnl DWARF-ELF Lower-level Functions support library.
576AC_CONFIG_FILES([libdwelf/Makefile])
577
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000578dnl DWARF library.
579AC_CONFIG_FILES([libdw/Makefile])
580
581dnl Higher-level DWARF support library.
582AC_CONFIG_FILES([libdwfl/Makefile])
583
584dnl CPU handling library.
585AC_CONFIG_FILES([libcpu/Makefile])
586
587dnl Assembler library.
588AC_CONFIG_FILES([libasm/Makefile])
589
Roland McGrathe47ab762005-11-17 03:16:00 +0000590dnl CPU-specific backend libraries.
591AC_CONFIG_FILES([backends/Makefile])
592
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000593dnl Tools.
594AC_CONFIG_FILES([src/Makefile po/Makefile.in])
595
596dnl Test suite.
597AC_CONFIG_FILES([tests/Makefile])
598
Mark Wielaard0aa60ac2016-01-04 21:41:52 +0100599dnl pkgconfig files
Aaron Merey288f6b12019-10-28 13:29:26 -0400600AC_CONFIG_FILES([config/libelf.pc config/libdw.pc config/libdebuginfod.pc])
Mark Wielaard0aa60ac2016-01-04 21:41:52 +0100601
Dmitry V. Levindd52d2a2020-12-15 08:00:00 +0000602dnl As long as "git grep 'PRI[diouxX]' po" reports matches in
603dnl translatable strings, we must use need-formatstring-macros here.
604AM_GNU_GETTEXT([external], [need-formatstring-macros])
605
606dnl AM_GNU_GETTEXT_VERSION is still needed for old versions
607dnl of autoreconf that do not recognize AM_GNU_GETTEXT_REQUIRE_VERSION.
608dnl 0.19.6 is the first version of gettext that provides
609dnl AM_GNU_GETTEXT_REQUIRE_VERSION support.
610AM_GNU_GETTEXT_VERSION([0.19.6])
611AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.6])
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000612
Roland McGrathb4d6f0f2008-08-25 22:55:17 +0000613dnl Appended to the config.h file.
614dnl We hide all kinds of configuration magic in lib/eu-config.h.
615AH_BOTTOM([#include <eu-config.h>])
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000616
Roland McGrathfbc72452008-12-16 17:03:03 -0800617dnl Version compatibility header.
618AC_CONFIG_FILES([version.h:config/version.h.in])
619AC_SUBST([eu_version])
Roland McGrathee9d60d2009-04-17 13:18:35 -0700620
621# 1.234<whatever> -> 1234<whatever>
622case "$PACKAGE_VERSION" in
Roland McGrathe9bf1d32011-10-08 15:14:30 -0700623[[0-9]].*) eu_version=`echo "$PACKAGE_VERSION" | sed 's@\.@@'` ;;
Roland McGrathee9d60d2009-04-17 13:18:35 -0700624*) AC_MSG_ERROR([confused by version number '$PACKAGE_VERSION']) ;;
625esac
626case "$eu_version" in
627*.*)
628 # 1234.567 -> "1234", "567"
629 eu_extra_version="${eu_version#*.}"
630 eu_version="${eu_version%%.*}"
631 case "$eu_extra_version" in
632 [[0-9]][[0-9]][[0-9]]) ;;
633 [[0-9]][[0-9]]) eu_extra_version="${eu_extra_version}0" ;;
634 [[0-9]]) eu_extra_version="${eu_extra_version}00" ;;
635 *) AC_MSG_ERROR([confused by version number '$PACKAGE_VERSION']) ;;
636 esac
637 ;;
638*)
639 eu_extra_version=000
640 ;;
641esac
642
643case "$eu_version" in
644 0[[0-9]][[0-9]][[0-9]]) eu_version="${eu_version#0}$eu_extra_version" ;;
645[[0-9]][[0-9]][[0-9]][[0-9]]) eu_version="${eu_version}$eu_extra_version" ;;
646[[0-9]][[0-9]][[0-9]]) eu_version="${eu_version}0$eu_extra_version" ;;
Ulrich Drepper2c712522010-06-28 12:10:53 -0700647[[0-9]][[0-9]]) eu_version="${eu_version}00$eu_extra_version";;
Roland McGrathee9d60d2009-04-17 13:18:35 -0700648*) AC_MSG_ERROR([confused by version number '$PACKAGE_VERSION']) ;;
Roland McGrathfbc72452008-12-16 17:03:03 -0800649esac
650
Roland McGrath105e3982009-04-19 16:07:45 -0700651# Round up to the next release API (x.y) version.
Roland McGrathe9bf1d32011-10-08 15:14:30 -0700652eu_version=$(( (eu_version + 999) / 1000 ))
Roland McGrath105e3982009-04-19 16:07:45 -0700653
Jan Kratochvil0b867462013-05-30 14:37:38 +0200654AC_CHECK_SIZEOF(long)
655
Kyle McMartinc1e0fcb2014-06-09 21:06:26 +0200656# On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
657# of the user_regs_struct from sys/user.h. They are structurally the same
658# but we get either one or the other.
659AC_CHECK_TYPE([struct user_regs_struct],
660 [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
661 [[#include <sys/ptrace.h>]
662 [#include <sys/time.h>]
663 [#include <sys/user.h>]])
664if test "$sys_user_has_user_regs" = "yes"; then
665 AC_DEFINE(HAVE_SYS_USER_REGS, 1,
666 [Define to 1 if <sys/user.h> defines struct user_regs_struct])
667fi
668
Jan Kratochvil0b867462013-05-30 14:37:38 +0200669# On a 64-bit host where can can use $CC -m32, we'll run two sets of tests.
670# Likewise in a 32-bit build on a host where $CC -m64 works.
671utrace_BIARCH
672# `$utrace_biarch' will be `-m64' even on an uniarch i386 machine.
Jan Kratochvil8ae9bc92013-12-02 20:54:28 +0100673CC_BIARCH="$CC $utrace_biarch"
Jan Kratochvil0b867462013-05-30 14:37:38 +0200674AC_SUBST([CC_BIARCH])
675
Mark Wielaard4664fd52015-05-30 22:50:37 +0200676# In maintainer mode we really need flex and bison.
677# Otherwise we really need a release dir with maintainer files generated.
678if test "x$enable_maintainer_mode" = xyes; then
679 AC_CHECK_PROG(HAVE_FLEX, flex, yes, no)
680 if test "$HAVE_FLEX" = "no"; then
681 AC_MSG_ERROR([flex needed in maintainer mode])
682 fi
683 AC_CHECK_PROG(HAVE_BISON, bison, yes, no)
684 if test "$HAVE_BISON" = "no"; then
685 AC_MSG_ERROR([bison needed in maintainer mode])
686 fi
Ross Burtond6126842018-07-04 12:11:07 +0100687 AC_CHECK_PROG(HAVE_GAWK, gawk, yes, no)
688 if test "$HAVE_GAWK" = "no"; then
689 AC_MSG_ERROR([gawk needed in maintainer mode])
690 fi
Mark Wielaard4664fd52015-05-30 22:50:37 +0200691else
692 if test ! -f ${srcdir}/libdw/known-dwarf.h; then
693 AC_MSG_ERROR([No libdw/known-dwarf.h. configure --enable-maintainer-mode])
694 fi
695fi
696
697# The testfiles are all compressed, we need bunzip2 when running make check
698AC_CHECK_PROG(HAVE_BUNZIP2, bunzip2, yes, no)
699if test "$HAVE_BUNZIP2" = "no"; then
700 AC_MSG_WARN([No bunzip2, needed to run make check])
701fi
702
Mark Wielaard52536d72020-09-18 12:49:29 +0200703# For tests that need to use zstd compression
704AC_CHECK_PROG(HAVE_ZSTD, zstd, yes, no)
705AM_CONDITIONAL([HAVE_ZSTD],[test "x$HAVE_ZSTD" = "xyes"])
706
Mark Wielaardf7f0cdc2020-06-19 19:41:08 +0200707# Look for libcurl for libdebuginfod minimum version as per rhel7.
708AC_ARG_ENABLE([libdebuginfod],AC_HELP_STRING([--enable-libdebuginfod], [Build debuginfod client library (can be =dummy)]))
709AS_IF([test "x$enable_libdebuginfod" != "xno"], [
710 if test "x$enable_libdebuginfod" != "xdummy"; then
711 AC_MSG_NOTICE([checking libdebuginfod dependencies, --disable-libdebuginfod or --enable-libdebuginfo=dummy to skip])
712 enable_libdebuginfod=yes # presume success
713 PKG_PROG_PKG_CONFIG
714 PKG_CHECK_MODULES([libcurl],[libcurl >= 7.29.0],[],[enable_libdebuginfod=no])
715 if test "x$enable_libdebuginfod" = "xno"; then
716 AC_MSG_ERROR([dependencies not found, use --disable-libdebuginfod to disable or --enable-libdebuginfod=dummy to build a (bootstrap) dummy library.])
717 fi
718 else
719 AC_MSG_NOTICE([building (bootstrap) dummy libdebuginfo library])
720 fi
721])
722
Frank Ch. Eigler69fc2b32021-03-30 13:22:43 -0400723AC_CHECK_LIB(pthread, pthread_setname_np, [
724 AC_DEFINE([HAVE_PTHREAD_SETNAME_NP],[1],[Enable pthread_setname_np])])
725
Dmitry V. Levin4ced3012020-08-20 23:27:24 +0300726AS_IF([test "x$enable_libdebuginfod" = "xyes" || test "x$enable_libdebuginfod" = "xdummy"],
727 [AC_DEFINE([ENABLE_LIBDEBUGINFOD], [1], [Enable libdebuginfod])])
728AS_IF([test "x$enable_libdebuginfod" = "xdummy"],
729 [AC_DEFINE([DUMMY_LIBDEBUGINFOD], [1], [Build dummy libdebuginfod])])
Mark Wielaardf7f0cdc2020-06-19 19:41:08 +0200730AM_CONDITIONAL([LIBDEBUGINFOD],[test "x$enable_libdebuginfod" = "xyes" || test "x$enable_libdebuginfod" = "xdummy"])
731AM_CONDITIONAL([DUMMY_LIBDEBUGINFOD],[test "x$enable_libdebuginfod" = "xdummy"])
732
733# Look for libmicrohttpd, libarchive, sqlite for debuginfo server
734# minimum versions as per rhel7.
735AC_ARG_ENABLE([debuginfod],AC_HELP_STRING([--enable-debuginfod], [Build debuginfod server]))
Frank Ch. Eiglere27e30c2019-10-28 13:29:26 -0400736AC_PROG_CXX
Frank Ch. Eiglere27e30c2019-10-28 13:29:26 -0400737AS_IF([test "x$enable_debuginfod" != "xno"], [
Frank Ch. Eigler14d5b412020-02-03 06:29:31 -0500738 AC_MSG_NOTICE([checking debuginfod C++11 support, --disable-debuginfod to skip])
739 AX_CXX_COMPILE_STDCXX(11, noext, mandatory)
740 AC_MSG_NOTICE([checking debuginfod dependencies, --disable-debuginfod to skip])
Mark Wielaardf7f0cdc2020-06-19 19:41:08 +0200741 if test "x$enable_libdebuginfod" = "xno"; then
742 AC_MSG_ERROR([need libdebuginfod (or dummy), use --disable-debuginfod to disable.])
743 fi
Frank Ch. Eiglere27e30c2019-10-28 13:29:26 -0400744 enable_debuginfod=yes # presume success
745 PKG_PROG_PKG_CONFIG
Frank Ch. Eiglere27e30c2019-10-28 13:29:26 -0400746 PKG_CHECK_MODULES([libmicrohttpd],[libmicrohttpd >= 0.9.33],[],[enable_debuginfod=no])
Frank Ch. Eiglere27e30c2019-10-28 13:29:26 -0400747 PKG_CHECK_MODULES([sqlite3],[sqlite3 >= 3.7.17],[],[enable_debuginfod=no])
748 PKG_CHECK_MODULES([libarchive],[libarchive >= 3.1.2],[],[enable_debuginfod=no])
749 if test "x$enable_debuginfod" = "xno"; then
Frank Ch. Eigler14d5b412020-02-03 06:29:31 -0500750 AC_MSG_ERROR([dependencies not found, use --disable-debuginfod to disable.])
Frank Ch. Eiglere27e30c2019-10-28 13:29:26 -0400751 fi
752])
Aaron Merey288f6b12019-10-28 13:29:26 -0400753
Frank Ch. Eiglere27e30c2019-10-28 13:29:26 -0400754AS_IF([test "x$enable_debuginfod" != "xno"],AC_DEFINE([ENABLE_DEBUGINFOD],[1],[Build debuginfod]))
Aaron Merey288f6b12019-10-28 13:29:26 -0400755AM_CONDITIONAL([DEBUGINFOD],[test "x$enable_debuginfod" = "xyes"])
756
Frank Ch. Eigler94708e92020-10-01 16:56:49 -0400757dnl for /etc/profile.d/elfutils.{csh,sh}
758default_debuginfod_urls=""
759AC_ARG_ENABLE(debuginfod-urls,
760 [AS_HELP_STRING([--enable-debuginfod-urls@<:@=URLS@:>@],[add URLS to profile.d DEBUGINFOD_URLS])],
761 [if test "x${enableval}" = "xyes";
762 then default_debuginfod_urls="https://debuginfod.elfutils.org/";
763 elif test "x${enableval}" != "xno"; then
764 default_debuginfod_urls="${enableval}";
765 fi],
766 [default_debuginfod_urls=""])
767AC_SUBST(DEBUGINFOD_URLS, $default_debuginfod_urls)
768AC_CONFIG_FILES([config/profile.sh config/profile.csh])
Aaron Merey288f6b12019-10-28 13:29:26 -0400769
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000770AC_OUTPUT
Mark Wielaard7702a3c2015-05-01 09:23:57 +0200771
772AC_MSG_NOTICE([
773=====================================================================
774 elfutils: ${PACKAGE_VERSION} (eu_version: ${eu_version})
775=====================================================================
776
777 Prefix : ${prefix}
778 Program prefix ("eu-" recommended) : ${program_prefix}
779 Source code location : ${srcdir}
780 Maintainer mode : ${enable_maintainer_mode}
Mark Wielaard7702a3c2015-05-01 09:23:57 +0200781 build arch : ${ac_cv_build}
782
783 RECOMMENDED FEATURES (should all be yes)
784 gzip support : ${with_zlib}
785 bzip2 support : ${with_bzlib}
786 lzma/xz support : ${with_lzma}
Mark Wielaard52536d72020-09-18 12:49:29 +0200787 zstd support : ${with_zstd}
Mark Wielaarde6e80da2015-05-01 10:31:36 +0200788 libstdc++ demangle support : ${enable_demangler}
Mark Wielaard7702a3c2015-05-01 09:23:57 +0200789 File textrel check : ${enable_textrelcheck}
790 Symbol versioning : ${enable_symbol_versioning}
791
792 NOT RECOMMENDED FEATURES (should all be no)
793 Experimental thread safety : ${use_locks}
Mark Wielaardb63007e2019-01-18 14:18:22 +0100794 install elf.h : ${install_elfh}
Mark Wielaard7702a3c2015-05-01 09:23:57 +0200795
796 OTHER FEATURES
797 Deterministic archives by default : ${default_ar_deterministic}
798 Native language support : ${USE_NLS}
Jonathon Anderson5e2a8e22019-08-25 09:53:50 -0500799 Extra Valgrind annotations : ${use_vg_annotations}
Mark Wielaardf7f0cdc2020-06-19 19:41:08 +0200800 libdebuginfod client support : ${enable_libdebuginfod}
801 Debuginfod server support : ${enable_debuginfod}
Frank Ch. Eigler94708e92020-10-01 16:56:49 -0400802 Default DEBUGINFOD_URLS : ${default_debuginfod_urls}
Mark Wielaard7702a3c2015-05-01 09:23:57 +0200803
804 EXTRA TEST FEATURES (used with make check)
Mark Wielaard4664fd52015-05-30 22:50:37 +0200805 have bunzip2 installed (required) : ${HAVE_BUNZIP2}
Mark Wielaard52536d72020-09-18 12:49:29 +0200806 have zstd installed : ${HAVE_ZSTD}
Mark Wielaard7702a3c2015-05-01 09:23:57 +0200807 debug branch prediction : ${use_debugpred}
808 gprof support : ${use_gprof}
809 gcov support : ${use_gcov}
810 run all tests under valgrind : ${use_valgrind}
Mark Wielaard2b250b72015-05-21 23:36:51 +0200811 gcc undefined behaviour sanitizer : ${use_undefined}
Mark Wielaard7702a3c2015-05-01 09:23:57 +0200812 use rpath in tests : ${tests_use_rpath}
813 test biarch : ${utrace_cv_cc_biarch}
814])
Mark Wielaardb63007e2019-01-18 14:18:22 +0100815
816if test "$install_elfh" = yes; then
817 if test "${prefix}" = "/usr/local" -o "${prefix}" = "/usr"; then
818 AC_MSG_WARN([installing elf.h in ${includedir} might conflict with glibc/system elf.h])
819 fi
820fi