strace/m4/st_demangle.m4
Dmitry V. Levin 2713444cb7 unwind: prepare configure subsystem for alternative unwinders
Introduce --enable-stacktrace configure option to control whether
-k option support is compiled in, --with-libunwind option remains
available to control whether libunwind can be used as an unwinder.

* m4/st_demangle.m4: New file.
* m4/st_libunwind.m4: Likewise.
* m4/st_stacktrace.m4: Likewise.
* configure.ac: Replace all libunwind and libiberty checks
with a single st_STACKTRACE invocation.
* Makefile.am: Conditionalize checks for USE_LIBUNWIND and USE_DEMANGLE
on ENABLE_STACKTRACE.
[ENABLE_STACKTRACE] (strace_SOURCES): Append unwind.c and unwind.h.
* strace.1.in: Replace libunwind with an unwinder-agnostic wording.
* defs.h: Replace USE_LIBUNWIND with ENABLE_STACKTRACE.
* strace.c: Likewise.
(print_version): Print stack-trace instead of stack-unwind.
* syscall.c: Replace USE_LIBUNWIND with ENABLE_STACKTRACE.
* tests/Makefile.am: Likewise.  Replace LIBUNWIND_TESTS
with STACKTRACE_TESTS.
* tests/strace-V.test: Update expected output.
2018-04-08 22:01:12 +00:00

83 lines
2.8 KiB
Plaintext

#!/usr/bin/m4
#
# Copyright (c) 2017-2018 The strace developers.
# All rights reserved.
#
# 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.
AC_DEFUN([st_DEMANGLE], [dnl
AC_ARG_WITH([libiberty],
[AS_HELP_STRING([--with-libiberty],
[use libiberty to demangle symbols in stack trace])],
[case "${withval}" in
yes|no|check) ;;
*) with_libiberty=yes
libiberty_CPPFLAGS="-I${withval}/include"
libiberty_LDFLAGS="-L${withval}/lib" ;;
esac],
[with_libiberty=check]
)
libiberty_CPPFLAGS=
libiberty_LDFLAGS=
libiberty_LIBS=
use_libiberty=no
AS_IF([test "x$with_libiberty" != xno],
[saved_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $libiberty_CPPFLAGS"
AC_CHECK_HEADERS([demangle.h libiberty/demangle.h],
[saved_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $libiberty_LDFLAGS"
AC_CHECK_LIB([iberty],[cplus_demangle],
[libiberty_LIBS="-liberty"
use_libiberty=yes
],
[if test "x$with_libiberty" != xcheck; then
AC_MSG_FAILURE([failed to find cplus_demangle in libiberty])
fi
]
)
LDFLAGS="$saved_LDFLAGS"
],
[if test "x$with_libiberty" != xcheck; then
AC_MSG_FAILURE([failed to find demangle.h])
fi
]
)
CPPFLAGS="$saved_CPPFLAGS"
]
)
AC_MSG_CHECKING([whether to enable symbols demangling in stack trace])
if test "x$use_libiberty" = xyes; then
AC_DEFINE([USE_DEMANGLE], 1, [Do symbols demangling in stack trace])
AC_SUBST(libiberty_LIBS)
AC_SUBST(libiberty_LDFLAGS)
AC_SUBST(libiberty_CPPFLAGS)
fi
AC_MSG_RESULT([$use_libiberty])
])