Skip to content

Commit 1c5af5c

Browse files
committed
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 <[email protected]> Tested-by: Randy Dunlap <[email protected]> Acked-by: Randy Dunlap <[email protected]> Reviewed-by: Sam Ravnborg <[email protected]>
1 parent b464ef5 commit 1c5af5c

File tree

5 files changed

+113
-128
lines changed

5 files changed

+113
-128
lines changed

scripts/kconfig/Makefile

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -173,59 +173,49 @@ help:
173173
@echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support'
174174
@echo ' tinyconfig - Configure the tiniest possible kernel'
175175

176-
# lxdialog stuff
177-
check-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)
181-
HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
182-
-DLOCALE
183-
184176
# ===========================================================================
185177
# Shared Makefile for the various kconfig executables:
186178
# 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
191179
# object files used by all kconfig flavours
192180

193-
lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
194-
lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
195-
196181
conf-objs := conf.o zconf.tab.o
197-
mconf-objs := mconf.o zconf.tab.o $(lxdialog)
198-
nconf-objs := nconf.o zconf.tab.o nconf.gui.o
199182
kxgettext-objs := kxgettext.o zconf.tab.o
200183

201-
hostprogs-y := conf nconf mconf kxgettext
184+
hostprogs-y := conf kxgettext
202185

203186
targets += zconf.lex.c
204187
clean-files += gconf.glade.h
205188
clean-files += config.pot linux.pot
206189

207-
# Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
208-
PHONY += $(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-
213-
always := dochecklxdialog
214-
215190
# Add environment specific flags
216-
HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
217-
HOST_EXTRACXXFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCXX) $(HOSTCXXFLAGS))
218-
191+
HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS)) \
192+
-DLOCALE
193+
HOST_EXTRACXXFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCXX) $(HOSTCXXFLAGS)) \
194+
-DLOCALE
219195
# generated files seem to need this to find local include files
220196
HOSTCFLAGS_zconf.lex.o := -I$(src)
221197
HOSTCFLAGS_zconf.tab.o := -I$(src)
222198

223-
HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
199+
# nconf: Used for the nconfig target based on ncurses
200+
hostprogs-y += nconf
201+
nconf-objs := nconf.o zconf.tab.o nconf.gui.o
202+
203+
HOSTLOADLIBES_nconf = $(shell . $(obj)/.nconf-cfg && echo $$libs)
204+
HOSTCFLAGS_nconf.o = $(shell . $(obj)/.nconf-cfg && echo $$cflags)
205+
HOSTCFLAGS_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
210+
hostprogs-y += mconf
211+
lxdialog := checklist.o inputbox.o menubox.o textbox.o util.o yesno.o
212+
mconf-objs := mconf.o zconf.tab.o $(addprefix lxdialog/, $(lxdialog))
213+
214+
HOSTLOADLIBES_mconf = $(shell . $(obj)/.mconf-cfg && echo $$libs)
215+
$(foreach f, mconf.o $(lxdialog), \
216+
$(eval HOSTCFLAGS_$f = $$(shell . $(obj)/.mconf-cfg && echo $$$$cflags)))
224217

225-
HOSTLOADLIBES_nconf = $(shell \
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" )
218+
$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/.mconf-cfg
229219

230220
# qconf: Used for the xconfig target based on Qt
231221
hostprogs-y += qconf

scripts/kconfig/lxdialog/check-lxdialog.sh

Lines changed: 0 additions & 93 deletions
This file was deleted.

scripts/kconfig/lxdialog/dialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#ifdef __sun__
3636
#define CURS_MACROS
3737
#endif
38-
#include CURSES_LOC
38+
#include <ncurses.h>
3939

4040
/*
4141
* Colors in ncurses 1.9.9e do not work properly since foreground and

scripts/kconfig/mconf-cfg.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
PKG="ncursesw"
5+
PKG2="ncurses"
6+
7+
if pkg-config --exists $PKG; then
8+
echo cflags=\"$(pkg-config --cflags $PKG)\"
9+
echo libs=\"$(pkg-config --libs $PKG)\"
10+
exit 0
11+
fi
12+
13+
if pkg-config --exists $PKG2; then
14+
echo cflags=\"$(pkg-config --cflags $PKG2)\"
15+
echo libs=\"$(pkg-config --libs $PKG2)\"
16+
exit 0
17+
fi
18+
19+
# Unfortunately, some distributions (e.g. openSUSE) cannot find ncurses
20+
# by pkg-config.
21+
if [ -f /usr/include/ncursesw/ncurses.h ]; then
22+
echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\"
23+
echo libs=\"-lncursesw\"
24+
exit 0
25+
fi
26+
27+
if [ -f /usr/include/ncurses/ncurses.h ]; then
28+
echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncurses\"
29+
echo libs=\"-lncurses\"
30+
exit 0
31+
fi
32+
33+
if [ -f /usr/include/ncurses.h ]; then
34+
echo cflags=\"-D_GNU_SOURCE\"
35+
echo libs=\"-lncurses\"
36+
exit 0
37+
fi
38+
39+
echo >&2 "*"
40+
echo >&2 "* Unable to find the ncurses package."
41+
echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev"
42+
echo >&2 "* depending on your distribution)."
43+
echo >&2 "*"
44+
exit 1

scripts/kconfig/nconf-cfg.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
PKG="ncursesw menuw panelw"
5+
PKG2="ncurses menu panel"
6+
7+
if pkg-config --exists $PKG; then
8+
echo cflags=\"$(pkg-config --cflags $PKG)\"
9+
echo libs=\"$(pkg-config --libs $PKG)\"
10+
exit 0
11+
fi
12+
13+
if pkg-config --exists $PKG2; then
14+
echo cflags=\"$(pkg-config --cflags $PKG2)\"
15+
echo libs=\"$(pkg-config --libs $PKG2)\"
16+
exit 0
17+
fi
18+
19+
# Unfortunately, some distributions (e.g. openSUSE) cannot find ncurses
20+
# by pkg-config.
21+
if [ -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
25+
fi
26+
27+
if [ -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
31+
fi
32+
33+
if [ -f /usr/include/ncurses.h ]; then
34+
echo cflags=\"-D_GNU_SOURCE\"
35+
echo libs=\"-lncurses -lmenu -lpanel\"
36+
exit 0
37+
fi
38+
39+
echo >&2 "*"
40+
echo >&2 "* Unable to find the ncurses package."
41+
echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev"
42+
echo >&2 "* depending on your distribution)."
43+
echo >&2 "*"
44+
exit 1

0 commit comments

Comments
 (0)