From patchwork Thu Aug 23 16:19:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Corbin X-Patchwork-Id: 961477 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.137; helo=fraxinus.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="bM/AMFA/"; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41x8mF28knz9rvt for ; Fri, 24 Aug 2018 02:21:01 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id CFBB586793; Thu, 23 Aug 2018 16:20:59 +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 nvRbWTY9ChNi; Thu, 23 Aug 2018 16:20:58 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 026B186500; Thu, 23 Aug 2018 16:20:58 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id EBFB91C2B9D for ; Thu, 23 Aug 2018 16:20:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id E8E52220B3 for ; Thu, 23 Aug 2018 16:20:56 +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 holSkWs0Jno5 for ; Thu, 23 Aug 2018 16:20:56 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by silver.osuosl.org (Postfix) with ESMTPS id 0B2DE21F61 for ; Thu, 23 Aug 2018 16:20:56 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id o18-v6so6475927wmc.0 for ; Thu, 23 Aug 2018 09:20:55 -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=bM/AMFA/9gBMQ6Jc2BB1qv5CokSOSvigXjo9Jt1AbLxE10o+Afe5mTgrm5PFvJmfbM Qs/rGY3u9UcMbVR79Lzm+RPxK4zTRM7V3fu2ZQ5SEg82ybeuzp9ROs6RTnMT2qMX/uu7 bxYdS/4vdzMKeaEwQniALH6JlGULQvgkK6EaDYmqboi5+iOajpJrPRKeGdwF3U2ClrOA vsGsyBcUH5kkG9dbrRqc3oHD3PcpP5CTqozvO6mF0D9F0rdVqWvEPcIuVEFWsfCvDkWI C4fPOpi9nHXnfG6bZLH60k7mGzqwEjl3QXTgNpKSDNtR81sQ9y/IFIjfc3HLsDLRTltH NZ6Q== 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=mlRFP3ZZdbdlYNwkHUd3d2BNYoBnjgkDIOt6J2Bqh6zE2cvQ1iLU42f1ymCu8PmrcK eZJErjXIHtuNdf02zTzuVtYRJUBSa9LsucGsHYwRBC2YpHPk/DCHzVG0EwpeE9uilJ4/ EZLrGqw2eXJ5XwoldCWd5WqDg6E9dal5fEHBdv7z1kfPrV5JvS3ogv+lQG33gfup1/+p LU2DCs/c5aYWVxL9aCVbxjX0KH6fw31KihMGe0IZ5mHY70n/M+PV7EnvldwbNeKGTjnK Y+r+pMyCvLtHM3pMWvBczRBr3uoMsBo3ryt+cvCPCujz04TYVHiARdJA56r1GtME6b7V SpAg== X-Gm-Message-State: APzg51DxLuqU8IL3Rz/FezPNvUin+XHq4vGp6VEr5LDaelXiywvG6IXg 1A3hcRgwqzRU0HJj9qzdc/+S8mp71+I= X-Google-Smtp-Source: ANB0Vda32yTx2M3DL+D1fans1Mf/Z0D66QDpsvrU21ayVoHByP9/htk5VXuTyBXYWFrooFUa40Jfvw== X-Received: by 2002:a1c:c44a:: with SMTP id u71-v6mr5656668wmf.43.1535041254310; Thu, 23 Aug 2018 09:20:54 -0700 (PDT) Received: from localhost.localdomain (cust64-dsl91-135-5.idnet.net. [91.135.5.64]) by smtp.gmail.com with ESMTPSA id 88-v6sm4327562wrf.95.2018.08.23.09.20.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Aug 2018 09:20:53 -0700 (PDT) From: Mark Corbin To: buildroot@buildroot.org Date: Thu, 23 Aug 2018 17:19:30 +0100 Message-Id: <20180823161930.18461-3-mark.corbin@embecosm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180823161930.18461-1-mark.corbin@embecosm.com> References: <20180823161930.18461-1-mark.corbin@embecosm.com> Subject: [Buildroot] [PATCH v2 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),\