From a7df146e9e8fb14a132e6ea513b710cd2a25ef2b Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Wed, 25 Apr 2018 15:25:53 +0000 Subject: [PATCH] added libunwind detection to configure.ac --- moo/Makefile.in | 1 + moo/configure | 64 ++++++++++++++++++++++++++++++++++++++++---- moo/configure.ac | 16 +++++++++-- moo/lib/Makefile.in | 1 + moo/lib/moo-cfg.h.in | 6 +++++ moo/mod/Makefile.in | 1 + 6 files changed, 82 insertions(+), 7 deletions(-) diff --git a/moo/Makefile.in b/moo/Makefile.in index f882b14..2105b34 100644 --- a/moo/Makefile.in +++ b/moo/Makefile.in @@ -307,6 +307,7 @@ SOCKET_LIBS = @SOCKET_LIBS@ STRIP = @STRIP@ TERMINAL_LIBS = @TERMINAL_LIBS@ UNICOWS_LIBS = @UNICOWS_LIBS@ +UNWIND_LIBS = @UNWIND_LIBS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ diff --git a/moo/configure b/moo/configure index 256edbd..f68671d 100755 --- a/moo/configure +++ b/moo/configure @@ -673,6 +673,7 @@ QUADMATH_LIBS UNICOWS_LIBS SOCKET_LIBS TERMINAL_LIBS +UNWIND_LIBS DYNCALL_LIBS LTDL_LIBS DL_LIBS @@ -18263,12 +18264,13 @@ fi done -for ac_header in dyncall.h +for ac_header in netinet/in.h sys/un.h netpacket/packet.h net/if_dl.h do : - ac_fn_c_check_header_mongrel "$LINENO" "dyncall.h" "ac_cv_header_dyncall_h" "$ac_includes_default" -if test "x$ac_cv_header_dyncall_h" = xyes; then : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF -#define HAVE_DYNCALL_H 1 +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -18287,7 +18289,7 @@ fi done -for ac_header in netinet/in.h sys/un.h netpacket/packet.h net/if_dl.h +for ac_header in dyncall.h libunwind.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -18566,6 +18568,58 @@ fi +if test "x${ac_cv_header_libunwind_h}" = "xyes" +then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for unw_backtrace in -lunwind" >&5 +$as_echo_n "checking for unw_backtrace in -lunwind... " >&6; } +if ${ac_cv_lib_unwind_unw_backtrace+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lunwind $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char unw_backtrace (); +int +main () +{ +return unw_backtrace (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_unwind_unw_backtrace=yes +else + ac_cv_lib_unwind_unw_backtrace=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_unwind_unw_backtrace" >&5 +$as_echo "$ac_cv_lib_unwind_unw_backtrace" >&6; } +if test "x$ac_cv_lib_unwind_unw_backtrace" = xyes; then : + + UNWIND_LIBS="-lunwind" + +$as_echo "#define HAVE_UNWIND_LIB 1" >>confdefs.h + + + +fi + + +fi + + save_LIBS="$LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing setupterm" >&5 $as_echo_n "checking for library containing setupterm... " >&6; } diff --git a/moo/configure.ac b/moo/configure.ac index f3c1daa..e38f824 100644 --- a/moo/configure.ac +++ b/moo/configure.ac @@ -129,9 +129,9 @@ AC_CHECK_HEADERS([stddef.h wchar.h wctype.h errno.h signal.h fcntl.h dirent.h]) AC_CHECK_HEADERS([time.h sys/time.h utime.h spawn.h execinfo.h ucontext.h]) AC_CHECK_HEADERS([dlfcn.h ltdl.h sys/mman.h]) AC_CHECK_HEADERS([sys/devpoll.h sys/epoll.h poll.h]) -AC_CHECK_HEADERS([dyncall.h]) -AC_CHECK_HEADERS([xcb/xcb.h]) AC_CHECK_HEADERS([netinet/in.h sys/un.h netpacket/packet.h net/if_dl.h]) +AC_CHECK_HEADERS([xcb/xcb.h]) +AC_CHECK_HEADERS([dyncall.h libunwind.h]) dnl check data types dnl AC_CHECK_TYPE([wchar_t], @@ -179,6 +179,18 @@ AC_CHECK_LIB([dyncall_s], [dcNewCallVM], ) AC_SUBST(DYNCALL_LIBS) +if test "x${ac_cv_header_libunwind_h}" = "xyes" +then + AC_CHECK_LIB([unwind], [unw_backtrace], + [ + UNWIND_LIBS="-lunwind" + AC_DEFINE([HAVE_UNWIND_LIB], [1], [libunwind is available]) + ] + ) + AC_SUBST(UNWIND_LIBS) +fi + + save_LIBS="$LIBS" AC_SEARCH_LIBS([setupterm], [tinfo termcap curses ncurses ncursesw], [TERMINAL_LIBS="$ac_cv_search_setupterm"]) LIBS="$save_LIBS" diff --git a/moo/lib/Makefile.in b/moo/lib/Makefile.in index 4fd345d..b09dd70 100644 --- a/moo/lib/Makefile.in +++ b/moo/lib/Makefile.in @@ -350,6 +350,7 @@ SOCKET_LIBS = @SOCKET_LIBS@ STRIP = @STRIP@ TERMINAL_LIBS = @TERMINAL_LIBS@ UNICOWS_LIBS = @UNICOWS_LIBS@ +UNWIND_LIBS = @UNWIND_LIBS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ diff --git a/moo/lib/moo-cfg.h.in b/moo/lib/moo-cfg.h.in index cd24643..eb1d52f 100644 --- a/moo/lib/moo-cfg.h.in +++ b/moo/lib/moo-cfg.h.in @@ -99,6 +99,9 @@ /* labels as values */ #undef HAVE_LABELS_AS_VALUES +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBUNWIND_H + /* Define to 1 if you have the `log10q' function. */ #undef HAVE_LOG10Q @@ -243,6 +246,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H +/* libunwind is available */ +#undef HAVE_UNWIND_LIB + /* Define to 1 if you have the `usleep' function. */ #undef HAVE_USLEEP diff --git a/moo/mod/Makefile.in b/moo/mod/Makefile.in index f792e57..0902ff8 100644 --- a/moo/mod/Makefile.in +++ b/moo/mod/Makefile.in @@ -376,6 +376,7 @@ SOCKET_LIBS = @SOCKET_LIBS@ STRIP = @STRIP@ TERMINAL_LIBS = @TERMINAL_LIBS@ UNICOWS_LIBS = @UNICOWS_LIBS@ +UNWIND_LIBS = @UNWIND_LIBS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@