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