blob: 80788137c670b2b7e7740c99803f03edd9803a3f [file] [log] [blame]
Sam Ravnborgae215b12006-01-08 18:39:44 +01001#!/bin/sh
2# Check ncurses compatibility
3
4# What library to link
5ldflags()
6{
Yaakov Selkowitz3725f3e2012-06-12 19:05:15 -05007 for ext in so a dll.a dylib ; do
Mike Frysinger03c95872007-05-17 15:06:31 -04008 for lib in ncursesw ncurses curses ; do
9 $cc -print-file-name=lib${lib}.${ext} | grep -q /
10 if [ $? -eq 0 ]; then
11 echo "-l${lib}"
12 exit
13 fi
14 done
15 done
Sam Ravnborg60f33b82006-01-15 15:28:35 +010016 exit 1
Sam Ravnborgae215b12006-01-08 18:39:44 +010017}
18
19# Where is ncurses.h?
20ccflags()
21{
Yaakov Selkowitz84354252012-06-12 19:05:02 -050022 if [ -f /usr/include/ncursesw/curses.h ]; then
23 echo '-I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"'
Krzysztof Mazur7d5bb962012-10-08 18:18:22 +020024 echo ' -DNCURSES_WIDECHAR=1'
Yaakov Selkowitz84354252012-06-12 19:05:02 -050025 elif [ -f /usr/include/ncurses/ncurses.h ]; then
Sam Ravnborgae215b12006-01-08 18:39:44 +010026 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
27 elif [ -f /usr/include/ncurses/curses.h ]; then
28 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
29 elif [ -f /usr/include/ncurses.h ]; then
30 echo '-DCURSES_LOC="<ncurses.h>"'
31 else
32 echo '-DCURSES_LOC="<curses.h>"'
33 fi
34}
35
Sam Ravnborg3835f822006-01-21 12:03:09 +010036# Temp file, try to clean up after us
37tmp=.lxdialog.tmp
38trap "rm -f $tmp" 0 1 2 3 15
39
Sam Ravnborgae215b12006-01-08 18:39:44 +010040# Check if we can link to ncurses
41check() {
Jean Delvareb1e0d8b2012-10-02 16:42:36 +020042 $cc -x c - -o $tmp 2>/dev/null <<'EOF'
Sam Ravnborgb44158d2008-05-01 19:29:47 +020043#include CURSES_LOC
44main() {}
45EOF
Sam Ravnborgae215b12006-01-08 18:39:44 +010046 if [ $? != 0 ]; then
Sam Ravnborg6e588f62007-12-09 20:11:15 +010047 echo " *** Unable to find the ncurses libraries or the" 1>&2
48 echo " *** required header files." 1>&2
49 echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2
50 echo " *** " 1>&2
51 echo " *** Install ncurses (ncurses-devel) and try again." 1>&2
52 echo " *** " 1>&2
53 exit 1
Sam Ravnborgae215b12006-01-08 18:39:44 +010054 fi
55}
56
57usage() {
Sam Ravnborgf6682f92008-12-03 22:11:14 +010058 printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
Sam Ravnborgae215b12006-01-08 18:39:44 +010059}
60
Mike Frysingere99c3432007-05-23 21:37:45 -040061if [ $# -eq 0 ]; then
Sam Ravnborgae215b12006-01-08 18:39:44 +010062 usage
63 exit 1
64fi
65
Sam Ravnborg3835f822006-01-21 12:03:09 +010066cc=""
Sam Ravnborgae215b12006-01-08 18:39:44 +010067case "$1" in
68 "-check")
69 shift
Sam Ravnborg60f33b82006-01-15 15:28:35 +010070 cc="$@"
Sam Ravnborgae215b12006-01-08 18:39:44 +010071 check
72 ;;
73 "-ccflags")
74 ccflags
75 ;;
76 "-ldflags")
Sam Ravnborg60f33b82006-01-15 15:28:35 +010077 shift
78 cc="$@"
Sam Ravnborgae215b12006-01-08 18:39:44 +010079 ldflags
80 ;;
81 "*")
82 usage
83 exit 1
84 ;;
85esac