]> git.ipfire.org Git - thirdparty/elfutils.git/blame - configure.ac
PR 30991: srcfiles tarball feature
[thirdparty/elfutils.git] / configure.ac
CommitLineData
b08d5a8f
UD
1dnl Process this file with autoconf to produce a configure script.
2dnl Configure input file for elfutils. -*-autoconf-*-
3dnl
e27e30ca 4dnl Copyright (C) 1996-2019 Red Hat, Inc.
c9c055a6 5dnl Copyright (C) 2022, 2023 Mark J. Wielaard <mark@klomp.org>
b08d5a8f 6dnl
de2ed97f 7dnl This file is part of elfutils.
b08d5a8f 8dnl
de2ed97f
MW
9dnl This file is free software; you can redistribute it and/or modify
10dnl it under the terms of the GNU General Public License as published by
11dnl the Free Software Foundation; either version 3 of the License, or
12dnl (at your option) any later version.
b08d5a8f 13dnl
de2ed97f
MW
14dnl elfutils is distributed in the hope that it will be useful, but
15dnl WITHOUT ANY WARRANTY; without even the implied warranty of
16dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17dnl GNU General Public License for more details.
b08d5a8f 18dnl
de2ed97f
MW
19dnl You should have received a copy of the GNU General Public License
20dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
3b5072e2 21AC_INIT([elfutils],[0.190],[https://sourceware.org/bugzilla],[elfutils],[http://elfutils.org/])
b08d5a8f 22
34b037b8
MW
23dnl Workaround for older autoconf < 2.64
24m4_ifndef([AC_PACKAGE_URL],
25 [AC_DEFINE([PACKAGE_URL], ["http://elfutils.org/"],
26 [Define to home page for this package])
27 AC_SUBST([PACKAGE_URL], ["http://elfutils.org/"])])
28
fc5e808d
DL
29LIBDEBUGINFOD_SONAME=libdebuginfod.so.1
30AC_SUBST([LIBDEBUGINFOD_SONAME])
31
9ba24584
MW
32# We want eu- as default program prefix if none was given by the user.
33# But if the user explicitly provided --program-prefix="" then pretend
34# it wasn't set at all (NONE). We want to test this really early before
35# configure has a chance to use the value.
36
37if test "x$program_prefix" = "xNONE"; then
38 AC_MSG_NOTICE([No --program-prefix given, using "eu-"])
39 program_prefix="eu-"
40elif test "x$program_prefix" = "x"; then
41 AC_MSG_NOTICE([Using no program-prefix])
42 program_prefix=NONE
43fi
44
b08d5a8f
UD
45AC_CONFIG_AUX_DIR([config])
46AC_CONFIG_FILES([config/Makefile])
47
67a187d4 48AC_COPYRIGHT([Copyright (C) 1996-2023 The elfutils developers.])
db12f164 49AC_PREREQ(2.63) dnl Minimum Autoconf version required.
b08d5a8f 50
9aa8ef7f 51dnl We use GNU make extensions; automake 1.10 defaults to -Wportability.
86be792c 52AM_INIT_AUTOMAKE([gnits 1.11 -Wno-portability dist-bzip2 no-dist-gzip parallel-tests])
c373d850 53AM_MAINTAINER_MODE
b08d5a8f 54
c04f491f
MW
55AM_SILENT_RULES([yes])
56
b08d5a8f
UD
57AC_CONFIG_SRCDIR([libelf/libelf.h])
58AC_CONFIG_FILES([Makefile])
59AC_CONFIG_HEADERS([config.h])
60
b08d5a8f
UD
61dnl The RPM spec file. We substitute a few values in the file.
62AC_CONFIG_FILES([elfutils.spec:config/elfutils.spec.in])
63
288f6b19 64dnl debuginfo-server client & server parts.
fc5e808d 65AC_CONFIG_FILES([debuginfod/Makefile debuginfod/debuginfod.h])
b08d5a8f
UD
66
67AC_CANONICAL_HOST
68
3284b799
RM
69AC_ARG_ENABLE(deterministic-archives,
70[AS_HELP_STRING([--enable-deterministic-archives],
71 [ar and ranlib default to -D behavior])], [
72if test "${enableval}" = no; then
73 default_ar_deterministic=false
74else
75 default_ar_deterministic=true
76fi], [default_ar_deterministic=false])
77AC_DEFINE_UNQUOTED(DEFAULT_AR_DETERMINISTIC, $default_ar_deterministic,
78 [Should ar and ranlib use -D behavior by default?])
79
7e678fa3 80AC_ARG_ENABLE([thread-safety],
09c9bb92
MW
81AS_HELP_STRING([--enable-thread-safety],
82 [enable thread safety of libraries EXPERIMENTAL]),
83 use_locks=$enableval, use_locks=no)
7e678fa3
UD
84AM_CONDITIONAL(USE_LOCKS, test "$use_locks" = yes)
85AS_IF([test "$use_locks" = yes], [AC_DEFINE(USE_LOCKS)])
09c9bb92
MW
86AS_IF([test "$use_locks" = yes],
87 [AC_MSG_WARN([thread-safety is EXPERIMENTAL tests might fail.])])
d56e232f 88
7e678fa3 89AH_TEMPLATE([USE_LOCKS], [Defined if libraries should be thread-safe.])
b08d5a8f 90
65b3fb51 91m4_version_prereq([2.70], [AC_PROG_CC], [AC_PROG_CC_C99])
29859f2e 92AC_PROG_CXX
b08d5a8f
UD
93AC_PROG_RANLIB
94AC_PROG_YACC
65b3fb51 95AC_PROG_LEX([noyywrap])
a45c8043
MF
96# Only available since automake 1.12
97m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
98AC_CHECK_TOOL([READELF], [readelf])
99AC_CHECK_TOOL([NM], [nm])
b08d5a8f 100
1127470a
UH
101AC_CACHE_CHECK([whether gcc supports __attribute__((visibility()))],
102 ac_cv_visibility, [dnl
103save_CFLAGS="$CFLAGS"
104CFLAGS="$save_CFLAGS -Werror"
105AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl
106int __attribute__((visibility("hidden")))
107foo (int a)
108{
109 return a;
110}])], ac_cv_visibility=yes, ac_cv_visibility=no)
111CFLAGS="$save_CFLAGS"])
112if test "$ac_cv_visibility" = "yes"; then
113 AC_DEFINE([HAVE_VISIBILITY], [1],
114 [Defined if __attribute__((visibility())) is supported])
115fi
116
17d7194d
UH
117AC_CACHE_CHECK([whether gcc supports __attribute__((gcc_struct))],
118 ac_cv_gcc_struct, [dnl
119save_CFLAGS="$CFLAGS"
120CFLAGS="$save_CFLAGS -Werror"
121AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl
122struct test { int x; } __attribute__((gcc_struct));
123])], ac_cv_gcc_struct=yes, ac_cv_gcc_struct=no)
124CFLAGS="$save_CFLAGS"])
125if test "$ac_cv_gcc_struct" = "yes"; then
126 AC_DEFINE([HAVE_GCC_STRUCT], [1],
127 [Defined if __attribute__((gcc_struct)) is supported])
128fi
129
07737584
UH
130AC_CACHE_CHECK([whether gcc supports -fPIC], ac_cv_fpic, [dnl
131save_CFLAGS="$CFLAGS"
132CFLAGS="$save_CFLAGS -fPIC -Werror"
133AC_COMPILE_IFELSE([AC_LANG_SOURCE()], ac_cv_fpic=yes, ac_cv_fpic=no)
134CFLAGS="$save_CFLAGS"
135])
136if test "$ac_cv_fpic" = "yes"; then
137 fpic_CFLAGS="-fPIC"
138else
139 fpic_CFLAGS=""
140fi
141AC_SUBST([fpic_CFLAGS])
142
143AC_CACHE_CHECK([whether gcc supports -fPIE], ac_cv_fpie, [dnl
144save_CFLAGS="$CFLAGS"
145CFLAGS="$save_CFLAGS -fPIE -Werror"
146AC_COMPILE_IFELSE([AC_LANG_SOURCE()], ac_cv_fpie=yes, ac_cv_fpie=no)
147CFLAGS="$save_CFLAGS"
148])
149if test "$ac_cv_fpie" = "yes"; then
150 fpie_CFLAGS="-fPIE"
151else
152 fpie_CFLAGS=""
153fi
154AC_SUBST([fpie_CFLAGS])
155
156dso_LDFLAGS="-shared"
157
3fa98a6f
IL
158NO_UNDEFINED=-Wl,--no-undefined
159AC_ARG_ENABLE([sanitize-memory],
160 AS_HELP_STRING([--enable-sanitize-memory],
161 [Use clang memory sanitizer]),
162 [use_msan=$enableval], [use_msan=no])
163if test "$use_msan" = yes; then
164 old_CFLAGS="$CFLAGS"
165 old_CXXFLAGS="$CXXFLAGS"
166 old_LDFLAGS="$LDFLAGS"
167 # -fsanitize=memory is not compatible with -D_FORTIFY_SOURCE, -Wl,-z,defs and --no-undefined
168 CFLAGS="$CFLAGS -fsanitize=memory -fsanitize-memory-track-origins -D_FORTIFY_SOURCE=0"
169 CXXFLAGS="$CXXFLAGS -fsanitize=memory -fsanitize-memory-track-origins -D_FORTIFY_SOURCE=0"
170 LDFLAGS="-shared"
171 AC_LINK_IFELSE([AC_LANG_SOURCE([int main (int argc, char **argv) { return 0; }])], use_msan=yes, use_msan=no)
a9834d7d 172 AS_IF([test "x$use_msan" = xyes],
3fa98a6f
IL
173 ac_cv_zdefs=no NO_UNDEFINED=,
174 AC_MSG_WARN([clang memory sanitizer not available])
175 CFLAGS="$old_CFLAGS" CXXFLAGS="$old_CXXFLAGS")
176 LDFLAGS="$old_LDFLAGS"
177fi
178AC_SUBST(NO_UNDEFINED)
179AM_CONDITIONAL(USE_MEMORY_SANITIZER, test "$use_msan" = yes)
180
07737584
UH
181ZDEFS_LDFLAGS="-Wl,-z,defs"
182AC_CACHE_CHECK([whether gcc supports $ZDEFS_LDFLAGS], ac_cv_zdefs, [dnl
183save_LDFLAGS="$LDFLAGS"
184LDFLAGS="$ZDEFS_LDFLAGS $save_LDFLAGS"
185AC_LINK_IFELSE([AC_LANG_PROGRAM()], ac_cv_zdefs=yes, ac_cv_zdefs=no)
186LDFLAGS="$save_LDFLAGS"
187])
188if test "$ac_cv_zdefs" = "yes"; then
189 dso_LDFLAGS="$dso_LDFLAGS $ZDEFS_LDFLAGS"
190fi
191
cf1b5fe1
MW
192# We really want build-ids. Warn and force generating them if gcc was
193# configure without --enable-linker-build-id
194AC_CACHE_CHECK([whether the compiler generates build-ids], ac_cv_buildid, [dnl
9698a399 195AC_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]))])
cf1b5fe1
MW
196if test "$ac_cv_buildid" = "no"; then
197 AC_MSG_WARN([compiler doesn't generate build-id by default])
198 LDFLAGS="$LDFLAGS -Wl,--build-id"
199fi
200
07737584
UH
201ZRELRO_LDFLAGS="-Wl,-z,relro"
202AC_CACHE_CHECK([whether gcc supports $ZRELRO_LDFLAGS], ac_cv_zrelro, [dnl
203save_LDFLAGS="$LDFLAGS"
204LDFLAGS="$ZRELRO_LDFLAGS $save_LDFLAGS"
205AC_LINK_IFELSE([AC_LANG_PROGRAM()], ac_cv_zrelro=yes, ac_cv_zrelro=no)
206LDFLAGS="$save_LDFLAGS"
207])
208if test "$ac_cv_zrelro" = "yes"; then
209 dso_LDFLAGS="$dso_LDFLAGS $ZRELRO_LDFLAGS"
210fi
211
212AC_SUBST([dso_LDFLAGS])
213
8181739c 214AC_CACHE_CHECK([for __thread support], ac_cv_tls, [dnl
e72bf15c
RM
215# Use the same flags that we use for our DSOs, so the test is representative.
216# Some old compiler/linker/libc combinations fail some ways and not others.
217save_CFLAGS="$CFLAGS"
218save_LDFLAGS="$LDFLAGS"
07737584
UH
219CFLAGS="$fpic_CFLAGS $CFLAGS"
220LDFLAGS="$dso_LDFLAGS $LDFLAGS"
8181739c 221AC_LINK_IFELSE([dnl
0a35e3ac
MW
222AC_LANG_PROGRAM([[#include <stdlib.h>
223#undef __thread
e72bf15c 224static __thread int a; int foo (int b) { return a + b; }]],
8181739c 225 [[exit (foo (0));]])],
e72bf15c
RM
226 ac_cv_tls=yes, ac_cv_tls=no)
227CFLAGS="$save_CFLAGS"
228LDFLAGS="$save_LDFLAGS"])
7e678fa3 229AS_IF([test "x$ac_cv_tls" != xyes],
8181739c 230 AC_MSG_ERROR([__thread support required]))
7e678fa3 231
98b69a97 232dnl Before 4.9 gcc doesn't ship stdatomic.h, but the necessary atomics are
77b66a71
JA
233dnl available by (at least) 4.7. So if the system doesn't have a stdatomic.h we
234dnl fall back on one copied from FreeBSD that handles the difference.
235AC_CACHE_CHECK([whether gcc provides stdatomic.h], ac_cv_has_stdatomic,
236 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdatomic.h>]])],
237 ac_cv_has_stdatomic=yes, ac_cv_has_stdatomic=no)])
238AM_CONDITIONAL(HAVE_STDATOMIC_H, test "x$ac_cv_has_stdatomic" = xyes)
239AS_IF([test "x$ac_cv_has_stdatomic" = xyes], [AC_DEFINE(HAVE_STDATOMIC_H)])
240
241AH_TEMPLATE([HAVE_STDATOMIC_H], [Define to 1 if `stdatomic.h` is provided by the
242 system, 0 otherwise.])
243
b08d5a8f
UD
244dnl This test must come as early as possible after the compiler configuration
245dnl tests, because the choice of the file model can (in principle) affect
246dnl whether functions and headers are available, whether they work, etc.
247AC_SYS_LARGEFILE
248
ee225020
MW
249dnl Older glibc had a broken fts that didn't work with Large File Systems.
250dnl We want the version that can handler LFS, but include workaround if we
251dnl get a bad one. Add define to CFLAGS (not AC_DEFINE it) since we need to
252dnl check it before including config.h (which might define _FILE_OFFSET_BITS).
253AC_CACHE_CHECK([whether fts.h is bad when included (with LFS)], ac_cv_bad_fts,
254 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <fts.h>]])],
255 ac_cv_bad_fts=no, ac_cv_bad_fts=yes)])
ad7036f1
MW
256AS_IF([test "x$ac_cv_bad_fts" = "xyes"],
257 [CFLAGS="$CFLAGS -DBAD_FTS=1" CXXFLAGS="$CXXFLAGS -DBAD_FTS=1"])
ee225020 258
29859f2e 259# See if we can add -D_FORTIFY_SOURCE=2 or =3. Don't do it if it is already
01b994e3
MW
260# (differently) defined or if it generates warnings/errors because we
261# don't use the right optimisation level (string.h will warn about that).
29859f2e 262AC_MSG_CHECKING([whether to add -D_FORTIFY_SOURCE=2 or =3 to CFLAGS])
01b994e3 263case "$CFLAGS" in
29859f2e 264 *-D_FORTIFY_SOURCE=*)
01b994e3
MW
265 AC_MSG_RESULT([no, already there])
266 ;;
267 *)
268 save_CFLAGS="$CFLAGS"
29859f2e
MW
269 # Try 3 first.
270 CFLAGS="-D_FORTIFY_SOURCE=3 $save_CFLAGS -Werror"
271 fortified_cflags=""
01b994e3
MW
272 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
273 #include <string.h>
274 int main() { return 0; }
29859f2e
MW
275 ]])], [ AC_MSG_RESULT([yes -D_FORTIFY_SOURCE=3])
276 fortified_cflags="-D_FORTIFY_SOURCE=3" ], [])
277
278 # If that didn't work, try 2.
279 if test -z "$fortified_cflags"; then
280 CFLAGS="-D_FORTIFY_SOURCE=2 $save_CFLAGS -Werror"
281 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
282 #include <string.h>
283 int main() { return 0; }
284 ]])], [ AC_MSG_RESULT([yes -D_FORTIFY_SOURCE=2])
285 fortified_cflags="-D_FORTIFY_SOURCE=2" ],
286 [ AC_MSG_RESULT([no, cannot be used])])
287 fi
288 CFLAGS="$fortified_cflags $save_CFLAGS"
289 CXXFLAGS="$fortified_cflags $CXXFLAGS"
290 ;;
01b994e3
MW
291esac
292
3cbdd387 293dnl enable debugging of branch prediction.
28a0c615 294AC_ARG_ENABLE([debugpred],
db12f164 295AS_HELP_STRING([--enable-debugpred],[build binaries with support to debug branch prediction]),
8f3002e2
MF
296[use_debugpred=$enableval], [use_debugpred=no])
297case $use_debugpred in
7702a3c1
MW
298 yes) use_debugpred_val=1 ;;
299 *) use_debugpred_val=0 ;;
8f3002e2 300esac
7702a3c1 301AC_SUBST([DEBUGPRED], $use_debugpred_val)
3cbdd387 302
98b69a97 303dnl Enable gprof support.
47be795d 304AC_ARG_ENABLE([gprof],
8f3002e2 305AS_HELP_STRING([--enable-gprof],[build binaries with gprof support]), [use_gprof=$enableval], [use_gprof=no])
47be795d
UD
306if test "$use_gprof" = yes; then
307 CFLAGS="$CFLAGS -pg"
308 LDFLAGS="$LDFLAGS -pg"
309fi
310AM_CONDITIONAL(GPROF, test "$use_gprof" = yes)
fbe998a0 311
98b69a97 312# Enable gcov support.
fbe998a0 313AC_ARG_ENABLE([gcov],
8f3002e2 314AS_HELP_STRING([--enable-gcov],[build binaries with gcov support]), [use_gcov=$enableval], [use_gcov=no])
fbe998a0
UD
315if test "$use_gcov" = yes; then
316 CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
3f81dbd2 317 CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage"
fbe998a0 318 LDFLAGS="$LDFLAGS -fprofile-arcs"
2a16a0fc
DL
319 AC_CHECK_PROG([GCOV], [gcov], [gcov])
320 AC_CHECK_PROG([LCOV], [lcov], [lcov])
321 AC_CHECK_PROG([GENHTML], [genhtml], [genhtml])
fbe998a0 322fi
39cec7a0 323AM_CONDITIONAL(GCOV, test "$use_gcov" = yes)
fbe998a0 324
2b250b75
MW
325AC_ARG_ENABLE([sanitize-undefined],
326 AS_HELP_STRING([--enable-sanitize-undefined],
327 [Use gcc undefined behaviour sanitizer]),
328 [use_undefined=$enableval], [use_undefined=no])
329if test "$use_undefined" = yes; then
330 old_CFLAGS="$CFLAGS"
331 old_CXXFLAGS="$CXXFLAGS"
332 # We explicitly use unaligned access when possible (see ALLOW_UNALIGNED)
333 # We want to fail immediately on first error, don't try to recover.
170f1bb0
MW
334 CFLAGS="$CFLAGS -fsanitize=undefined -fno-sanitize-recover"
335 CXXFLAGS="$CXXFLAGS -fsanitize=undefined -fno-sanitize-recover"
336 AC_LINK_IFELSE([AC_LANG_SOURCE([int main (int argc, char **argv) { return 0; }])], use_undefined=yes, use_undefined=no)
2b250b75
MW
337 AS_IF([test "x$use_undefined" != xyes],
338 AC_MSG_WARN([gcc undefined behaviour sanitizer not available])
339 CFLAGS="$old_CFLAGS" CXXFLAGS="$old_CXXFLAGS")
340fi
170f1bb0
MW
341case $use_undefined in
342 yes) check_undefined_val=1 ;;
343 *) check_undefined_val=0 ;;
344esac
345AC_DEFINE_UNQUOTED(CHECK_UNDEFINED, $check_undefined_val,
346 [Building with -fsanitize=undefined or not])
2b250b75 347
5ba884a5
MW
348AC_ARG_ENABLE([sanitize-address],
349 AS_HELP_STRING([--enable-sanitize-address],
350 [Use gcc address sanitizer]),
351 [use_address=$enableval], [use_address=no])
352if test "$use_address" = yes; then
353 old_CFLAGS="$CFLAGS"
354 old_CXXFLAGS="$CXXFLAGS"
355 old_LDFLAGS="$LDFLAGS"
356 # We want to fail immediately on first error, don't try to recover.
357 CFLAGS="$CFLAGS -fsanitize=address -fno-sanitize-recover"
358 CXXFLAGS="$CXXFLAGS -fsanitize=address -fno-sanitize-recover"
359 # Some compilers don't handle -fsanatize=address correctly with --no-undefined
360 LDFLAGS="-Wl,-z,defs -shared"
361 AC_LINK_IFELSE([AC_LANG_SOURCE([int main (int argc, char **argv) { return 0; }])], use_address=yes, use_address=no)
362 AS_IF([test "x$use_address" != xyes],
363 AC_MSG_WARN([gcc address sanitizer not available])
364 CFLAGS="$old_CFLAGS" CXXFLAGS="$old_CXXFLAGS")
365 LDFLAGS="$old_LDFLAGS"
366fi
367AM_CONDITIONAL(USE_ADDRESS_SANITIZER, test "$use_address" = yes)
368
e3e3ee26
MW
369AC_ARG_ENABLE([valgrind],
370AS_HELP_STRING([--enable-valgrind],[run all tests under valgrind]),
371[use_valgrind=$enableval], [use_valgrind=no])
372if test "$use_valgrind" = yes; then
5ba884a5
MW
373 if test "$use_address" = yes; then
374 AC_MSG_ERROR([cannot enable valgrind and sanitize address together])
375 fi
e3e3ee26
MW
376 AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no)
377 if test "$HAVE_VALGRIND" = "no"; then
378 AC_MSG_ERROR([valgrind not found])
379 fi
380fi
381AM_CONDITIONAL(USE_VALGRIND, test "$use_valgrind" = yes)
382
5e2a8e25
JA
383AC_ARG_WITH([valgrind],
384AS_HELP_STRING([--with-valgrind],[include directory for Valgrind headers]),
385[with_valgrind_headers=$withval], [with_valgrind_headers=no])
386if test "x$with_valgrind_headers" != xno; then
387 save_CFLAGS="$CFLAGS"
388 CFLAGS="$CFLAGS -I$with_valgrind_headers"
389 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
390 #include <valgrind/valgrind.h>
391 int main() { return 0; }
392 ]])], [ HAVE_VALGRIND_HEADERS="yes"
393 CFLAGS="$save_CFLAGS -I$with_valgrind_headers" ],
394 [ AC_MSG_ERROR([invalid valgrind include directory: $with_valgrind_headers]) ])
395fi
396
397AC_ARG_ENABLE([valgrind-annotations],
398AS_HELP_STRING([--enable-valgrind-annotations],[insert extra annotations for better valgrind support]),
399[use_vg_annotations=$enableval], [use_vg_annotations=no])
400if test "$use_vg_annotations" = yes; then
401 if test "x$HAVE_VALGRIND_HEADERS" != "xyes"; then
402 AC_MSG_CHECKING([whether Valgrind headers are available])
403 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
404 #include <valgrind/valgrind.h>
405 int main() { return 0; }
406 ]])], [ AC_MSG_RESULT([yes]) ],
407 [ AC_MSG_ERROR([valgrind annotations requested but no headers are available]) ])
408 fi
409fi
410AM_CONDITIONAL(USE_VG_ANNOTATIONS, test "$use_vg_annotations" = yes)
411
b63007ed
MW
412AC_ARG_ENABLE([install-elfh],
413AS_HELP_STRING([--enable-install-elfh],[install elf.h in include dir]),
414 [install_elfh=$enableval], [install_elfh=no])
415AM_CONDITIONAL(INSTALL_ELFH, test "$install_elfh" = yes)
416
47be795d 417AM_CONDITIONAL(BUILD_STATIC, [dnl
32324794 418test "$use_gprof" = yes -o "$use_gcov" = yes])
47be795d 419
1b8b446a 420AC_ARG_ENABLE([tests-rpath],
db12f164 421AS_HELP_STRING([--enable-tests-rpath],[build $ORIGIN-using rpath into tests]),
8f3002e2 422 [tests_use_rpath=$enableval], [tests_use_rpath=no])
1b8b446a
RM
423AM_CONDITIONAL(TESTS_RPATH, test "$tests_use_rpath" = yes)
424
528cb45f 425dnl zlib is mandatory.
bca43152
RM
426save_LIBS="$LIBS"
427LIBS=
24169646 428eu_ZIPLIB(zlib,ZLIB,z,gzdirect,gzip)
2d703bf1 429AS_IF([test "x$with_zlib" = xno], [AC_MSG_ERROR([zlib not found but is required])])
528cb45f
MW
430LIBS="$save_LIBS"
431
52536d7d
MW
432dnl Test for bzlib and xz/lzma/zstd, gives BZLIB/LZMALIB/ZSTD .am
433dnl conditional and config.h USE_BZLIB/USE_LZMALIB/USE_ZSTD #define.
528cb45f
MW
434save_LIBS="$LIBS"
435LIBS=
24169646 436eu_ZIPLIB(bzlib,BZLIB,bz2,BZ2_bzdopen,bzip2)
0aa60ac6
MW
437# We need this since bzip2 doesn't have a pkgconfig file.
438BZ2_LIB="$LIBS"
439AC_SUBST([BZ2_LIB])
24169646 440eu_ZIPLIB(lzma,LZMA,lzma,lzma_auto_decoder,[LZMA (xz)])
0aa60ac6
MW
441AS_IF([test "x$with_lzma" = xyes], [LIBLZMA="liblzma"], [LIBLZMA=""])
442AC_SUBST([LIBLZMA])
52536d7d
MW
443eu_ZIPLIB(zstd,ZSTD,zstd,ZSTD_decompress,[ZSTD (zst)])
444AS_IF([test "x$with_zstd" = xyes], [LIBZSTD="libzstd"], [LIBLZSTD=""])
445AC_SUBST([LIBZSTD])
a5b07cdf
ML
446zstd_LIBS="$LIBS"
447AC_SUBST([zstd_LIBS])
bca43152
RM
448zip_LIBS="$LIBS"
449LIBS="$save_LIBS"
450AC_SUBST([zip_LIBS])
451
a5b07cdf
ML
452dnl zstd compression support requires libzstd 1.4.0+
453AS_IF([test "x$with_zstd" = xyes], [
454 PKG_PROG_PKG_CONFIG
455 PKG_CHECK_MODULES([ZSTD_COMPRESS],[libzstd >= 1.4.0],
456 [with_zstd_compress="yes"],[with_zstd_compress="no"])],
457 [with_zstd_compress="no"])
458AM_CONDITIONAL(USE_ZSTD_COMPRESS, test "x$with_zstd_compress" = "xyes")
459AS_IF([test "x$with_zstd_compress" = "xyes"],
460 [AC_DEFINE([USE_ZSTD_COMPRESS], [1], [zstd compression support])])
461
a24d52ac
AO
462AC_CHECK_DECLS([memrchr, rawmemchr],[],[],
463 [#define _GNU_SOURCE
464 #include <string.h>])
465AC_CHECK_DECLS([powerof2],[],[],[#include <sys/param.h>])
b3248e68
UH
466AC_CHECK_DECLS([mempcpy],[],[],
467 [#define _GNU_SOURCE
468 #include <string.h>])
1a13c35d
MW
469AC_CHECK_DECLS([reallocarray],[],[],
470 [#define _GNU_SOURCE
471 #include <stdlib.h>])
a24d52ac 472
3cf38698
MW
473AC_CHECK_FUNCS([process_vm_readv mremap])
474
475AS_IF([test "x$ac_cv_func_mremap" = "xno"],
476 [AC_MSG_WARN([elf_update needs mremap to support ELF_C_RDWR_MMAP])])
afffdff2 477
76c84c13
SA
478AC_CHECK_HEADERS([error.h])
479AC_CHECK_HEADERS([err.h])
480
dcb40f9c
FCE
481dnl for debuginfod concurrency heuristics
482AC_CHECK_HEADERS([sched.h])
483AC_CHECK_FUNCS([sched_getaffinity])
484AC_CHECK_HEADERS([sys/resource.h])
485AC_CHECK_FUNCS([getrlimit])
486
8db222e3
ÉR
487old_CFLAGS="$CFLAGS"
488CFLAGS="$CFLAGS -D_GNU_SOURCE"
489AC_FUNC_STRERROR_R()
490CFLAGS="$old_CFLAGS"
491
0ffe2874
IL
492AC_ARG_ENABLE([demangler],
493AS_HELP_STRING([--disable-demangler],
494 [Disable libstdc++ demangle support]),
495 [], [enable_demangler=yes])
a9834d7d 496AS_IF([test "x$enable_demangler" = xyes],
b4a16cf0
UD
497AC_CHECK_LIB([stdc++], [__cxa_demangle], [dnl
498AC_DEFINE([USE_DEMANGLE], [1], [Defined if demangling is enabled])])
1ce4a459
MF
499AM_CONDITIONAL(DEMANGLE, test "x$ac_cv_lib_stdcpp___cxa_demangle" = "xyes")
500AS_IF([test "x$ac_cv_lib_stdcpp___cxa_demangle" = "xyes"],
73e212b0
MW
501 [enable_demangler=yes],
502 [AC_MSG_ERROR([[__cxa_demangle not found in libstdc++, use --disable-demangler to disable demangler support.]])]),
0ffe2874 503AM_CONDITIONAL(DEMANGLE, false))
b4a16cf0 504
805ec833
MW
505AC_ARG_ENABLE([textrelcheck],
506AS_HELP_STRING([--disable-textrelcheck],
507 [Disable textrelcheck being a fatal error]))
508AM_CONDITIONAL(FATAL_TEXTREL, [test "x$enable_textrelcheck" != "xno"])
7702a3c1
MW
509AS_IF([test "x$enable_textrelcheck" != "xno"],
510 [enable_textrelcheck=yes],[enable_textrelcheck=no])
805ec833 511
bafacaca
MF
512AC_ARG_ENABLE([symbol-versioning],
513AS_HELP_STRING([--disable-symbol-versioning],
514 [Disable symbol versioning in shared objects]))
4a3330a9
UH
515
516AC_CACHE_CHECK([whether symbol versioning is supported], ac_cv_symbol_versioning, [dnl
517AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl
518#define NEW_VERSION(name, version) \
519 asm (".symver " #name "," #name "@@@" #version);
520int foo(int x) { return x + 1; }
521NEW_VERSION (foo, ELFUTILS_12.12)
522])], ac_cv_symbol_versioning=yes, ac_cv_symbol_versioning=no)])
523if test "$ac_cv_symbol_versioning" = "no"; then
524 if test "x$enable_symbol_versioning" != "xno"; then
525 AC_MSG_ERROR([Symbol versioning is not supported.
526 Use --disable-symbol-versioning to build without.])
527 fi
528fi
529
bafacaca
MF
530AM_CONDITIONAL(SYMBOL_VERSIONING, [test "x$enable_symbol_versioning" != "xno"])
531AS_IF([test "x$enable_symbol_versioning" = "xno"],
7702a3c1
MW
532 [AC_MSG_WARN([Disabling symbol versioning breaks ABI compatibility.])
533 enable_symbol_versioning=no],[enable_symbol_versioning=yes])
bafacaca 534
4b7953db
MW
535AC_CACHE_CHECK([whether gcc accepts -Wstack-usage], ac_cv_stack_usage, [dnl
536old_CFLAGS="$CFLAGS"
239cd48b 537CFLAGS="$CFLAGS -Wstack-usage=262144 -Werror"
4b7953db
MW
538AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
539 ac_cv_stack_usage=yes, ac_cv_stack_usage=no)
540CFLAGS="$old_CFLAGS"])
541AM_CONDITIONAL(ADD_STACK_USAGE_WARNING, [test "x$ac_cv_stack_usage" != "xno"])
542
8bc1423b
MW
543# -Wlogical-op was too fragile in the past, make sure we get a sane one.
544AC_CACHE_CHECK([whether gcc has a sane -Wlogical-op], ac_cv_logical_op, [dnl
545old_CFLAGS="$CFLAGS"
546CFLAGS="$CFLAGS -Wlogical-op -Werror"
547AC_COMPILE_IFELSE([AC_LANG_SOURCE(
548 [#define FLAG 1
549 int f (int r, int f) { return (r && (FLAG || (FLAG & f))); }])],
550 ac_cv_logical_op=yes, ac_cv_logical_op=no)
551CFLAGS="$old_CFLAGS"])
552AM_CONDITIONAL(SANE_LOGICAL_OP_WARNING,
553 [test "x$ac_cv_logical_op" != "xno"])
554
555# -Wduplicated-cond was added by GCC6
556AC_CACHE_CHECK([whether gcc accepts -Wduplicated-cond], ac_cv_duplicated_cond, [dnl
557old_CFLAGS="$CFLAGS"
239cd48b 558CFLAGS="$CFLAGS -Wduplicated-cond -Werror"
8bc1423b
MW
559AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
560 ac_cv_duplicated_cond=yes, ac_cv_duplicated_cond=no)
561CFLAGS="$old_CFLAGS"])
562AM_CONDITIONAL(HAVE_DUPLICATED_COND_WARNING,
563 [test "x$ac_cv_duplicated_cond" != "xno"])
564
6993d408
MW
565# -Wnull-dereference was added by GCC6
566AC_CACHE_CHECK([whether gcc accepts -Wnull-dereference], ac_cv_null_dereference, [dnl
567old_CFLAGS="$CFLAGS"
239cd48b 568CFLAGS="$CFLAGS -Wnull-dereference -Werror"
6993d408
MW
569AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
570 ac_cv_null_dereference=yes, ac_cv_null_dereference=no)
571CFLAGS="$old_CFLAGS"])
572AM_CONDITIONAL(HAVE_NULL_DEREFERENCE_WARNING,
573 [test "x$ac_cv_null_dereference" != "xno"])
574
a3cc8182
MW
575# -Wimplicit-fallthrough was added by GCC7
576AC_CACHE_CHECK([whether gcc accepts -Wimplicit-fallthrough], ac_cv_implicit_fallthrough, [dnl
577old_CFLAGS="$CFLAGS"
578CFLAGS="$CFLAGS -Wimplicit-fallthrough -Werror"
579AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
580 ac_cv_implicit_fallthrough=yes, ac_cv_implicit_fallthrough=no)
581CFLAGS="$old_CFLAGS"])
582AM_CONDITIONAL(HAVE_IMPLICIT_FALLTHROUGH_WARNING,
583 [test "x$ac_cv_implicit_fallthrough" != "xno"])
584
d6c85cff
TB
585# Check whether the compiler additionally accepts -Wimplicit-fallthrough=5
586# GCC accepts this and 5 means "don't parse any fallthrough comments and
587# only accept the fallthrough attribute"
588AC_CACHE_CHECK([whether the compiler accepts -Wimplicit-fallthrough=5], ac_cv_implicit_fallthrough_5, [dnl
589old_CFLAGS="$CFLAGS"
590CFLAGS="$CFLAGS -Wimplicit-fallthrough=5 -Werror"
591AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
592 ac_cv_implicit_fallthrough_5=yes, ac_cv_implicit_fallthrough_5=no)
593CFLAGS="$old_CFLAGS"])
594AM_CONDITIONAL(HAVE_IMPLICIT_FALLTHROUGH_5_WARNING,
595 [test "x$ac_cv_implicit_fallthrough_5" != "xno"])
596
555e15eb
JW
597# Assume the fallthrough attribute is supported if -Wimplict-fallthrough is supported
598if test "$ac_cv_implicit_fallthrough" = "yes"; then
599 AC_DEFINE([HAVE_FALLTHROUGH], [1],
600 [Defined if __attribute__((fallthrough)) is supported])
601fi
602
00d92d0b
TB
603AC_CACHE_CHECK([whether the compiler accepts -Wtrampolines], ac_cv_trampolines, [dnl
604old_CFLAGS="$CFLAGS"
605CFLAGS="$CFLAGS -Wtrampolines -Werror"
606AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
607 ac_cv_trampolines=yes, ac_cv_trampolines=no)
608CFLAGS="$old_CFLAGS"])
609AM_CONDITIONAL(HAVE_TRAMPOLINES_WARNING,
610 [test "x$ac_cv_trampolines" != "xno"])
611
1645d4a7
TB
612AC_CACHE_CHECK([whether the compiler accepts -Wno-packed-not-aligned], ac_cv_no_packed_not_aligned, [dnl
613old_CFLAGS="$CFLAGS"
614CFLAGS="$CFLAGS -Wno-packed-not-aligned -Werror"
615AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
616 ac_cv_no_packed_not_aligned=yes, ac_cv_no_packed_not_aligned=no)
617CFLAGS="$old_CFLAGS"])
618AM_CONDITIONAL(HAVE_NO_PACKED_NOT_ALIGNED_WARNING,
619 [test "x$ac_cv_no_packed_not_aligned" != "xno"])
620
c9c055a6
MW
621AC_CACHE_CHECK([whether the compiler accepts -Wuse-after-free=3], ac_cv_use_after_free3, [dnl
622old_CFLAGS="$CFLAGS"
623CFLAGS="$CFLAGS -Wuse-after-free=3 -Werror"
624AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
625 ac_cv_use_after_free3=yes, ac_cv_use_after_free3=no)
626CFLAGS="$old_CFLAGS"])
627AM_CONDITIONAL(HAVE_USE_AFTER_FREE3_WARNING,
628 [test "x$ac_cv_use_after_free3" != "xno"])
629
2e7fbb96
IL
630AC_CACHE_CHECK([whether the compiler accepts -fno-addrsig], ac_cv_fno_addrsig, [dnl
631old_CFLAGS="$CFLAGS"
632CFLAGS="$CFLAGS -fno-addrsig -Werror"
633AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
634 ac_cv_fno_addrsig=yes, ac_cv_fno_addrsig=no)
635CFLAGS="$old_CFLAGS"])
636AS_IF([test "x$ac_cv_fno_addrsig" = "xyes"], CFLAGS="$CFLAGS -fno-addrsig")
637
be084ccb
DL
638saved_LIBS="$LIBS"
639AC_SEARCH_LIBS([argp_parse], [argp])
640LIBS="$saved_LIBS"
641case "$ac_cv_search_argp_parse" in
642 no) AC_MSG_FAILURE([failed to find argp_parse]) ;;
643 -l*) argp_LDADD="$ac_cv_search_argp_parse" ;;
644 *) argp_LDADD= ;;
645esac
1ab3c2be
AB
646AC_SUBST([argp_LDADD])
647
da855fc9
ÉR
648saved_LIBS="$LIBS"
649AC_SEARCH_LIBS([fts_close], [fts])
650LIBS="$saved_LIBS"
651case "$ac_cv_search_fts_close" in
652 no) AC_MSG_FAILURE([failed to find fts_close]) ;;
653 -l*) fts_LIBS="$ac_cv_search_fts_close" ;;
654 *) fts_LIBS= ;;
655esac
656AC_SUBST([fts_LIBS])
657
658saved_LIBS="$LIBS"
659AC_SEARCH_LIBS([_obstack_free], [obstack])
660LIBS="$saved_LIBS"
661case "$ac_cv_search__obstack_free" in
8ffada54 662 no) AC_MSG_FAILURE([failed to find _obstack_free]) ;;
da855fc9
ÉR
663 -l*) obstack_LIBS="$ac_cv_search__obstack_free" ;;
664 *) obstack_LIBS= ;;
665esac
666AC_SUBST([obstack_LIBS])
667
b08d5a8f
UD
668dnl The directories with content.
669
670dnl Documentation.
f0a51767 671AC_CONFIG_FILES([doc/Makefile])
b08d5a8f
UD
672
673dnl Support library.
674AC_CONFIG_FILES([lib/Makefile])
675
676dnl ELF library.
2c9ee4f9 677AC_CONFIG_FILES([libelf/Makefile])
b08d5a8f
UD
678
679dnl Higher-level ELF support library.
680AC_CONFIG_FILES([libebl/Makefile])
681
9380297e
MW
682dnl DWARF-ELF Lower-level Functions support library.
683AC_CONFIG_FILES([libdwelf/Makefile])
684
b08d5a8f
UD
685dnl DWARF library.
686AC_CONFIG_FILES([libdw/Makefile])
687
688dnl Higher-level DWARF support library.
689AC_CONFIG_FILES([libdwfl/Makefile])
690
691dnl CPU handling library.
692AC_CONFIG_FILES([libcpu/Makefile])
693
694dnl Assembler library.
695AC_CONFIG_FILES([libasm/Makefile])
696
e47ab76f
RM
697dnl CPU-specific backend libraries.
698AC_CONFIG_FILES([backends/Makefile])
699
b08d5a8f
UD
700dnl Tools.
701AC_CONFIG_FILES([src/Makefile po/Makefile.in])
702
703dnl Test suite.
704AC_CONFIG_FILES([tests/Makefile])
705
0aa60ac6 706dnl pkgconfig files
288f6b19 707AC_CONFIG_FILES([config/libelf.pc config/libdw.pc config/libdebuginfod.pc])
0aa60ac6 708
dd52d2ab
DL
709dnl As long as "git grep 'PRI[diouxX]' po" reports matches in
710dnl translatable strings, we must use need-formatstring-macros here.
711AM_GNU_GETTEXT([external], [need-formatstring-macros])
712
713dnl AM_GNU_GETTEXT_VERSION is still needed for old versions
714dnl of autoreconf that do not recognize AM_GNU_GETTEXT_REQUIRE_VERSION.
715dnl 0.19.6 is the first version of gettext that provides
716dnl AM_GNU_GETTEXT_REQUIRE_VERSION support.
717AM_GNU_GETTEXT_VERSION([0.19.6])
718AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.6])
b08d5a8f 719
b4d6f0f8
RM
720dnl Appended to the config.h file.
721dnl We hide all kinds of configuration magic in lib/eu-config.h.
722AH_BOTTOM([#include <eu-config.h>])
b08d5a8f 723
fbc7245d
RM
724dnl Version compatibility header.
725AC_CONFIG_FILES([version.h:config/version.h.in])
726AC_SUBST([eu_version])
ee9d60de
RM
727
728# 1.234<whatever> -> 1234<whatever>
729case "$PACKAGE_VERSION" in
e9bf1d30 730[[0-9]].*) eu_version=`echo "$PACKAGE_VERSION" | sed 's@\.@@'` ;;
ee9d60de
RM
731*) AC_MSG_ERROR([confused by version number '$PACKAGE_VERSION']) ;;
732esac
733case "$eu_version" in
734*.*)
735 # 1234.567 -> "1234", "567"
736 eu_extra_version="${eu_version#*.}"
737 eu_version="${eu_version%%.*}"
738 case "$eu_extra_version" in
739 [[0-9]][[0-9]][[0-9]]) ;;
740 [[0-9]][[0-9]]) eu_extra_version="${eu_extra_version}0" ;;
741 [[0-9]]) eu_extra_version="${eu_extra_version}00" ;;
742 *) AC_MSG_ERROR([confused by version number '$PACKAGE_VERSION']) ;;
743 esac
744 ;;
745*)
746 eu_extra_version=000
747 ;;
748esac
749
750case "$eu_version" in
751 0[[0-9]][[0-9]][[0-9]]) eu_version="${eu_version#0}$eu_extra_version" ;;
752[[0-9]][[0-9]][[0-9]][[0-9]]) eu_version="${eu_version}$eu_extra_version" ;;
753[[0-9]][[0-9]][[0-9]]) eu_version="${eu_version}0$eu_extra_version" ;;
2c71252e 754[[0-9]][[0-9]]) eu_version="${eu_version}00$eu_extra_version";;
ee9d60de 755*) AC_MSG_ERROR([confused by version number '$PACKAGE_VERSION']) ;;
fbc7245d
RM
756esac
757
105e3984 758# Round up to the next release API (x.y) version.
e9bf1d30 759eu_version=$(( (eu_version + 999) / 1000 ))
105e3984 760
0b867460
JK
761AC_CHECK_SIZEOF(long)
762
c1e0fcb9
KM
763# On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
764# of the user_regs_struct from sys/user.h. They are structurally the same
765# but we get either one or the other.
766AC_CHECK_TYPE([struct user_regs_struct],
767 [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
768 [[#include <sys/ptrace.h>]
769 [#include <sys/time.h>]
770 [#include <sys/user.h>]])
771if test "$sys_user_has_user_regs" = "yes"; then
772 AC_DEFINE(HAVE_SYS_USER_REGS, 1,
773 [Define to 1 if <sys/user.h> defines struct user_regs_struct])
774fi
775
0b867460 776# On a 64-bit host where can can use $CC -m32, we'll run two sets of tests.
0b867460 777utrace_BIARCH
8ae9bc9d 778CC_BIARCH="$CC $utrace_biarch"
0b867460
JK
779AC_SUBST([CC_BIARCH])
780
4664fd58
MW
781# In maintainer mode we really need flex and bison.
782# Otherwise we really need a release dir with maintainer files generated.
783if test "x$enable_maintainer_mode" = xyes; then
784 AC_CHECK_PROG(HAVE_FLEX, flex, yes, no)
785 if test "$HAVE_FLEX" = "no"; then
786 AC_MSG_ERROR([flex needed in maintainer mode])
787 fi
788 AC_CHECK_PROG(HAVE_BISON, bison, yes, no)
789 if test "$HAVE_BISON" = "no"; then
790 AC_MSG_ERROR([bison needed in maintainer mode])
791 fi
d6126841
RB
792 AC_CHECK_PROG(HAVE_GAWK, gawk, yes, no)
793 if test "$HAVE_GAWK" = "no"; then
794 AC_MSG_ERROR([gawk needed in maintainer mode])
795 fi
4664fd58
MW
796else
797 if test ! -f ${srcdir}/libdw/known-dwarf.h; then
798 AC_MSG_ERROR([No libdw/known-dwarf.h. configure --enable-maintainer-mode])
799 fi
800fi
801
802# The testfiles are all compressed, we need bunzip2 when running make check
803AC_CHECK_PROG(HAVE_BUNZIP2, bunzip2, yes, no)
804if test "$HAVE_BUNZIP2" = "no"; then
805 AC_MSG_WARN([No bunzip2, needed to run make check])
806fi
807
52536d7d
MW
808# For tests that need to use zstd compression
809AC_CHECK_PROG(HAVE_ZSTD, zstd, yes, no)
810AM_CONDITIONAL([HAVE_ZSTD],[test "x$HAVE_ZSTD" = "xyes"])
811
a4fafb77
IL
812# For tests that need to use C++11
813AX_CXX_COMPILE_STDCXX(11, noext, optional)
814AS_IF([test "x$HAVE_CXX11" = "x1"], [HAVE_CXX11=yes], [HAVE_CXX11=no])
815AM_CONDITIONAL([HAVE_CXX11],[test "x$HAVE_CXX11" = "xyes"])
816
f7f0cdc5 817# Look for libcurl for libdebuginfod minimum version as per rhel7.
9a363700 818AC_ARG_ENABLE([libdebuginfod],AS_HELP_STRING([--enable-libdebuginfod], [Build debuginfod client library (can be =dummy)]))
f7f0cdc5
MW
819AS_IF([test "x$enable_libdebuginfod" != "xno"], [
820 if test "x$enable_libdebuginfod" != "xdummy"; then
821 AC_MSG_NOTICE([checking libdebuginfod dependencies, --disable-libdebuginfod or --enable-libdebuginfo=dummy to skip])
822 enable_libdebuginfod=yes # presume success
823 PKG_PROG_PKG_CONFIG
824 PKG_CHECK_MODULES([libcurl],[libcurl >= 7.29.0],[],[enable_libdebuginfod=no])
825 if test "x$enable_libdebuginfod" = "xno"; then
826 AC_MSG_ERROR([dependencies not found, use --disable-libdebuginfod to disable or --enable-libdebuginfod=dummy to build a (bootstrap) dummy library.])
827 fi
828 else
829 AC_MSG_NOTICE([building (bootstrap) dummy libdebuginfo library])
830 fi
831])
832
69fc2b3a
FCE
833AC_CHECK_LIB(pthread, pthread_setname_np, [
834 AC_DEFINE([HAVE_PTHREAD_SETNAME_NP],[1],[Enable pthread_setname_np])])
835
4ced3010
DL
836AS_IF([test "x$enable_libdebuginfod" = "xyes" || test "x$enable_libdebuginfod" = "xdummy"],
837 [AC_DEFINE([ENABLE_LIBDEBUGINFOD], [1], [Enable libdebuginfod])])
838AS_IF([test "x$enable_libdebuginfod" = "xdummy"],
839 [AC_DEFINE([DUMMY_LIBDEBUGINFOD], [1], [Build dummy libdebuginfod])])
f7f0cdc5
MW
840AM_CONDITIONAL([LIBDEBUGINFOD],[test "x$enable_libdebuginfod" = "xyes" || test "x$enable_libdebuginfod" = "xdummy"])
841AM_CONDITIONAL([DUMMY_LIBDEBUGINFOD],[test "x$enable_libdebuginfod" = "xdummy"])
7f4d556a 842AC_CHECK_HEADERS([execinfo.h])
f7f0cdc5 843
75fb8c01 844# Look for libmicrohttpd, libarchive, sqlite for debuginfo server and srcfiles tool
f7f0cdc5 845# minimum versions as per rhel7.
9a363700 846AC_ARG_ENABLE([debuginfod],AS_HELP_STRING([--enable-debuginfod], [Build debuginfod server]))
e27e30ca 847AS_IF([test "x$enable_debuginfod" != "xno"], [
a4fafb77
IL
848 if test "x$HAVE_CXX11" = "xno"; then
849 AC_MSG_ERROR([the compiler does not support C++11, use --disable-debuginfod to disable.])
850 fi
14d5b412 851 AC_MSG_NOTICE([checking debuginfod dependencies, --disable-debuginfod to skip])
f7f0cdc5
MW
852 if test "x$enable_libdebuginfod" = "xno"; then
853 AC_MSG_ERROR([need libdebuginfod (or dummy), use --disable-debuginfod to disable.])
854 fi
e27e30ca 855 enable_debuginfod=yes # presume success
75fb8c01 856 AC_DEFINE([HAVE_LIBARCHIVE], [1], [Define to 1 if libarchive is available]) # presume success
e27e30ca 857 PKG_PROG_PKG_CONFIG
e27e30ca 858 PKG_CHECK_MODULES([libmicrohttpd],[libmicrohttpd >= 0.9.33],[],[enable_debuginfod=no])
8cbadd86 859 PKG_CHECK_MODULES([oldlibmicrohttpd],[libmicrohttpd < 0.9.51],[old_libmicrohttpd=yes],[old_libmicrohttpd=no])
e27e30ca 860 PKG_CHECK_MODULES([sqlite3],[sqlite3 >= 3.7.17],[],[enable_debuginfod=no])
75fb8c01 861 PKG_CHECK_MODULES([libarchive],[libarchive >= 3.1.2],[],[enable_debuginfod=no], AC_DEFINE([HAVE_LIBARCHIVE], [0], [Define to 0 if libarchive is not available]))
e27e30ca 862 if test "x$enable_debuginfod" = "xno"; then
14d5b412 863 AC_MSG_ERROR([dependencies not found, use --disable-debuginfod to disable.])
e27e30ca
FCE
864 fi
865])
866
867AS_IF([test "x$enable_debuginfod" != "xno"],AC_DEFINE([ENABLE_DEBUGINFOD],[1],[Build debuginfod]))
288f6b19 868AM_CONDITIONAL([DEBUGINFOD],[test "x$enable_debuginfod" = "xyes"])
8cbadd86 869AM_CONDITIONAL([OLD_LIBMICROHTTPD],[test "x$old_libmicrohttpd" = "xyes"])
288f6b19 870
94708e96
FCE
871dnl for /etc/profile.d/elfutils.{csh,sh}
872default_debuginfod_urls=""
873AC_ARG_ENABLE(debuginfod-urls,
874 [AS_HELP_STRING([--enable-debuginfod-urls@<:@=URLS@:>@],[add URLS to profile.d DEBUGINFOD_URLS])],
875 [if test "x${enableval}" = "xyes";
876 then default_debuginfod_urls="https://debuginfod.elfutils.org/";
877 elif test "x${enableval}" != "xno"; then
878 default_debuginfod_urls="${enableval}";
879 fi],
880 [default_debuginfod_urls=""])
881AC_SUBST(DEBUGINFOD_URLS, $default_debuginfod_urls)
882AC_CONFIG_FILES([config/profile.sh config/profile.csh])
288f6b19 883
b08d5a8f 884AC_OUTPUT
7702a3c1
MW
885
886AC_MSG_NOTICE([
887=====================================================================
888 elfutils: ${PACKAGE_VERSION} (eu_version: ${eu_version})
889=====================================================================
890
891 Prefix : ${prefix}
892 Program prefix ("eu-" recommended) : ${program_prefix}
893 Source code location : ${srcdir}
894 Maintainer mode : ${enable_maintainer_mode}
7702a3c1
MW
895 build arch : ${ac_cv_build}
896
29859f2e
MW
897 CFLAGS=${CFLAGS}
898 CXXFLAGS=${CXXFLAGS}
899
7702a3c1
MW
900 RECOMMENDED FEATURES (should all be yes)
901 gzip support : ${with_zlib}
902 bzip2 support : ${with_bzlib}
903 lzma/xz support : ${with_lzma}
52536d7d 904 zstd support : ${with_zstd}
a5b07cdf 905 zstd compression support : ${with_zstd_compress}
e6e80dae 906 libstdc++ demangle support : ${enable_demangler}
7702a3c1
MW
907 File textrel check : ${enable_textrelcheck}
908 Symbol versioning : ${enable_symbol_versioning}
909
910 NOT RECOMMENDED FEATURES (should all be no)
911 Experimental thread safety : ${use_locks}
b63007ed 912 install elf.h : ${install_elfh}
7702a3c1
MW
913
914 OTHER FEATURES
915 Deterministic archives by default : ${default_ar_deterministic}
916 Native language support : ${USE_NLS}
5e2a8e25 917 Extra Valgrind annotations : ${use_vg_annotations}
f7f0cdc5
MW
918 libdebuginfod client support : ${enable_libdebuginfod}
919 Debuginfod server support : ${enable_debuginfod}
94708e96 920 Default DEBUGINFOD_URLS : ${default_debuginfod_urls}
7702a3c1
MW
921
922 EXTRA TEST FEATURES (used with make check)
4664fd58 923 have bunzip2 installed (required) : ${HAVE_BUNZIP2}
52536d7d 924 have zstd installed : ${HAVE_ZSTD}
a4fafb77 925 C++11 : ${HAVE_CXX11}
7702a3c1
MW
926 debug branch prediction : ${use_debugpred}
927 gprof support : ${use_gprof}
928 gcov support : ${use_gcov}
929 run all tests under valgrind : ${use_valgrind}
2b250b75 930 gcc undefined behaviour sanitizer : ${use_undefined}
5ba884a5 931 gcc address sanitizer : ${use_address}
3fa98a6f 932 clang memory sanitizer : ${use_msan}
7702a3c1
MW
933 use rpath in tests : ${tests_use_rpath}
934 test biarch : ${utrace_cv_cc_biarch}
935])
b63007ed
MW
936
937if test "$install_elfh" = yes; then
938 if test "${prefix}" = "/usr/local" -o "${prefix}" = "/usr"; then
939 AC_MSG_WARN([installing elf.h in ${includedir} might conflict with glibc/system elf.h])
940 fi
941fi