Skip to content

Commit d522808

Browse files
committed
build: Also check libunwind through pkg-config
pkg-config is a better source for finding dependencies when linking with libunwind. In particular, we only need to test for '-llzma' if pkg-config is not available to provide that information. Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
1 parent db199ce commit d522808

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

configure.ac

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -963,9 +963,18 @@ case "$enable_unwind" in
963963
no)
964964
;;
965965
check|yes)
966-
if test "$enable_static" = yes; then
967-
AC_CHECK_LIB([lzma], [lzma_index_buffer_decode])
968-
fi
966+
HTOP_PKG_CHECK_MODULES(LIBUNWIND, libunwind,
967+
[],
968+
[
969+
if test "$enable_static" = yes; then
970+
AC_CHECK_LIB([lzma], [lzma_index_buffer_decode])
971+
fi
972+
: "${LIBUNWIND_LIBS='-lunwind'}"
973+
]
974+
)
975+
976+
htop_save_CFLAGS=$CFLAGS
977+
CFLAGS="$AM_CFLAGS $LIBUNWIND_CFLAGS $CFLAGS"
969978

970979
if htop_search_header_dir libunwind.h "/usr/include/libunwind"; then
971980
AC_DEFINE([HAVE_LIBUNWIND_H], 1, [Define to 1 if you have the <libunwind.h> header file.])
@@ -974,6 +983,8 @@ case "$enable_unwind" in
974983
else
975984
enable_unwind=no
976985
fi
986+
987+
CFLAGS=$htop_save_CFLAGS
977988
;;
978989
*)
979990
AC_MSG_ERROR([bad value '$enable_unwind' for --enable-unwind])
@@ -982,13 +993,15 @@ esac
982993

983994
if test "$enable_unwind" != no; then
984995
htop_save_CPPFLAGS=$CPPFLAGS
996+
htop_save_CFLAGS=$CFLAGS
985997
htop_save_LIBS=$LIBS
986998
CPPFLAGS="$AM_CPPFLAGS $CPPFLAGS"
987-
LIBS="-lunwind $LIBS"
999+
CFLAGS="$AM_CFLAGS $LIBUNWIND_CFLAGS $CFLAGS"
1000+
LIBS="$LIBUNWIND_LIBS $LIBS"
9881001

9891002
# unw_init_local() is a macro in HP's implemention of libunwind
9901003
# (the most popular one, Mosberger et al.)
991-
AC_MSG_CHECKING([whether -lunwind supports local unwinding])
1004+
AC_MSG_CHECKING([whether $LIBUNWIND_LIBS supports local unwinding])
9921005
AC_LINK_IFELSE(
9931006
[AC_LANG_PROGRAM(
9941007
[[
@@ -1048,9 +1061,11 @@ if test "$enable_unwind" != no; then
10481061
)
10491062

10501063
CPPFLAGS=$htop_save_CPPFLAGS
1064+
CFLAGS=$htop_save_CFLAGS
10511065
fi
10521066

10531067
if test "$enable_unwind" != no; then
1068+
AM_CFLAGS="$AM_CFLAGS $LIBUNWIND_CFLAGS"
10541069
enable_unwind=yes
10551070
AC_DEFINE([HAVE_LOCAL_UNWIND], 1, [Define to 1 if local unwinding is enabled.])
10561071
else

0 commit comments

Comments
 (0)