blob: 5075ebf2d3b995bee04c146d942abce4515b4559 [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{
Justin Lechere62c7152013-03-06 14:02:01 +01007 pkg-config --libs ncursesw 2>/dev/null && exit
8 pkg-config --libs ncurses 2>/dev/null && exit
Yaakov Selkowitz74f58ed2012-06-12 19:05:15 -05009 for ext in so a dll.a dylib ; do
Bernhard Reutner-Fischerf3d1e212008-08-27 07:39:57 +000010 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
Bernhard Reutner-Fischer1ebdacc2008-08-28 14:29:54 +000018 exit 1
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000019}
20
21# Where is ncurses.h?
22ccflags()
23{
Bjørn Forsmand63d77a2014-09-14 12:57:50 +020024 if pkg-config --cflags ncursesw 2>/dev/null; then
25 echo '-DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1'
26 elif pkg-config --cflags ncurses 2>/dev/null; then
27 echo '-DCURSES_LOC="<ncurses.h>"'
28 elif [ -f /usr/include/ncursesw/curses.h ]; then
Yann E. MORINd35ba8b2013-03-22 23:12:16 +010029 echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"'
Krzysztof Mazurf7554302012-10-08 18:18:22 +020030 echo ' -DNCURSES_WIDECHAR=1'
Yaakov Selkowitza0f24a02012-06-12 19:05:02 -050031 elif [ -f /usr/include/ncurses/ncurses.h ]; then
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000032 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
33 elif [ -f /usr/include/ncurses/curses.h ]; then
Yann E. MORINd35ba8b2013-03-22 23:12:16 +010034 echo '-I/usr/include/ncurses -DCURSES_LOC="<curses.h>"'
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000035 elif [ -f /usr/include/ncurses.h ]; then
36 echo '-DCURSES_LOC="<ncurses.h>"'
37 else
38 echo '-DCURSES_LOC="<curses.h>"'
39 fi
40}
41
42# Temp file, try to clean up after us
43tmp=.lxdialog.tmp
44trap "rm -f $tmp" 0 1 2 3 15
45
46# Check if we can link to ncurses
47check() {
Jean Delvare8c3f9432012-10-02 16:42:36 +020048 $cc -x c - -o $tmp 2>/dev/null <<'EOF'
Bernhard Reutner-Fischerf3d1e212008-08-27 07:39:57 +000049#include CURSES_LOC
50main() {}
51EOF
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000052 if [ $? != 0 ]; then
Bernhard Reutner-Fischerf3d1e212008-08-27 07:39:57 +000053 echo " *** Unable to find the ncurses libraries or the" 1>&2
54 echo " *** required header files." 1>&2
55 echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2
56 echo " *** " 1>&2
57 echo " *** Install ncurses (ncurses-devel) and try again." 1>&2
58 echo " *** " 1>&2
59 exit 1
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000060 fi
61}
62
63usage() {
Bernhard Reutner-Fischeraa30efc2010-06-11 15:31:54 +020064 printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000065}
66
Bernhard Reutner-Fischerf3d1e212008-08-27 07:39:57 +000067if [ $# -eq 0 ]; then
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000068 usage
69 exit 1
70fi
71
72cc=""
73case "$1" in
74 "-check")
75 shift
76 cc="$@"
77 check
78 ;;
79 "-ccflags")
80 ccflags
81 ;;
82 "-ldflags")
83 shift
84 cc="$@"
85 ldflags
86 ;;
87 "*")
88 usage
89 exit 1
90 ;;
91esac