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 | { |
Justin Lecher | fc9c6e0 | 2013-03-06 14:02:01 +0100 | [diff] [blame] | 7 | pkg-config --libs ncursesw 2>/dev/null && exit |
| 8 | pkg-config --libs ncurses 2>/dev/null && exit |
Yaakov Selkowitz | 3725f3e | 2012-06-12 19:05:15 -0500 | [diff] [blame] | 9 | for ext in so a dll.a dylib ; do |
Mike Frysinger | 03c9587 | 2007-05-17 15:06:31 -0400 | [diff] [blame] | 10 | for lib in ncursesw ncurses curses ; do |
| 11 | $cc -print-file-name=lib${lib}.${ext} | grep -q / |
| 12 | if [ $? -eq 0 ]; then |
| 13 | echo "-l${lib}" |
| 14 | exit |
| 15 | fi |
| 16 | done |
| 17 | done |
Sam Ravnborg | 60f33b8 | 2006-01-15 15:28:35 +0100 | [diff] [blame] | 18 | exit 1 |
Sam Ravnborg | ae215b1 | 2006-01-08 18:39:44 +0100 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | # Where is ncurses.h? |
| 22 | ccflags() |
| 23 | { |
Yaakov Selkowitz | 8435425 | 2012-06-12 19:05:02 -0500 | [diff] [blame] | 24 | if [ -f /usr/include/ncursesw/curses.h ]; then |
Yann E. MORIN | cdf0c2c | 2013-03-22 23:12:16 +0100 | [diff] [blame^] | 25 | echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"' |
Krzysztof Mazur | 7d5bb96 | 2012-10-08 18:18:22 +0200 | [diff] [blame] | 26 | echo ' -DNCURSES_WIDECHAR=1' |
Yaakov Selkowitz | 8435425 | 2012-06-12 19:05:02 -0500 | [diff] [blame] | 27 | elif [ -f /usr/include/ncurses/ncurses.h ]; then |
Sam Ravnborg | ae215b1 | 2006-01-08 18:39:44 +0100 | [diff] [blame] | 28 | echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"' |
| 29 | elif [ -f /usr/include/ncurses/curses.h ]; then |
Yann E. MORIN | cdf0c2c | 2013-03-22 23:12:16 +0100 | [diff] [blame^] | 30 | echo '-I/usr/include/ncurses -DCURSES_LOC="<curses.h>"' |
Sam Ravnborg | ae215b1 | 2006-01-08 18:39:44 +0100 | [diff] [blame] | 31 | elif [ -f /usr/include/ncurses.h ]; then |
| 32 | echo '-DCURSES_LOC="<ncurses.h>"' |
| 33 | else |
| 34 | echo '-DCURSES_LOC="<curses.h>"' |
| 35 | fi |
| 36 | } |
| 37 | |
Sam Ravnborg | 3835f82 | 2006-01-21 12:03:09 +0100 | [diff] [blame] | 38 | # Temp file, try to clean up after us |
| 39 | tmp=.lxdialog.tmp |
| 40 | trap "rm -f $tmp" 0 1 2 3 15 |
| 41 | |
Sam Ravnborg | ae215b1 | 2006-01-08 18:39:44 +0100 | [diff] [blame] | 42 | # Check if we can link to ncurses |
| 43 | check() { |
Jean Delvare | b1e0d8b | 2012-10-02 16:42:36 +0200 | [diff] [blame] | 44 | $cc -x c - -o $tmp 2>/dev/null <<'EOF' |
Sam Ravnborg | b44158d | 2008-05-01 19:29:47 +0200 | [diff] [blame] | 45 | #include CURSES_LOC |
| 46 | main() {} |
| 47 | EOF |
Sam Ravnborg | ae215b1 | 2006-01-08 18:39:44 +0100 | [diff] [blame] | 48 | if [ $? != 0 ]; then |
Sam Ravnborg | 6e588f6 | 2007-12-09 20:11:15 +0100 | [diff] [blame] | 49 | echo " *** Unable to find the ncurses libraries or the" 1>&2 |
| 50 | echo " *** required header files." 1>&2 |
| 51 | echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2 |
| 52 | echo " *** " 1>&2 |
| 53 | echo " *** Install ncurses (ncurses-devel) and try again." 1>&2 |
| 54 | echo " *** " 1>&2 |
| 55 | exit 1 |
Sam Ravnborg | ae215b1 | 2006-01-08 18:39:44 +0100 | [diff] [blame] | 56 | fi |
| 57 | } |
| 58 | |
| 59 | usage() { |
Sam Ravnborg | f6682f9 | 2008-12-03 22:11:14 +0100 | [diff] [blame] | 60 | printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n" |
Sam Ravnborg | ae215b1 | 2006-01-08 18:39:44 +0100 | [diff] [blame] | 61 | } |
| 62 | |
Mike Frysinger | e99c343 | 2007-05-23 21:37:45 -0400 | [diff] [blame] | 63 | if [ $# -eq 0 ]; then |
Sam Ravnborg | ae215b1 | 2006-01-08 18:39:44 +0100 | [diff] [blame] | 64 | usage |
| 65 | exit 1 |
| 66 | fi |
| 67 | |
Sam Ravnborg | 3835f82 | 2006-01-21 12:03:09 +0100 | [diff] [blame] | 68 | cc="" |
Sam Ravnborg | ae215b1 | 2006-01-08 18:39:44 +0100 | [diff] [blame] | 69 | case "$1" in |
| 70 | "-check") |
| 71 | shift |
Sam Ravnborg | 60f33b8 | 2006-01-15 15:28:35 +0100 | [diff] [blame] | 72 | cc="$@" |
Sam Ravnborg | ae215b1 | 2006-01-08 18:39:44 +0100 | [diff] [blame] | 73 | check |
| 74 | ;; |
| 75 | "-ccflags") |
| 76 | ccflags |
| 77 | ;; |
| 78 | "-ldflags") |
Sam Ravnborg | 60f33b8 | 2006-01-15 15:28:35 +0100 | [diff] [blame] | 79 | shift |
| 80 | cc="$@" |
Sam Ravnborg | ae215b1 | 2006-01-08 18:39:44 +0100 | [diff] [blame] | 81 | ldflags |
| 82 | ;; |
| 83 | "*") |
| 84 | usage |
| 85 | exit 1 |
| 86 | ;; |
| 87 | esac |