aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2018-05-22 03:22:21 -0400
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-05-28 05:25:21 -0400
commit1c5af5cf9308fff327f52c7efd2dfa732d370871 (patch)
tree4213cc0e09349a31a41715acb94b6196f415abdb
parentb464ef583dc71bb066ea83bda43317196f94da9c (diff)
kconfig: refactor ncurses package checks for building mconf and nconf
The mconf (or its infrastructure, lxdiaglog) depends on the ncurses. Move and rename check-lxdialog.sh to mconf-cfg.sh to make it work in the same way as for qconf and gconf. This commit fixes some more weirdnesses. The nconf also needs ncurses packages. HOSTLOADLIBES_nconf is set to the libraries needed for nconf, but the cflags is not explicitly set. Actually, nconf relies on the check-lxdialog.sh for the proper cflags: HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \ -DLOCALE The code above passes the ncurses flags to all objects, even for conf, qconf, gconf. Let's pass the ncurses flags only to mconf and nconf. Currently, the presence of ncurses is not checked for nconf. Let's show a prompt like the mconf case. According to Randy's report, the shell scripts still need to carry the fallback code in case the pkg-config fails to find the ncurses packages. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Tested-by: Randy Dunlap <rdunlap@infradead.org> Acked-by: Randy Dunlap <rdunlap@infradead.org> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
-rw-r--r--scripts/kconfig/Makefile58
-rwxr-xr-xscripts/kconfig/lxdialog/check-lxdialog.sh93
-rw-r--r--scripts/kconfig/lxdialog/dialog.h2
-rwxr-xr-xscripts/kconfig/mconf-cfg.sh44
-rw-r--r--scripts/kconfig/nconf-cfg.sh44
5 files changed, 113 insertions, 128 deletions
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index c2227455a2f8..a71596c7ecfd 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -173,59 +173,49 @@ help:
173 @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support' 173 @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support'
174 @echo ' tinyconfig - Configure the tiniest possible kernel' 174 @echo ' tinyconfig - Configure the tiniest possible kernel'
175 175
176# lxdialog stuff
177check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
178
179# Use recursively expanded variables so we do not call gcc unless
180# we really need to do so. (Do not call gcc as part of make mrproper)
181HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
182 -DLOCALE
183
184# =========================================================================== 176# ===========================================================================
185# Shared Makefile for the various kconfig executables: 177# Shared Makefile for the various kconfig executables:
186# conf: Used for defconfig, oldconfig and related targets 178# conf: Used for defconfig, oldconfig and related targets
187# nconf: Used for the nconfig target.
188# Utilizes ncurses
189# mconf: Used for the menuconfig target
190# Utilizes the lxdialog package
191# object files used by all kconfig flavours 179# object files used by all kconfig flavours
192 180
193lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
194lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
195
196conf-objs := conf.o zconf.tab.o 181conf-objs := conf.o zconf.tab.o
197mconf-objs := mconf.o zconf.tab.o $(lxdialog)
198nconf-objs := nconf.o zconf.tab.o nconf.gui.o
199kxgettext-objs := kxgettext.o zconf.tab.o 182kxgettext-objs := kxgettext.o zconf.tab.o
200 183
201hostprogs-y := conf nconf mconf kxgettext 184hostprogs-y := conf kxgettext
202 185
203targets += zconf.lex.c 186targets += zconf.lex.c
204clean-files += gconf.glade.h 187clean-files += gconf.glade.h
205clean-files += config.pot linux.pot 188clean-files += config.pot linux.pot
206 189
207# Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
208PHONY += $(obj)/dochecklxdialog
209$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/dochecklxdialog
210$(obj)/dochecklxdialog:
211 $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf)
212
213always := dochecklxdialog
214
215# Add environment specific flags 190# Add environment specific flags
216HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS)) 191HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS)) \
217HOST_EXTRACXXFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCXX) $(HOSTCXXFLAGS)) 192 -DLOCALE
218 193HOST_EXTRACXXFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCXX) $(HOSTCXXFLAGS)) \
194 -DLOCALE
219# generated files seem to need this to find local include files 195# generated files seem to need this to find local include files
220HOSTCFLAGS_zconf.lex.o := -I$(src) 196HOSTCFLAGS_zconf.lex.o := -I$(src)
221HOSTCFLAGS_zconf.tab.o := -I$(src) 197HOSTCFLAGS_zconf.tab.o := -I$(src)
222 198
223HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) 199# nconf: Used for the nconfig target based on ncurses
200hostprogs-y += nconf
201nconf-objs := nconf.o zconf.tab.o nconf.gui.o
202
203HOSTLOADLIBES_nconf = $(shell . $(obj)/.nconf-cfg && echo $$libs)
204HOSTCFLAGS_nconf.o = $(shell . $(obj)/.nconf-cfg && echo $$cflags)
205HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/.nconf-cfg && echo $$cflags)
206
207$(obj)/nconf.o: $(obj)/.nconf-cfg
208
209# mconf: Used for the menuconfig target based on lxdialog
210hostprogs-y += mconf
211lxdialog := checklist.o inputbox.o menubox.o textbox.o util.o yesno.o
212mconf-objs := mconf.o zconf.tab.o $(addprefix lxdialog/, $(lxdialog))
213
214HOSTLOADLIBES_mconf = $(shell . $(obj)/.mconf-cfg && echo $$libs)
215$(foreach f, mconf.o $(lxdialog), \
216 $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/.mconf-cfg && echo $$$$cflags)))
224 217
225HOSTLOADLIBES_nconf = $(shell \ 218$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/.mconf-cfg
226 pkg-config --libs menuw panelw ncursesw 2>/dev/null \
227 || pkg-config --libs menu panel ncurses 2>/dev/null \
228 || echo "-lmenu -lpanel -lncurses" )
229 219
230# qconf: Used for the xconfig target based on Qt 220# qconf: Used for the xconfig target based on Qt
231hostprogs-y += qconf 221hostprogs-y += qconf
diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh
deleted file mode 100755
index 6c0bcd9c472d..000000000000
--- a/scripts/kconfig/lxdialog/check-lxdialog.sh
+++ /dev/null
@@ -1,93 +0,0 @@
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# Check ncurses compatibility
4
5# What library to link
6ldflags()
7{
8 pkg-config --libs ncursesw 2>/dev/null && exit
9 pkg-config --libs ncurses 2>/dev/null && exit
10 for ext in so a dll.a dylib ; do
11 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
19 exit 1
20}
21
22# Where is ncurses.h?
23ccflags()
24{
25 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
30 echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"'
31 echo ' -DNCURSES_WIDECHAR=1'
32 elif [ -f /usr/include/ncurses/ncurses.h ]; then
33 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
34 elif [ -f /usr/include/ncurses/curses.h ]; then
35 echo '-I/usr/include/ncurses -DCURSES_LOC="<curses.h>"'
36 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
43# Temp file, try to clean up after us
44tmp=.lxdialog.tmp
45trap "rm -f $tmp" 0 1 2 3 15
46
47# Check if we can link to ncurses
48check() {
49 $cc -x c - -o $tmp 2>/dev/null <<'EOF'
50#include CURSES_LOC
51main() {}
52EOF
53 if [ $? != 0 ]; then
54 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 or libncurses-dev " 1>&2
59 echo " *** depending on your distribution) and try again." 1>&2
60 echo " *** " 1>&2
61 exit 1
62 fi
63}
64
65usage() {
66 printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
67}
68
69if [ $# -eq 0 ]; then
70 usage
71 exit 1
72fi
73
74cc=""
75case "$1" in
76 "-check")
77 shift
78 cc="$@"
79 check
80 ;;
81 "-ccflags")
82 ccflags
83 ;;
84 "-ldflags")
85 shift
86 cc="$@"
87 ldflags
88 ;;
89 "*")
90 usage
91 exit 1
92 ;;
93esac
diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h
index fcffd5b41fb0..52e30a0012f1 100644
--- a/scripts/kconfig/lxdialog/dialog.h
+++ b/scripts/kconfig/lxdialog/dialog.h
@@ -35,7 +35,7 @@
35#ifdef __sun__ 35#ifdef __sun__
36#define CURS_MACROS 36#define CURS_MACROS
37#endif 37#endif
38#include CURSES_LOC 38#include <ncurses.h>
39 39
40/* 40/*
41 * Colors in ncurses 1.9.9e do not work properly since foreground and 41 * Colors in ncurses 1.9.9e do not work properly since foreground and
diff --git a/scripts/kconfig/mconf-cfg.sh b/scripts/kconfig/mconf-cfg.sh
new file mode 100755
index 000000000000..e6f9facd0077
--- /dev/null
+++ b/scripts/kconfig/mconf-cfg.sh
@@ -0,0 +1,44 @@
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3
4PKG="ncursesw"
5PKG2="ncurses"
6
7if pkg-config --exists $PKG; then
8 echo cflags=\"$(pkg-config --cflags $PKG)\"
9 echo libs=\"$(pkg-config --libs $PKG)\"
10 exit 0
11fi
12
13if pkg-config --exists $PKG2; then
14 echo cflags=\"$(pkg-config --cflags $PKG2)\"
15 echo libs=\"$(pkg-config --libs $PKG2)\"
16 exit 0
17fi
18
19# Unfortunately, some distributions (e.g. openSUSE) cannot find ncurses
20# by pkg-config.
21if [ -f /usr/include/ncursesw/ncurses.h ]; then
22 echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\"
23 echo libs=\"-lncursesw\"
24 exit 0
25fi
26
27if [ -f /usr/include/ncurses/ncurses.h ]; then
28 echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncurses\"
29 echo libs=\"-lncurses\"
30 exit 0
31fi
32
33if [ -f /usr/include/ncurses.h ]; then
34 echo cflags=\"-D_GNU_SOURCE\"
35 echo libs=\"-lncurses\"
36 exit 0
37fi
38
39echo >&2 "*"
40echo >&2 "* Unable to find the ncurses package."
41echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev"
42echo >&2 "* depending on your distribution)."
43echo >&2 "*"
44exit 1
diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh
new file mode 100644
index 000000000000..42f5ac73548e
--- /dev/null
+++ b/scripts/kconfig/nconf-cfg.sh
@@ -0,0 +1,44 @@
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3
4PKG="ncursesw menuw panelw"
5PKG2="ncurses menu panel"
6
7if pkg-config --exists $PKG; then
8 echo cflags=\"$(pkg-config --cflags $PKG)\"
9 echo libs=\"$(pkg-config --libs $PKG)\"
10 exit 0
11fi
12
13if pkg-config --exists $PKG2; then
14 echo cflags=\"$(pkg-config --cflags $PKG2)\"
15 echo libs=\"$(pkg-config --libs $PKG2)\"
16 exit 0
17fi
18
19# Unfortunately, some distributions (e.g. openSUSE) cannot find ncurses
20# by pkg-config.
21if [ -f /usr/include/ncursesw/ncurses.h ]; then
22 echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\"
23 echo libs=\"-lncursesw -lmenuw -lpanelw\"
24 exit 0
25fi
26
27if [ -f /usr/include/ncurses/ncurses.h ]; then
28 echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncurses\"
29 echo libs=\"-lncurses -lmenu -lpanel\"
30 exit 0
31fi
32
33if [ -f /usr/include/ncurses.h ]; then
34 echo cflags=\"-D_GNU_SOURCE\"
35 echo libs=\"-lncurses -lmenu -lpanel\"
36 exit 0
37fi
38
39echo >&2 "*"
40echo >&2 "* Unable to find the ncurses package."
41echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev"
42echo >&2 "* depending on your distribution)."
43echo >&2 "*"
44exit 1