Browse Source
This adds DWARF 5 support as well as an enhanced testsuite. Patch assembled by Than McIntosh.lib

62 changed files with 17863 additions and 3829 deletions
@ -0,0 +1,136 @@
@@ -0,0 +1,136 @@
|
||||
/* allocfail.c -- Test for libbacktrace library
|
||||
Copyright (C) 2018-2019 Free Software Foundation, Inc. |
||||
|
||||
Redistribution and use in source and binary forms, with or without |
||||
modification, are permitted provided that the following conditions are |
||||
met: |
||||
|
||||
(1) Redistributions of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
(2) Redistributions in binary form must reproduce the above copyright |
||||
notice, this list of conditions and the following disclaimer in |
||||
the documentation and/or other materials provided with the |
||||
distribution. |
||||
|
||||
(3) The name of the author may not be used to |
||||
endorse or promote products derived from this software without |
||||
specific prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||||
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, |
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||||
POSSIBILITY OF SUCH DAMAGE. */ |
||||
|
||||
#include <assert.h> |
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
#include <string.h> |
||||
#include <unistd.h> |
||||
|
||||
#include "filenames.h" |
||||
|
||||
#include "backtrace.h" |
||||
#include "backtrace-supported.h" |
||||
|
||||
#include "testlib.h" |
||||
|
||||
extern uint64_t get_nr_allocs (void); |
||||
extern void set_fail_at_alloc (uint64_t); |
||||
extern int at_fail_alloc_p (void); |
||||
|
||||
static int test1 (void) __attribute__ ((noinline, unused)); |
||||
static int f2 (int) __attribute__ ((noinline)); |
||||
static int f3 (int, int) __attribute__ ((noinline)); |
||||
|
||||
static unsigned callback_errors = 0; |
||||
|
||||
static void |
||||
error_callback_full (void *vdata ATTRIBUTE_UNUSED, |
||||
const char *msg ATTRIBUTE_UNUSED, |
||||
int errnum ATTRIBUTE_UNUSED) |
||||
{ |
||||
if (at_fail_alloc_p ()) |
||||
{ |
||||
set_fail_at_alloc (0); |
||||
return; |
||||
} |
||||
|
||||
callback_errors++; |
||||
} |
||||
|
||||
static int |
||||
callback_full (void *vdata ATTRIBUTE_UNUSED, uintptr_t pc ATTRIBUTE_UNUSED, |
||||
const char *filename ATTRIBUTE_UNUSED, |
||||
int lineno ATTRIBUTE_UNUSED, |
||||
const char *function ATTRIBUTE_UNUSED) |
||||
{ |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
static int |
||||
test1 (void) |
||||
{ |
||||
return f2 (__LINE__) + 1; |
||||
} |
||||
|
||||
static int |
||||
f2 (int f1line) |
||||
{ |
||||
return f3 (f1line, __LINE__) + 2; |
||||
} |
||||
|
||||
static int |
||||
f3 (int f1line ATTRIBUTE_UNUSED, int f2line ATTRIBUTE_UNUSED) |
||||
{ |
||||
int i; |
||||
|
||||
i = backtrace_full (state, 0, callback_full, error_callback_full, NULL); |
||||
|
||||
if (i != 0) |
||||
{ |
||||
fprintf (stderr, "test1: unexpected return value %d\n", i); |
||||
++failures; |
||||
} |
||||
|
||||
if (callback_errors) |
||||
++failures; |
||||
|
||||
return failures; |
||||
} |
||||
|
||||
/* Run all the tests. */ |
||||
|
||||
int |
||||
main (int argc, char **argv) |
||||
{ |
||||
uint64_t fail_at = 0; |
||||
|
||||
if (argc == 2) |
||||
{ |
||||
fail_at = atoi (argv[1]); |
||||
set_fail_at_alloc (fail_at); |
||||
} |
||||
|
||||
state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS, |
||||
error_callback_full, NULL); |
||||
if (state == NULL) |
||||
exit (failures ? EXIT_FAILURE : EXIT_SUCCESS); |
||||
|
||||
#if BACKTRACE_SUPPORTED |
||||
test1 (); |
||||
#endif |
||||
|
||||
if (argc == 1) |
||||
fprintf (stderr, "%llu\n", (long long unsigned) get_nr_allocs ()); |
||||
|
||||
exit (failures ? EXIT_FAILURE : EXIT_SUCCESS); |
||||
} |
@ -0,0 +1,104 @@
@@ -0,0 +1,104 @@
|
||||
#!/bin/sh |
||||
|
||||
# allocfail.sh -- Test for libbacktrace library. |
||||
# Copyright (C) 2018-2019 Free Software Foundation, Inc. |
||||
|
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions are |
||||
# met: |
||||
|
||||
# (1) Redistributions of source code must retain the above copyright |
||||
# notice, this list of conditions and the following disclaimer. |
||||
|
||||
# (2) Redistributions in binary form must reproduce the above copyright |
||||
# notice, this list of conditions and the following disclaimer in |
||||
# the documentation and/or other materials provided with the |
||||
# distribution. |
||||
|
||||
# (3) The name of the author may not be used to |
||||
# endorse or promote products derived from this software without |
||||
# specific prior written permission. |
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||||
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, |
||||
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
||||
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||||
# POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
set -e |
||||
|
||||
if [ ! -f ./allocfail ]; then |
||||
# Hard failure. |
||||
exit 99 |
||||
fi |
||||
|
||||
allocs=$(./allocfail 2>&1) |
||||
if [ "$allocs" = "" ]; then |
||||
# Hard failure. |
||||
exit 99 |
||||
fi |
||||
|
||||
# This generates the following output: |
||||
# ... |
||||
# $ allocfail.sh |
||||
# allocs: 80495 |
||||
# Status changed to 0 at 1 |
||||
# Status changed to 1 at 3 |
||||
# Status changed to 0 at 11 |
||||
# Status changed to 1 at 12 |
||||
# Status changed to 0 at 845 |
||||
# ... |
||||
# |
||||
# We have status 0 for an allocation failure at: |
||||
# - 1 because backtrace_create_state handles failure robustly |
||||
# - 2 because the fail switches backtrace_full to !can_alloc mode. |
||||
# - 11 because failure of elf_open_debugfile_by_buildid does not generate an |
||||
# error callback beyond the one for the allocation failure itself. |
||||
|
||||
echo "allocs: $allocs" |
||||
|
||||
step=1 |
||||
i=1 |
||||
passes=0 |
||||
prev_status=-1 |
||||
while [ $i -le $allocs ]; do |
||||
if ./allocfail $i >/dev/null 2>&1; status=$?; then |
||||
true |
||||
fi |
||||
if [ $status -gt 1 ]; then |
||||
echo "Unallowed fail found: $i" |
||||
# Failure. |
||||
exit 1 |
||||
fi |
||||
|
||||
# The test-case would run too long if we would excercise all allocs. |
||||
# So, run with step 1 initially, and increase the step once we have 10 |
||||
# subsequent passes, and drop back to step 1 once we encounter another |
||||
# failure. This takes ~2.6 seconds on an i7-6600U CPU @ 2.60GHz. |
||||
if [ $status -eq 0 ]; then |
||||
passes=$(($passes + 1)) |
||||
if [ $passes -ge 10 ]; then |
||||
step=$((step * 10)) |
||||
passes=0 |
||||
fi |
||||
elif [ $status -eq 1 ]; then |
||||
passes=0 |
||||
step=1 |
||||
fi |
||||
|
||||
if [ $status -ne $prev_status ]; then |
||||
echo "Status changed to $status at $i" |
||||
fi |
||||
prev_status=$status |
||||
|
||||
i=$(($i + $step)) |
||||
done |
||||
|
||||
# Success. |
||||
exit 0 |
@ -0,0 +1,348 @@
@@ -0,0 +1,348 @@
|
||||
#! /bin/sh |
||||
# Wrapper for compilers which do not understand '-c -o'. |
||||
|
||||
scriptversion=2016-01-11.22; # UTC |
||||
|
||||
# Copyright (C) 1999-2017 Free Software Foundation, Inc. |
||||
# Written by Tom Tromey <tromey@cygnus.com>. |
||||
# |
||||
# This program is free software; you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License as published by |
||||
# the Free Software Foundation; either version 2, or (at your option) |
||||
# any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
||||
# As a special exception to the GNU General Public License, if you |
||||
# distribute this file as part of a program that contains a |
||||
# configuration script generated by Autoconf, you may include it under |
||||
# the same distribution terms that you use for the rest of that program. |
||||
|
||||
# This file is maintained in Automake, please report |
||||
# bugs to <bug-automake@gnu.org> or send patches to |
||||
# <automake-patches@gnu.org>. |
||||
|
||||
nl=' |
||||
' |
||||
|
||||
# We need space, tab and new line, in precisely that order. Quoting is |
||||
# there to prevent tools from complaining about whitespace usage. |
||||
IFS=" "" $nl" |
||||
|
||||
file_conv= |
||||
|
||||
# func_file_conv build_file lazy |
||||
# Convert a $build file to $host form and store it in $file |
||||
# Currently only supports Windows hosts. If the determined conversion |
||||
# type is listed in (the comma separated) LAZY, no conversion will |
||||
# take place. |
||||
func_file_conv () |
||||
{ |
||||
file=$1 |
||||
case $file in |
||||
/ | /[!/]*) # absolute file, and not a UNC file |
||||
if test -z "$file_conv"; then |
||||
# lazily determine how to convert abs files |
||||
case `uname -s` in |
||||
MINGW*) |
||||
file_conv=mingw |
||||
;; |
||||
CYGWIN*) |
||||
file_conv=cygwin |
||||
;; |
||||
*) |
||||
file_conv=wine |
||||
;; |
||||
esac |
||||
fi |
||||
case $file_conv/,$2, in |
||||
*,$file_conv,*) |
||||
;; |
||||
mingw/*) |
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` |
||||
;; |
||||
cygwin/*) |
||||
file=`cygpath -m "$file" || echo "$file"` |
||||
;; |
||||
wine/*) |
||||
file=`winepath -w "$file" || echo "$file"` |
||||
;; |
||||
esac |
||||
;; |
||||
esac |
||||
} |
||||
|
||||
# func_cl_dashL linkdir |
||||
# Make cl look for libraries in LINKDIR |
||||
func_cl_dashL () |
||||
{ |
||||
func_file_conv "$1" |
||||
if test -z "$lib_path"; then |
||||
lib_path=$file |
||||
else |
||||
lib_path="$lib_path;$file" |
||||
fi |
||||
linker_opts="$linker_opts -LIBPATH:$file" |
||||
} |
||||
|
||||
# func_cl_dashl library |
||||
# Do a library search-path lookup for cl |
||||
func_cl_dashl () |
||||
{ |
||||
lib=$1 |
||||
found=no |
||||
save_IFS=$IFS |
||||
IFS=';' |
||||
for dir in $lib_path $LIB |
||||
do |
||||
IFS=$save_IFS |
||||
if $shared && test -f "$dir/$lib.dll.lib"; then |
||||
found=yes |
||||
lib=$dir/$lib.dll.lib |
||||
break |
||||
fi |
||||
if test -f "$dir/$lib.lib"; then |
||||
found=yes |
||||
lib=$dir/$lib.lib |
||||
break |
||||
fi |
||||
if test -f "$dir/lib$lib.a"; then |
||||
found=yes |
||||
lib=$dir/lib$lib.a |
||||
break |
||||
fi |
||||
done |
||||
IFS=$save_IFS |
||||
|
||||
if test "$found" != yes; then |
||||
lib=$lib.lib |
||||
fi |
||||
} |
||||
|
||||
# func_cl_wrapper cl arg... |
||||
# Adjust compile command to suit cl |
||||
func_cl_wrapper () |
||||
{ |
||||
# Assume a capable shell |
||||
lib_path= |
||||
shared=: |
||||
linker_opts= |
||||
for arg |
||||
do |
||||
if test -n "$eat"; then |
||||
eat= |
||||
else |
||||
case $1 in |
||||
-o) |
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'. |
||||
eat=1 |
||||
case $2 in |
||||
*.o | *.[oO][bB][jJ]) |
||||
func_file_conv "$2" |
||||
set x "$@" -Fo"$file" |
||||
shift |
||||
;; |
||||
*) |
||||
func_file_conv "$2" |
||||
set x "$@" -Fe"$file" |
||||
shift |
||||
;; |
||||
esac |
||||
;; |
||||
-I) |
||||
eat=1 |
||||
func_file_conv "$2" mingw |
||||
set x "$@" -I"$file" |
||||
shift |
||||
;; |
||||
-I*) |
||||
func_file_conv "${1#-I}" mingw |
||||
set x "$@" -I"$file" |
||||
shift |
||||
;; |
||||
-l) |
||||
eat=1 |
||||
func_cl_dashl "$2" |
||||
set x "$@" "$lib" |
||||
shift |
||||
;; |
||||
-l*) |
||||
func_cl_dashl "${1#-l}" |
||||
set x "$@" "$lib" |
||||
shift |
||||
;; |
||||
-L) |
||||
eat=1 |
||||
func_cl_dashL "$2" |
||||
;; |
||||
-L*) |
||||
func_cl_dashL "${1#-L}" |
||||
;; |
||||
-static) |
||||
shared=false |
||||
;; |
||||
-Wl,*) |
||||
arg=${1#-Wl,} |
||||
save_ifs="$IFS"; IFS=',' |
||||
for flag in $arg; do |
||||
IFS="$save_ifs" |
||||
linker_opts="$linker_opts $flag" |
||||
done |
||||
IFS="$save_ifs" |
||||
;; |
||||
-Xlinker) |
||||
eat=1 |
||||
linker_opts="$linker_opts $2" |
||||
;; |
||||
-*) |
||||
set x "$@" "$1" |
||||
shift |
||||
;; |
||||
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++) |
||||
func_file_conv "$1" |
||||
set x "$@" -Tp"$file" |
||||
shift |
||||
;; |
||||
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) |
||||
func_file_conv "$1" mingw |
||||
set x "$@" "$file" |
||||
shift |
||||
;; |
||||
*) |
||||
set x "$@" "$1" |
||||
shift |
||||
;; |
||||
esac |
||||
fi |
||||
shift |
||||
done |
||||
if test -n "$linker_opts"; then |
||||
linker_opts="-link$linker_opts" |
||||
fi |
||||
exec "$@" $linker_opts |
||||
exit 1 |
||||
} |
||||
|
||||
eat= |
||||
|
||||
case $1 in |
||||
'') |
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2 |
||||
exit 1; |
||||
;; |
||||
-h | --h*) |
||||
cat <<\EOF |
||||
Usage: compile [--help] [--version] PROGRAM [ARGS] |
||||
|
||||
Wrapper for compilers which do not understand '-c -o'. |
||||
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining |
||||
arguments, and rename the output as expected. |
||||
|
||||
If you are trying to build a whole package this is not the |
||||
right script to run: please start by reading the file 'INSTALL'. |
||||
|
||||
Report bugs to <bug-automake@gnu.org>. |
||||
EOF |
||||
exit $? |
||||
;; |
||||
-v | --v*) |
||||
echo "compile $scriptversion" |
||||
exit $? |
||||
;; |
||||
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ |
||||
icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) |
||||
func_cl_wrapper "$@" # Doesn't return... |
||||
;; |
||||
esac |
||||
|
||||
ofile= |
||||
cfile= |
||||
|
||||
for arg |
||||
do |
||||
if test -n "$eat"; then |
||||
eat= |
||||
else |
||||
case $1 in |
||||
-o) |
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'. |
||||
# So we strip '-o arg' only if arg is an object. |
||||
eat=1 |
||||
case $2 in |
||||
*.o | *.obj) |
||||
ofile=$2 |
||||
;; |
||||
*) |
||||
set x "$@" -o "$2" |
||||
shift |
||||
;; |
||||
esac |
||||
;; |
||||
*.c) |
||||
cfile=$1 |
||||
set x "$@" "$1" |
||||
shift |
||||
;; |
||||
*) |
||||
set x "$@" "$1" |
||||
shift |
||||
;; |
||||
esac |
||||
fi |
||||
shift |
||||
done |
||||
|
||||
if test -z "$ofile" || test -z "$cfile"; then |
||||
# If no '-o' option was seen then we might have been invoked from a |
||||
# pattern rule where we don't need one. That is ok -- this is a |
||||
# normal compilation that the losing compiler can handle. If no |
||||
# '.c' file was seen then we are probably linking. That is also |
||||
# ok. |
||||
exec "$@" |
||||
fi |
||||
|
||||
# Name of file we expect compiler to create. |
||||
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` |
||||
|
||||
# Create the lock directory. |
||||
# Note: use '[/\\:.-]' here to ensure that we don't use the same name |
||||
# that we are using for the .o file. Also, base the name on the expected |
||||
# object file name, since that is what matters with a parallel build. |
||||
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d |
||||
while true; do |
||||
if mkdir "$lockdir" >/dev/null 2>&1; then |
||||
break |
||||
fi |
||||
sleep 1 |
||||
done |
||||
# FIXME: race condition here if user kills between mkdir and trap. |
||||
trap "rmdir '$lockdir'; exit 1" 1 2 15 |
||||
|
||||
# Run the compile. |
||||
"$@" |
||||
ret=$? |
||||
|
||||
if test -f "$cofile"; then |
||||
test "$cofile" = "$ofile" || mv "$cofile" "$ofile" |
||||
elif test -f "${cofile}bj"; then |
||||
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" |
||||
fi |
||||
|
||||
rmdir "$lockdir" |
||||
exit $ret |
||||
|
||||
# Local Variables: |
||||
# mode: shell-script |
||||
# sh-indentation: 2 |
||||
# eval: (add-hook 'write-file-hooks 'time-stamp) |
||||
# time-stamp-start: "scriptversion=" |
||||
# time-stamp-format: "%:y-%02m-%02d.%02H" |
||||
# time-stamp-time-zone: "UTC0" |
||||
# time-stamp-end: "; # UTC" |
||||
# End: |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
dnl ---------------------------------------------------------------------- |
||||
dnl This whole bit snagged from libstdc++-v3. |
||||
|
||||
dnl |
||||
dnl GCC_ENABLE |
||||
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING) |
||||
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c) |
||||
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER) |
||||
dnl |
||||
dnl See docs/html/17_intro/configury.html#enable for documentation. |
||||
dnl |
||||
AC_DEFUN([GCC_ENABLE],[dnl |
||||
m4_define([_g_switch],[--enable-$1])dnl |
||||
m4_define([_g_help],[AC_HELP_STRING(_g_switch$3,[$4 @<:@default=$2@:>@])])dnl |
||||
AC_ARG_ENABLE($1,_g_help, |
||||
m4_bmatch([$5], |
||||
[^permit ], |
||||
[[ |
||||
case "$enableval" in |
||||
m4_bpatsubst([$5],[permit ])) ;; |
||||
*) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;; |
||||
dnl Idea for future: generate a URL pointing to |
||||
dnl "onlinedocs/configopts.html#whatever" |
||||
esac |
||||
]], |
||||
[^$], |
||||
[[ |
||||
case "$enableval" in |
||||
yes|no) ;; |
||||
*) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;; |
||||
esac |
||||
]], |
||||
[[$5]]), |
||||
[enable_]m4_bpatsubst([$1],-,_)[=][$2]) |
||||
m4_undefine([_g_switch])dnl |
||||
m4_undefine([_g_help])dnl |
||||
]) |
||||
|
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
# -*- Autoconf -*- |
||||
# Copyright (C) 2003, 2009 Free Software Foundation, Inc. |
||||
|
||||
# This program is free software; you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License as published by |
||||
# the Free Software Foundation; either version 3, or (at your option) |
||||
# any later version. |
||||
|
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
|
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; see the file COPYING3. If not see |
||||
# <http://www.gnu.org/licenses/>. |
||||
|
||||
# serial 1 |
||||
|
||||
# Check whether the underlying file-system supports filenames |
||||
# with a leading dot. For instance MS-DOS doesn't. |
||||
AC_DEFUN([AM_SET_LEADING_DOT], |
||||
[rm -rf .tst 2>/dev/null |
||||
mkdir .tst 2>/dev/null |
||||
if test -d .tst; then |
||||
am__leading_dot=. |
||||
else |
||||
am__leading_dot=_ |
||||
fi |
||||
rmdir .tst 2>/dev/null |
||||
AC_SUBST([am__leading_dot])]) |
@ -0,0 +1,68 @@
@@ -0,0 +1,68 @@
|
||||
## -*- Autoconf -*- |
||||
# Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2008 |
||||
# Free Software Foundation, Inc. |
||||
# |
||||
# This file is free software; the Free Software Foundation |
||||
# gives unlimited permission to copy and/or distribute it, |
||||
# with or without modifications, as long as this notice is preserved. |
||||
|
||||
# serial 6 |
||||
|
||||
# AM_ENABLE_MULTILIB([MAKEFILE], [REL-TO-TOP-SRCDIR]) |
||||
# --------------------------------------------------- |
||||
# Add --enable-multilib to configure. |
||||
AC_DEFUN([AM_ENABLE_MULTILIB], |
||||
[# Default to --enable-multilib |
||||
AC_ARG_ENABLE(multilib, |
||||
[ --enable-multilib build many library versions (default)], |
||||
[case "$enableval" in |
||||
yes) multilib=yes ;; |
||||
no) multilib=no ;; |
||||
*) AC_MSG_ERROR([bad value $enableval for multilib option]) ;; |
||||
esac], |
||||
[multilib=yes]) |
||||
|
||||
# We may get other options which we leave undocumented: |
||||
# --with-target-subdir, --with-multisrctop, --with-multisubdir |
||||
# See config-ml.in if you want the gory details. |
||||
|
||||
if test "$srcdir" = "."; then |
||||
if test "$with_target_subdir" != "."; then |
||||
multi_basedir="$srcdir/$with_multisrctop../$2" |
||||
else |
||||
multi_basedir="$srcdir/$with_multisrctop$2" |
||||
fi |
||||
else |
||||
multi_basedir="$srcdir/$2" |
||||
fi |
||||
AC_SUBST(multi_basedir) |
||||
|
||||
# Even if the default multilib is not a cross compilation, |
||||
# it may be that some of the other multilibs are. |
||||
if test $cross_compiling = no && test $multilib = yes \ |
||||
&& test "x${with_multisubdir}" != x ; then |
||||
cross_compiling=maybe |
||||
fi |
||||
|
||||
AC_OUTPUT_COMMANDS([ |
||||
# Only add multilib support code if we just rebuilt the top-level |
||||
# Makefile. |
||||
case " $CONFIG_FILES " in |
||||
*" ]m4_default([$1],Makefile)[ "*) |
||||
ac_file=]m4_default([$1],Makefile)[ . ${multi_basedir}/config-ml.in |
||||
;; |
||||
esac], |
||||
[ |
||||
srcdir="$srcdir" |
||||
host="$host" |
||||
target="$target" |
||||
with_multisubdir="$with_multisubdir" |
||||
with_multisrctop="$with_multisrctop" |
||||
with_target_subdir="$with_target_subdir" |
||||
ac_configure_args="${multilib_arg} ${ac_configure_args}" |
||||
multi_basedir="$multi_basedir" |
||||
CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} |
||||
CC="$CC" |
||||
CXX="$CXX" |
||||
GFORTRAN="$GFORTRAN" |
||||
GDC="$GDC"])])dnl |
@ -0,0 +1,116 @@
@@ -0,0 +1,116 @@
|
||||
dnl Fix Autoconf bugs by overriding broken internal Autoconf |
||||
dnl macros with backports of fixes from newer releases. |
||||
dnl |
||||
dnl The override bits of this file should be a no-op for the newest |
||||
dnl Autoconf version, which means they can be removed once the complete |
||||
dnl tree has moved to a new enough Autoconf version. |
||||
dnl |
||||
dnl The _GCC_AUTOCONF_VERSION_TEST ensures that exactly the desired |
||||
dnl Autoconf version is used. It should be kept for consistency. |
||||
|
||||
dnl Use ifdef/ifelse over m4_ifdef/m4_ifelse to be clean for 2.13. |
||||
ifdef([m4_PACKAGE_VERSION], [ |
||||
|
||||
dnl Provide m4_copy_force and m4_rename_force for old Autoconf versions. |
||||
|
||||
m4_ifndef([m4_copy_force], |
||||
[m4_define([m4_copy_force], |
||||
[m4_ifdef([$2], [m4_undefine([$2])])m4_copy($@)])]) |
||||
|
||||
m4_ifndef([m4_rename_force], |
||||
[m4_define([m4_rename_force], |
||||
[m4_ifdef([$2], [m4_undefine([$2])])m4_rename($@)])]) |
||||
|
||||
dnl AC_DEFUN a commonly used macro so this file is picked up. |
||||
m4_copy([AC_PREREQ], [_AC_PREREQ]) |
||||
AC_DEFUN([AC_PREREQ], [frob]) |
||||
m4_copy_force([_AC_PREREQ], [AC_PREREQ]) |
||||
|
||||
|
||||
dnl Ensure exactly this Autoconf version is used |
||||
m4_ifndef([_GCC_AUTOCONF_VERSION], |
||||
[m4_define([_GCC_AUTOCONF_VERSION], [2.69])]) |
||||
|
||||
dnl Test for the exact version when AC_INIT is expanded. |
||||
dnl This allows to update the tree in steps (for testing) |
||||
dnl by putting |
||||
dnl m4_define([_GCC_AUTOCONF_VERSION], [X.Y]) |
||||
dnl in configure.ac before AC_INIT, |
||||
dnl without rewriting this file. |
||||
dnl Or for updating the whole tree at once with the definition above. |
||||
AC_DEFUN([_GCC_AUTOCONF_VERSION_CHECK], |
||||
[m4_if(m4_defn([_GCC_AUTOCONF_VERSION]), |
||||
m4_defn([m4_PACKAGE_VERSION]), [], |
||||
[m4_fatal([Please use exactly Autoconf ]_GCC_AUTOCONF_VERSION[ instead of ]m4_defn([m4_PACKAGE_VERSION])[.])]) |
||||
]) |
||||
m4_define([AC_INIT], m4_defn([AC_INIT])[ |
||||
_GCC_AUTOCONF_VERSION_CHECK |
||||
]) |
||||
|
||||
|
||||
dnl Ensure we do not use a buggy M4. |
||||
m4_if(m4_index([..wi.d.], [.d.]), [-1], |
||||
[m4_fatal(m4_do([m4 with buggy strstr detected. Please install |
||||
GNU M4 1.4.16 or newer and set the M4 environment variable]))]) |
||||
|
||||
|
||||
dnl Fix 2.64 cross compile detection for AVR and RTEMS |
||||
dnl by not trying to compile fopen. |
||||
m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.64], |
||||
[m4_foreach([_GCC_LANG], [C, C++, Fortran, Fortran 77], |
||||
[m4_define([_AC_LANG_IO_PROGRAM(]_GCC_LANG[)], m4_defn([AC_LANG_PROGRAM(]_GCC_LANG[)]))])]) |
||||
|
||||
m4_version_prereq([2.66],, [ |
||||
dnl We need AC_CHECK_DECL which works for overloaded C++ functions. |
||||
|
||||
# _AC_CHECK_DECL_BODY |
||||
# ------------------- |
||||
# Shell function body for AC_CHECK_DECL. |
||||
m4_define([_AC_CHECK_DECL_BODY], |
||||
[ AS_LINENO_PUSH([$[]1]) |
||||
[as_decl_name=`echo $][2|sed 's/ *(.*//'`] |
||||
[as_decl_use=`echo $][2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`] |
||||
AC_CACHE_CHECK([whether $as_decl_name is declared], [$[]3], |
||||
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$[]4], |
||||
[@%:@ifndef $[]as_decl_name |
||||
@%:@ifdef __cplusplus |
||||
(void) $[]as_decl_use; |
||||
@%:@else |
||||
(void) $[]as_decl_name; |
||||
@%:@endif |
||||
@%:@endif |
||||
])], |
||||
[AS_VAR_SET([$[]3], [yes])], |
||||
[AS_VAR_SET([$[]3], [no])])]) |
||||
AS_LINENO_POP |
||||
])# _AC_CHECK_DECL_BODY |
||||
|
||||
# _AC_CHECK_DECLS(SYMBOL, ACTION-IF_FOUND, ACTION-IF-NOT-FOUND, |
||||
# INCLUDES) |
||||
# ------------------------------------------------------------- |
||||
# Helper to AC_CHECK_DECLS, which generates the check for a single |
||||
# SYMBOL with INCLUDES, performs the AC_DEFINE, then expands |
||||
# ACTION-IF-FOUND or ACTION-IF-NOT-FOUND. |
||||
m4_define([_AC_CHECK_DECLS], |
||||
[AC_CHECK_DECL([$1], [ac_have_decl=1], [ac_have_decl=0], [$4])]dnl |
||||
[AC_DEFINE_UNQUOTED(AS_TR_CPP(m4_bpatsubst(HAVE_DECL_[$1],[ *(.*])), |
||||
[$ac_have_decl], |
||||
[Define to 1 if you have the declaration of `$1', |
||||
and to 0 if you don't.])]dnl |
||||
[m4_ifvaln([$2$3], [AS_IF([test $ac_have_decl = 1], [$2], [$3])])]) |
||||
|
||||
]) |
||||
|
||||
dnl If flex/lex are not found, the top level configure sets LEX to |
||||
dnl "/path_to/missing flex". When AC_PROG_LEX tries to find the flex |
||||
dnl output file, it calls $LEX to do so, but the current lightweight |
||||
dnl "missing" won't create a file. This results in an error. |
||||
dnl Avoid calling the bulk of AC_PROG_LEX when $LEX is "missing". |
||||
AC_DEFUN_ONCE([AC_PROG_LEX], |
||||
[AC_CHECK_PROGS(LEX, flex lex, :) |
||||
case "$LEX" in |
||||
:|*"missing "*) ;; |
||||
*) _AC_PROG_LEX_YYTEXT_DECL ;; |
||||
esac]) |
||||
|
||||
]) |