BR2_KERNEL_HEADERS_TARGET: Add support for using target kernel for toolchain kernel headers.
RFC PATCH 1/1 BR2_KERNEL_HEADERS_TARGET: Add support for using target kernel for toolchain kernel headers.
This patch allows the toolchain to use the target kernel's headers instead of having to download an additional linux tree just for the toolchain.
Tested with the internal toolchain.
Only problem observed is that the kernel-headers..../.unpacked target is recreated on sub-sequent 'make' invocations, which recreates uclibc. But someone with more make-wizardry may be able to solve that.
It also copies the linux source, which may not be strictly required, but it seemed to be the safest option for now.
--- toolchain/kernel-headers/Config.in | 8 ++++++++ toolchain/kernel-headers/kernel-headers.mk | 8 ++++++++ 2 files changed, 16 insertions(+)
(quoted diff) +0 -0
b/toolchain/kernel-headers/Config.in
index 6155ef1..dc04fd2 100644
toolchain/kernel-headers/Config.in +8 -0
@@ -52,6 +52,13 @@ choice config BR2_KERNEL_HEADERS_SNAP bool "Local Linux snapshot (linux-2.6.tar.bz2)" + + config BR2_KERNEL_HEADERS_TARGET + bool "Target Linux kernel" + depends on BR2_LINUX_KERNEL + help + Use the Linux kernel specified for the target in + the Kernel menu. endchoice config BR2_DEFAULT_KERNEL_VERSION
@@ -73,4 +80,5 @@ config BR2_DEFAULT_KERNEL_HEADERS default "3.7.10" if BR2_KERNEL_HEADERS_3_7 default "3.8.7" if BR2_KERNEL_HEADERS_3_8 default "2.6" if BR2_KERNEL_HEADERS_SNAP + default "target.0" if BR2_KERNEL_HEADERS_TARGET default $BR2_DEFAULT_KERNEL_VERSION if BR2_KERNEL_HEADERS_VERSION
(quoted diff) +0 -0
kernel-headers.mk
index adf7bc4..731f508 100644
toolchain/kernel-headers/kernel-headers.mk +0 -0
@@ -42,8 +42,12 @@ $(LINUX_HEADERS_UNPACK_DIR)/.unpacked:
$(DL_DIR)/$(LINUX_HEADERS_SOURCE)
$(Q)$(call MESSAGE,"Extracting kernel headers") rm -rf $(LINUX_HEADERS_DIR)
$(INSTALL) -d $(@D)
+ifeq ($(BR2_KERNEL_HEADERS_TARGET),y)
+ rsync -au $(LINUX_DIR)/ $(@D)
+else
$(LINUX_HEADERS_CAT) $(DL_DIR)/$(LINUX_HEADERS_SOURCE) | \
tar $(TAR_STRIP_COMPONENTS)=1 -C $(@D) $(TAR_OPTIONS) -
+endif
touch $@
$(LINUX_HEADERS_UNPACK_DIR)/.patched:
$(LINUX_HEADERS_UNPACK_DIR)/.unpacked $(LINUX_HEADERS_DEPENDS) @@ -66,12 +70,16 @@ $(LINUX_HEADERS_DIR)/.configured:
$(LINUX_HEADERS_UNPACK_DIR)/.patched
)
touch $@
+ifeq ($(BR2_KERNEL_HEADERS_TARGET),y) +$(DL_DIR)/$(LINUX_HEADERS_SOURCE): linux-source linux-extract +else
$(DL_DIR)/$(LINUX_HEADERS_SOURCE):
ifeq ($(BR2_KERNEL_HEADERS_SNAP),y)
$(error No local $@ found, cannot continue. Are you sure you wanted to
enable BR2_KERNEL_HEADERS_SNAP?)
endif
$(Q)$(call MESSAGE,"Downloading kernel headers")
$(call DOWNLOAD,$(LINUX_HEADERS_SITE:/=)/$(LINUX_HEADERS_SOURCE))
+endif
kernel-headers: $(LINUX_HEADERS_DIR)/.configured
Signature · 4 lines
1.7.9.5 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20130417/c9bb3b11/attachment.html>
RFC PATCH 1/1 BR2_KERNEL_HEADERS_TARGET: Add support for using target kernel for toolchain kernel headers.
Dear Magnus Edenhill,
Quoted 9 lines · Magnus Edenhill
This patch allows the toolchain to use the target kernel's headers instead of having to download an additional linux tree just for the toolchain.
Tested with the internal toolchain.
Only problem observed is that the kernel-headers..../.unpacked target is recreated on sub-sequent 'make' invocations, which recreates uclibc. But someone with more make-wizardry may be able to solve that.
Quoted 7 lines
It also copies the linux source, which may not be strictly required, but it seemed to be the safest option for now.
--- toolchain/kernel-headers/Config.in | 8 ++++++++ toolchain/kernel-headers/kernel-headers.mk | 8 ++++++++ 2 files changed, 16 insertions(+)
Thanks for this contribution, and sorry for the long delay. During the current Buildroot meeting, we have looked at this patch, and came up with some suggestions before it can be merged:
1/ It should be rebased on top of the latest master, in which a number
of changes have been made to the internal toolchain backend.
2/ Instead of copying the Linux kernel sources from LINUX_DIR,
LINUX_HEADERS_DIR should do its own download and extract of the kernel sources. So package/linux-headers/linux-headers.mk should look like:
ifeq ($(BR2_KERNEL_HEADERS_SAME_AS_KERNEL),y) LINUX_HEADERS_VERSION = $(LINUX_VERSION) LINUX_HEADERS_SOURCE = $(LINUX_SOURCE)LINUX_HEADERS_SITE = $(LINUX_SITE) LINUX_HEADERS_SITE_METHOD = $(LINUX_SITE_METHOD)
elseLINUX_HEADERS_VERSION = $(call qstrip,$(BR2_DEFAULT_KERNEL_HEADERS)) ifeq ($(findstring x2.6.,x$(LINUX_HEADERS_VERSION)),x2.6.) LINUX_HEADERS_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v2.6/ elseLINUX_HEADERS_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v3.x/ endifLINUX_HEADERS_SOURCE = linux-$(LINUX_HEADERS_VERSION).tar.xz endif
The idea is that when we want to use the same kernel sources for the kernel headers and the kernel itself, we define the version, source, site and site method variables to be the same.
Quoted 7 lines
toolchain/kernel-headers/Config.in +0
-0
toolchain/kernel-headers/Config.in choice · line 59
Quoted 8 lines
toolchain/kernel-headers/Config.in +5
-0@@ -52,6 +52,13 @@ choice config BR2_KERNEL_HEADERS_SNAP bool "Local Linux snapshot (linux-2.6.tar.bz2)" + + config BR2_KERNEL_HEADERS_TARGET + bool "Target Linux kernel" + depends on BR2_LINUX_KERNEL + help
Your patch was broken in terms of tabs. Can you make sure to use "git send-email" instead, so that your patch doesn't get modified by your e-mail client?
Would you mind working on this and submit an updated patch?
Thanks a lot!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com