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 # SPDX-License-Identifier: GPL-2.0-only
/conf /conf
/[gmnq]conf /[gmnq]conf
/[gmnq]conf-cfg /[gmnq]conf-bin
/[gmnq]conf-cflags
/[gmnq]conf-libs
/qconf-moc.cc /qconf-moc.cc

View file

@ -159,11 +159,12 @@ conf-objs := conf.o $(common-objs)
hostprogs += nconf hostprogs += nconf
nconf-objs := nconf.o nconf.gui.o $(common-objs) nconf-objs := nconf.o nconf.gui.o $(common-objs)
HOSTLDLIBS_nconf = $(shell . $(obj)/nconf-cfg && echo $$libs) HOSTLDLIBS_nconf = $(call read-file, $(obj)/nconf-libs)
HOSTCFLAGS_nconf.o = $(shell . $(obj)/nconf-cfg && echo $$cflags) HOSTCFLAGS_nconf.o = $(call read-file, $(obj)/nconf-cflags)
HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/nconf-cfg && echo $$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 # mconf: Used for the menuconfig target based on lxdialog
hostprogs += mconf hostprogs += mconf
@ -171,27 +172,28 @@ lxdialog := $(addprefix lxdialog/, \
checklist.o inputbox.o menubox.o textbox.o util.o yesno.o) checklist.o inputbox.o menubox.o textbox.o util.o yesno.o)
mconf-objs := mconf.o $(lxdialog) $(common-objs) 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), \ $(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 # qconf: Used for the xconfig target based on Qt
hostprogs += qconf hostprogs += qconf
qconf-cxxobjs := qconf.o qconf-moc.o qconf-cxxobjs := qconf.o qconf-moc.o
qconf-objs := images.o $(common-objs) qconf-objs := images.o $(common-objs)
HOSTLDLIBS_qconf = $(shell . $(obj)/qconf-cfg && echo $$libs) HOSTLDLIBS_qconf = $(call read-file, $(obj)/qconf-libs)
HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/qconf-cfg && echo $$cflags) HOSTCXXFLAGS_qconf.o = -std=c++11 -fPIC $(call read-file, $(obj)/qconf-cflags)
HOSTCXXFLAGS_qconf-moc.o = $(shell . $(obj)/qconf-cfg && echo $$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-cfg $(obj)/qconf.o $(obj)/qconf-moc.o: | $(obj)/qconf-cflags
quiet_cmd_moc = MOC $@ 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) $(call if_changed,moc)
targets += qconf-moc.cc targets += qconf-moc.cc
@ -200,15 +202,16 @@ targets += qconf-moc.cc
hostprogs += gconf hostprogs += gconf
gconf-objs := gconf.o images.o $(common-objs) gconf-objs := gconf.o images.o $(common-objs)
HOSTLDLIBS_gconf = $(shell . $(obj)/gconf-cfg && echo $$libs) HOSTLDLIBS_gconf = $(call read-file, $(obj)/gconf-libs)
HOSTCFLAGS_gconf.o = $(shell . $(obj)/gconf-cfg && echo $$cflags) 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 # 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 $(obj)/%conf-cflags $(obj)/%conf-libs $(obj)/%conf-bin: $(src)/%conf-cfg.sh
$(call filechk,conf_cfg) $(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 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 -include $(objk)/Makefile.real
unexport KCONFIG_DEFCONFIG_LIST unexport KCONFIG_DEFCONFIG_LIST

View file

@ -1,6 +1,9 @@
#!/bin/sh #!/bin/sh
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
cflags=$1
libs=$2
PKG="gtk+-2.0 gmodule-2.0 libglade-2.0" PKG="gtk+-2.0 gmodule-2.0 libglade-2.0"
if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then 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 exit 1
fi fi
echo cflags=\"$(${HOSTPKG_CONFIG} --cflags $PKG)\" ${HOSTPKG_CONFIG} --cflags ${PKG} > ${cflags}
echo libs=\"$(${HOSTPKG_CONFIG} --libs $PKG)\" ${HOSTPKG_CONFIG} --libs ${PKG} > ${libs}

View file

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

View file

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

View file

@ -163,6 +163,12 @@ static const char mconf_readme[] =
"(especially with a larger number of unrolled categories) than the\n" "(especially with a larger number of unrolled categories) than the\n"
"default mode.\n" "default mode.\n"
"\n" "\n"
"Search\n"
"-------\n"
"Pressing the forward-slash (/) anywhere brings up a search dialog box.\n"
"\n"
"Different color themes available\n" "Different color themes available\n"
"--------------------------------\n" "--------------------------------\n"
"It is possible to select different color themes using the variable\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); res = get_relations_str(sym_arr, &head);
set_subtitle(); set_subtitle();
dres = show_textbox_ext("Search Results", (char *) dres = show_textbox_ext("Search Results", str_get(&res), 0, 0,
str_get(&res), 0, 0, keys, &vscroll, keys, &vscroll, &hscroll, &update_text,
&hscroll, &update_text, (void *)
&data); &data);
again = false; again = false;
for (i = 0; i < JUMP_NB && keys[i]; i++) 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; menu = prop->menu;
for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) { for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) {
bool accessible = menu_is_visible(menu);
submenu[i++] = menu; submenu[i++] = menu;
if (location == NULL && accessible) if (location == NULL && menu_is_visible(menu))
location = menu; location = menu;
} }
if (head && location) { if (head && location) {

View file

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

View file

@ -102,7 +102,7 @@ Index: kconfig/mconf.c
static const char mconf_readme[] = static const char mconf_readme[] =
"Overview\n" "Overview\n"
"--------\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) static int handle_exit(void)
{ {
int res; int res;
@ -110,7 +110,7 @@ Index: kconfig/mconf.c
save_and_exit = 1; save_and_exit = 1;
reset_subtitle(); 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); end_dialog(saved_x, saved_y);

View file

@ -13,7 +13,7 @@ Index: kconfig/mconf-cfg.sh
=================================================================== ===================================================================
--- kconfig.orig/mconf-cfg.sh --- kconfig.orig/mconf-cfg.sh
+++ kconfig/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 exit 0
fi fi

View file

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

View file

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