Commit 3122c844 authored by Masahiro Yamada's avatar Masahiro Yamada

kconfig: refactor Makefile to reduce process forks

Refactor Makefile and use read-file macro. For Make >= 4.2, it can read
out a file by using the built-in function.
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
Reviewed-by: default avatarNicolas Schier <nicolas@fjasle.eu>
parent 6768fa4b
# 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-cflags
/[gmnq]conf-libs
/qconf-bin
/qconf-moc.cc /qconf-moc.cc
...@@ -159,11 +159,12 @@ conf-objs := conf.o $(common-objs) ...@@ -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/, \ ...@@ -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 ...@@ -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)
$(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
#!/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 ...@@ -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}
#!/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,22 +25,22 @@ fi ...@@ -22,22 +25,22 @@ 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
# 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
......
#!/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 ...@@ -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
......
#!/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 ...@@ -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
......
...@@ -47,3 +47,5 @@ rm -f arch/riscv/purgatory/kexec-purgatory.c ...@@ -47,3 +47,5 @@ rm -f arch/riscv/purgatory/kexec-purgatory.c
rm -f scripts/extract-cert rm -f scripts/extract-cert
rm -f arch/x86/purgatory/kexec-purgatory.c rm -f arch/x86/purgatory/kexec-purgatory.c
rm -f scripts/kconfig/[gmnq]conf-cfg
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment