]>
Commit | Line | Data |
---|---|---|
eff02e4f | 1 | # configure.ac -- Backtrace configure script. |
99dee823 | 2 | # Copyright (C) 2012-2021 Free Software Foundation, Inc. |
eff02e4f ILT |
3 | |
4 | # Redistribution and use in source and binary forms, with or without | |
5 | # modification, are permitted provided that the following conditions are | |
6 | # met: | |
7 | ||
8 | # (1) Redistributions of source code must retain the above copyright | |
84ebf639 | 9 | # notice, this list of conditions and the following disclaimer. |
eff02e4f ILT |
10 | |
11 | # (2) Redistributions in binary form must reproduce the above copyright | |
12 | # notice, this list of conditions and the following disclaimer in | |
13 | # the documentation and/or other materials provided with the | |
84ebf639 CL |
14 | # distribution. |
15 | ||
eff02e4f ILT |
16 | # (3) The name of the author may not be used to |
17 | # endorse or promote products derived from this software without | |
18 | # specific prior written permission. | |
19 | ||
20 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
21 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
22 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
23 | # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | |
24 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
25 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
27 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
28 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
29 | # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | # POSSIBILITY OF SUCH DAMAGE. | |
31 | ||
eff02e4f ILT |
32 | AC_INIT(package-unused, version-unused,, libbacktrace) |
33 | AC_CONFIG_SRCDIR(backtrace.h) | |
34 | AC_CONFIG_HEADER(config.h) | |
35 | ||
405a6b1c MK |
36 | if test -n "${with_target_subdir}"; then |
37 | AM_ENABLE_MULTILIB(, ..) | |
38 | fi | |
39 | ||
eff02e4f ILT |
40 | AC_CANONICAL_SYSTEM |
41 | target_alias=${target_alias-$host_alias} | |
42 | ||
d4c059d5 ILT |
43 | AC_USE_SYSTEM_EXTENSIONS |
44 | ||
eff02e4f ILT |
45 | libtool_VERSION=1:0:0 |
46 | AC_SUBST(libtool_VERSION) | |
47 | ||
af710874 ILT |
48 | # 1.11.1: Require that version of automake. |
49 | # foreign: Don't require README, INSTALL, NEWS, etc. | |
50 | # no-define: Don't define PACKAGE and VERSION. | |
51 | # no-dependencies: Don't generate automatic dependencies. | |
52 | # (because it breaks when using bootstrap-lean, since some of the | |
53 | # headers are gone at "make install" time). | |
54 | # -Wall: Issue all automake warnings. | |
55 | # -Wno-portability: Don't warn about constructs supported by GNU make. | |
56 | # (because GCC requires GNU make anyhow). | |
57 | AM_INIT_AUTOMAKE([1.11.1 foreign no-dist no-define no-dependencies -Wall -Wno-portability]) | |
eff02e4f ILT |
58 | |
59 | AM_MAINTAINER_MODE | |
60 | ||
61 | AC_ARG_WITH(target-subdir, | |
62 | [ --with-target-subdir=SUBDIR Configuring in a subdirectory for target]) | |
63 | ||
64 | # We must force CC to /not/ be precious variables; otherwise | |
65 | # the wrong, non-multilib-adjusted value will be used in multilibs. | |
66 | # As a side effect, we have to subst CFLAGS ourselves. | |
67 | m4_rename([_AC_ARG_VAR_PRECIOUS],[backtrace_PRECIOUS]) | |
68 | m4_define([_AC_ARG_VAR_PRECIOUS],[]) | |
69 | AC_PROG_CC | |
70 | m4_rename_force([backtrace_PRECIOUS],[_AC_ARG_VAR_PRECIOUS]) | |
71 | ||
72 | AC_SUBST(CFLAGS) | |
73 | ||
74 | AC_PROG_RANLIB | |
75 | ||
76 | AC_PROG_AWK | |
77 | case "$AWK" in | |
78 | "") AC_MSG_ERROR([can't build without awk]) ;; | |
79 | esac | |
80 | ||
10f48858 TV |
81 | AC_CHECK_PROG(DWZ, dwz, dwz) |
82 | AM_CONDITIONAL(HAVE_DWZ, test "$DWZ" != "") | |
83 | ||
7e5c7547 | 84 | LT_INIT |
eff02e4f ILT |
85 | AM_PROG_LIBTOOL |
86 | ||
e91a2ddc RB |
87 | AC_SYS_LARGEFILE |
88 | ||
eff02e4f ILT |
89 | backtrace_supported=yes |
90 | ||
91 | if test -n "${with_target_subdir}"; then | |
92 | # We are compiling a GCC library. We can assume that the unwind | |
93 | # library exists. | |
eff02e4f ILT |
94 | BACKTRACE_FILE="backtrace.lo simple.lo" |
95 | else | |
96 | AC_CHECK_HEADER([unwind.h], | |
97 | [AC_CHECK_FUNC([_Unwind_Backtrace], | |
98 | [BACKTRACE_FILE="backtrace.lo simple.lo"], | |
99 | [BACKTRACE_FILE="nounwind.lo" | |
100 | backtrace_supported=no])], | |
101 | [BACKTRACE_FILE="nounwind.lo" | |
102 | backtrace_supported=no]) | |
103 | fi | |
104 | AC_SUBST(BACKTRACE_FILE) | |
105 | ||
56195009 | 106 | EXTRA_FLAGS= |
32061319 | 107 | if test -n "${with_target_subdir}"; then |
36a58fb3 | 108 | EXTRA_FLAGS="-funwind-tables -frandom-seed=\$@" |
32061319 ILT |
109 | else |
110 | AC_CACHE_CHECK([for -funwind-tables option], | |
111 | [libbacktrace_cv_c_unwind_tables], | |
112 | [CFLAGS_hold="$CFLAGS" | |
113 | CFLAGS="$CFLAGS -funwind-tables" | |
114 | AC_COMPILE_IFELSE( | |
115 | [AC_LANG_PROGRAM([static int f() { return 0; }], [return f();])], | |
116 | [libbacktrace_cv_c_unwind_tables=yes], | |
117 | [libbacktrace_cv_c_unwind_tables=no]) | |
118 | CFLAGS="$CFLAGS_hold"]) | |
36a58fb3 JJ |
119 | if test "$libbacktrace_cv_c_unwind_tables" = "yes"; then |
120 | EXTRA_FLAGS=-funwind-tables | |
121 | fi | |
122 | AC_CACHE_CHECK([for -frandom-seed=string option], | |
123 | [libbacktrace_cv_c_random_seed_string], | |
124 | [CFLAGS_hold="$CFLAGS" | |
125 | CFLAGS="$CFLAGS -frandom-seed=conftest.lo" | |
126 | AC_COMPILE_IFELSE( | |
127 | [AC_LANG_PROGRAM([], [return 0;])], | |
128 | [libbacktrace_cv_c_random_seed_string=yes], | |
129 | [libbacktrace_cv_c_random_seed_string=no]) | |
130 | CFLAGS="$CFLAGS_hold"]) | |
131 | if test "$libbacktrace_cv_c_random_seed_string" = "yes"; then | |
132 | EXTRA_FLAGS="$EXTRA_FLAGS -frandom-seed=\$@" | |
133 | fi | |
56195009 | 134 | fi |
44685d37 IT |
135 | |
136 | if test -n "${with_target_subdir}"; then | |
137 | # Add CET specific flags is Intel CET is enabled. | |
138 | GCC_CET_FLAGS(CET_FLAGS) | |
139 | EXTRA_FLAGS="$EXTRA_FLAGS $CET_FLAGS" | |
140 | fi | |
56195009 UB |
141 | AC_SUBST(EXTRA_FLAGS) |
142 | ||
eff02e4f ILT |
143 | ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \ |
144 | -Wmissing-prototypes -Wold-style-definition \ | |
145 | -Wmissing-format-attribute -Wcast-qual], | |
146 | [WARN_FLAGS]) | |
147 | ||
73c3ed27 | 148 | if test -n "${with_target_subdir}"; then |
eff02e4f ILT |
149 | WARN_FLAGS="$WARN_FLAGS -Werror" |
150 | fi | |
151 | ||
152 | AC_SUBST(WARN_FLAGS) | |
153 | ||
64b89453 ILT |
154 | if test -n "${with_target_subdir}"; then |
155 | GCC_CHECK_UNWIND_GETIPINFO | |
156 | else | |
385710cf JH |
157 | ac_save_CFFLAGS="$CFLAGS" |
158 | CFLAGS="$CFLAGS -Werror-implicit-function-declaration" | |
159 | AC_MSG_CHECKING([for _Unwind_GetIPInfo]) | |
63fefb4b | 160 | AC_LINK_IFELSE( |
385710cf JH |
161 | [AC_LANG_PROGRAM( |
162 | [#include "unwind.h" | |
163 | struct _Unwind_Context *context; | |
164 | int ip_before_insn = 0;], | |
165 | [return _Unwind_GetIPInfo (context, &ip_before_insn);])], | |
166 | [have_unwind_getipinfo=yes], [have_unwind_getipinfo=no]) | |
167 | CFLAGS="$ac_save_CFLAGS" | |
168 | AC_MSG_RESULT([$have_unwind_getipinfo]) | |
64b89453 ILT |
169 | if test "$have_unwind_getipinfo" = "yes"; then |
170 | AC_DEFINE(HAVE_GETIPINFO, 1, [Define if _Unwind_GetIPInfo is available.]) | |
171 | fi | |
172 | fi | |
eff02e4f | 173 | |
7e5c7547 | 174 | # Enable --enable-host-shared. |
459260ec DM |
175 | AC_ARG_ENABLE(host-shared, |
176 | [AS_HELP_STRING([--enable-host-shared], | |
177 | [build host code as shared libraries])], | |
7e5c7547 | 178 | [PIC_FLAG=-fPIC], [PIC_FLAG=]) |
eff02e4f ILT |
179 | AC_SUBST(PIC_FLAG) |
180 | ||
d2148648 L |
181 | # Enable Intel CET on Intel CET enabled host if jit is enabled. |
182 | GCC_CET_HOST_FLAGS(CET_HOST_FLAGS) | |
183 | case x$enable_languages in | |
184 | *jit*) | |
185 | ;; | |
186 | *) | |
187 | CET_HOST_FLAGS= | |
188 | ;; | |
189 | esac | |
190 | AC_SUBST(CET_HOST_FLAGS) | |
191 | ||
eff02e4f ILT |
192 | # Test for __sync support. |
193 | AC_CACHE_CHECK([__sync extensions], | |
194 | [libbacktrace_cv_sys_sync], | |
195 | [if test -n "${with_target_subdir}"; then | |
2f401a8f JDA |
196 | case "${host}" in |
197 | hppa*-*-hpux*) libbacktrace_cv_sys_sync=no ;; | |
198 | *) libbacktrace_cv_sys_sync=yes ;; | |
199 | esac | |
eff02e4f ILT |
200 | else |
201 | AC_LINK_IFELSE( | |
202 | [AC_LANG_PROGRAM([int i;], | |
203 | [__sync_bool_compare_and_swap (&i, i, i); | |
204 | __sync_lock_test_and_set (&i, 1); | |
205 | __sync_lock_release (&i);])], | |
206 | [libbacktrace_cv_sys_sync=yes], | |
207 | [libbacktrace_cv_sys_sync=no]) | |
208 | fi]) | |
209 | BACKTRACE_SUPPORTS_THREADS=0 | |
210 | if test "$libbacktrace_cv_sys_sync" = "yes"; then | |
211 | BACKTRACE_SUPPORTS_THREADS=1 | |
212 | AC_DEFINE([HAVE_SYNC_FUNCTIONS], 1, | |
213 | [Define to 1 if you have the __sync functions]) | |
214 | fi | |
215 | AC_SUBST(BACKTRACE_SUPPORTS_THREADS) | |
216 | ||
49579c7e ILT |
217 | # Test for __atomic support. |
218 | AC_CACHE_CHECK([__atomic extensions], | |
219 | [libbacktrace_cv_sys_atomic], | |
220 | [if test -n "${with_target_subdir}"; then | |
221 | libbacktrace_cv_sys_atomic=yes | |
222 | else | |
223 | AC_LINK_IFELSE( | |
224 | [AC_LANG_PROGRAM([int i;], | |
225 | [__atomic_load_n (&i, __ATOMIC_ACQUIRE); | |
226 | __atomic_store_n (&i, 1, __ATOMIC_RELEASE);])], | |
227 | [libbacktrace_cv_sys_atomic=yes], | |
228 | [libbacktrace_cv_sys_atomic=no]) | |
229 | fi]) | |
230 | if test "$libbacktrace_cv_sys_atomic" = "yes"; then | |
231 | AC_DEFINE([HAVE_ATOMIC_FUNCTIONS], 1, | |
232 | [Define to 1 if you have the __atomic functions]) | |
233 | fi | |
234 | ||
eff02e4f ILT |
235 | # The library needs to be able to read the executable itself. Compile |
236 | # a file to determine the executable format. The awk script | |
237 | # filetype.awk prints out the file type. | |
238 | AC_CACHE_CHECK([output filetype], | |
239 | [libbacktrace_cv_sys_filetype], | |
240 | [filetype= | |
241 | AC_COMPILE_IFELSE( | |
242 | [AC_LANG_PROGRAM([int i;], [int j;])], | |
243 | [filetype=`${AWK} -f $srcdir/filetype.awk conftest.$ac_objext`], | |
244 | [AC_MSG_FAILURE([compiler failed])]) | |
245 | libbacktrace_cv_sys_filetype=$filetype]) | |
246 | ||
247 | # Match the file type to decide what files to compile. | |
248 | FORMAT_FILE= | |
e24afc10 | 249 | backtrace_supports_data=yes |
eff02e4f ILT |
250 | case "$libbacktrace_cv_sys_filetype" in |
251 | elf*) FORMAT_FILE="elf.lo" ;; | |
dea40c94 | 252 | macho) FORMAT_FILE="macho.lo" ;; |
e24afc10 TG |
253 | pecoff) FORMAT_FILE="pecoff.lo" |
254 | backtrace_supports_data=no | |
255 | ;; | |
7e2a8417 TR |
256 | xcoff*) FORMAT_FILE="xcoff.lo" |
257 | backtrace_supports_data=no | |
258 | ;; | |
eff02e4f ILT |
259 | *) AC_MSG_WARN([could not determine output file type]) |
260 | FORMAT_FILE="unknown.lo" | |
261 | backtrace_supported=no | |
262 | ;; | |
263 | esac | |
264 | AC_SUBST(FORMAT_FILE) | |
265 | ||
266 | # ELF defines. | |
267 | elfsize= | |
268 | case "$libbacktrace_cv_sys_filetype" in | |
269 | elf32) elfsize=32 ;; | |
270 | elf64) elfsize=64 ;; | |
e24afc10 | 271 | *) elfsize=unused |
eff02e4f ILT |
272 | esac |
273 | AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64]) | |
fddbc193 | 274 | AM_CONDITIONAL(HAVE_ELF, test "$FORMAT_FILE" = "elf.lo") |
eff02e4f | 275 | |
7e2a8417 TR |
276 | # XCOFF defines. |
277 | xcoffsize= | |
278 | case "$libbacktrace_cv_sys_filetype" in | |
279 | xcoff32) xcoffsize=32 ;; | |
280 | xcoff64) xcoffsize=64 ;; | |
281 | *) xcoffsize=unused | |
282 | esac | |
283 | AC_DEFINE_UNQUOTED([BACKTRACE_XCOFF_SIZE], [$xcoffsize], [XCOFF size: 32 or 64]) | |
284 | ||
eff02e4f ILT |
285 | BACKTRACE_SUPPORTED=0 |
286 | if test "$backtrace_supported" = "yes"; then | |
287 | BACKTRACE_SUPPORTED=1 | |
288 | fi | |
289 | AC_SUBST(BACKTRACE_SUPPORTED) | |
290 | ||
e24afc10 TG |
291 | BACKTRACE_SUPPORTS_DATA=0 |
292 | if test "$backtrace_supports_data" = "yes"; then | |
293 | BACKTRACE_SUPPORTS_DATA=1 | |
294 | fi | |
295 | AC_SUBST(BACKTRACE_SUPPORTS_DATA) | |
296 | ||
76850556 RO |
297 | GCC_HEADER_STDINT(gstdint.h) |
298 | ||
eff02e4f ILT |
299 | AC_CHECK_HEADERS(sys/mman.h) |
300 | if test "$ac_cv_header_sys_mman_h" = "no"; then | |
301 | have_mmap=no | |
302 | else | |
303 | if test -n "${with_target_subdir}"; then | |
304 | # When built as a GCC target library, we can't do a link test. We | |
305 | # simply assume that if we have mman.h, we have mmap. | |
306 | have_mmap=yes | |
1b533361 | 307 | case "${host}" in |
2f2aeda9 UW |
308 | *-*-msdosdjgpp) |
309 | # DJGPP has sys/man.h, but no mmap | |
1b533361 UW |
310 | have_mmap=no ;; |
311 | esac | |
eff02e4f ILT |
312 | else |
313 | AC_CHECK_FUNC(mmap, [have_mmap=yes], [have_mmap=no]) | |
314 | fi | |
315 | fi | |
316 | if test "$have_mmap" = "no"; then | |
317 | VIEW_FILE=read.lo | |
318 | ALLOC_FILE=alloc.lo | |
319 | else | |
320 | VIEW_FILE=mmapio.lo | |
22e05272 | 321 | AC_PREPROC_IFELSE([AC_LANG_SOURCE([ |
eff02e4f ILT |
322 | #include <sys/mman.h> |
323 | #if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON) | |
324 | #error no MAP_ANONYMOUS | |
325 | #endif | |
22e05272 | 326 | ])], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo]) |
eff02e4f ILT |
327 | fi |
328 | AC_SUBST(VIEW_FILE) | |
329 | AC_SUBST(ALLOC_FILE) | |
330 | ||
331 | BACKTRACE_USES_MALLOC=0 | |
332 | if test "$ALLOC_FILE" = "alloc.lo"; then | |
333 | BACKTRACE_USES_MALLOC=1 | |
334 | fi | |
335 | AC_SUBST(BACKTRACE_USES_MALLOC) | |
336 | ||
e561a992 ILT |
337 | # Check for dl_iterate_phdr. |
338 | AC_CHECK_HEADERS(link.h) | |
339 | if test "$ac_cv_header_link_h" = "no"; then | |
340 | have_dl_iterate_phdr=no | |
341 | else | |
342 | if test -n "${with_target_subdir}"; then | |
343 | # When built as a GCC target library, we can't do a link test. | |
344 | AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes], | |
345 | [have_dl_iterate_phdr=no]) | |
346 | else | |
347 | AC_CHECK_FUNC([dl_iterate_phdr], [have_dl_iterate_phdr=yes], | |
348 | [have_dl_iterate_phdr=no]) | |
349 | fi | |
350 | fi | |
351 | if test "$have_dl_iterate_phdr" = "yes"; then | |
352 | AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.]) | |
353 | fi | |
354 | ||
dea40c94 ILT |
355 | # Check for header file for Mach-O image functions. |
356 | AC_CHECK_HEADERS(mach-o/dyld.h) | |
357 | ||
7e2a8417 TR |
358 | # Check for loadquery. |
359 | AC_CHECK_HEADERS(sys/ldr.h) | |
360 | if test "$ac_cv_header_sys_ldr_h" = "no"; then | |
361 | have_loadquery=no | |
362 | else | |
363 | if test -n "${with_target_subdir}"; then | |
364 | # When built as a GCC target library, we can't do a link test. | |
365 | AC_EGREP_HEADER([loadquery], [sys/ldr.h], [have_loadquery=yes], | |
366 | [have_loadquery=no]) | |
367 | else | |
368 | AC_CHECK_FUNC([loadquery], [have_loadquery=yes], | |
369 | [have_loadquery=no]) | |
370 | fi | |
371 | fi | |
372 | if test "$have_loadquery" = "yes"; then | |
373 | AC_DEFINE(HAVE_LOADQUERY, 1, [Define if AIX loadquery is available.]) | |
374 | fi | |
375 | ||
3319ef17 ILT |
376 | # Check for the fcntl function. |
377 | if test -n "${with_target_subdir}"; then | |
378 | case "${host}" in | |
379 | *-*-mingw*) have_fcntl=no ;; | |
380 | *) have_fcntl=yes ;; | |
381 | esac | |
382 | else | |
383 | AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no]) | |
384 | fi | |
385 | if test "$have_fcntl" = "yes"; then | |
386 | AC_DEFINE([HAVE_FCNTL], 1, | |
387 | [Define to 1 if you have the fcntl function]) | |
388 | fi | |
389 | ||
47f4703c | 390 | AC_CHECK_DECLS([strnlen, getpagesize]) |
8c2ea6b2 | 391 | AC_CHECK_FUNCS(lstat readlink) |
772a71a9 | 392 | |
33521509 ILT |
393 | # Check for getexecname function. |
394 | if test -n "${with_target_subdir}"; then | |
395 | case "${host}" in | |
396 | *-*-solaris2*) have_getexecname=yes ;; | |
397 | *) have_getexecname=no ;; | |
398 | esac | |
399 | else | |
400 | AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no]) | |
401 | fi | |
402 | if test "$have_getexecname" = "yes"; then | |
403 | AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.]) | |
404 | fi | |
405 | ||
26135684 ILT |
406 | # Check for sysctl definitions. |
407 | ||
408 | AC_CACHE_CHECK([for KERN_PROC], | |
409 | [libbacktrace_cv_proc], | |
410 | [AC_COMPILE_IFELSE( | |
411 | [AC_LANG_PROGRAM([ | |
412 | #include <sys/types.h> | |
413 | #include <sys/sysctl.h> | |
414 | ], [int mib0 = CTL_KERN; int mib1 = KERN_PROC; int mib2 = KERN_PROC_PATHNAME;])], | |
415 | [libbacktrace_cv_proc=yes], | |
416 | [libbacktrace_cv_proc=no])]) | |
417 | if test "$libbacktrace_cv_proc" = "yes"; then | |
418 | AC_DEFINE([HAVE_KERN_PROC], 1, | |
419 | [Define to 1 if you have KERN_PROC and KERN_PROC_PATHNAME in <sys/sysctl.h>.]) | |
420 | fi | |
421 | ||
422 | AC_CACHE_CHECK([for KERN_PROG_ARGS], | |
423 | [libbacktrace_cv_procargs], | |
424 | [AC_COMPILE_IFELSE( | |
425 | [AC_LANG_PROGRAM([ | |
426 | #include <sys/types.h> | |
427 | #include <sys/sysctl.h> | |
428 | ], [int mib0 = CTL_KERN; int mib1 = KERN_PROC_ARGS; int mib2 = KERN_PROC_PATHNAME;])], | |
429 | [libbacktrace_cv_procargs=yes], | |
430 | [libbacktrace_cv_procargs=no])]) | |
431 | if test "$libbacktrace_cv_procargs" = "yes"; then | |
432 | AC_DEFINE([HAVE_KERN_PROC_ARGS], 1, | |
433 | [Define to 1 if you have KERN_PROCARGS and KERN_PROC_PATHNAME in <sys/sysctl.h>.]) | |
434 | fi | |
435 | ||
dbc31f20 TS |
436 | # Check for the clock_gettime function. |
437 | AC_CHECK_FUNCS(clock_gettime) | |
dd954c67 TS |
438 | clock_gettime_link= |
439 | # At least for glibc, clock_gettime is in librt. But don't | |
440 | # pull that in if it still doesn't give us the function we want. This | |
441 | # test is copied from libgomp, and modified to not link in -lrt as | |
442 | # we're using this for test timing only. | |
443 | if test "$ac_cv_func_clock_gettime" = no; then | |
444 | AC_CHECK_LIB(rt, clock_gettime, | |
8398c1df | 445 | [CLOCK_GETTIME_LINK=-lrt |
dd954c67 TS |
446 | AC_DEFINE(HAVE_CLOCK_GETTIME, 1, |
447 | [Define to 1 if you have the `clock_gettime' function.])]) | |
448 | fi | |
8398c1df | 449 | AC_SUBST(CLOCK_GETTIME_LINK) |
dbc31f20 | 450 | |
d1609a23 ILT |
451 | dnl Test whether the compiler supports the -pthread option. |
452 | AC_CACHE_CHECK([whether -pthread is supported], | |
453 | [libgo_cv_lib_pthread], | |
454 | [CFLAGS_hold=$CFLAGS | |
455 | CFLAGS="$CFLAGS -pthread" | |
22e05272 | 456 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])], |
d1609a23 ILT |
457 | [libgo_cv_lib_pthread=yes], |
458 | [libgo_cv_lib_pthread=no]) | |
459 | CFLAGS=$CFLAGS_hold]) | |
460 | PTHREAD_CFLAGS= | |
461 | if test "$libgo_cv_lib_pthread" = yes; then | |
462 | PTHREAD_CFLAGS=-pthread | |
463 | fi | |
464 | AC_SUBST(PTHREAD_CFLAGS) | |
465 | ||
466 | AM_CONDITIONAL(HAVE_PTHREAD, test "$libgo_cv_lib_pthread" = yes) | |
467 | ||
fccb41b9 | 468 | dnl Test whether the compiler and the linker support the -gdwarf-5 option. |
c926fd82 ILT |
469 | AC_CACHE_CHECK([whether -gdwarf-5 is supported], |
470 | [libbacktrace_cv_lib_dwarf5], | |
471 | [CFLAGS_hold=$CFLAGS | |
472 | CFLAGS="$CFLAGS -gdwarf-5" | |
fccb41b9 | 473 | AC_LINK_IFELSE([AC_LANG_PROGRAM([int i;], [return 0;])], |
c926fd82 ILT |
474 | [libbacktrace_cv_lib_dwarf5=yes], |
475 | [libbacktrace_cv_lib_dwarf5=no]) | |
476 | CFLAGS=$CFLAGS_hold]) | |
477 | AM_CONDITIONAL(HAVE_DWARF5, test "$libbacktrace_cv_lib_dwarf5" = yes) | |
478 | ||
2206fb89 IB |
479 | AC_CHECK_LIB([z], [compress], |
480 | [AC_DEFINE(HAVE_ZLIB, 1, [Define if -lz is available.])]) | |
8da872d9 ILT |
481 | AM_CONDITIONAL(HAVE_ZLIB, test "$ac_cv_lib_z_compress" = yes) |
482 | ||
483 | dnl Test whether the linker supports the --compress_debug_sections option. | |
484 | AC_CACHE_CHECK([whether --compress-debug-sections is supported], | |
485 | [libgo_cv_ld_compress], | |
486 | [LDFLAGS_hold=$LDFLAGS | |
487 | LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zlib-gnu" | |
488 | AC_LINK_IFELSE([AC_LANG_PROGRAM(,)], | |
489 | [libgo_cv_ld_compress=yes], | |
490 | [libgo_cv_ld_compress=no]) | |
491 | LDFLAGS=$LDFLAGS_hold]) | |
492 | AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG, test "$libgo_cv_ld_compress" = yes) | |
493 | ||
9283471b ILT |
494 | AC_ARG_VAR(OBJCOPY, [location of objcopy]) |
495 | AC_CHECK_PROG(OBJCOPY, objcopy, objcopy,) | |
fddbc193 | 496 | AC_CHECK_PROG(READELF, readelf, readelf) |
9283471b ILT |
497 | AC_CACHE_CHECK([whether objcopy supports debuglink], |
498 | [libbacktrace_cv_objcopy_debuglink], | |
499 | [if test -n "${with_target_subdir}"; then | |
500 | libbacktrace_cv_objcopy_debuglink=no | |
dea40c94 ILT |
501 | elif ! test -n "${OBJCOPY}"; then |
502 | libbacktrace_cv_objcopy_debuglink=no | |
3e2f329e | 503 | elif ${OBJCOPY} --help | fgrep add-gnu-debuglink >/dev/null 2>&1; then |
9283471b ILT |
504 | libbacktrace_cv_objcopy_debuglink=yes |
505 | else | |
506 | libbacktrace_cv_objcopy_debuglink=no | |
507 | fi]) | |
508 | AM_CONDITIONAL(HAVE_OBJCOPY_DEBUGLINK, test "$libbacktrace_cv_objcopy_debuglink" = yes) | |
509 | ||
dea40c94 ILT |
510 | AC_ARG_VAR(DSYMUTIL, [location of dsymutil]) |
511 | AC_CHECK_PROG(DSYMUTIL, dsymutil, dsymutil) | |
7c363a4e | 512 | AM_CONDITIONAL(USE_DSYMUTIL, test -n "${DSYMUTIL}" -a "$FORMAT_FILE" = "macho.lo") |
dea40c94 | 513 | |
05f40bc4 ILT |
514 | AC_ARG_VAR(NM, [location of nm]) |
515 | AC_CHECK_PROG(NM, nm, nm) | |
516 | ||
517 | AC_CHECK_PROG(XZ, xz, xz) | |
518 | AM_CONDITIONAL(HAVE_XZ, test "$XZ" != "") | |
519 | AC_CHECK_PROG(COMM, comm, comm) | |
520 | AM_CONDITIONAL(HAVE_COMM, test "$COMM" != "") | |
521 | ||
522 | AM_CONDITIONAL(HAVE_MINIDEBUG, | |
523 | test "${with_target_subdir}" = "" -a "$FORMAT_FILE" = "elf.lo" -a "${OBJCOPY}" != "" -a "${NM}" != "" -a "${XZ}" != "" -a "${COMM}" != "") | |
524 | ||
525 | AC_CHECK_LIB([lzma], [lzma_auto_decoder], | |
526 | [AC_DEFINE(HAVE_LIBLZMA, 1, [Define if -llzma is available.])]) | |
527 | AM_CONDITIONAL(HAVE_LIBLZMA, test "$ac_cv_lib_lzma_lzma_auto_decoder" = yes) | |
528 | ||
eff02e4f ILT |
529 | AC_CACHE_CHECK([whether tests can run], |
530 | [libbacktrace_cv_sys_native], | |
531 | [AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])], | |
532 | [libbacktrace_cv_sys_native=yes], | |
533 | [libbacktrace_cv_sys_native=no], | |
534 | [libbacktrace_cv_sys_native=no])]) | |
535 | AM_CONDITIONAL(NATIVE, test "$libbacktrace_cv_sys_native" = "yes") | |
536 | ||
537 | if test "${multilib}" = "yes"; then | |
538 | multilib_arg="--enable-multilib" | |
539 | else | |
540 | multilib_arg= | |
541 | fi | |
542 | ||
543 | AC_CONFIG_FILES(Makefile backtrace-supported.h) | |
fddbc193 | 544 | AC_CONFIG_FILES(install-debuginfo-for-buildid.sh, chmod +x install-debuginfo-for-buildid.sh) |
eff02e4f ILT |
545 | |
546 | # We need multilib support, but only if configuring for the target. | |
547 | AC_CONFIG_COMMANDS([default], | |
548 | [if test -n "$CONFIG_FILES"; then | |
549 | if test -n "${with_target_subdir}"; then | |
550 | # Multilibs need MULTISUBDIR defined correctly in certain makefiles so | |
551 | # that multilib installs will end up installed in the correct place. | |
552 | # The testsuite needs it for multilib-aware ABI baseline files. | |
553 | # To work around this not being passed down from config-ml.in -> | |
554 | # srcdir/Makefile.am -> srcdir/{src,libsupc++,...}/Makefile.am, manually | |
555 | # append it here. Only modify Makefiles that have just been created. | |
556 | # | |
557 | # Also, get rid of this simulated-VPATH thing that automake does. | |
558 | cat > vpsed << \_EOF | |
559 | s!`test -f '$<' || echo '$(srcdir)/'`!! | |
560 | _EOF | |
561 | for i in $SUBDIRS; do | |
562 | case $CONFIG_FILES in | |
563 | *${i}/Makefile*) | |
564 | #echo "Adding MULTISUBDIR to $i/Makefile" | |
565 | sed -f vpsed $i/Makefile > tmp | |
566 | grep '^MULTISUBDIR =' Makefile >> tmp | |
567 | mv tmp $i/Makefile | |
568 | ;; | |
569 | esac | |
570 | done | |
571 | rm vpsed | |
572 | fi | |
573 | fi | |
574 | ], | |
575 | [ | |
576 | # Variables needed in config.status (file generation) which aren't already | |
577 | # passed by autoconf. | |
578 | SUBDIRS="$SUBDIRS" | |
579 | ]) | |
580 | ||
581 | AC_OUTPUT |