blob: a10bd9d6fafd003a57aeb2baf24d4bc6dd04c982 [file] [log] [blame]
Sam Ravnborgae215b12006-01-08 18:39:44 +01001#!/bin/sh
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01002# SPDX-License-Identifier: GPL-2.0
Sam Ravnborgae215b12006-01-08 18:39:44 +01003# Check ncurses compatibility
4
5# What library to link
6ldflags()
7{
Justin Lecherfc9c6e02013-03-06 14:02:01 +01008 pkg-config --libs ncursesw 2>/dev/null && exit
9 pkg-config --libs ncurses 2>/dev/null && exit
Yaakov Selkowitz3725f3e2012-06-12 19:05:15 -050010 for ext in so a dll.a dylib ; do
Mike Frysinger03c95872007-05-17 15:06:31 -040011 for lib in ncursesw ncurses curses ; do
12 $cc -print-file-name=lib${lib}.${ext} | grep -q /
13 if [ $? -eq 0 ]; then
14 echo "-l${lib}"
15 exit
16 fi
17 done
18 done
Sam Ravnborg60f33b82006-01-15 15:28:35 +010019 exit 1
Sam Ravnborgae215b12006-01-08 18:39:44 +010020}
21
22# Where is ncurses.h?
23ccflags()
24{
Bjørn Forsmanbe8af2d2014-09-14 12:57:50 +020025 if pkg-config --cflags ncursesw 2>/dev/null; then
26 echo '-DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1'
27 elif pkg-config --cflags ncurses 2>/dev/null; then
28 echo '-DCURSES_LOC="<ncurses.h>"'
29 elif [ -f /usr/include/ncursesw/curses.h ]; then
Yann E. MORINcdf0c2c2013-03-22 23:12:16 +010030 echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"'
Krzysztof Mazur7d5bb962012-10-08 18:18:22 +020031 echo ' -DNCURSES_WIDECHAR=1'
Yaakov Selkowitz84354252012-06-12 19:05:02 -050032 elif [ -f /usr/include/ncurses/ncurses.h ]; then
Sam Ravnborgae215b12006-01-08 18:39:44 +010033 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
34 elif [ -f /usr/include/ncurses/curses.h ]; then
Yann E. MORINcdf0c2c2013-03-22 23:12:16 +010035 echo '-I/usr/include/ncurses -DCURSES_LOC="<curses.h>"'
Sam Ravnborgae215b12006-01-08 18:39:44 +010036 elif [ -f /usr/include/ncurses.h ]; then
37 echo '-DCURSES_LOC="<ncurses.h>"'
38 else
39 echo '-DCURSES_LOC="<curses.h>"'
40 fi
41}
42
Sam Ravnborg3835f822006-01-21 12:03:09 +010043# Temp file, try to clean up after us
44tmp=.lxdialog.tmp
45trap "rm -f $tmp" 0 1 2 3 15
46
Sam Ravnborgae215b12006-01-08 18:39:44 +010047# Check if we can link to ncurses
48check() {
Jean Delvareb1e0d8b2012-10-02 16:42:36 +020049 $cc -x c - -o $tmp 2>/dev/null <<'EOF'
Sam Ravnborgb44158d2008-05-01 19:29:47 +020050#include CURSES_LOC
51main() {}
52EOF
Sam Ravnborgae215b12006-01-08 18:39:44 +010053 if [ $? != 0 ]; then
Sam Ravnborg6e588f62007-12-09 20:11:15 +010054 echo " *** Unable to find the ncurses libraries or the" 1>&2
55 echo " *** required header files." 1>&2
56 echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2
57 echo " *** " 1>&2
58 echo " *** Install ncurses (ncurses-devel) and try again." 1>&2
59 echo " *** " 1>&2
60 exit 1
Sam Ravnborgae215b12006-01-08 18:39:44 +010061 fi
62}
63
64usage() {
Sam Ravnborgf6682f92008-12-03 22:11:14 +010065 printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
Sam Ravnborgae215b12006-01-08 18:39:44 +010066}
67
Mike Frysingere99c3432007-05-23 21:37:45 -040068if [ $# -eq 0 ]; then
Sam Ravnborgae215b12006-01-08 18:39:44 +010069 usage
70 exit 1
71fi
72
Sam Ravnborg3835f822006-01-21 12:03:09 +010073cc=""
Sam Ravnborgae215b12006-01-08 18:39:44 +010074case "$1" in
75 "-check")
76 shift
Sam Ravnborg60f33b82006-01-15 15:28:35 +010077 cc="$@"
Sam Ravnborgae215b12006-01-08 18:39:44 +010078 check
79 ;;
80 "-ccflags")
81 ccflags
82 ;;
83 "-ldflags")
Sam Ravnborg60f33b82006-01-15 15:28:35 +010084 shift
85 cc="$@"
Sam Ravnborgae215b12006-01-08 18:39:44 +010086 ldflags
87 ;;
88 "*")
89 usage
90 exit 1
91 ;;
92esac