diff mbox

[RFC] BR2_KERNEL_HEADERS_TARGET: Add support for using target kernel for toolchain kernel headers.

Message ID CAHCQUcAoruaNKt98BFU=fHpF2V6x4VbNg0J+kiuZ2n8zzKP9Hw@mail.gmail.com
State Superseded
Delegated to: Thomas De Schampheleire
Headers show

Commit Message

Magnus Edenhill April 17, 2013, 10:51 a.m. UTC
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(+)

 $(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

Comments

Thomas Petazzoni Feb. 4, 2014, 4:08 p.m. UTC | #1
Dear Magnus Edenhill,

On Wed, 17 Apr 2013 12:51:09 +0200, Magnus Edenhill wrote:

> 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(+)

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)
else
LINUX_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/
else
LINUX_HEADERS_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v3.x/
endif
LINUX_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.

> 
> diff --git a/toolchain/kernel-headers/Config.in
> b/toolchain/kernel-headers/Config.in
> index 6155ef1..dc04fd2 100644
> --- a/toolchain/kernel-headers/Config.in
> +++ b/toolchain/kernel-headers/Config.in
> @@ -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
diff mbox

Patch

diff --git a/toolchain/kernel-headers/Config.in
b/toolchain/kernel-headers/Config.in
index 6155ef1..dc04fd2 100644
--- a/toolchain/kernel-headers/Config.in
+++ b/toolchain/kernel-headers/Config.in
@@ -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
diff --git a/toolchain/kernel-headers/kernel-headers.mkb/toolchain/kernel-headers/
kernel-headers.mk
index adf7bc4..731f508 100644
--- a/toolchain/kernel-headers/kernel-headers.mk
+++ b/toolchain/kernel-headers/kernel-headers.mk
@@ -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 $@