From patchwork Thu Aug 23 13:15:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Corbin X-Patchwork-Id: 961320 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=embecosm.com header.i=@embecosm.com header.b="e57n2o8Y"; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41x4hN2xqZz9s5b for ; Thu, 23 Aug 2018 23:17:24 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 6B8C322011; Thu, 23 Aug 2018 13:17:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EebPgYFYKqUE; Thu, 23 Aug 2018 13:17:20 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id C5629220BC; Thu, 23 Aug 2018 13:17:20 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 2B4851C2361 for ; Thu, 23 Aug 2018 13:17:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 28701867EC for ; Thu, 23 Aug 2018 13:17:19 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3qZD1v8Q_l0m for ; Thu, 23 Aug 2018 13:17:18 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 128EA865E2 for ; Thu, 23 Aug 2018 13:17:18 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id 207-v6so5771004wme.5 for ; Thu, 23 Aug 2018 06:17:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NHwAhIrtRDE/4UiVPpn7gyFtfNKx3m9AhjfcLY8s1Mo=; b=e57n2o8YJkX7gieADceI6pgXuuuHeAHV2nf/fasci6cWA+Oztpr8YMW8/Zb/qkpXUD HrPzUmmzxQCwWuhF0Chc5BBjEHXoSPMctTH/MGRXi9/0CkBKwjRGJ37UyRmzVrqFW63/ 3LTxCj7lNU8xQZr77X+h1iY37waj02euA13ZKiOeqx3yU7kjCwaqxS7etmFOGKfcCCPK TpgKLlInnauLKlDlJjn60niIN43aH56vQd9Rj0SL3PHZN53OnFVGfGz4VuEkY8kuxK1w rrTc32Xff5x9LsGMrd1RLVMqiQYKmDCA1Ncwo2V83+QMekJ7vzBvKLvaAY5TgFJoztZS ywzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NHwAhIrtRDE/4UiVPpn7gyFtfNKx3m9AhjfcLY8s1Mo=; b=eXaunwVvHlX6KXm7DuJSUQb2Bpkye6KZ1DTKS+RzaR7VMcRLAsT1YQ+5Zhe2Ws2r5q 4C6CFwOuInN3SVwllBA24viH9Q7C+h7U0r4gDkoKXBTnkqaqKnmqoBp7voIcJ+1TvP4N cJjPGMRQW03vX6+c++0WVCcVHAtt9QD2qKzOORkWAn03FqM5P/khZFw8b0e8i1VVwSp7 /vuTE763pyKAPK+0jRP0wn50eS/0UAHwmY2lvR6Nv3ZXUORSmw80C0218hpYhxUFtk0K TgjhLet/D2kDvUWbXSb25nPkLsrMkN8dxJK1H7T/U+Lu72TRZ43b9BQH0ROKyOApt86g pATg== X-Gm-Message-State: APzg51DOah8O4klGYOBL5/xNP66KXE1fNYER+U0S4O9lqBiK3hQuUvG0 IzZKKjm31NJgo2QxtZpDBfGdpA+g+Ac= X-Google-Smtp-Source: ANB0Vda1Z24/PLAGE6O2d2LUUk7nJ9qrzaYkMZgHu6p1yFpZxOwyHAtd6WUB01L/CdL0w0xx8Dv67Q== X-Received: by 2002:a1c:e5cf:: with SMTP id c198-v6mr5304209wmh.113.1535030236288; Thu, 23 Aug 2018 06:17:16 -0700 (PDT) Received: from localhost.localdomain (cust64-dsl91-135-5.idnet.net. [91.135.5.64]) by smtp.gmail.com with ESMTPSA id t131-v6sm5643382wmg.10.2018.08.23.06.17.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Aug 2018 06:17:15 -0700 (PDT) From: Mark Corbin To: buildroot@buildroot.org Date: Thu, 23 Aug 2018 14:15:51 +0100 Message-Id: <20180823131551.10903-3-mark.corbin@embecosm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180823131551.10903-1-mark.corbin@embecosm.com> References: <20180823131551.10903-1-mark.corbin@embecosm.com> Subject: [Buildroot] [PATCH 3/3] package/linux-headers: add support for custom headers. X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Corbin MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Add support for building toolchains against custom headers. Allows the selection of a manual version, custom tarball or custom git repository for the kernel headers. This enables toolchains to be built against custom kernel headers without having to build a full kernel. This is particularly useful for new architectures, such as RISC-V where updated kernel headers may not have made it into the mainline kernel yet. Signed-off-by: Mark Corbin --- package/linux-headers/Config.in.host | 40 ++++++++++- package/linux-headers/linux-headers.mk | 94 +++++++++++++++----------- 2 files changed, 93 insertions(+), 41 deletions(-) diff --git a/package/linux-headers/Config.in.host b/package/linux-headers/Config.in.host index 5c20c997f9..f8f78f90d1 100644 --- a/package/linux-headers/Config.in.host +++ b/package/linux-headers/Config.in.host @@ -86,6 +86,23 @@ config BR2_KERNEL_HEADERS_VERSION URL at kernel.org. Instead, select "Custom tarball" and specify the right URL directly. +config BR2_KERNEL_HEADERS_CUSTOM_TARBALL + bool "Custom tarball" + help + This option allows you to specify a URL pointing to a kernel + source tarball. This URL can use any protocol recognized by + Buildroot, like http://, ftp://, file:// or scp://. + + When pointing to a local tarball using file://, you may want + to use a make variable like $(TOPDIR) to reference the root of + the Buildroot tree. + +config BR2_KERNEL_HEADERS_CUSTOM_GIT + bool "Custom Git repository" + help + This option allows Buildroot to get the Linux kernel source + code from a Git repository. + endchoice config BR2_DEFAULT_KERNEL_VERSION @@ -95,9 +112,27 @@ config BR2_DEFAULT_KERNEL_VERSION Specify the version you want to use. E.G.: 3.6.10 +config BR2_KERNEL_HEADERS_CUSTOM_TARBALL_LOCATION + string "URL of custom kernel tarball" + depends on BR2_KERNEL_HEADERS_CUSTOM_TARBALL + +if BR2_KERNEL_HEADERS_CUSTOM_GIT + +config BR2_KERNEL_HEADERS_CUSTOM_REPO_URL + string "URL of custom repository" + +config BR2_KERNEL_HEADERS_CUSTOM_REPO_VERSION + string "Custom repository version" + help + Revision to use in the typical format used by + Git/Mercurial/Subversion E.G. a sha id, a tag, branch, .. + +endif + choice bool "Custom kernel headers series" - depends on BR2_KERNEL_HEADERS_VERSION || BR2_KERNEL_HEADERS_AS_KERNEL + depends on BR2_KERNEL_HEADERS_VERSION || BR2_KERNEL_HEADERS_AS_KERNEL || \ + BR2_KERNEL_HEADERS_CUSTOM_TARBALL || BR2_KERNEL_HEADERS_CUSTOM_GIT help Specify the kernel headers series you manually selected, above. @@ -277,3 +312,6 @@ config BR2_DEFAULT_KERNEL_HEADERS default "4.16.18" if BR2_KERNEL_HEADERS_4_16 default "4.17.18" if BR2_KERNEL_HEADERS_4_17 default BR2_DEFAULT_KERNEL_VERSION if BR2_KERNEL_HEADERS_VERSION + default "custom" if BR2_KERNEL_HEADERS_CUSTOM_TARBALL + default BR2_KERNEL_HEADERS_CUSTOM_REPO_VERSION \ + if BR2_KERNEL_HEADERS_CUSTOM_GIT diff --git a/package/linux-headers/linux-headers.mk b/package/linux-headers/linux-headers.mk index 954c6b7978..6bc60d8d74 100644 --- a/package/linux-headers/linux-headers.mk +++ b/package/linux-headers/linux-headers.mk @@ -7,27 +7,50 @@ # This package is used to provide Linux kernel headers for the # internal toolchain backend. +# Set variables depending on whether we are using headers from a kernel +# build or a standalone header package. ifeq ($(BR2_KERNEL_HEADERS_AS_KERNEL),y) - +LINUX_HEADERS_CUSTOM_TARBALL = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_TARBALL)) +LINUX_HEADERS_CUSTOM_GIT = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_GIT)) +LINUX_HEADERS_CUSTOM_HG = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_HG)) +LINUX_HEADERS_CUSTOM_SVN = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_SVN)) LINUX_HEADERS_VERSION = $(call qstrip,$(BR2_LINUX_KERNEL_VERSION)) +LINUX_HEADERS_CUSTOM_TARBALL_LOCATION = \ +$(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION)) +LINUX_HEADERS_REPO_URL = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_REPO_URL)) +else # ! BR2_KERNEL_HEADERS_AS_KERNEL +LINUX_HEADERS_CUSTOM_TARBALL = $(call qstrip,$(BR2_KERNEL_HEADERS_CUSTOM_TARBALL)) +LINUX_HEADERS_CUSTOM_GIT = $(call qstrip,$(BR2_KERNEL_HEADERS_CUSTOM_GIT)) +LINUX_HEADERS_CUSTOM_HG = +LINUX_HEADERS_CUSTOM_SVN = +LINUX_HEADERS_VERSION = $(call qstrip,$(BR2_DEFAULT_KERNEL_HEADERS)) +LINUX_HEADERS_CUSTOM_TARBALL_LOCATION = \ +$(call qstrip,$(BR2_KERNEL_HEADERS_CUSTOM_TARBALL_LOCATION)) +LINUX_HEADERS_REPO_URL = $(call qstrip,$(BR2_KERNEL_HEADERS_CUSTOM_REPO_URL)) +endif # BR2_KERNEL_HEADERS_AS_KERNEL + +# Configure tarball filenames. +ifeq ($(LINUX_HEADERS_CUSTOM_TARBALL),y) +LINUX_HEADERS_SOURCE = $(notdir $(LINUX_HEADERS_CUSTOM_TARBALL_LOCATION)) +else ifeq ($(LINUX_HEADERS_CUSTOM_GIT)$(LINUX_HEADERS_CUSTOM_HG)$(LINUX_HEADERS_CUSTOM_SVN),y) +LINUX_HEADERS_SOURCE = linux-$(LINUX_HEADERS_VERSION).tar.gz +else +LINUX_HEADERS_SOURCE = linux-$(LINUX_HEADERS_VERSION).tar.xz +endif -# Compute LINUX_HEADERS_SOURCE and LINUX_HEADERS_SITE from the configuration -ifeq ($(BR2_LINUX_KERNEL_CUSTOM_TARBALL),y) -LINUX_HEADERS_TARBALL = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION)) -LINUX_HEADERS_SITE = $(patsubst %/,%,$(dir $(LINUX_HEADERS_TARBALL))) -LINUX_HEADERS_SOURCE = $(notdir $(LINUX_HEADERS_TARBALL)) -else ifeq ($(BR2_LINUX_KERNEL_CUSTOM_GIT),y) -LINUX_HEADERS_SITE = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_REPO_URL)) +# Configure the various kernel source locations. +ifeq ($(LINUX_HEADERS_CUSTOM_TARBALL),y) +LINUX_HEADERS_SITE = $(patsubst %/,%,$(dir $(LINUX_HEADERS_CUSTOM_TARBALL_LOCATION))) +else ifeq ($(LINUX_HEADERS_CUSTOM_GIT),y) +LINUX_HEADERS_SITE = $(LINUX_HEADERS_REPO_URL) LINUX_HEADERS_SITE_METHOD = git -# use same git tarball as linux kernel -LINUX_HEADERS_SOURCE = linux-$(LINUX_HEADERS_VERSION).tar.gz -else ifeq ($(BR2_LINUX_KERNEL_CUSTOM_HG),y) -LINUX_HEADERS_SITE = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_REPO_URL)) +else ifeq ($(LINUX_HEADERS_CUSTOM_HG),y) +LINUX_HEADERS_SITE = $(LINUX_HEADERS_REPO_URL) LINUX_HEADERS_SITE_METHOD = hg -# use same hg tarball as linux kernel -LINUX_HEADERS_SOURCE = linux-$(LINUX_HEADERS_VERSION).tar.gz +else ifeq ($(LINUX_HEADERS_CUSTOM_SVN),y) +LINUX_HEADERS_SITE = $(LINUX_HEADERS_REPO_URL) +LINUX_HEADERS_SITE_METHOD = svn else -LINUX_HEADERS_SOURCE = linux-$(LINUX_HEADERS_VERSION).tar.xz # In X.Y.Z, get X and Y. We replace dots and dashes by spaces in order # to use the $(word) function. We support versions such as 4.0, 3.1, # 2.6.32, 2.6.32-rc1, 3.0-rc6, etc. @@ -37,13 +60,16 @@ else ifeq ($(findstring x3.,x$(LINUX_HEADERS_VERSION)),x3.) LINUX_HEADERS_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v3.x else ifeq ($(findstring x4.,x$(LINUX_HEADERS_VERSION)),x4.) LINUX_HEADERS_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v4.x -endif +endif # x2.6 # release candidates are in testing/ subdir ifneq ($(findstring -rc,$(LINUX_HEADERS_VERSION)),) LINUX_HEADERS_SITE := $(LINUX_HEADERS_SITE)/testing endif # -rc -endif +endif # LINUX_HEADERS_CUSTOM_TARBALL +# Apply any necessary patches if we are using the headers from a kernel +# build. +ifeq ($(BR2_KERNEL_HEADERS_AS_KERNEL),y) LINUX_HEADERS_PATCHES = $(call qstrip,$(BR2_LINUX_KERNEL_PATCH)) # We rely on the generic package infrastructure to download and apply @@ -53,35 +79,23 @@ LINUX_HEADERS_PATCHES = $(call qstrip,$(BR2_LINUX_KERNEL_PATCH)) LINUX_HEADERS_PATCH = $(filter ftp://% http://% https://%,$(LINUX_HEADERS_PATCHES)) define LINUX_HEADERS_APPLY_LOCAL_PATCHES - for p in $(filter-out ftp://% http://% https://%,$(LINUX_HEADERS_PATCHES)) ; do \ - if test -d $$p ; then \ - $(APPLY_PATCHES) $(@D) $$p \*.patch || exit 1 ; \ - else \ - $(APPLY_PATCHES) $(@D) `dirname $$p` `basename $$p` || exit 1; \ - fi \ - done + for p in $(filter-out ftp://% http://% https://%,$(LINUX_HEADERS_PATCHES)) ; do \ + if test -d $$p ; then \ + $(APPLY_PATCHES) $(@D) $$p \*.patch || exit 1 ; \ + else \ + $(APPLY_PATCHES) $(@D) `dirname $$p` `basename $$p` || exit 1; \ + fi \ + done endef LINUX_HEADERS_POST_PATCH_HOOKS += LINUX_HEADERS_APPLY_LOCAL_PATCHES +endif # BR2_KERNEL_HEADERS_AS_KERNEL -else # ! BR2_KERNEL_HEADERS_AS_KERNEL - -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 ifeq ($(findstring x3.,x$(LINUX_HEADERS_VERSION)),x3.) -LINUX_HEADERS_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v3.x -else ifeq ($(findstring x4.,x$(LINUX_HEADERS_VERSION)),x4.) -LINUX_HEADERS_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v4.x -endif -LINUX_HEADERS_SOURCE = linux-$(LINUX_HEADERS_VERSION).tar.xz - -ifeq ($(BR2_KERNEL_HEADERS_VERSION),y) +# Skip hash checking for custom kernel headers. +ifeq ($(BR2_KERNEL_HEADERS_VERSION)$(BR2_KERNEL_HEADERS_CUSTOM_TARBALL)$(BR2_KERNEL_HEADERS_CUSTOM_GIT),y) BR_NO_CHECK_HASH_FOR += $(LINUX_HEADERS_SOURCE) endif -endif # ! BR2_KERNEL_HEADERS_AS_KERNEL - # linux-headers really is the same as the linux package LINUX_HEADERS_DL_SUBDIR = linux @@ -125,7 +139,7 @@ define LINUX_HEADERS_INSTALL_STAGING_CMDS headers_install) endef -ifeq ($(BR2_KERNEL_HEADERS_VERSION)$(BR2_KERNEL_HEADERS_AS_KERNEL),y) +ifeq ($(BR2_KERNEL_HEADERS_VERSION)$(BR2_KERNEL_HEADERS_AS_KERNEL)$(BR2_KERNEL_HEADERS_CUSTOM_TARBALL)$(BR2_KERNEL_HEADERS_CUSTOM_GIT),y) define LINUX_HEADERS_CHECK_VERSION $(call check_kernel_headers_version,\ $(STAGING_DIR),\