util/kconfig: Uprev to Linux 6.2's kconfig

The upstream build system uses a newly introduced function `read-file`,
so copy that in from Linux 6.2.

TEST=`util/abuild/abuild -C` output (config.h and config.build) remains
the same

Change-Id: Ic100bf189ebd3eaa0eb26904ae8602910329a180
Signed-off-by: Patrick Georgi <patrick@coreboot.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/79179
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin L Roth <gaumless@gmail.com>
This commit is contained in:
Patrick Georgi 2023-11-20 18:03:34 +01:00
parent 7f93aa4919
commit 7eab8ef8b7
13 changed files with 94 additions and 59 deletions

View File

@ -1,5 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-only
/conf
/[gmnq]conf
/[gmnq]conf-cfg
/[gmnq]conf-bin
/[gmnq]conf-cflags
/[gmnq]conf-libs
/qconf-moc.cc

View File

@ -159,11 +159,12 @@ conf-objs := conf.o $(common-objs)
hostprogs += nconf
nconf-objs := nconf.o nconf.gui.o $(common-objs)
HOSTLDLIBS_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)
HOSTLDLIBS_nconf = $(call read-file, $(obj)/nconf-libs)
HOSTCFLAGS_nconf.o = $(call read-file, $(obj)/nconf-cflags)
HOSTCFLAGS_nconf.gui.o = $(call read-file, $(obj)/nconf-cflags)
$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg
$(obj)/nconf: | $(obj)/nconf-libs
$(obj)/nconf.o $(obj)/nconf.gui.o: | $(obj)/nconf-cflags
# mconf: Used for the menuconfig target based on lxdialog
hostprogs += mconf
@ -171,27 +172,28 @@ lxdialog := $(addprefix lxdialog/, \
checklist.o inputbox.o menubox.o textbox.o util.o yesno.o)
mconf-objs := mconf.o $(lxdialog) $(common-objs)
HOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs)
HOSTLDLIBS_mconf = $(call read-file, $(obj)/mconf-libs)
$(foreach f, mconf.o $(lxdialog), \
$(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags)))
$(eval HOSTCFLAGS_$f = $$(call read-file, $(obj)/mconf-cflags)))
$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg
$(obj)/mconf: | $(obj)/mconf-libs
$(addprefix $(obj)/, mconf.o $(lxdialog)): | $(obj)/mconf-cflags
# qconf: Used for the xconfig target based on Qt
hostprogs += qconf
qconf-cxxobjs := qconf.o qconf-moc.o
qconf-objs := images.o $(common-objs)
HOSTLDLIBS_qconf = $(shell . $(obj)/qconf-cfg && echo $$libs)
HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/qconf-cfg && echo $$cflags)
HOSTCXXFLAGS_qconf-moc.o = $(shell . $(obj)/qconf-cfg && echo $$cflags)
$(obj)/qconf.o: $(obj)/qconf-cfg
HOSTLDLIBS_qconf = $(call read-file, $(obj)/qconf-libs)
HOSTCXXFLAGS_qconf.o = -std=c++11 -fPIC $(call read-file, $(obj)/qconf-cflags)
HOSTCXXFLAGS_qconf-moc.o = -std=c++11 -fPIC $(call read-file, $(obj)/qconf-cflags)
$(obj)/qconf: | $(obj)/qconf-libs
$(obj)/qconf.o $(obj)/qconf-moc.o: | $(obj)/qconf-cflags
quiet_cmd_moc = MOC $@
cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) $< -o $@
cmd_moc = $(call read-file, $(obj)/qconf-bin)/moc $< -o $@
$(obj)/qconf-moc.cc: $(src)/qconf.h $(obj)/qconf-cfg FORCE
$(obj)/qconf-moc.cc: $(src)/qconf.h FORCE | $(obj)/qconf-bin
$(call if_changed,moc)
targets += qconf-moc.cc
@ -200,15 +202,16 @@ targets += qconf-moc.cc
hostprogs += gconf
gconf-objs := gconf.o images.o $(common-objs)
HOSTLDLIBS_gconf = $(shell . $(obj)/gconf-cfg && echo $$libs)
HOSTCFLAGS_gconf.o = $(shell . $(obj)/gconf-cfg && echo $$cflags)
HOSTLDLIBS_gconf = $(call read-file, $(obj)/gconf-libs)
HOSTCFLAGS_gconf.o = $(call read-file, $(obj)/gconf-cflags)
$(obj)/gconf.o: $(obj)/gconf-cfg
$(obj)/gconf: | $(obj)/gconf-libs
$(obj)/gconf.o: | $(obj)/gconf-cflags
# check if necessary packages are available, and configure build flags
filechk_conf_cfg = $(CONFIG_SHELL) $<
cmd_conf_cfg = $< $(addprefix $(obj)/$*conf-, cflags libs bin); touch $(obj)/$*conf-bin
$(obj)/%conf-cfg: $(src)/%conf-cfg.sh FORCE
$(call filechk,conf_cfg)
$(obj)/%conf-cflags $(obj)/%conf-libs $(obj)/%conf-bin: $(src)/%conf-cfg.sh
$(call cmd,conf_cfg)
clean-files += *conf-cfg
clean-files += *conf-cflags *conf-libs *conf-bin

