blob: 448e353923f3b52545a7473d4ff5a4e342a7f959 [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{
Sam Ravnborg60f33b82006-01-15 15:28:35 +01007 echo "main() {}" | $cc -lncursesw -xc - -o /dev/null 2> /dev/null
8 if [ $? -eq 0 ]; then
9 echo '-lncursesw'
10 exit
Sam Ravnborgae215b12006-01-08 18:39:44 +010011 fi
Sam Ravnborg60f33b82006-01-15 15:28:35 +010012 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 Ravnborgae215b12006-01-08 18:39:44 +010023}
24
25# Where is ncurses.h?
26ccflags()
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
39compiler=""
40# Check if we can link to ncurses
41check() {
Sam Ravnborg60f33b82006-01-15 15:28:35 +010042 echo "main() {}" | $cc -xc - -o /dev/null 2> /dev/null
Sam Ravnborgae215b12006-01-08 18:39:44 +010043 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
53usage() {
54 printf "Usage: $0 [-check compiler options|-header|-library]\n"
55}
56
57if [ $# == 0 ]; then
58 usage
59 exit 1
60fi
61
62case "$1" in
63 "-check")
64 shift
Sam Ravnborg60f33b82006-01-15 15:28:35 +010065 cc="$@"
Sam Ravnborgae215b12006-01-08 18:39:44 +010066 check
67 ;;
68 "-ccflags")
69 ccflags
70 ;;
71 "-ldflags")
Sam Ravnborg60f33b82006-01-15 15:28:35 +010072 shift
73 cc="$@"
Sam Ravnborgae215b12006-01-08 18:39:44 +010074 ldflags
75 ;;
76 "*")
77 usage
78 exit 1
79 ;;
80esac