[OpenWrt-Devel] [PATCH v2] build: fix make kernel_menuconfig

Eneas Queiroz cotequeiroz at gmail.com
Tue Sep 24 16:06:28 EDT 2019


This is still failing on gentoo.  The problem is that when
scripts/config/lxdialog/check-lxdialog.sh is run, it will still use
the staging_dir/host/bin/pkg-config script without STAGING_PREFIX set.
See my suggestion below.

On Mon, Sep 23, 2019 at 4:39 AM Petr Štetiar <ynezz at true.cz> wrote:
>
> On a recent Gentoo Linux installation, invoking `make kernel_menuconfig`
> in the build system fails, whereas `make menuconfig` in the kernel tree
> alone works as expected.
>
> This is happening because STAGING_PREFIX is not defined when kernel's
> menuconfig target calls pkg-config from the toolchain/host and thus
> pkg-config returns an empty value, and the fallback values in the kernel
> config script are applied but those are off and the linking fails.
>
> Solution is to use system's pkg-config for kernel_menuconfig target in
> order to provide proper compiler/linker flags.
>
> Ref: FS#2423
> Cc: Thomas Albers <thomas.gameiro at gmail.com>
> Signed-off-by: Petr Štetiar <ynezz at true.cz>
> ---
>
> changes in v2:
>
>  * fixed kernel_nconfig path
>
>  Makefile                | 1 +
>  include/toplevel.mk     | 8 +++++++-
>  scripts/config/Makefile | 2 --
>  3 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index ab97eacc9d2b..65ee10a84b8d 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -18,6 +18,7 @@ $(if $(findstring $(space),$(TOPDIR)),$(error ERROR: The path to the OpenWrt dir
>
>  world:
>
> +DISTRO_PKG_CONFIG:=$(shell which -a pkg-config | grep -E '\/usr' | head -n 1)
If we export this, then we can check its existence in
tools/pkg-config/files/pkg-config, and decide which pkg-config we want
to run.
The following is optional, since it already works as is, but I would
suggest not using `/usr` as a filter here; TOPDIR may be in /usr.
Instead, we can filter-out "staging_dir/host/bin", which is what we
are adding to PATH below:

export DISTRO_PKG_CONFIG:=$(shell which -a pkg-config | grep -vE
'/staging_dir/host/bin/pkg-config' | head -n 1)

Then, we can use the variable in our pkg-config script to decide what
to run, using just pkg-config.real as a fallback if nothing is defined
(alternatively, we can fail instead):

--- a/tools/pkg-config/files/pkg-config
+++ b/tools/pkg-config/files/pkg-config
@@ -1,3 +1,9 @@
 #!/bin/sh

-pkg-config.real --define-variable=prefix=${STAGING_PREFIX}
--define-variable=exec_prefix=${STAGING_PREFIX}
--define-variable=bindir=${STAGING_PREFIX}/bin $@
+if [ -n "${STAGING_PREFIX}" ]; then
+       pkg-config.real --define-variable=prefix=${STAGING_PREFIX}
--define-variable=exec_prefix=${STAGING_PREFIX}
--define-variable=bindir=${STAGING_PREFIX}/bin $@
+elif [ -n "${DISTRO_PKG_CONFIG}" ]; then
+       ${DISTRO_PKG_CONFIG} $@
+else
+       pkg-config.real $@
+fi

Regards,

Eneas

_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list