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 | 60f33b8 | 2006-01-15 15:28:35 +0100 | [diff] [blame^] | 7 | echo "main() {}" | $cc -lncursesw -xc - -o /dev/null 2> /dev/null |
| 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 | 60f33b8 | 2006-01-15 15:28:35 +0100 | [diff] [blame^] | 12 | echo "main() {}" | $cc -lncurses -xc - -o /dev/null 2> /dev/null |
| 13 | if [ $? -eq 0 ]; then |
| 14 | echo '-lncurses' |
| 15 | exit |
| 16 | fi |
| 17 | echo "main() {}" | $cc -lcurses -xc - -o /dev/null 2> /dev/null |
| 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 | |
| 39 | compiler="" |
| 40 | # Check if we can link to ncurses |
| 41 | check() { |
Sam Ravnborg | 60f33b8 | 2006-01-15 15:28:35 +0100 | [diff] [blame^] | 42 | echo "main() {}" | $cc -xc - -o /dev/null 2> /dev/null |
Sam Ravnborg | ae215b1 | 2006-01-08 18:39:44 +0100 | [diff] [blame] | 43 | if [ $? != 0 ]; then |
| 44 | echo " *** Unable to find the ncurses libraries." 1>&2 |
| 45 | echo " *** make menuconfig require the ncurses libraries" 1>&2 |
| 46 | echo " *** " 1>&2 |
| 47 | echo " *** Install ncurses (ncurses-devel) and try again" 1>&2 |
| 48 | echo " *** " 1>&2 |
| 49 | exit 1 |
| 50 | fi |
| 51 | } |
| 52 | |
| 53 | usage() { |
| 54 | printf "Usage: $0 [-check compiler options|-header|-library]\n" |
| 55 | } |
| 56 | |
| 57 | if [ $# == 0 ]; then |
| 58 | usage |
| 59 | exit 1 |
| 60 | fi |
| 61 | |
| 62 | case "$1" in |
| 63 | "-check") |
| 64 | shift |
Sam Ravnborg | 60f33b8 | 2006-01-15 15:28:35 +0100 | [diff] [blame^] | 65 | cc="$@" |
Sam Ravnborg | ae215b1 | 2006-01-08 18:39:44 +0100 | [diff] [blame] | 66 | check |
| 67 | ;; |
| 68 | "-ccflags") |
| 69 | ccflags |
| 70 | ;; |
| 71 | "-ldflags") |
Sam Ravnborg | 60f33b8 | 2006-01-15 15:28:35 +0100 | [diff] [blame^] | 72 | shift |
| 73 | cc="$@" |
Sam Ravnborg | ae215b1 | 2006-01-08 18:39:44 +0100 | [diff] [blame] | 74 | ldflags |
| 75 | ;; |
| 76 | "*") |
| 77 | usage |
| 78 | exit 1 |
| 79 | ;; |
| 80 | esac |