View File

@ -25,6 +25,20 @@ $(objk)/Makefile.real: $(dir $(lastword $(MAKEFILE_LIST)))Makefile
kecho := echo
###
# Read a file, replacing newlines with spaces
#
# Make 4.2 or later can read a file by using its builtin function.
#
# Imported from Linux upstream:
# commit 6768fa4bcb6c1618248f135d04b9287ba2724ae0
# Author: Masahiro Yamada <masahiroy@kernel.org>
ifneq ($(filter-out 3.% 4.0 4.1, $(MAKE_VERSION)),)
read-file = $(subst $(newline),$(space),$(file < $1))
else
read-file = $(shell cat $1 2>/dev/null)
endif
-include $(objk)/Makefile.real
unexport KCONFIG_DEFCONFIG_LIST

View File

@ -1,6 +1,9 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
cflags=$1
libs=$2
PKG="gtk+-2.0 gmodule-2.0 libglade-2.0"
if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then
@ -26,5 +29,5 @@ if ! ${HOSTPKG_CONFIG} --atleast-version=2.0.0 gtk+-2.0; then
exit 1
fi
echo cflags=\"$(${HOSTPKG_CONFIG} --cflags $PKG)\"
echo libs=\"$(${HOSTPKG_CONFIG} --libs $PKG)\"
${HOSTPKG_CONFIG} --cflags ${PKG} > ${cflags}
${HOSTPKG_CONFIG} --libs ${PKG} > ${libs}

View File

@ -80,7 +80,7 @@ struct gstr str_new(void);
void str_free(struct gstr *gs);
void str_append(struct gstr *gs, const char *s);
void str_printf(struct gstr *gs, const char *fmt, ...);
const char *str_get(struct gstr *gs);
char *str_get(struct gstr *gs);
/* menu.c */
void _menu_init(void);

View File

@ -1,19 +1,22 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
cflags=$1
libs=$2
PKG="ncursesw"
PKG2="ncurses"
if [ -n "$(command -v ${HOSTPKG_CONFIG})" ]; then
if ${HOSTPKG_CONFIG} --exists $PKG; then
echo cflags=\"$(${HOSTPKG_CONFIG} --cflags $PKG)\"
echo libs=\"$(${HOSTPKG_CONFIG} --libs $PKG)\"
${HOSTPKG_CONFIG} --cflags ${PKG} > ${cflags}
${HOSTPKG_CONFIG} --libs ${PKG} > ${libs}
exit 0
fi
if ${HOSTPKG_CONFIG} --exists $PKG2; then
echo cflags=\"$(${HOSTPKG_CONFIG} --cflags $PKG2)\"
echo libs=\"$(${HOSTPKG_CONFIG} --libs $PKG2)\"
if ${HOSTPKG_CONFIG} --exists ${PKG2}; then
${HOSTPKG_CONFIG} --cflags ${PKG2} > ${cflags}
${HOSTPKG_CONFIG} --libs ${PKG2} > ${libs}
exit 0
fi
fi
@ -22,14 +25,14 @@ fi
# (Even if it is installed, some distributions such as 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\"
echo -D_GNU_SOURCE -I/usr/include/ncursesw > ${cflags}
echo -lncursesw > ${libs}
exit 0
fi
if [ -f /usr/include/ncurses/ncurses.h ]; then
echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncurses\"
echo libs=\"-lncurses\"
echo -D_GNU_SOURCE -I/usr/include/ncurses > ${cflags}
echo -lncurses > ${libs}
exit 0
fi
@ -42,8 +45,8 @@ fi
# As a final fallback before giving up, check if $HOSTCC knows of a default
# ncurses installation (e.g. from a vendor-specific sysroot).
if echo '#include <ncurses.h>' | ${HOSTCC} -E - >/dev/null 2>&1; then
echo cflags=\"-D_GNU_SOURCE\"
echo libs=\"-lncurses\"
echo -D_GNU_SOURCE > ${cflags}
echo -lncurses > ${libs}
exit 0
fi

View File

