blob: 9d2a4c585ee18526f4f141988f965852c2765e73 [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{
Yaakov Selkowitza0f24a02012-06-12 19:05:02 -050024 if [ -f /usr/include/ncursesw/curses.h ]; then
Yann E. MORINd35ba8b2013-03-22 23:12:16 +010025 echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"'
Krzysztof Mazurf7554302012-10-08 18:18:22 +020026 echo ' -DNCURSES_WIDECHAR=1'
Yaakov Selkowitza0f24a02012-06-12 19:05:02 -050027 elif [ -f /usr/include/ncurses/ncurses.h ]; then
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000028 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
29 elif [ -f /usr/include/ncurses/curses.h ]; then
Yann E. MORINd35ba8b2013-03-22 23:12:16 +010030 echo '-I/usr/include/ncurses -DCURSES_LOC="<curses.h>"'
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000031 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
38# Temp file, try to clean up after us
39tmp=.lxdialog.tmp
40trap "rm -f $tmp" 0 1 2 3 15
41
42# Check if we can link to ncurses
43check() {
Jean Delvare8c3f9432012-10-02 16:42:36 +020044 $cc -x c - -o $tmp 2>/dev/null <<'EOF'
Bernhard Reutner-Fischerf3d1e212008-08-27 07:39:57 +000045#include CURSES_LOC
46main() {}
47EOF
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000048 if [ $? != 0 ]; then
Bernhard Reutner-Fischerf3d1e212008-08-27 07:39:57 +000049 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
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000056 fi
57}
58
59usage() {
Bernhard Reutner-Fischeraa30efc2010-06-11 15:31:54 +020060 printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000061}
62
Bernhard Reutner-Fischerf3d1e212008-08-27 07:39:57 +000063if [ $# -eq 0 ]; then
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000064 usage
65 exit 1
66fi
67
68cc=""
69case "$1" in
70 "-check")
71 shift
72 cc="$@"
73 check
74 ;;
75 "-ccflags")
76 ccflags
77 ;;
78 "-ldflags")
79 shift
80 cc="$@"
81 ldflags
82 ;;
83 "*")
84 usage
85 exit 1
86 ;;
87esac