448e353923f3b52545a7473d4ff5a4e342a7f959
[linux-2.6.git] / scripts / kconfig / lxdialog / check-lxdialog.sh
1 #!/bin/sh
2 # Check ncurses compatibility
3
4 # What library to link
5 ldflags()
6 {
7         echo "main() {}" | $cc -lncursesw -xc - -o /dev/null 2> /dev/null
8         if [ $? -eq 0 ]; then
9                 echo '-lncursesw'
10                 exit
11         fi
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
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() {
42         echo "main() {}" | $cc -xc - -o /dev/null 2> /dev/null
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
65                 cc="$@"
66                 check
67                 ;;
68         "-ccflags")
69                 ccflags
70                 ;;
71         "-ldflags")
72                 shift
73                 cc="$@"
74                 ldflags
75                 ;;
76         "*")
77                 usage
78                 exit 1
79                 ;;
80 esac