Skip to content

Commit

Permalink
kconfig: refactor ncurses package checks for building mconf and nconf
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Masahiro Yamada committed May 28, 2018
1 parent b464ef5 commit 1c5af5c
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 128 deletions.
58 changes: 24 additions & 34 deletions scripts/kconfig/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -173,59 +173,49 @@ help:
@echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support'
@echo ' tinyconfig - Configure the tiniest possible kernel'

# lxdialog stuff
check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh

# Use recursively expanded variables so we do not call gcc unless
# we really need to do so. (Do not call gcc as part of make mrproper)
HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
-DLOCALE

# ===========================================================================
# Shared Makefile for the various kconfig executables:
# conf: Used for defconfig, oldconfig and related targets
# nconf: Used for the nconfig target.
# Utilizes ncurses
# mconf: Used for the menuconfig target
# Utilizes the lxdialog package
# object files used by all kconfig flavours

lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o

conf-objs := conf.o zconf.tab.o
mconf-objs := mconf.o zconf.tab.o $(lxdialog)
nconf-objs := nconf.o zconf.tab.o nconf.gui.o
kxgettext-objs := kxgettext.o zconf.tab.o

hostprogs-y := conf nconf mconf kxgettext
hostprogs-y := conf kxgettext

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

# Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
PHONY += $(obj)/dochecklxdialog
$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/dochecklxdialog
$(obj)/dochecklxdialog:
$(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf)

always := dochecklxdialog

# Add environment specific flags
HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
HOST_EXTRACXXFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCXX) $(HOSTCXXFLAGS))

HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS)) \
-DLOCALE
HOST_EXTRACXXFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCXX) $(HOSTCXXFLAGS)) \
-DLOCALE
# generated files seem to need this to find local include files
HOSTCFLAGS_zconf.lex.o := -I$(src)
HOSTCFLAGS_zconf.tab.o := -I$(src)

HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
# nconf: Used for the nconfig target based on ncurses
hostprogs-y += nconf
nconf-objs := nconf.o zconf.tab.o nconf.gui.o

HOSTLOADLIBES_nconf = $(shell . $(obj)/.nconf-cfg && echo $$libs)
HOSTCFLAGS_nconf.o = $(shell . $(obj)/.nconf-cfg && echo $$cflags)
HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/.nconf-cfg && echo $$cflags)

$(obj)/nconf.o: $(obj)/.nconf-cfg

# mconf: Used for the menuconfig target based on lxdialog
hostprogs-y += mconf
lxdialog := checklist.o inputbox.o menubox.o textbox.o util.o yesno.o
mconf-objs := mconf.o zconf.tab.o $(addprefix lxdialog/, $(lxdialog))

HOSTLOADLIBES_mconf = $(shell . $(obj)/.mconf-cfg && echo $$libs)
$(foreach f, mconf.o $(lxdialog), \
$(eval HOSTCFLAGS_$f = $$(shell . $(obj)/.mconf-cfg && echo $$$$cflags)))

HOSTLOADLIBES_nconf = $(shell \
pkg-config --libs menuw panelw ncursesw 2>/dev/null \
|| pkg-config --libs menu panel ncurses 2>/dev/null \
|| echo "-lmenu -lpanel -lncurses" )
$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/.mconf-cfg

# qconf: Used for the xconfig target based on Qt
hostprogs-y += qconf
Expand Down
93 changes: 0 additions & 93 deletions scripts/kconfig/lxdialog/check-lxdialog.sh

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/kconfig/lxdialog/dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#ifdef __sun__
#define CURS_MACROS
#endif
#include CURSES_LOC
#include <ncurses.h>

/*
* Colors in ncurses 1.9.9e do not work properly since foreground and
Expand Down
44 changes: 44 additions & 0 deletions scripts/kconfig/mconf-cfg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0

PKG="ncursesw"
PKG2="ncurses"

if pkg-config --exists $PKG; then
echo cflags=\"$(pkg-config --cflags $PKG)\"
echo libs=\"$(pkg-config --libs $PKG)\"
exit 0
fi

if pkg-config --exists $PKG2; then
echo cflags=\"$(pkg-config --cflags $PKG2)\"
echo libs=\"$(pkg-config --libs $PKG2)\"
exit 0
fi

# Unfortunately, some distributions (e.g. openSUSE) cannot find ncurses
# by pkg-config.
if [ -f /usr/include/ncursesw/ncurses.h ]; then
echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\"
echo libs=\"-lncursesw\"
exit 0
fi

if [ -f /usr/include/ncurses/ncurses.h ]; then
echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncurses\"
echo libs=\"-lncurses\"
exit 0
fi

if [ -f /usr/include/ncurses.h ]; then
echo cflags=\"-D_GNU_SOURCE\"
echo libs=\"-lncurses\"
exit 0
fi

echo >&2 "*"
echo >&2 "* Unable to find the ncurses package."
echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev"
echo >&2 "* depending on your distribution)."
echo >&2 "*"
exit 1
44 changes: 44 additions & 0 deletions scripts/kconfig/nconf-cfg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0

PKG="ncursesw menuw panelw"
PKG2="ncurses menu panel"

if pkg-config --exists $PKG; then
echo cflags=\"$(pkg-config --cflags $PKG)\"
echo libs=\"$(pkg-config --libs $PKG)\"
exit 0
fi

if pkg-config --exists $PKG2; then
echo cflags=\"$(pkg-config --cflags $PKG2)\"
echo libs=\"$(pkg-config --libs $PKG2)\"
exit 0
fi

# Unfortunately, some distributions (e.g. openSUSE) cannot find ncurses
# by pkg-config.
if [ -f /usr/include/ncursesw/ncurses.h ]; then
echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\"
echo libs=\"-lncursesw -lmenuw -lpanelw\"
exit 0
fi

if [ -f /usr/include/ncurses/ncurses.h ]; then
echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncurses\"
echo libs=\"-lncurses -lmenu -lpanel\"
exit 0
fi

if [ -f /usr/include/ncurses.h ]; then
echo cflags=\"-D_GNU_SOURCE\"
echo libs=\"-lncurses -lmenu -lpanel\"
exit 0
fi

echo >&2 "*"
echo >&2 "* Unable to find the ncurses package."
echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev"
echo >&2 "* depending on your distribution)."
echo >&2 "*"
exit 1

0 comments on commit 1c5af5c

Please sign in to comment.