2007-06-28 12:46:19 +02:00
|
|
|
#!/bin/sh
|
2018-09-19 13:36:15 +02:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
2007-06-28 12:46:19 +02:00
|
|
|
# Check ncurses compatibility
|
|
|
|
|
|
|
|
# What library to link
|
|
|
|
ldflags()
|
|
|
|
{
|
2013-11-14 00:53:35 +01:00
|
|
|
pkg-config --libs ncursesw 2>/dev/null && exit
|
|
|
|
pkg-config --libs ncurses 2>/dev/null && exit
|
2013-04-04 13:24:24 +02:00
|
|
|
for ext in so a dll.a dylib ; do
|
2007-09-23 16:06:59 +02:00
|
|
|
for lib in ncursesw ncurses curses ; do
|
|
|
|
$cc -print-file-name=lib${lib}.${ext} | grep -q /
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "-l${lib}"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
2007-06-28 12:46:19 +02:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Where is ncurses.h?
|
|
|
|
ccflags()
|
|
|
|
{
|
2015-01-03 00:58:48 +01:00
|
|
|
if pkg-config --cflags ncursesw 2>/dev/null; then
|
|
|
|
echo '-DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1'
|
|
|
|
elif pkg-config --cflags ncurses 2>/dev/null; then
|
|
|
|
echo '-DCURSES_LOC="<ncurses.h>"'
|
|
|
|
elif [ -f /usr/include/ncursesw/curses.h ]; then
|
2013-11-14 00:53:35 +01:00
|
|
|
echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"'
|
2013-04-04 13:24:24 +02:00
|
|
|
echo ' -DNCURSES_WIDECHAR=1'
|
|
|
|
elif [ -f /usr/include/ncurses/ncurses.h ]; then
|
2007-06-28 12:46:19 +02:00
|
|
|
echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
|
|
|
|
elif [ -f /usr/include/ncurses/curses.h ]; then
|
2013-11-14 00:53:35 +01:00
|
|
|
echo '-I/usr/include/ncurses -DCURSES_LOC="<curses.h>"'
|
2007-06-28 12:46:19 +02:00
|
|
|
elif [ -f /usr/include/ncurses.h ]; then
|
|
|
|
echo '-DCURSES_LOC="<ncurses.h>"'
|
|
|
|
else
|
|
|
|
echo '-DCURSES_LOC="<curses.h>"'
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Temp file, try to clean up after us
|
2010-06-21 22:31:12 +02:00
|
|
|
tmp=$(mktemp)
|
2007-06-28 12:46:19 +02:00
|
|
|
trap "rm -f $tmp" 0 1 2 3 15
|
|
|
|
|
|
|
|
# Check if we can link to ncurses
|
|
|
|
check() {
|
2013-04-04 13:24:24 +02:00
|
|
|
$cc -x c - -o $tmp 2>/dev/null <<'EOF'
|
2009-07-20 18:50:58 +02:00
|
|
|
#include CURSES_LOC
|
|
|
|
main() {}
|
|
|
|
EOF
|
2007-06-28 12:46:19 +02:00
|
|
|
if [ $? != 0 ]; then
|
2009-07-20 18:50:58 +02:00
|
|
|
echo " *** Unable to find the ncurses libraries or the" 1>&2
|
|
|
|
echo " *** required header files." 1>&2
|
|
|
|
echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2
|
|
|
|
echo " *** " 1>&2
|
2018-09-19 13:36:15 +02:00
|
|
|
echo " *** Install ncurses (ncurses-devel or libncurses-dev " 1>&2
|
|
|
|
echo " *** depending on your distribution) and try again." 1>&2
|
2009-07-20 18:50:58 +02:00
|
|
|
echo " *** " 1>&2
|
|
|
|
exit 1
|
2007-06-28 12:46:19 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
usage() {
|
2009-07-20 18:50:58 +02:00
|
|
|
printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
|
2007-06-28 12:46:19 +02:00
|
|
|
}
|
|
|
|
|
2008-06-19 10:11:43 +02:00
|
|
|
if [ $# -eq 0 ]; then
|
2007-06-28 12:46:19 +02:00
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cc=""
|
|
|
|
case "$1" in
|
|
|
|
"-check")
|
|
|
|
shift
|
|
|
|
cc="$@"
|
|
|
|
check
|
|
|
|
;;
|
|
|
|
"-ccflags")
|
|
|
|
ccflags
|
|
|
|
;;
|
|
|
|
"-ldflags")
|
|
|
|
shift
|
|
|
|
cc="$@"
|
|
|
|
ldflags
|
|
|
|
;;
|
|
|
|
"*")
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|