Skip to content

Commit 2592200

Browse files
author
vysheng
committed
Add -lexecinfo if no bt found
1 parent 5cae1a7 commit 2592200

File tree

4 files changed

+148
-67
lines changed

4 files changed

+148
-67
lines changed

‎config.h

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
/* Define to 1 if you have the `edit' library (-ledit). */
1717
/* #undef HAVE_LIBEDIT */
1818

19+
/* Define to 1 if you have the `execinfo' library (-lexecinfo). */
20+
/* #undef HAVE_LIBEXECINFO */
21+
1922
/* Define to 1 if you have the `m' library (-lm). */
2023
#define HAVE_LIBM 1
2124

‎config.h.in

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
/* Define to 1 if you have the `edit' library (-ledit). */
1616
#undef HAVE_LIBEDIT
1717

18+
/* Define to 1 if you have the `execinfo' library (-lexecinfo). */
19+
#undef HAVE_LIBEXECINFO
20+
1821
/* Define to 1 if you have the `m' library (-lm). */
1922
#undef HAVE_LIBM
2023

‎configure

+127-67
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,73 @@ fi
14691469
14701470
} # ac_fn_c_try_link
14711471
1472+
# ac_fn_c_check_func LINENO FUNC VAR
1473+
# ----------------------------------
1474+
# Tests whether FUNC exists, setting the cache variable VAR accordingly
1475+
ac_fn_c_check_func ()
1476+
{
1477+
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1478+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
1479+
$as_echo_n "checking for $2... " >&6; }
1480+
if eval \${$3+:} false; then :
1481+
$as_echo_n "(cached) " >&6
1482+
else
1483+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1484+
/* end confdefs.h. */
1485+
/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
1486+
For example, HP-UX 11i <limits.h> declares gettimeofday. */
1487+
#define $2 innocuous_$2
1488+
1489+
/* System header to define __stub macros and hopefully few prototypes,
1490+
which can conflict with char $2 (); below.
1491+
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
1492+
<limits.h> exists even on freestanding compilers. */
1493+
1494+
#ifdef __STDC__
1495+
# include <limits.h>
1496+
#else
1497+
# include <assert.h>
1498+
#endif
1499+
1500+
#undef $2
1501+
1502+
/* Override any GCC internal prototype to avoid an error.
1503+
Use char because int might match the return type of a GCC
1504+
builtin and then its argument prototype would still apply. */
1505+
#ifdef __cplusplus
1506+
extern "C"
1507+
#endif
1508+
char $2 ();
1509+
/* The GNU C library defines this for functions which it implements
1510+
to always fail with ENOSYS. Some functions are actually named
1511+
something starting with __ and the normal name is an alias. */
1512+
#if defined __stub_$2 || defined __stub___$2
1513+
choke me
1514+
#endif
1515+
1516+
int
1517+
main ()
1518+
{
1519+
return $2 ();
1520+
;
1521+
return 0;
1522+
}
1523+
_ACEOF
1524+
if ac_fn_c_try_link "$LINENO"; then :
1525+
eval "$3=yes"
1526+
else
1527+
eval "$3=no"
1528+
fi
1529+
rm -f core conftest.err conftest.$ac_objext \
1530+
conftest$ac_exeext conftest.$ac_ext
1531+
fi
1532+
eval ac_res=\$$3
1533+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
1534+
$as_echo "$ac_res" >&6; }
1535+
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1536+
1537+
} # ac_fn_c_check_func
1538+
14721539
# ac_fn_c_try_cpp LINENO
14731540
# ----------------------
14741541
# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
@@ -1719,73 +1786,6 @@ $as_echo "$ac_res" >&6; }
17191786
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
17201787

