From patchwork Sun Jan 20 23:52:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 214007 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hemlock.osuosl.org (hemlock.osuosl.org [140.211.166.133]) by ozlabs.org (Postfix) with ESMTP id 5462A2C008D for ; Mon, 21 Jan 2013 10:54:10 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id A6C73A0190; Sun, 20 Jan 2013 23:54:10 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WfAqxmBnt4nn; Sun, 20 Jan 2013 23:54:02 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 07648A0144; Sun, 20 Jan 2013 23:54:00 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (hemlock.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 75A6E8F74B for ; Sun, 20 Jan 2013 23:54:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id BA4E8A0150 for ; Sun, 20 Jan 2013 23:53:57 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qnY0PCa6n99i for ; Sun, 20 Jan 2013 23:53:45 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.free-electrons.com (mail.free-electrons.com [94.23.35.102]) by hemlock.osuosl.org (Postfix) with ESMTP id 0C9AEA0163 for ; Sun, 20 Jan 2013 23:53:39 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 106) id 2B79B5ED4; Mon, 21 Jan 2013 00:53:35 +0100 (CET) Received: from localhost (unknown [37.160.30.44]) by mail.free-electrons.com (Postfix) with ESMTPSA id 669805ED3 for ; Mon, 21 Jan 2013 00:53:11 +0100 (CET) From: Thomas Petazzoni To: buildroot@uclibc.org Date: Mon, 21 Jan 2013 00:52:20 +0100 Message-Id: <1358725943-31485-12-git-send-email-thomas.petazzoni@free-electrons.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1358725943-31485-1-git-send-email-thomas.petazzoni@free-electrons.com> References: <1358725943-31485-1-git-send-email-thomas.petazzoni@free-electrons.com> Subject: [Buildroot] [RFC v1 11/14] linux: support out of tree build X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net Supporting out of tree build in the Linux package requires a few changes: * A clarification of KERNEL_ARCH_PATH, which used to point to $(O)/build/linux-/arch//. Instead, we now have KERNEL_ARCH_SRCDIR (pointing to the architecture directory in the sources) and KERNEL_ARCH_BUILDDIR (pointing to the architectire directory in the build directory) * The custom Device Tree source file (if any) is now copied through a post-patch hook, rather than during the build step. This is needed because copying a Device Tree source file in the source tree requires the source tree to be writable, which is no longer the case after the patch step. And copying something into the source tree *is* a patching action, so doing this in the patch step looks like the right thing to do. The only consequence of this is that this action will no longer be done if LINUX_OVERRIDE_SRCDIR is defined, because the extract/patch steps are not done on packages for which the source directory is overriden. But it doesn't seem like a big issue since, if the user has overriden the kernel source directory, we assume that (s)he can store the Device Tree source file in the kernel source directory itself. * We no longer use the trick of creating a buildroot_defconfig, since this requires creating a buildroot_defconfig file in the source tree during the configure step. And it doesn't work with out-of-tree because the source tree is read only during the configure step (and onwards). So instead, we copy the defconfig to .config, and run a silent oldconfig on it. Signed-off-by: Thomas Petazzoni --- linux/linux.mk | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/linux/linux.mk b/linux/linux.mk index 91a9f50..f7adffd 100644 --- a/linux/linux.mk +++ b/linux/linux.mk @@ -35,6 +35,7 @@ LINUX_PATCHES = $(call qstrip,$(BR2_LINUX_KERNEL_PATCH)) LINUX_INSTALL_IMAGES = YES LINUX_DEPENDENCIES += host-module-init-tools +LINUX_SUPPORTS_OUT_OF_TREE = YES ifeq ($(BR2_LINUX_KERNEL_UBOOT_IMAGE),y) LINUX_DEPENDENCIES += host-uboot-tools @@ -106,22 +107,25 @@ endif # for bzImage, arch/i386 and arch/x86_64 do not exist when copying the # defconfig file. ifeq ($(KERNEL_ARCH),i386) -KERNEL_ARCH_PATH=$(LINUX_DIR)/arch/x86 +KERNEL_ARCH_SUBDIR=arch/x86 else ifeq ($(KERNEL_ARCH),x86_64) -KERNEL_ARCH_PATH=$(LINUX_DIR)/arch/x86 +KERNEL_ARCH_SUBDIR=arch/x86 else -KERNEL_ARCH_PATH=$(LINUX_DIR)/arch/$(KERNEL_ARCH) +KERNEL_ARCH_SUBDIR=arch/$(KERNEL_ARCH) endif +KERNEL_ARCH_SRCDIR=$(LINUX_SRCDIR)/$(KERNEL_ARCH_SUBDIR) +KERNEL_ARCH_BUILDDIR=$(LINUX_BUILDDIR)/$(KERNEL_ARCH_SUBDIR) + ifeq ($(BR2_LINUX_KERNEL_VMLINUX),y) -LINUX_IMAGE_PATH=$(LINUX_DIR)/$(LINUX_IMAGE_NAME) +LINUX_IMAGE_PATH=$(LINUX_BUILDDIR)/$(LINUX_IMAGE_NAME) else ifeq ($(BR2_LINUX_KERNEL_VMLINUZ),y) -LINUX_IMAGE_PATH=$(LINUX_DIR)/$(LINUX_IMAGE_NAME) +LINUX_IMAGE_PATH=$(LINUX_BUILDDIR)/$(LINUX_IMAGE_NAME) else ifeq ($(KERNEL_ARCH),avr32) -LINUX_IMAGE_PATH=$(KERNEL_ARCH_PATH)/boot/images/$(LINUX_IMAGE_NAME) +LINUX_IMAGE_PATH=$(KERNEL_ARCH_BUILDDIR)/boot/images/$(LINUX_IMAGE_NAME) else -LINUX_IMAGE_PATH=$(KERNEL_ARCH_PATH)/boot/$(LINUX_IMAGE_NAME) +LINUX_IMAGE_PATH=$(KERNEL_ARCH_BUILDDIR)/boot/$(LINUX_IMAGE_NAME) endif endif # BR2_LINUX_KERNEL_VMLINUX @@ -150,15 +154,22 @@ LINUX_POST_PATCH_HOOKS += LINUX_APPLY_PATCHES ifeq ($(BR2_LINUX_KERNEL_USE_DEFCONFIG),y) -KERNEL_SOURCE_CONFIG = $(KERNEL_ARCH_PATH)/configs/$(call qstrip,$(BR2_LINUX_KERNEL_DEFCONFIG))_defconfig +KERNEL_SOURCE_CONFIG = $(KERNEL_ARCH_SRCDIR)/configs/$(call qstrip,$(BR2_LINUX_KERNEL_DEFCONFIG))_defconfig else ifeq ($(BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG),y) KERNEL_SOURCE_CONFIG = $(BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE) endif +define LINUX_COPY_DTS + cp $(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH) $(KERNEL_ARCH_SRCDIR)/boot/dts/) +endef + +ifneq ($(BR2_LINUX_KERNEL_USE_CUSTOM_DTS),) +LINUX_POST_PATCH_HOOKS += LINUX_COPY_DTS +endif + define LINUX_CONFIGURE_CMDS - cp $(KERNEL_SOURCE_CONFIG) $(KERNEL_ARCH_PATH)/configs/buildroot_defconfig - $(TARGET_MAKE_ENV) $(MAKE1) $(LINUX_MAKE_FLAGS) -C $(@D) buildroot_defconfig - rm $(KERNEL_ARCH_PATH)/configs/buildroot_defconfig + cp $(KERNEL_SOURCE_CONFIG) $(@D)/.config + yes '' | $(TARGET_MAKE_ENV) $(MAKE1) $(LINUX_MAKE_FLAGS) -C $(LINUX_SRCDIR) O=$(@D) oldconfig $(if $(BR2_ARM_EABI), $(call KCONFIG_ENABLE_OPT,CONFIG_AEABI,$(@D)/.config), $(call KCONFIG_DISABLE_OPT,CONFIG_AEABI,$(@D)/.config)) @@ -194,8 +205,8 @@ endef define LINUX_INSTALL_DTB # dtbs moved from arch/$ARCH/boot to arch/$ARCH/boot/dts since 3.8-rc1 cp $(addprefix \ - $(KERNEL_ARCH_PATH)/boot/$(if $(wildcard \ - $(addprefix $(KERNEL_ARCH_PATH)/boot/dts/,$(KERNEL_DTBS))),dts/),$(KERNEL_DTBS)) \ + $(KERNEL_ARCH_BUILDDIR)/boot/$(if $(wildcard \ + $(addprefix $(KERNEL_ARCH_BUILDDIR)/boot/dts/,$(KERNEL_DTBS))),dts/),$(KERNEL_DTBS)) \ $(BINARIES_DIR)/ endef endif @@ -204,11 +215,11 @@ endif ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB),y) # dtbs moved from arch/$ARCH/boot to arch/$ARCH/boot/dts since 3.8-rc1 define LINUX_APPEND_DTB - if [ -e $(KERNEL_ARCH_PATH)/boot/$(KERNEL_DTS_NAME).dtb ]; then \ - cat $(KERNEL_ARCH_PATH)/boot/$(KERNEL_DTS_NAME).dtb; \ + if [ -e $(KERNEL_ARCH_BUILDDIR)/boot/$(KERNEL_DTS_NAME).dtb ]; then \ + cat $(KERNEL_ARCH_BUILDDIR)/boot/$(KERNEL_DTS_NAME).dtb; \ else \ - cat $(KERNEL_ARCH_PATH)/boot/dts/$(KERNEL_DTS_NAME).dtb; \ - fi >> $(KERNEL_ARCH_PATH)/boot/zImage + cat $(KERNEL_ARCH_BUILDDIR)/boot/dts/$(KERNEL_DTS_NAME).dtb; \ + fi >> $(KERNEL_ARCH_BUILDDIR)/boot/zImage endef ifeq ($(BR2_LINUX_KERNEL_APPENDED_UIMAGE),y) # We need to generate the uImage here after that so that the uImage is @@ -220,8 +231,6 @@ endif # Compilation. We make sure the kernel gets rebuilt when the # configuration has changed. define LINUX_BUILD_CMDS - $(if $(BR2_LINUX_KERNEL_USE_CUSTOM_DTS), - cp $(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH) $(KERNEL_ARCH_PATH)/boot/dts/) $(TARGET_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_IMAGE_TARGET) @if grep -q "CONFIG_MODULES=y" $(@D)/.config; then \ $(TARGET_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) modules ; \