blob: 9e277b1c79b033d893f96452373427c8fab5896e [file] [log] [blame]
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00001#!/bin/sh
2# Check ncurses compatibility
3
4# What library to link
5ldflags()
6{
7 $cc -print-file-name=libncursesw.so | grep -q /
8 if [ $? -eq 0 ]; then
9 echo '-lncursesw'
10 exit
11 fi
12 $cc -print-file-name=libncurses.so | grep -q /
13 if [ $? -eq 0 ]; then
14 echo '-lncurses'
15 exit
16 fi
17 $cc -print-file-name=libcurses.so | grep -q /
18 if [ $? -eq 0 ]; then
19 echo '-lcurses'
20 exit
21 fi
Denis Vlasenkoa619b852007-09-26 18:18:59 +000022 #bbox# exit 1
23 echo '-lcurses'
24 exit
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000025}
26
27# Where is ncurses.h?
28ccflags()
29{
30 if [ -f /usr/include/ncurses/ncurses.h ]; then
31 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
32 elif [ -f /usr/include/ncurses/curses.h ]; then
33 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
34 elif [ -f /usr/include/ncurses.h ]; then
35 echo '-DCURSES_LOC="<ncurses.h>"'
36 else
37 echo '-DCURSES_LOC="<curses.h>"'
38 fi
39}
40
41# Temp file, try to clean up after us
42tmp=.lxdialog.tmp
43trap "rm -f $tmp" 0 1 2 3 15
44
45# Check if we can link to ncurses
46check() {
47 echo "main() {}" | $cc -xc - -o $tmp 2> /dev/null
48 if [ $? != 0 ]; then
49 echo " *** Unable to find the ncurses libraries." 1>&2
50 echo " *** make menuconfig require the ncurses libraries" 1>&2
51 echo " *** " 1>&2
52 echo " *** Install ncurses (ncurses-devel) and try again" 1>&2
53 echo " *** " 1>&2
54 exit 1
55 fi
56}
57
58usage() {
59 printf "Usage: $0 [-check compiler options|-header|-library]\n"
60}
61
62if [ $# == 0 ]; then
63 usage
64 exit 1
65fi
66
67cc=""
68case "$1" in
69 "-check")
70 shift
71 cc="$@"
72 check
73 ;;
74 "-ccflags")
75 ccflags
76 ;;
77 "-ldflags")
78 shift
79 cc="$@"
80 ldflags
81 ;;
82 "*")
83 usage
84 exit 1
85 ;;
86esac