Portability fixes for "make menuconfig"
v3 cover Portability fixes for "make menuconfig"
Hi,
Here are two portability fixes needed to be able to run "make menuconfig" on NixOS[1].
[1]: http://nixos.org/
Bj?rn Forsman (2):
Makefile: pass host PKG_CONFIG_PATH at "make menuconfig" time kconfig/lxdialog: get ncurses CFLAGS with pkg-config
Makefile | 4 +- support/kconfig/lxdialog/check-lxdialog.sh | 6 ++- ...dialog-get-ncurses-CFLAGS-with-pkg-config.patch | 50 ++++++++++++++++++++++ support/kconfig/patches/series | 1 + 4 files changed, 59 insertions(+), 2 deletions(-) mode change 100644 => 100755 support/kconfig/lxdialog/check-lxdialog.sh create mode 100644 support/kconfig/patches/17-kconfig-lxdialog-get-ncurses-CFLAGS-with-pkg-config.patch
Changes v2 -> v3:
- fixup kconfig/lxdialog patch a/... b/... sub-paths (kconfig is located in different sub-directories in linux and buildroot) and apply the patch with quilt. (I apparently didn't test v2 properly; I thought the patch series were automatically applied by Buildroot, but it has to be applied manually and then committed.)
- address comments from Yann:
- use immediate assignment for HOST_PKG_CONFIG_PATH
- drop unneeded export of HOST_PKG_CONFIG_PATH
- drop unneeded sub-shell, place PKG_CONFIG_PATH in front of $(MAKE) instead
- re-order patches
- add quotes around expansion of $HOST_PKG_CONFIG_PATH
Changes v1 -> v2:
- make the kconfig/lxdialog patch a separate patch file, instead of modifying the kconfig sources (which are synced with linux from time to time). Suggested by Thomas P.
Signature · 1 line
2.1.3
PATCH v3 1/2 Makefile: pass host PKG_CONFIG_PATH at "make menuconfig" time
Buildroot unexports PKG_CONFIG_PATH in the top-level Makefile for purity reasons. But it has an unfortunate side-effect in that "make menuconfig" will not (necessarily) be able to pick up ncurses via host pkg-config, breaking "make menuconfig" on systems where ncurses is installed in a non-standard location.
This patch saves the original PKG_CONFIG_PATH variable in HOST_PKG_CONFIG_PATH and restores the original PKG_CONFIG_PATH variable only in the sub-processes that builds the various menuconfig/nconfig/... targets.
(PKG_CONFIG_PATH has to be placed in front of the make command so that it propagates to sub-processes. If given as an argument, it doesn't work.)
--- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Makefile +3 -1
@@ -264,6 +264,7 @@ export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE # Make sure pkg-config doesn't look outside the buildroot tree +HOST_PKG_CONFIG_PATH := $(PKG_CONFIG_PATH) unexport PKG_CONFIG_PATH unexport PKG_CONFIG_SYSROOT_DIR unexport PKG_CONFIG_LIBDIR
@@ -692,7 +693,8 @@ export HOSTCFLAGS $(BUILD_DIR)/buildroot-config/%onf: mkdir -p $(@D)/lxdialog - $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F) + PKG_CONFIG_PATH="$(HOST_PKG_CONFIG_PATH)" $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" \ + obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F) DEFCONFIG = $(call qstrip,$(BR2_DEFCONFIG))
Signature · 1 line
2.1.3
PATCH v3 1/2 Makefile: pass host PKG_CONFIG_PATH at "make menuconfig" time
Bj?rn, All,
On 2015-01-03 00:58 +0100, Bj?rn Forsman spake thusly:
Quoted 11 lines
Buildroot unexports
PKG_CONFIG_PATHin the top-levelMakefilefor purity reasons. But it has an unfortunate side-effect in that "make menuconfig" will not (necessarily) be able to pick up ncurses via host pkg-config, breaking "make menuconfig" on systems where ncurses is installed in a non-standard location.This patch saves the original
PKG_CONFIG_PATHvariable inHOST_PKG_CONFIG_PATHand restores the originalPKG_CONFIG_PATHvariable only in the sub-processes that builds the various menuconfig/nconfig/... targets.
Quoted 4 lines
(
PKG_CONFIG_PATHhas to be placed in front of the make command so that it propagates to sub-processes. If given as an argument, it doesn't work.)Signed-off-by Bj?rn Forsman <[email protected]>
Regards,
Yann E. MORIN.
Quoted 33 lines
--- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)Makefile +3
-1@@ -264,6 +264,7 @@ export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE # Make sure pkg-config doesn't look outside the buildroot tree +HOST_PKG_CONFIG_PATH := $(PKG_CONFIG_PATH) unexport PKG_CONFIG_PATH unexport PKG_CONFIG_SYSROOT_DIR unexport PKG_CONFIG_LIBDIR@@ -692,7 +693,8 @@ export HOSTCFLAGS $(BUILD_DIR)/buildroot-config/%onf: mkdir -p $(@D)/lxdialog - $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F) + PKG_CONFIG_PATH="$(HOST_PKG_CONFIG_PATH)" $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" \ + obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F) DEFCONFIG = $(call qstrip,$(BR2_DEFCONFIG))Signature · 6 lines
2.1.3 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH v3 2/2 kconfig/lxdialog: get ncurses CFLAGS with pkg-config
In reply to Bjørn ForsmanThis makes "make menuconfig" also work on systems where ncurses is not installed in a standard location (such as on NixOS).
This patch changes ccflags() so that it tries pkg-config first, and only if pkg-config fails does it go back to the fallback/manual checks. This is the same algorithm that ldflags() already uses.
[This patch is already applied upstream (is part of linux v3.18):
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=be8af2d54a66911693eddc556e4f7a866670082b
I'm adding this instead of doing a full upstream kconfig sync because there was a conflict in one of the Buildroot kconfig patches (against linux 3.18-rc1), which I was unable to resolve. Just drop this patch next time Buildroot kconfig is synced against upstream.
]
--- support/kconfig/lxdialog/check-lxdialog.sh | 6 ++- ...dialog-get-ncurses-CFLAGS-with-pkg-config.patch | 50 ++++++++++++++++++++++ support/kconfig/patches/series | 1 + 3 files changed, 56 insertions(+), 1 deletion(-) mode change 100644 => 100755 support/kconfig/lxdialog/check-lxdialog.sh create mode 100644 support/kconfig/patches/17-kconfig-lxdialog-get-ncurses-CFLAGS-with-pkg-config.patch
support/kconfig/lxdialog/check-lxdialog.sh +5 -1
@@ -21,7 +21,11 @@ ldflags() # Where is ncurses.h? ccflags() { - if [ -f /usr/include/ncursesw/curses.h ]; then + if pkg-config --cflags ncursesw 2>/dev/null; then + echo '-DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1' + elif pkg-config --cflags ncurses 2>/dev/null; then + echo '-DCURSES_LOC="<ncurses.h>"' + elif [ -f /usr/include/ncursesw/curses.h ]; then echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"' echo ' -DNCURSES_WIDECHAR=1' elif [ -f /usr/include/ncurses/ncurses.h ]; then
support/kconfig/patches/17-kconfig-lxdialog-get-ncurses-CFLAGS-with-pkg-config.patch new file +50 -0
50 lines not on this page · raw message
support/kconfig/patches/series +1 -0
@@ -6,3 +6,4 @@ 14-support-out-of-tree-config.patch 15-fix-qconf-moc-rule.patch 16-fix-space-to-de-select-options.patch +17-kconfig-lxdialog-get-ncurses-CFLAGS-with-pkg-config.patch
Signature · 1 line
2.1.3
PATCH v3 2/2 kconfig/lxdialog: get ncurses CFLAGS with pkg-config
Bj?rn, All,
On 2015-01-03 00:58 +0100, Bj?rn Forsman spake thusly:
Quoted 10 lines
This makes "make menuconfig" also work on systems where ncurses is not installed in a standard location (such as on NixOS).
This patch changes
ccflags()so that it tries pkg-config first, and only if pkg-config fails does it go back to the fallback/manual checks. This is the same algorithm thatldflags()already uses.[This patch is already applied upstream (is part of linux v3.18):
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=be8af2d54a66911693eddc556e4f7a866670082b
Quoted 7 lines
I'm adding this instead of doing a full upstream kconfig sync because there was a conflict in one of the Buildroot kconfig patches (against linux 3.18-rc1), which I was unable to resolve. Just drop this patch next time Buildroot kconfig is synced against upstream.
]Signed-off-by Bj?rn Forsman <[email protected]>
Regards,
Yann E. MORIN.
Quoted 99 lines
--- support/kconfig/lxdialog/check-lxdialog.sh | 6 ++- ...dialog-get-ncurses-CFLAGS-with-pkg-config.patch | 50 ++++++++++++++++++++++ support/kconfig/patches/series | 1 + 3 files changed, 56 insertions(+), 1 deletion(-) mode change 100644 => 100755 support/kconfig/lxdialog/check-lxdialog.sh create mode 100644 support/kconfig/patches/17-kconfig-lxdialog-get-ncurses-CFLAGS-with-pkg-config.patchsupport/kconfig/lxdialog/check-lxdialog.sh +5
-1@@ -21,7 +21,11 @@ ldflags() # Where is ncurses.h? ccflags() { - if [ -f /usr/include/ncursesw/curses.h ]; then + if pkg-config --cflags ncursesw 2>/dev/null; then + echo '-DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1' + elif pkg-config --cflags ncurses 2>/dev/null; then + echo '-DCURSES_LOC="<ncurses.h>"' + elif [ -f /usr/include/ncursesw/curses.h ]; then echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"' echo ' -DNCURSES_WIDECHAR=1' elif [ -f /usr/include/ncurses/ncurses.h ]; thensupport/kconfig/patches/17-kconfig-lxdialog-get-ncurses-CFLAGS-with-pkg-config.patch new file +50
-0@@ -0,0 +1,50 @@ +From be8af2d54a66911693eddc556e4f7a866670082b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= <[email protected]> +Date: Sun, 14 Sep 2014 12:57:50 +0200 +Subject: [PATCH] kconfig/lxdialog: get ncurses CFLAGS with pkg-config +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This makes "make menuconfig" also work on systems where ncurses is not +installed in a standard location (such as on NixOS). + +This patch changes ccflags() so that it tries pkg-config first, and only +if pkg-config fails does it go back to the fallback/manual checks. This +is the same algorithm that ldflags() already uses. + +Signed-off-by: Bj?rn Forsman <[email protected]> +Signed-off-by: Michal Marek <[email protected]> +--- +[This patch is already applied upstream (is part of linux v3.18): +https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=be8af2d54a66911693eddc556e4f7a866670082b + +I'm adding this instead of doing a full upstream kconfig sync because +there was a conflict in one of the Buildroot kconfig patches (against +linux 3.18-rc1), which I was unable to resolve. Just drop this patch next time +Buildroot kconfig is synced against upstream. +] + + scripts/kconfig/lxdialog/check-lxdialog.sh | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh +index 9d2a4c5..5075ebf 100755 +--- a/lxdialog/check-lxdialog.sh ++++ b/lxdialog/check-lxdialog.sh +@@ -21,7 +21,11 @@ ldflags() + # Where is ncurses.h? + ccflags() + { +- if [ -f /usr/include/ncursesw/curses.h ]; then ++ if pkg-config --cflags ncursesw 2>/dev/null; then ++ echo '-DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1' ++ elif pkg-config --cflags ncurses 2>/dev/null; then ++ echo '-DCURSES_LOC="<ncurses.h>"' ++ elif [ -f /usr/include/ncursesw/curses.h ]; then + echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"' + echo ' -DNCURSES_WIDECHAR=1' + elif [ -f /usr/include/ncurses/ncurses.h ]; then +-- +2.1.3 +support/kconfig/patches/series +1
-0@@ -6,3 +6,4 @@ 14-support-out-of-tree-config.patch 15-fix-qconf-moc-rule.patch 16-fix-space-to-de-select-options.patch +17-kconfig-lxdialog-get-ncurses-CFLAGS-with-pkg-config.patchSignature · 6 lines
2.1.3 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
v3 cover Portability fixes for "make menuconfig"
In reply to Bjørn ForsmanDear Bj?rn Forsman,
Quoted 3 lines · Bj?rn Forsman
Bj?rn Forsman (2):
Makefile: pass hostPKG_CONFIG_PATHat "make menuconfig" time kconfig/lxdialog: get ncurses CFLAGS with pkg-config
Both patches applied, thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
v3 cover Portability fixes for "make menuconfig"
Quoted 9 lines · Thomas Petazzoni
Dear Bj?rn Forsman,
Quoted 3 lines · Bj?rn Forsman
Bj?rn Forsman (2):
Makefile: pass hostPKG_CONFIG_PATHat "make menuconfig" time kconfig/lxdialog: get ncurses CFLAGS with pkg-configBoth patches applied, thanks!
Weee! Thanks.
It is one year and seven days since I first posted that kconfig/lxdialog patch to the upstream linux kbuild mailing list. Now finally it is merged both upstream and in Buildroot :-)
Best regards,
Bj?rn Forsman
v3 cover Portability fixes for "make menuconfig"
Dear Bj?rn Forsman,
Quoted 5 lines · Bj?rn Forsman
Weee! Thanks.
It is one year and seven days since I first posted that kconfig/lxdialog patch to the upstream linux kbuild mailing list. Now finally it is merged both upstream and in Buildroot :-)
Yeah, sorry for the long delay, thanks a lot for your persistence!
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com