@ -163,6 +163,12 @@ static const char mconf_readme[] =
"(especially with a larger number of unrolled categories) than the\n"
"default mode.\n"
"\n"
"Search\n"
"-------\n"
"Pressing the forward-slash (/) anywhere brings up a search dialog box.\n"
"\n"
"Different color themes available\n"
"--------------------------------\n"
"It is possible to select different color themes using the variable\n"
@ -442,9 +448,8 @@ again:
res = get_relations_str(sym_arr, &head);
set_subtitle();
dres = show_textbox_ext("Search Results", (char *)
str_get(&res), 0, 0, keys, &vscroll,
&hscroll, &update_text, (void *)
dres = show_textbox_ext("Search Results", str_get(&res), 0, 0,
keys, &vscroll, &hscroll, &update_text,
&data);
again = false;
for (i = 0; i < JUMP_NB && keys[i]; i++)

View File

@ -724,10 +724,8 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
menu = prop->menu;
for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) {
bool accessible = menu_is_visible(menu);
submenu[i++] = menu;
if (location == NULL && accessible)
if (location == NULL && menu_is_visible(menu))
location = menu;
}
if (head && location) {

View File

@ -1,19 +1,22 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
cflags=$1
libs=$2
PKG="ncursesw menuw panelw"
PKG2="ncurses menu panel"
if [ -n "$(command -v ${HOSTPKG_CONFIG})" ]; then
if ${HOSTPKG_CONFIG} --exists $PKG; then
echo cflags=\"$(${HOSTPKG_CONFIG} --cflags $PKG)\"
echo libs=\"$(${HOSTPKG_CONFIG} --libs $PKG)\"
${HOSTPKG_CONFIG} --cflags ${PKG} > ${cflags}
${HOSTPKG_CONFIG} --libs ${PKG} > ${libs}
exit 0
fi
if ${HOSTPKG_CONFIG} --exists $PKG2; then
echo cflags=\"$(${HOSTPKG_CONFIG} --cflags $PKG2)\"
echo libs=\"$(${HOSTPKG_CONFIG} --libs $PKG2)\"
${HOSTPKG_CONFIG} --cflags ${PKG2} > ${cflags}
${HOSTPKG_CONFIG} --libs ${PKG2} > ${libs}
exit 0
fi
fi
@ -22,20 +25,20 @@ fi
# (Even if it is installed, some distributions such as 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\"
echo -D_GNU_SOURCE -I/usr/include/ncursesw > ${cflags}
echo -lncursesw -lmenuw -lpanelw > ${libs}
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\"
echo -D_GNU_SOURCE -I/usr/include/ncurses > ${cflags}
echo -lncurses -lmenu -lpanel > ${libs}
exit 0
fi
if [ -f /usr/include/ncurses.h ]; then
echo cflags=\"-D_GNU_SOURCE\"
echo libs=\"-lncurses -lmenu -lpanel\"
echo -D_GNU_SOURCE > ${cflags}
echo -lncurses -lmenu -lpanel > ${libs}
exit 0
fi

View File

@ -102,7 +102,7 @@ Index: kconfig/mconf.c
static const char mconf_readme[] =
"Overview\n"
"--------\n"
@@ -948,6 +950,7 @@ static void conf_save(void)
@@ -953,6 +955,7 @@ static void conf_save(void)
static int handle_exit(void)
{
int res;
@ -110,7 +110,7 @@ Index: kconfig/mconf.c
save_and_exit = 1;
reset_subtitle();
@@ -962,6 +965,13 @@ static int handle_exit(void)
@@ -967,6 +970,13 @@ static int handle_exit(void)
end_dialog(saved_x, saved_y);

View File

@ -13,7 +13,7 @@ Index: kconfig/mconf-cfg.sh
===================================================================
--- kconfig.orig/mconf-cfg.sh
+++ kconfig/mconf-cfg.sh
@@ -33,6 +33,12 @@ if [ -f /usr/include/ncurses/ncurses.h ]
@@ -36,6 +36,12 @@ if [ -f /usr/include/ncurses/ncurses.h ]
exit 0
fi

View File

@ -1,6 +1,10 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
cflags=$1
libs=$2
bin=$3
PKG="Qt5Core Qt5Gui Qt5Widgets"
if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then
@ -11,9 +15,9 @@ if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then
fi
if ${HOSTPKG_CONFIG} --exists $PKG; then
echo cflags=\"-std=c++11 -fPIC $(${HOSTPKG_CONFIG} --cflags $PKG)\"
echo libs=\"$(${HOSTPKG_CONFIG} --libs $PKG)\"
echo moc=\"$(${HOSTPKG_CONFIG} --variable=host_bins Qt5Core)/moc\"
${HOSTPKG_CONFIG} --cflags ${PKG} > ${cflags}
${HOSTPKG_CONFIG} --libs ${PKG} > ${libs}
${HOSTPKG_CONFIG} --variable=host_bins Qt5Core > ${bin}
exit 0
fi

View File

@ -74,7 +74,7 @@ void str_printf(struct gstr *gs, const char *fmt, ...)
}
/* Retrieve value of growable string */
const char *str_get(struct gstr *gs)
char *str_get(struct gstr *gs)
{
return gs->s;
}