17211788
} # ac_fn_c_check_type
1722-
1723-
# ac_fn_c_check_func LINENO FUNC VAR
1724-
# ----------------------------------
1725-
# Tests whether FUNC exists, setting the cache variable VAR accordingly
1726-
ac_fn_c_check_func ()
1727-
{
1728-
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1729-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
1730-
$as_echo_n "checking for $2... " >&6; }
1731-
if eval \${$3+:} false; then :
1732-
$as_echo_n "(cached) " >&6
1733-
else
1734-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1735-
/* end confdefs.h. */
1736-
/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
1737-
For example, HP-UX 11i <limits.h> declares gettimeofday. */
1738-
#define $2 innocuous_$2
1739-
1740-
/* System header to define __stub macros and hopefully few prototypes,
1741-
which can conflict with char $2 (); below.
1742-
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
1743-
<limits.h> exists even on freestanding compilers. */
1744-
1745-
#ifdef __STDC__
1746-
# include <limits.h>
1747-
#else
1748-
# include <assert.h>
1749-
#endif
1750-
1751-
#undef $2
1752-
1753-
/* Override any GCC internal prototype to avoid an error.
1754-
Use char because int might match the return type of a GCC
1755-
builtin and then its argument prototype would still apply. */
1756-
#ifdef __cplusplus
1757-
extern "C"
1758-
#endif
1759-
char $2 ();
1760-
/* The GNU C library defines this for functions which it implements
1761-
to always fail with ENOSYS. Some functions are actually named
1762-
something starting with __ and the normal name is an alias. */
1763-
#if defined __stub_$2 || defined __stub___$2
1764-
choke me
1765-
#endif
1766-
1767-
int
1768-
main ()
1769-
{
1770-
return $2 ();
1771-
;
1772-
return 0;
1773-
}
1774-
_ACEOF
1775-
if ac_fn_c_try_link "$LINENO"; then :
1776-
eval "$3=yes"
1777-
else
1778-
eval "$3=no"
1779-
fi
1780-
rm -f core conftest.err conftest.$ac_objext \
1781-
conftest$ac_exeext conftest.$ac_ext
1782-
fi
1783-
eval ac_res=\$$3
1784-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
1785-
$as_echo "$ac_res" >&6; }
1786-
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1787-
1788-
} # ac_fn_c_check_func
17891789
cat >config.log <<_ACEOF
17901790
This file contains any messages produced by compilers while
17911791
running configure, to aid debugging if configure makes a mistake.
@@ -3028,6 +3028,66 @@ fi
30283028

30293029
EXTRA_LIBS=""
30303030

3031+
BT=
3032+
ac_fn_c_check_func "$LINENO" "backtrace" "ac_cv_func_backtrace"
3033+
if test "x$ac_cv_func_backtrace" = xyes; then :
3034+
3035+
BT=1
3036+
3037+
fi
3038+
3039+
3040+
if test "x$BT" = "x" ; then
3041+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
3042+
$as_echo "no" >&6; }
3043+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for backtrace in -lexecinfo" >&5
3044+
$as_echo_n "checking for backtrace in -lexecinfo... " >&6; }
3045+
if ${ac_cv_lib_execinfo_backtrace+:} false; then :
3046+
$as_echo_n "(cached) " >&6
3047+
else
3048+
ac_check_lib_save_LIBS=$LIBS
3049+
LIBS="-lexecinfo $LIBS"
3050+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3051+
/* end confdefs.h. */
3052+
3053+
/* Override any GCC internal prototype to avoid an error.
3054+
Use char because int might match the return type of a GCC
3055+
builtin and then its argument prototype would still apply. */
3056+
#ifdef __cplusplus
3057+
extern "C"
3058+
#endif
3059+
char backtrace ();
3060+
int
3061+
main ()
3062+
{
3063+
return backtrace ();
3064+
;
3065+
return 0;
3066+
}
3067+
_ACEOF
3068+
if ac_fn_c_try_link "$LINENO"; then :
3069+
ac_cv_lib_execinfo_backtrace=yes
3070+
else
3071+
ac_cv_lib_execinfo_backtrace=no
3072+
fi
3073+
rm -f core conftest.err conftest.$ac_objext \
3074+
conftest$ac_exeext conftest.$ac_ext
3075+
LIBS=$ac_check_lib_save_LIBS
3076+
fi
3077+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_execinfo_backtrace" >&5
3078+
$as_echo "$ac_cv_lib_execinfo_backtrace" >&6; }
3079+
if test "x$ac_cv_lib_execinfo_backtrace" = xyes; then :
3080+
cat >>confdefs.h <<_ACEOF
3081+
#define HAVE_LIBEXECINFO 1
3082+
_ACEOF
3083+
3084+
LIBS="-lexecinfo $LIBS"
3085+
3086+
fi
3087+
3088+
EXTRA_LIBS+=" -lexecinfo" ;
3089+
fi
3090+
30313091
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_save_prompt in -lreadline" >&5
30323092
$as_echo_n "checking for rl_save_prompt in -lreadline... " >&6; }
30333093
if ${ac_cv_lib_readline_rl_save_prompt+:} false; then :

‎configure.ac

+15
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@ AC_CHECK_LIB([crypto], [AES_set_encrypt_key])
1212

1313
EXTRA_LIBS=""
1414

15+
BT=
16+
AC_CHECK_FUNC([backtrace],
17+
[
18+
BT=1
19+
],
20+
[
21+
]
22+
)
23+
24+
if test "x$BT" = "x" ; then
25+
AC_MSG_RESULT([no])
26+
AC_CHECK_LIB([execinfo], [backtrace])
27+
[ EXTRA_LIBS+=" -lexecinfo" ; ]
28+
fi
29+
1530
AC_CHECK_LIB([readline], [rl_save_prompt],
1631
[
1732
AC_DEFINE([READLINE_GNU], [1], [Use gnu libreadline])

0 commit comments

Comments
 (0)