Skip to content

Commit 082b977

Browse files
Explorer09BenBE
authored andcommitted
build: Add friendly warning to advise user to install pkg-config
If we can detect the presence of '*curses*.pc' files in some pkg-config default search directories, print a warning message. Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
1 parent d5f24d2 commit 082b977

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

configure.ac

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,53 @@ esac
566566

567567
case ${htop_curses_capability}-$enable_unicode in
568568
none-*|nonwide-yes)
569+
if test "x$PKG_CONFIG" = x; then (
570+
# Friendly warning to advise user to install pkg-config.
571+
# The local variables get discarded when done.
572+
list=""
573+
echo "" >conftest.c
574+
if test "$cross_compiling" != yes; then
575+
# "-print-multi-directory" supported in GCC 3.0 or later
576+
name=""
577+
if $CC $CPPFLAGS $CFLAGS -print-multi-directory -E conftest.c >/dev/null 2>&1; then
578+
name=`$CC $CPPFLAGS $CFLAGS -print-multi-directory -E conftest.c 2>/dev/null |
579+
sed '/^ *#/ d; s/^\.$//; q'`
580+
fi
581+
list="/usr/lib${name}/pkgconfig $list"
582+
case $host_os in
583+
darwin*)
584+
list="/opt/homebrew/Library/Homebrew/os/mac/pkgconfig $list"
585+
;;
586+
freebsd*)
587+
list="/usr/libdata/pkgconfig $list"
588+
;;
589+
netbsd*)
590+
list="/usr/pkg/lib/pkgconfig $list"
591+
;;
592+
esac
593+
fi
594+
if test "x$host_alias" != x; then
595+
list="/usr/lib/${host_alias}/pkgconfig $list"
596+
fi
597+
# "-print-multiarch" supported in GCC 4.6 or later
598+
if $CC $CPPFLAGS $CFLAGS -print-multiarch -E conftest.c >/dev/null 2>&1; then
599+
name=`$CC $CPPFLAGS $CFLAGS -print-multiarch -E conftest.c 2>/dev/null |
600+
sed '/^ *#/ d; q'`
601+
if test "x$name" != x; then
602+
list="/usr/lib/${name}/pkgconfig $list"
603+
fi
604+
fi
605+
rm -f conftest.*
606+
607+
for d in $list; do
608+
result=`find "$d" -name '*curses*.pc' 2>/dev/null | sed '1 q'`
609+
if test "x$result" != x; then
610+
AC_MSG_WARN([your system supports pkg-config; installing pkg-config is recommended before configuring htop])
611+
break
612+
fi
613+
done
614+
) fi
615+
569616
# OpenBSD and Solaris are known to not provide '*curses*.pc' files.
570617
AC_MSG_RESULT([no curses information found through '*-config' utilities; will guess the linker flags])
571618
for curses_name in $curses_pkg_names; do

0 commit comments

Comments
 (0)