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