diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2018-05-05 14:38:38 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2018-05-05 14:38:38 +0000 |
commit | c9ace844ba2adde13a2f7f1d353f38853717426c (patch) | |
tree | ea7a6f259fe3d292ec20e90ec0c516bb0f8202f5 /m4/st_libdw.m4 | |
parent | ee5d88c5b6a1060889dc4d922c3840a6fb46852d (diff) | |
download | strace-c9ace844ba2adde13a2f7f1d353f38853717426c.tar.gz |
build: rewrite libdw detection without pkg-config
pkg-config expected to be more convenient way to configure libdw,
but in practice it appeared to be less portable than good old
AC_CHECK_HEADERS and AC_CHECK_LIB.
* ci/install-dependencies.sh (common_packages): Remove pkg-config.
(STACKTRACE == "libdw"): Do not install libz-dev and liblzma-dev.
* debian/control (Build-Depends): Remove pkg-config.
* m4/st_libdw.m4 (st_ARG_LIBDW, st_LIBDW): Rewrite without pkg-config.
Diffstat (limited to 'm4/st_libdw.m4')
-rw-r--r-- | m4/st_libdw.m4 | 82 |
1 files changed, 36 insertions, 46 deletions
diff --git a/m4/st_libdw.m4 b/m4/st_libdw.m4 index 5b80fac33..f33ec3568 100644 --- a/m4/st_libdw.m4 +++ b/m4/st_libdw.m4 @@ -27,6 +27,11 @@ AC_DEFUN([st_ARG_LIBDW], [dnl +: ${libdw_CPPFLAGS=} +: ${libdw_CFLAGS=} +: ${libdw_LDFLAGS=} +: ${libdw_LIBS=} + AC_ARG_WITH([libdw], [AS_HELP_STRING([--with-libdw], [use libdw to implement stack tracing support] @@ -34,9 +39,9 @@ AC_ARG_WITH([libdw], ], [case "${withval}" in yes|no|check) ;; - *) - AC_MSG_ERROR([Use pkg-config variables instead of giving path to --with-libdw]) - ;; + *) libdw_CPPFLAGS="-I${withval}/include" + libdw_LDFLAGS="-L${withval}/lib" + with_libdw=yes ;; esac ], [with_libdw=check] @@ -46,60 +51,45 @@ AC_ARG_WITH([libdw], AC_DEFUN([st_LIBDW], [dnl -: ${libdw_CPPFLAGS=} -: ${libdw_CFLAGS=} -: ${libdw_LDFLAGS=} -: ${libdw_LIBS=} have_libdw= -AS_IF([test "x$with_libdw" != xno], - [ - dnl If libdw.pc is not available, then libdw is not new enough - dnl to be used for stack tracing. - AS_IF([test "x$with_libdw" = xyes], - [PKG_CHECK_MODULES([libdw], [libdw], [have_libdw=yes])], - [PKG_CHECK_MODULES([libdw], [libdw], [have_libdw=yes], [:])] - ) - ] - ) - -AS_IF([test "x$have_libdw" = xyes], - [ - dnl If libdw.pc is available, check whether libdw can be used - dnl for stack tracing. - saved_CPPFLAGS="$CPPFLAGS" +AS_IF([test "x$with_libdw" != xno && test "x$use_unwinder" = x], + [saved_CPPFLAGS="$CPPFLAGS" saved_CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS $libdw_CPPFLAGS" CFLAGS="$CFLAGS $libdw_CFLAGS" AC_CHECK_HEADERS([elfutils/libdwfl.h], - [ - AC_MSG_CHECKING([for dwfl_linux_proc_attach in libdw]) - saved_LDFLAGS="$LDFLAGS" - saved_LIBS="$LIBS" - LDFLAGS="$LDFLAGS $libdw_LDFLAGS" - LIBS="$LIBS $libdw_LIBS" - - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <elfutils/libdwfl.h>]], - [[return dwfl_linux_proc_attach(0, 0, 0)]] - ) - ], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no]) - AS_IF([test "x$with_libdw" = xyes], - [AC_MSG_FAILURE([failed to find dwfl_linux_proc_attach in libdw])], - ) - have_libdw= - ] - ) - - LIBS="$saved_LIBS" - LDFLAGS="$saved_LDFLAGS" + [AC_CHECK_LIB([dw], [dwfl_linux_proc_attach], + [libdw_LIBS="-ldw $libdw_LIBS" + AC_CACHE_CHECK([for elfutils version], + [st_cv_ELFUTILS_VERSION], + [[st_cv_ELFUTILS_VERSION="$(echo _ELFUTILS_VERSION | + $CPP $CPPFLAGS -P -imacros elfutils/version.h - | + grep '^[0-9]')" + test -n "$st_cv_ELFUTILS_VERSION" || + st_cv_ELFUTILS_VERSION=0 + ]] + ) + AS_IF([test "$st_cv_ELFUTILS_VERSION" -ge 164], + [have_libdw=yes], + [AS_IF([test "x$with_libdw" = xyes], + [AC_MSG_ERROR([elfutils version >= 164 is required for stack tracing support])], + [AC_MSG_WARN([elfutils version >= 164 is required for stack tracing support])] + ) + ] + ) + ], + [AS_IF([test "x$with_libdw" = xyes], + [AC_MSG_FAILURE([failed to find dwfl_linux_proc_attach in libdw])], + ) + ], + [$libdw_LDFLAGS $libdw_LIBS] + ) ], [AS_IF([test "x$with_libdw" = xyes], [AC_MSG_FAILURE([failed to find elfutils/libdwfl.h])] ) - have_libdw= ] ) |