author | "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr> |
Tue Jul 03 22:28:14 2007 +0000 (2007-07-03) | |
changeset 201 | 038d9ad0db6b |
child 706 | 607277e3cdab |
permissions | -rw-r--r-- |
yann@1 | 1 |
#!/bin/sh |
yann@1 | 2 |
# Check ncurses compatibility |
yann@1 | 3 |
|
yann@1 | 4 |
# What library to link |
yann@1 | 5 |
ldflags() |
yann@1 | 6 |
{ |
yann@1 | 7 |
$cc -print-file-name=libncursesw.so | grep -q / |
yann@1 | 8 |
if [ $? -eq 0 ]; then |
yann@1 | 9 |
echo '-lncursesw' |
yann@1 | 10 |
exit |
yann@1 | 11 |
fi |
yann@1 | 12 |
$cc -print-file-name=libncurses.so | grep -q / |
yann@1 | 13 |
if [ $? -eq 0 ]; then |
yann@1 | 14 |
echo '-lncurses' |
yann@1 | 15 |
exit |
yann@1 | 16 |
fi |
yann@1 | 17 |
$cc -print-file-name=libcurses.so | grep -q / |
yann@1 | 18 |
if [ $? -eq 0 ]; then |
yann@1 | 19 |
echo '-lcurses' |
yann@1 | 20 |
exit |
yann@1 | 21 |
fi |
yann@1 | 22 |
exit 1 |
yann@1 | 23 |
} |
yann@1 | 24 |
|
yann@1 | 25 |
# Where is ncurses.h? |
yann@1 | 26 |
ccflags() |
yann@1 | 27 |
{ |
yann@1 | 28 |
if [ -f /usr/include/ncurses/ncurses.h ]; then |
yann@1 | 29 |
echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"' |
yann@1 | 30 |
elif [ -f /usr/include/ncurses/curses.h ]; then |
yann@1 | 31 |
echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"' |
yann@1 | 32 |
elif [ -f /usr/include/ncurses.h ]; then |
yann@1 | 33 |
echo '-DCURSES_LOC="<ncurses.h>"' |
yann@1 | 34 |
else |
yann@1 | 35 |
echo '-DCURSES_LOC="<curses.h>"' |
yann@1 | 36 |
fi |
yann@1 | 37 |
} |
yann@1 | 38 |
|
yann@1 | 39 |
# Temp file, try to clean up after us |
yann@1 | 40 |
tmp=.lxdialog.tmp |
yann@1 | 41 |
trap "rm -f $tmp" 0 1 2 3 15 |
yann@1 | 42 |
|
yann@1 | 43 |
# Check if we can link to ncurses |
yann@1 | 44 |
check() { |
yann@1 | 45 |
echo "main() {}" | $cc -xc - -o $tmp 2> /dev/null |
yann@1 | 46 |
if [ $? != 0 ]; then |
yann@1 | 47 |
echo " *** Unable to find the ncurses libraries." 1>&2 |
yann@1 | 48 |
echo " *** make menuconfig require the ncurses libraries" 1>&2 |
yann@1 | 49 |
echo " *** " 1>&2 |
yann@1 | 50 |
echo " *** Install ncurses (ncurses-devel) and try again" 1>&2 |
yann@1 | 51 |
echo " *** " 1>&2 |
yann@1 | 52 |
exit 1 |
yann@1 | 53 |
fi |
yann@1 | 54 |
} |
yann@1 | 55 |
|
yann@1 | 56 |
usage() { |
yann@1 | 57 |
printf "Usage: $0 [-check compiler options|-header|-library]\n" |
yann@1 | 58 |
} |
yann@1 | 59 |
|
yann@1 | 60 |
if [ $# == 0 ]; then |
yann@1 | 61 |
usage |
yann@1 | 62 |
exit 1 |
yann@1 | 63 |
fi |
yann@1 | 64 |
|
yann@1 | 65 |
cc="" |
yann@1 | 66 |
case "$1" in |
yann@1 | 67 |
"-check") |
yann@1 | 68 |
shift |
yann@1 | 69 |
cc="$@" |
yann@1 | 70 |
check |
yann@1 | 71 |
;; |
yann@1 | 72 |
"-ccflags") |
yann@1 | 73 |
ccflags |
yann@1 | 74 |
;; |
yann@1 | 75 |
"-ldflags") |
yann@1 | 76 |
shift |
yann@1 | 77 |
cc="$@" |
yann@1 | 78 |
ldflags |
yann@1 | 79 |
;; |
yann@1 | 80 |
"*") |
yann@1 | 81 |
usage |
yann@1 | 82 |
exit 1 |
yann@1 | 83 |
;; |
yann@1 | 84 |
esac |