blob: 9d2a4c585ee18526f4f141988f965852c2765e73 [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{
Justin Lecherfc9c6e02013-03-06 14:02:01 +01007 pkg-config --libs ncursesw 2>/dev/null && exit
8 pkg-config --libs ncurses 2>/dev/null && exit
Yaakov Selkowitz3725f3e2012-06-12 19:05:15 -05009 for ext in so a dll.a dylib ; do
Mike Frysinger03c95872007-05-17 15:06:31 -040010 for lib in ncursesw ncurses curses ; do
11 $cc -print-file-name=lib${lib}.${ext} | grep -q /
12 if [ $? -eq 0 ]; then
13 echo "-l${lib}"
14 exit
15 fi
16 done
17 done
Sam Ravnborg60f33b82006-01-15 15:28:35 +010018 exit 1
Sam Ravnborgae215b12006-01-08 18:39:44 +010019}
20
21# Where is ncurses.h?
22ccflags()
23{
Yaakov Selkowitz84354252012-06-12 19:05:02 -050024 if [ -f /usr/include/ncursesw/curses.h ]; then
Yann E. MORINcdf0c2c2013-03-22 23:12:16 +010025 echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"'
Krzysztof Mazur7d5bb962012-10-08 18:18:22 +020026 echo ' -DNCURSES_WIDECHAR=1'
Yaakov Selkowitz84354252012-06-12 19:05:02 -050027 elif [ -f /usr/include/ncurses/ncurses.h ]; then
Sam Ravnborgae215b12006-01-08 18:39:44 +010028 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
29 elif [ -f /usr/include/ncurses/curses.h ]; then
Yann E. MORINcdf0c2c2013-03-22 23:12:16 +010030 echo '-I/usr/include/ncurses -DCURSES_LOC="<curses.h>"'
Sam Ravnborgae215b12006-01-08 18:39:44 +010031 elif [ -f /usr/include/ncurses.h ]; then
32 echo '-DCURSES_LOC="<ncurses.h>"'
33 else
34 echo '-DCURSES_LOC="<curses.h>"'
35 fi
36}
37
Sam Ravnborg3835f822006-01-21 12:03:09 +010038# Temp file, try to clean up after us
39tmp=.lxdialog.tmp
40trap "rm -f $tmp" 0 1 2 3 15
41
Sam Ravnborgae215b12006-01-08 18:39:44 +010042# Check if we can link to ncurses
43check() {
Jean Delvareb1e0d8b2012-10-02 16:42:36 +020044 $cc -x c - -o $tmp 2>/dev/null <<'EOF'
Sam Ravnborgb44158d2008-05-01 19:29:47 +020045#include CURSES_LOC
46main() {}
47EOF
Sam Ravnborgae215b12006-01-08 18:39:44 +010048 if [ $? != 0 ]; then
Sam Ravnborg6e588f62007-12-09 20:11:15 +010049 echo " *** Unable to find the ncurses libraries or the" 1>&2
50 echo " *** required header files." 1>&2
51 echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2
52 echo " *** " 1>&2
53 echo " *** Install ncurses (ncurses-devel) and try again." 1>&2
54 echo " *** " 1>&2
55 exit 1
Sam Ravnborgae215b12006-01-08 18:39:44 +010056 fi
57}
58
59usage() {
Sam Ravnborgf6682f92008-12-03 22:11:14 +010060 printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
Sam Ravnborgae215b12006-01-08 18:39:44 +010061}
62
Mike Frysingere99c3432007-05-23 21:37:45 -040063if [ $# -eq 0 ]; then
Sam Ravnborgae215b12006-01-08 18:39:44 +010064 usage
65 exit 1
66fi
67
Sam Ravnborg3835f822006-01-21 12:03:09 +010068cc=""
Sam Ravnborgae215b12006-01-08 18:39:44 +010069case "$1" in
70 "-check")
71 shift
Sam Ravnborg60f33b82006-01-15 15:28:35 +010072 cc="$@"
Sam Ravnborgae215b12006-01-08 18:39:44 +010073 check
74 ;;
75 "-ccflags")
76 ccflags
77 ;;
78 "-ldflags")
Sam Ravnborg60f33b82006-01-15 15:28:35 +010079 shift
80 cc="$@"
Sam Ravnborgae215b12006-01-08 18:39:44 +010081 ldflags
82 ;;
83 "*")
84 usage
85 exit 1
86 ;;
87esac