blob: 120d624e672c5740faf2aa744aa7785c5edbecab [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 Ravnborg3835f822006-01-21 12:03:09 +01007 $cc -print-file-name=libncursesw.so | grep -q /
Sam Ravnborg60f33b82006-01-15 15:28:35 +01008 if [ $? -eq 0 ]; then
9 echo '-lncursesw'
10 exit
Sam Ravnborgae215b12006-01-08 18:39:44 +010011 fi
Sam Ravnborg3835f822006-01-21 12:03:09 +010012 $cc -print-file-name=libncurses.so | grep -q /
Sam Ravnborg60f33b82006-01-15 15:28:35 +010013 if [ $? -eq 0 ]; then
14 echo '-lncurses'
15 exit
16 fi
Sam Ravnborg3835f822006-01-21 12:03:09 +010017 $cc -print-file-name=libcurses.so | grep -q /
Sam Ravnborg60f33b82006-01-15 15:28:35 +010018 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
Sam Ravnborg3835f822006-01-21 12:03:09 +010039# Temp file, try to clean up after us
40tmp=.lxdialog.tmp
41trap "rm -f $tmp" 0 1 2 3 15
42
Sam Ravnborgae215b12006-01-08 18:39:44 +010043# Check if we can link to ncurses
44check() {
Sam Ravnborg3835f822006-01-21 12:03:09 +010045 echo "main() {}" | $cc -xc - -o $tmp 2> /dev/null
Sam Ravnborgae215b12006-01-08 18:39:44 +010046 if [ $? != 0 ]; then
47 echo " *** Unable to find the ncurses libraries." 1>&2
48 echo " *** make menuconfig require the ncurses libraries" 1>&2
49 echo " *** " 1>&2
50 echo " *** Install ncurses (ncurses-devel) and try again" 1>&2
51 echo " *** " 1>&2
52 exit 1
53 fi
54}
55
56usage() {
57 printf "Usage: $0 [-check compiler options|-header|-library]\n"
58}
59
60if [ $# == 0 ]; then
61 usage
62 exit 1
63fi
64
Sam Ravnborg3835f822006-01-21 12:03:09 +010065cc=""
Sam Ravnborgae215b12006-01-08 18:39:44 +010066case "$1" in
67 "-check")
68 shift
Sam Ravnborg60f33b82006-01-15 15:28:35 +010069 cc="$@"
Sam Ravnborgae215b12006-01-08 18:39:44 +010070 check
71 ;;
72 "-ccflags")
73 ccflags
74 ;;
75 "-ldflags")
Sam Ravnborg60f33b82006-01-15 15:28:35 +010076 shift
77 cc="$@"
Sam Ravnborgae215b12006-01-08 18:39:44 +010078 ldflags
79 ;;
80 "*")
81 usage
82 exit 1
83 ;;
84esac