Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR
@ 2026-10-23 21:47 Florian Fainelli via buildroot
  2026-10-23 21:47 ` [Buildroot] [PATCH 01/23] package: prepare removal of <pkg>_DIR Florian Fainelli via buildroot
                   ` (8 more replies)
  0 siblings, 9 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:47 UTC (permalink / raw)
  To: buildroot
  Cc: Eric Le Bihan, Gary Bisson, Jérôme Pouiller,
	Florian Fainelli, Bernd Kuhls, Thomas Perale, Maxime Chevallier,
	Refik Tuzakli, Francois Perrad, Thomas Petazzoni,
	Arnout Vandecappelle, Petr Vorel, Spenser Gilliland,
	Giulio Benetti, Pascal de Bruijn, Luca Ceresoli, Romain Naour,
	Mahyar Koshkouei

Hello,

This series lets a package that is built from an OVERRIDE_SRCDIR be built
out of tree, i.e. without rsync'ing its sources into output/build/<pkg>-custom/,
and enables it for the Linux kernel.

For a large source tree such as the kernel, the rsync step is slow, doubles
the disk usage, and leaves the developer's tree and the build directory out
of sync. With this series, with LINUX_OVERRIDE_SRCDIR set, the kernel is
configured and built with O=output/build/linux-custom and the sources in
the overridden directory are never written to.

Most of the groundwork comes from the out-of-tree work Thomas Petazzoni
and Yann E. Morin did in 2015-2017, which was never merged. It has been
rebased on current master, and extended to cover the custom logo, custom
device tree files, and linux-tools. Their authorship is preserved.

Series overview
===============

Patches 1-8, infra preparation:
  - introduce <pkg>_SRCDIR (where the sources are) and <pkg>_BUILDDIR
    (where the package is built, and where the stamp files live), both
    defaulting to <pkg>_DIR, so nothing changes for existing packages;
  - fix up the users of LINUX_DIR that need the build directory
    (boot-wrapper-aarch64, mxs-bootlets, the linux extensions), and run
    the kernel version probing from the build directory;
  - introduce <pkg>_SRCSUBDIR (<pkg>_SRCDIR/<pkg>_SUBDIR) and convert the
    infras (cargo, hare, luarocks, meson, perl, waf) and gcc-final to it.

Patch 9, the kernel:
  - add <pkg>_SUPPORTS_OUT_OF_TREE. When it is YES and <pkg>_OVERRIDE_SRCDIR
    is set, the rsync step is skipped, the stamp files go in the build
    directory and kconfig is called with -C $(SRCDIR) O=$(BUILDDIR);
  - opt linux in, in the same patch. Kbuild requires a clean source tree
    for O=: a tree with a stale .config, include/config or
    arch/*/include/generated is rejected by kbuild itself.

Patches 10-19, host/target consistency. When the sources are shared between
the host and the target variant of a package, they must not be patched
differently, so:
  - sync the host and target patch hooks, and fix omniorb, lua and perl
    which did different things between the two variants;
  - have host packages inherit the extra downloads and apply the libtool
    patch to host libtool;
  - warn about packages that autoreconf without the libtool patch;
  - replace $(PKG)_DIR with $(@D) where this is possible.

Patches 20-21, the parts that write to the kernel sources:
  - the custom logo (BR2_LINUX_KERNEL_CUSTOM_LOGO_PATH) and custom device
    tree files (BR2_LINUX_KERNEL_CUSTOM_DTS_PATH) are copied into the kernel
    sources. For an out-of-tree build, linux is then built from a "shadow"
    tree: real directories whose files are symbolic links to the original
    tree, created by the new support/scripts/symlink-tree. Files are
    replaced rather than written through the links, so the overridden
    tree is never modified;
  - linux-tools checks which tools are available in $(LINUX_SRCDIR)/tools,
    and builds them in a shadow of that directory, because several of the
    kernel tools build in place, and some (mm, tmon) do not support
    OUTPUT/O= at all. This also covers the PCI endpoint selftests path.

Patches 22-23:
  - packages that read kernel headers from the source tree use
    $(LINUX_SRCDIR) instead of $(LINUX_DIR);
  - document the feature and the new variables in the manual.

Things this series intentionally does not do
============================================

  - Only linux opts in. Other packages are unchanged and still rsync.
    A package opts in with <pkg>_SUPPORTS_OUT_OF_TREE = YES.
  - The "hooks sanity check" and "host inherits the target hooks" patches
    of the original series are not included: they do not work with the
    infras that register per-name hooks (e.g. golang).
  - The Python 2 and asterisk patches of the original series are dropped:
    those packages are gone or no longer need them.

Testing
=======

All of the following build and, where noted, boot, with the series
applied on top of master (fd9c348c227e):

  - raspberrypi4_64_defconfig, stock (in-tree kernel);
  - raspberrypi4_64_defconfig with the Raspberry Pi kernel built out of tree
    through LINUX_OVERRIDE_SRCDIR: the Image differs from the in-tree one
    only by the embedded build timestamp, the dtbs are identical;
  - qemu_x86_64 and qemu_arm_vexpress, stock, and with an out-of-tree
    kernel; the out-of-tree ones boot to a login prompt in QEMU;
  - a wide package set on arm64 (autotools, cmake, meson, perl, python,
    cargo, golang, waf, luarocks, hare, kernel modules, asterisk, ffmpeg,
    libvpx, u-boot, and the linux-tools gpio, iio, perf, pci, cpupower,
    rtla, tmon, mm, usbtools), both with an in-tree and an out-of-tree
    kernel: the content of target/ is identical;
  - a custom logo and a custom device tree file with a #include, out of
    tree, with the overridden tree left unmodified;
  - the same package set in the Buildroot CI docker image, offline;
  - every patch of the series builds, tested on a small package set.

Known issues, not caused by this series and identical with and without it:
xtables-addons does not build with the Raspberry Pi 6.12 kernel, and
some linux-tools selftests (mm) fail to link. I have not tested the
selftests in the docker image, as the container has no python yaml.

Not tested: the other kernel extensions (rtai, xenomai), which are
adapted but not built, and booting on real hardware.

Changes
=======

This is the first version.

Regards,
Florian

Florian Fainelli (6):
  package: use <pkg>_SRCSUBDIR where <pkg>_SRCDIR used to include
    _SUBDIR
  linux: build out of tree when LINUX_OVERRIDE_SRCDIR is set
  linux: support custom logo and devicetree files in out-of-tree builds
  package/linux-tools: support an out-of-tree kernel build
  package: read kernel headers from LINUX_SRCDIR
  docs/manual: document out-of-tree package builds and the new srcdir
    variables

Thomas Petazzoni (7):
  package: prepare removal of <pkg>_DIR
  infra: introduce a global SRC_DIR variable
  packages: sync host and target patch hooks
  omniorb: avoid target-only patch hook
  lua: rework post-patch hook usage
  package/libtool: use post-patch hooks
  package/{ffmpeg,libvpx}: use $(@D) instead of $(pkg_SRCDIR) when
    possible

Yann E. MORIN (10):
  package: fix <pkg>_SRCDIR and <pkg>_BUILDDIR values
  boot/boot-wrapper-aarch64: needs LINUX_BUILDDIR
  boot/mxs-bootlets: needs (BAREBOX,LINUX,UBOOT)_BUILDDIR
  linux/extensions: point to proper _SRCDIR and @D
  linux/linux: LINUX_VERSION_PROBED should run from build directory
  infra: host packages inherit the target extra downloads
  package/libtool: also apply libtool-patch to host libtool
  package/perl: apply the perl-cross even for the host variant
  infra/autotools: warn for package that autoreconf without libtool
    patch
  packages: replace $(PKG)_DIR with @D where possible

 Makefile                                      |  1 +
 .../boot-wrapper-aarch64.mk                   |  8 +-
 boot/mxs-bootlets/mxs-bootlets.mk             |  6 +-
 docs/manual/adding-packages-generic.adoc      | 11 +++
 docs/manual/using-buildroot-development.adoc  | 30 ++++++++
 linux/linux-ext-rtai.mk                       |  8 +-
 linux/linux-ext-xenomai.mk                    |  4 +-
 linux/linux.mk                                | 40 ++++++++--
 package/a10disp/a10disp.mk                    |  2 +-
 package/android-tools/android-tools.mk        |  1 -
 package/binutils/binutils.mk                  |  1 -
 package/ffmpeg/ffmpeg.mk                      |  2 +-
 .../imx-alsa-plugins/imx-alsa-plugins.mk      |  2 +-
 package/freescale-imx/imx-lib/imx-lib.mk      |  2 +-
 package/gcc/gcc-final/gcc-final.mk            |  2 +-
 package/gdb/gdb.mk                            |  1 -
 package/gstreamer1/gst1-imx/gst1-imx.mk       |  2 +-
 package/icu/icu.mk                            |  1 +
 package/libtool/libtool.mk                    |  5 +-
 package/libvpx/libvpx.mk                      |  2 +-
 package/linux-backports/linux-backports.mk    |  2 +-
 package/linux-tools/linux-tool-cpupower.mk.in |  8 +-
 package/linux-tools/linux-tool-gpio.mk.in     |  6 +-
 package/linux-tools/linux-tool-hv.mk.in       |  6 +-
 package/linux-tools/linux-tool-iio.mk.in      |  6 +-
 package/linux-tools/linux-tool-mm.mk.in       | 10 +--
 package/linux-tools/linux-tool-pci.mk.in      | 12 +--
 package/linux-tools/linux-tool-perf.mk.in     | 29 +++++---
 package/linux-tools/linux-tool-rtla.mk.in     | 10 +--
 .../linux-tools/linux-tool-selftests.mk.in    | 15 ++--
 package/linux-tools/linux-tool-tmon.mk.in     |  8 +-
 package/linux-tools/linux-tool-usbtools.mk.in |  6 +-
 package/linux-tools/linux-tools.mk            | 20 ++++-
 package/lua/lua.mk                            |  9 ++-
 package/ncftp/ncftp.mk                        |  2 +-
 .../omniorb/0002-optional-appl-services.patch | 29 ++++++++
 package/omniorb/omniorb.mk                    | 26 +++----
 package/pciutils/pciutils.mk                  |  2 +-
 package/perl/perl.mk                          |  2 +
 package/php/php.mk                            |  2 +-
 package/pkg-autotools.mk                      | 28 +++----
 package/pkg-cargo.mk                          |  8 +-
 package/pkg-cmake.mk                          |  8 +-
 package/pkg-generic.mk                        | 74 ++++++++++++-------
 package/pkg-hare.mk                           |  8 +-
 package/pkg-kconfig.mk                        | 48 ++++++------
 package/pkg-luarocks.mk                       | 10 +--
 package/pkg-meson.mk                          | 26 +++----
 package/pkg-perl.mk                           | 12 +--
 package/pkg-waf.mk                            |  8 +-
 .../xdriver_xf86-video-imx.mk                 |  2 +-
 support/scripts/symlink-tree                  | 58 +++++++++++++++
 52 files changed, 422 insertions(+), 209 deletions(-)
 create mode 100644 package/omniorb/0002-optional-appl-services.patch
 create mode 100755 support/scripts/symlink-tree

-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 01/23] package: prepare removal of <pkg>_DIR
  2026-10-23 21:47 [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR Florian Fainelli via buildroot
@ 2026-10-23 21:47 ` Florian Fainelli via buildroot
  2026-10-23 21:47 ` [Buildroot] [PATCH 02/23] infra: introduce a global SRC_DIR variable Florian Fainelli via buildroot
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:47 UTC (permalink / raw)
  To: buildroot
  Cc: Thomas Petazzoni, Eric Le Bihan, Jérôme Pouiller,
	Florian Fainelli, Gary Bisson, Romain Naour, Bernd Kuhls,
	Thomas Perale, Maxime Chevallier, Refik Tuzakli, Francois Perrad,
	Thomas Petazzoni, Arnout Vandecappelle, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Yann E. MORIN, Mahyar Koshkouei

From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

As part of the out-of-tree mechanism introduction, we want to get rid
of the <pkg>_DIR variable, because it isn't clear whether it refers to
the source or build directory.

Therefore, we modify the package infrastructure to no longer use
<pkg>_DIR, but instead use <pkg>_SRCDIR or <pkg>_BUILDDIR where
appropriate.

Since some of the build steps now have their stamp files in the package
source directory, we also adjust the corresponding make rules.

There is one single stamp we take special care of: the dirclean one.
This stamp file is never created; it only serves to have a correct $(@D)
to be able to remove the package directory. What is really important in
fact is to remove the build directory, so that's where we move it into.

Note that at this point, $(BUILD_DIR) and $(SRC_DIR) still point to the
same directory, so this commit is really a no-op.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
[yann.morin.1998@free.fr:
  - rebase on master
  - change the location of the dirclean stamp
  - expand commit log accordingly
]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
(cherry picked from commit a1048c500d134df5ba3d92be463e190ce7768274)
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 package/pkg-generic.mk | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index 4e2ce2e7a09a..fe5200475504 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -171,7 +171,7 @@ endef
 ################################################################################
 
 # Retrieve the archive
-$(BUILD_DIR)/%/.stamp_downloaded:
+$(SRC_DIR)/%/.stamp_downloaded:
 	@$(call step_start,download)
 	$(call prepare-per-package-directory,$($(PKG)_FINAL_DOWNLOAD_DEPENDENCIES))
 	$(foreach hook,$($(PKG)_PRE_DOWNLOAD_HOOKS),$(call $(hook))$(sep))
@@ -196,7 +196,7 @@ $(BUILD_DIR)/%/.stamp_downloaded:
 	$(Q)touch $@
 
 # Retrieve actual source archive, e.g. for prebuilt external toolchains
-$(BUILD_DIR)/%/.stamp_actual_downloaded:
+$(SRC_DIR)/%/.stamp_actual_downloaded:
 	@$(call step_start,actual-download)
 	$(call DOWNLOAD,$($(PKG)_ACTUAL_SOURCE_SITE)/$($(PKG)_ACTUAL_SOURCE_TARBALL))
 	$(Q)mkdir -p $(@D)
@@ -204,7 +204,7 @@ $(BUILD_DIR)/%/.stamp_actual_downloaded:
 	$(Q)touch $@
 
 # Unpack the archive
-$(BUILD_DIR)/%/.stamp_extracted:
+$(SRC_DIR)/%/.stamp_extracted:
 	@$(call step_start,extract)
 	@$(call MESSAGE,"Extracting")
 	$(call prepare-per-package-directory,$($(PKG)_FINAL_EXTRACT_DEPENDENCIES))
@@ -219,7 +219,7 @@ $(BUILD_DIR)/%/.stamp_extracted:
 
 # Rsync the source directory if the <pkg>_OVERRIDE_SRCDIR feature is
 # used.
-$(BUILD_DIR)/%/.stamp_rsynced:
+$(SRC_DIR)/%/.stamp_rsynced:
 	@$(call step_start,rsync)
 	@$(call MESSAGE,"Syncing from source dir $(SRCDIR)")
 	@mkdir -p $(@D)
@@ -231,7 +231,7 @@ $(BUILD_DIR)/%/.stamp_rsynced:
 	$(Q)touch $@
 
 # Patch
-$(BUILD_DIR)/%/.stamp_patched:
+$(SRC_DIR)/%/.stamp_patched:
 	@$(call step_start,patch)
 	@$(call MESSAGE,"Patching")
 	$(foreach hook,$($(PKG)_PRE_PATCH_HOOKS),$(call $(hook))$(sep))
@@ -836,19 +836,19 @@ $(2)_FINAL_RECURSIVE_RDEPENDENCIES = $$(sort \
 	$$($(2)_FINAL_RECURSIVE_RDEPENDENCIES__X))
 
 # define sub-target stamps
-$(2)_TARGET_INSTALL =           $$($(2)_DIR)/.stamp_installed
-$(2)_TARGET_INSTALL_TARGET =	$$($(2)_DIR)/.stamp_target_installed
-$(2)_TARGET_INSTALL_STAGING =	$$($(2)_DIR)/.stamp_staging_installed
-$(2)_TARGET_INSTALL_IMAGES =	$$($(2)_DIR)/.stamp_images_installed
-$(2)_TARGET_INSTALL_HOST =	$$($(2)_DIR)/.stamp_host_installed
-$(2)_TARGET_BUILD =		$$($(2)_DIR)/.stamp_built
-$(2)_TARGET_CONFIGURE =		$$($(2)_DIR)/.stamp_configured
-$(2)_TARGET_RSYNC =		$$($(2)_DIR)/.stamp_rsynced
-$(2)_TARGET_PATCH =		$$($(2)_DIR)/.stamp_patched
-$(2)_TARGET_EXTRACT =		$$($(2)_DIR)/.stamp_extracted
-$(2)_TARGET_SOURCE =		$$($(2)_DIR)/.stamp_downloaded
-$(2)_TARGET_ACTUAL_SOURCE =	$$($(2)_DIR)/.stamp_actual_downloaded
-$(2)_TARGET_DIRCLEAN =		$$($(2)_DIR)/.stamp_dircleaned
+$(2)_TARGET_INSTALL =           $$($(2)_BUILDDIR)/.stamp_installed
+$(2)_TARGET_INSTALL_TARGET =	$$($(2)_BUILDDIR)/.stamp_target_installed
+$(2)_TARGET_INSTALL_STAGING =	$$($(2)_BUILDDIR)/.stamp_staging_installed
+$(2)_TARGET_INSTALL_IMAGES =	$$($(2)_BUILDDIR)/.stamp_images_installed
+$(2)_TARGET_INSTALL_HOST =	$$($(2)_BUILDDIR)/.stamp_host_installed
+$(2)_TARGET_BUILD =		$$($(2)_BUILDDIR)/.stamp_built
+$(2)_TARGET_CONFIGURE =		$$($(2)_BUILDDIR)/.stamp_configured
+$(2)_TARGET_RSYNC =		$$($(2)_SRCDIR)/.stamp_rsynced
+$(2)_TARGET_PATCH =		$$($(2)_SRCDIR)/.stamp_patched
+$(2)_TARGET_EXTRACT =		$$($(2)_SRCDIR)/.stamp_extracted
+$(2)_TARGET_SOURCE =		$$($(2)_SRCDIR)/.stamp_downloaded
+$(2)_TARGET_ACTUAL_SOURCE =	$$($(2)_SRCDIR)/.stamp_actual_downloaded
+$(2)_TARGET_DIRCLEAN =		$$($(2)_BUILDDIR)/.stamp_dircleaned
 
 # default extract command
 $(2)_EXTRACT_CMDS ?= \
@@ -1176,7 +1176,7 @@ else
 			$$$${f} \
 			$$($(2)_REDIST_SOURCES_DIR) || exit 1; \
 		printf "%s\n" "$$$${f##*/}" >>$$($(2)_REDIST_SOURCES_DIR)/series || exit 1; \
-	done <$$($(2)_DIR)/.applied_patches_list
+	done <$$($(2)_SRCDIR)/.applied_patches_list
 endif # other packages
 
 endif # redistribute
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 02/23] infra: introduce a global SRC_DIR variable
  2026-10-23 21:47 [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR Florian Fainelli via buildroot
  2026-10-23 21:47 ` [Buildroot] [PATCH 01/23] package: prepare removal of <pkg>_DIR Florian Fainelli via buildroot
@ 2026-10-23 21:47 ` Florian Fainelli via buildroot
  2026-10-23 21:47 ` [Buildroot] [PATCH 03/23] package: fix <pkg>_SRCDIR and <pkg>_BUILDDIR values Florian Fainelli via buildroot
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:47 UTC (permalink / raw)
  To: buildroot
  Cc: Thomas Petazzoni, Eric Le Bihan, Jérôme Pouiller,
	Florian Fainelli, Gary Bisson, Romain Naour, Bernd Kuhls,
	Thomas Perale, Maxime Chevallier, Refik Tuzakli, Francois Perrad,
	Thomas Petazzoni, Arnout Vandecappelle, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Yann E. MORIN, Mahyar Koshkouei

From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

This commit introduces the global SRC_DIR variable, to point to a
directory where we will want to extract the packages sources into.
For now, it points to the same directory as BUILD_DIR, since we
don't yet support out-of-tree build of packages.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
[yann.morin.1998@free.fr:
  - rebase on master
  - slightly expand commit log
]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
(cherry picked from commit 3471f1620f8d78c5533d16d1c6d73b58e3e69962)
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile b/Makefile
index 9b62da3e4065..c1f12a4bfc38 100644
--- a/Makefile
+++ b/Makefile
@@ -211,6 +211,7 @@ endif
 # Avoids doing the $(or...) everytime
 BR_GRAPH_OUT := $(or $(BR2_GRAPH_OUT),pdf)
 
+SRC_DIR := $(BASE_DIR)/build
 BUILD_DIR := $(BASE_DIR)/build
 BINARIES_DIR := $(BASE_DIR)/images
 BASE_TARGET_DIR := $(BASE_DIR)/target
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 03/23] package: fix <pkg>_SRCDIR and <pkg>_BUILDDIR values
  2026-10-23 21:47 [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR Florian Fainelli via buildroot
  2026-10-23 21:47 ` [Buildroot] [PATCH 01/23] package: prepare removal of <pkg>_DIR Florian Fainelli via buildroot
  2026-10-23 21:47 ` [Buildroot] [PATCH 02/23] infra: introduce a global SRC_DIR variable Florian Fainelli via buildroot
@ 2026-10-23 21:47 ` Florian Fainelli via buildroot
  2026-10-23 21:47 ` [Buildroot] [PATCH 04/23] boot/boot-wrapper-aarch64: needs LINUX_BUILDDIR Florian Fainelli via buildroot
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:47 UTC (permalink / raw)
  To: buildroot
  Cc: Thomas Petazzoni, Eric Le Bihan, Jérôme Pouiller,
	Florian Fainelli, Gary Bisson, Romain Naour, Bernd Kuhls,
	Thomas Perale, Maxime Chevallier, Refik Tuzakli, Francois Perrad,
	Thomas Petazzoni, Arnout Vandecappelle, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Yann E. MORIN, Mahyar Koshkouei

From: "Yann E. MORIN" <yann.morin.1998@free.fr>

WIP: review and complete the parts about the individual infras: cmake,
     autotools, luarock, kconfig...

Until now, <pkg>_SRCDIR and <pkg>_BUILDDIR were taking into account the
potential <pkg>_SUBDIR, which indicates that the configure script is not
at the root of the source directory, but in some subdirectory.

However, in preparation for the out-of-tree build of packages, we want
to get rid of the <pkg>_DIR definition (because <pkg>_DIR doesn't
explicit whether it's the source or build directory), so we want
<pkg>_SRCDIR and <pkg>_BUILDDIR to become the real locations of the
source and build directories, respectively. To do so, they no longer
take into account <pkg>_SUBDIR.

Instead, a separate <pkg>_SRCSUBDIR variable has been introduced, which
points to the sub-directory in which the configure script (or
CMakeLists.txt file) is.

The autotools infrastructure is fixed to used <pkg>_SRCSUBDIR instead of
PKG_SRCDIR.

The cmake infrastructure is fixed to use <pkg>_SRCSUBDIR everywhere,
even in places where it was using <pkg>_BUILDDIR. The reason is that
now, <pkg>_BUILDDIR doesn't take into account the <pkg>_SUBDIR. Of
course, later patches will fix the CMake infrastructure back to use a
separate build directory.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
[yann.morin.1998@free.fr:
  - rebase on master
  - cmake already has its own BUILDDIR now
  - also convert the extract commands
  - also move the filelist step-hooks
  - convert pkg-kconfig and pkg-luarocks
]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>

(cherry picked from commit 49b7c84d4a23fd562c0e054acea4e8ebdbd8cb41)
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 package/pkg-autotools.mk | 20 +++++++++---------
 package/pkg-cmake.mk     |  8 ++++----
 package/pkg-generic.mk   |  9 ++++----
 package/pkg-kconfig.mk   | 44 ++++++++++++++++++++--------------------
 package/pkg-luarocks.mk  |  6 +++---
 5 files changed, 44 insertions(+), 43 deletions(-)

diff --git a/package/pkg-autotools.mk b/package/pkg-autotools.mk
index bb65d639dff1..58b63317cb60 100644
--- a/package/pkg-autotools.mk
+++ b/package/pkg-autotools.mk
@@ -59,7 +59,7 @@ endef
 #
 define LIBTOOL_PATCH_HOOK
 	@$(call MESSAGE,"Patching libtool")
-	$(Q)for i in `find $($(PKG)_DIR) -name ltmain.sh`; do \
+	$(Q)for i in `find $($(PKG)_SRCSUBDIR) -name ltmain.sh`; do \
 		ltmain_version=`sed -n '/^[ \t]*VERSION=/{s/^[ \t]*VERSION=//;p;q;}' $$i | \
 		sed -e 's/\([0-9]*\.[0-9]*\).*/\1/' -e 's/\"//'`; \
 		ltmain_patchlevel=`sed -n '/^[ \t]*VERSION=/{s/^[ \t]*VERSION=//;p;q;}' $$i | \
@@ -92,7 +92,7 @@ endef
 #
 define CONFIGURE_FIX_POWERPC64_HOOK
 	@$(call MESSAGE,"Checking configure (powerpc64/powerpc64le)")
-	support/scripts/fix-configure-powerpc64.sh $($(PKG)_DIR)
+	support/scripts/fix-configure-powerpc64.sh $($(PKG)_SRCSUBDIR)
 endef
 
 #
@@ -100,7 +100,7 @@ endef
 #
 define AUTORECONF_HOOK
 	@$(call MESSAGE,"Autoreconfiguring")
-	$(Q)cd $($(PKG)_SRCDIR) && $($(PKG)_AUTORECONF_ENV) $(AUTORECONF) $($(PKG)_AUTORECONF_OPTS)
+	$(Q)cd $($(PKG)_SRCSUBDIR) && $($(PKG)_AUTORECONF_ENV) $(AUTORECONF) $($(PKG)_AUTORECONF_OPTS)
 endef
 
 ################################################################################
@@ -171,7 +171,7 @@ ifeq ($(4),target)
 
 # Configure package for target
 define $(2)_CONFIGURE_CMDS
-	(cd $$($$(PKG)_SRCDIR) && rm -rf config.cache && \
+	(cd $$($$(PKG)_SRCSUBDIR) && rm -rf config.cache && \
 	$$(TARGET_CONFIGURE_OPTS) \
 	$$(TARGET_CONFIGURE_ARGS) \
 	$$($$(PKG)_CONF_ENV) \
@@ -206,7 +206,7 @@ else
 # because it often relies on host tools which may or may not be
 # installed.
 define $(2)_CONFIGURE_CMDS
-	(cd $$($$(PKG)_SRCDIR) && rm -rf config.cache; \
+	(cd $$($$(PKG)_SRCSUBDIR) && rm -rf config.cache; \
 	$$(HOST_CONFIGURE_OPTS) \
 	$$($$(PKG)_CONF_ENV) \
 	CONFIG_SITE=/dev/null \
@@ -272,11 +272,11 @@ endif
 ifndef $(2)_BUILD_CMDS
 ifeq ($(4),target)
 define $(2)_BUILD_CMDS
-	$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_SRCDIR)
+	$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_SRCSUBDIR)
 endef
 else
 define $(2)_BUILD_CMDS
-	$$(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_SRCDIR)
+	$$(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_SRCSUBDIR)
 endef
 endif
 endif
@@ -287,7 +287,7 @@ endif
 #
 ifndef $(2)_INSTALL_CMDS
 define $(2)_INSTALL_CMDS
-	$$(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_INSTALL_OPTS) -C $$($$(PKG)_SRCDIR)
+	$$(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_INSTALL_OPTS) -C $$($$(PKG)_SRCSUBDIR)
 endef
 endif
 
@@ -297,7 +297,7 @@ endif
 #
 ifndef $(2)_INSTALL_STAGING_CMDS
 define $(2)_INSTALL_STAGING_CMDS
-	$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_INSTALL_STAGING_OPTS) -C $$($$(PKG)_SRCDIR)
+	$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_INSTALL_STAGING_OPTS) -C $$($$(PKG)_SRCSUBDIR)
 endef
 endif
 
@@ -307,7 +307,7 @@ endif
 #
 ifndef $(2)_INSTALL_TARGET_CMDS
 define $(2)_INSTALL_TARGET_CMDS
-	$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_INSTALL_TARGET_OPTS) -C $$($$(PKG)_SRCDIR)
+	$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_INSTALL_TARGET_OPTS) -C $$($$(PKG)_SRCSUBDIR)
 endef
 endif
 
diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
index f572bdebb3da..d0dcdfbd50fd 100644
--- a/package/pkg-cmake.mk
+++ b/package/pkg-cmake.mk
@@ -57,9 +57,9 @@ $(3)_SUPPORTS_IN_SOURCE_BUILD ?= YES
 $(3)_CMAKE_BACKEND ?= make
 
 ifeq ($$($(3)_SUPPORTS_IN_SOURCE_BUILD),YES)
-$(2)_BUILDDIR			= $$($(2)_SRCDIR)
+$(2)_BUILDDIR			= $$($(2)_SRCSUBDIR)
 else
-$(2)_BUILDDIR			= $$($(2)_SRCDIR)/buildroot-build
+$(2)_BUILDDIR			= $$($(2)_SRCSUBDIR)/buildroot-build
 endif
 
 ifeq ($$($(3)_CMAKE_BACKEND),make)
@@ -103,7 +103,7 @@ define $(2)_CONFIGURE_CMDS
 	rm -f CMakeCache.txt && \
 	PATH=$$(BR_PATH) \
 	$$(if $$(BR2_INSTALL_LIBSTDCPP),,CXX=/bin/false) \
-	$$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCDIR) \
+	$$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCSUBDIR) \
 		-G$$($$(PKG)_GENERATOR) \
 		-DCMAKE_MAKE_PROGRAM="$$($$(PKG)_GENERATOR_PROGRAM)" \
 		-DCMAKE_TOOLCHAIN_FILE="$$(HOST_DIR)/share/buildroot/toolchainfile.cmake" \
@@ -135,7 +135,7 @@ define $(2)_CONFIGURE_CMDS
 	PKG_CONFIG_LIBDIR="$$(HOST_DIR)/lib/pkgconfig:$$(HOST_DIR)/share/pkgconfig" \
 	PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
 	PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \
-	$$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCDIR) \
+	$$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCSUBDIR) \
 		-G$$($$(PKG)_GENERATOR) \
 		-DCMAKE_MAKE_PROGRAM="$$($$(PKG)_GENERATOR_PROGRAM)" \
 		-DCMAKE_INSTALL_SO_NO_EXE=0 \
diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index fe5200475504..138fe9ccef4f 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -558,8 +558,9 @@ ifndef $(2)_STRIP_COMPONENTS
  endif
 endif
 
-$(2)_SRCDIR		       = $$($(2)_DIR)/$$($(2)_SUBDIR)
-$(2)_BUILDDIR		       ?= $$($(2)_SRCDIR)
+$(2)_SRCDIR = $$($(2)_DIR)
+$(2)_BUILDDIR = $$($(2)_DIR)
+$(2)_SRCSUBDIR = $$($(2)_SRCDIR)/$$($(2)_SUBDIR)
 
 ifneq ($$($(2)_OVERRIDE_SRCDIR),)
 $(2)_VERSION = custom
@@ -854,7 +855,7 @@ $(2)_TARGET_DIRCLEAN =		$$($(2)_BUILDDIR)/.stamp_dircleaned
 $(2)_EXTRACT_CMDS ?= \
 	$$(if $$($(2)_SOURCE),$$(INFLATE$$(suffix $$($(2)_SOURCE))) $$($(2)_DL_DIR)/$$($(2)_SOURCE) | \
 	$$(TAR) --strip-components=$$($(2)_STRIP_COMPONENTS) \
-		-C $$($(2)_DIR) \
+		-C $$($(2)_SRCDIR) \
 		$$(foreach x,$$($(2)_EXCLUDES),--exclude='$$(x)' ) \
 		$$(TAR_OPTIONS) -)
 
@@ -1141,7 +1142,7 @@ ifneq ($$(call qstrip,$$($(2)_SOURCE)),)
 ifeq ($$(call qstrip,$$($(2)_LICENSE_FILES)),)
 	$(Q)$$(call legal-warning-pkg,$$($(2)_BASENAME_RAW),cannot save license ($(2)_LICENSE_FILES not defined))
 else
-	$(Q)$$(foreach F,$$($(2)_LICENSE_FILES),$$(call legal-license-file,$$(call UPPERCASE,$(4)),$$($(2)_RAWNAME),$$($(2)_BASENAME_RAW),$$(F),$$($(2)_DIR)/$$(F),$$($(2)_HASH_FILES))$$(sep))
+	$(Q)$$(foreach F,$$($(2)_LICENSE_FILES),$$(call legal-license-file,$$(call UPPERCASE,$(4)),$$($(2)_RAWNAME),$$($(2)_BASENAME_RAW),$$(F),$$($(2)_SRCDIR)/$$(F),$$($(2)_HASH_FILES))$$(sep))
 endif # license files
 
 ifeq ($$($(2)_REDISTRIBUTE),YES)
diff --git a/package/pkg-kconfig.mk b/package/pkg-kconfig.mk
index 8000de16c49e..8a63d55be033 100644
--- a/package/pkg-kconfig.mk
+++ b/package/pkg-kconfig.mk
@@ -23,8 +23,8 @@ define kconfig-package-update-config
 		exit 1; \
 	fi
 	$(Q)mkdir -p $(dir $($(PKG)_KCONFIG_FILE))
-	cp -f $($(PKG)_DIR)/$(1) $($(PKG)_KCONFIG_FILE)
-	$(Q)touch --reference $($(PKG)_DIR)/$($(PKG)_KCONFIG_STAMP_DOTCONFIG) $($(PKG)_KCONFIG_FILE)
+	cp -f $($(PKG)_BUILDDIR)/$(1) $($(PKG)_KCONFIG_FILE)
+	$(Q)touch --reference $($(PKG)_BUILDDIR)/$($(PKG)_KCONFIG_STAMP_DOTCONFIG) $($(PKG)_KCONFIG_FILE)
 endef
 
 PKG_KCONFIG_COMMON_OPTS = \
@@ -117,8 +117,8 @@ endif
 
 # Call the generic package infrastructure to generate the necessary
 # make targets.
-# Note: this must be done _before_ attempting to use $$($(2)_DIR) in a
-# dependency expression
+# Note: this must be done _before_ attempting to use either $$($(2)_SRCDIR)
+# or $$($(2)_BUILDDIR) in a dependency expression
 $(call inner-generic-package,$(1),$(2),$(3),$(4))
 
 # Do not use $(2)_KCONFIG_DOTCONFIG as stamp file, because the package
@@ -148,23 +148,23 @@ $$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES): | $(1)-patch
 	done
 
 $(2)_KCONFIG_MAKE = \
-	$$($(2)_MAKE_ENV) $$($(2)_MAKE) -C $$($(2)_DIR) \
+	$$($(2)_MAKE_ENV) $$($(2)_MAKE) -C $$($(2)_BUILDDIR) \
 		$$(PKG_KCONFIG_COMMON_OPTS) $$($(2)_KCONFIG_OPTS)
 
 # The specified source configuration file and any additional configuration file
 # fragments are merged together to .config, after the package has been patched.
 # Since the file could be a defconfig file it needs to be expanded to a
 # full .config first.
-$$($(2)_DIR)/$$($(2)_KCONFIG_STAMP_DOTCONFIG): $$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES)
+$$($(2)_BUILDDIR)/$$($(2)_KCONFIG_STAMP_DOTCONFIG): $$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES)
 	$$(call prepare-per-package-directory,$$($(2)_KCONFIG_DEPENDENCIES))
 	$$(call kconfig-package-merge-config,$(2),$$(@D)/$$($(2)_KCONFIG_DOTCONFIG),\
 		$$($(2)_KCONFIG_FRAGMENT_FILES))
-	$$(Q)touch $$(@D)/$$($(2)_KCONFIG_STAMP_DOTCONFIG)
+	$$(Q)touch $$($(2)_BUILDDIR)/$$($(2)_KCONFIG_STAMP_DOTCONFIG)
 
 # If _KCONFIG_FILE or _KCONFIG_FRAGMENT_FILES exists, this dependency is
 # already implied, but if we only have a _KCONFIG_DEFCONFIG we have to add
 # it explicitly. It doesn't hurt to always have it though.
-$$($(2)_DIR)/$$($(2)_KCONFIG_STAMP_DOTCONFIG): | $(1)-patch
+$$($(2)_BUILDDIR)/$$($(2)_KCONFIG_STAMP_DOTCONFIG): | $(1)-patch
 
 # Some packages may need additional tools to be present by the time their
 # kconfig structure is parsed (e.g. the linux kernel may need to call to
@@ -176,21 +176,21 @@ $$($(2)_DIR)/$$($(2)_KCONFIG_STAMP_DOTCONFIG): | $$($(2)_KCONFIG_DEPENDENCIES)
 define $(2)_FIXUP_DOT_CONFIG
 	$$($(2)_KCONFIG_FIXUP_CMDS)
 	$$(call kconfig-package-regen-dot-config,$(2))
-	$$(Q)touch $$($(2)_DIR)/.stamp_kconfig_fixup_done
+	$$(Q)touch $$($(2)_BUILDDIR)/.stamp_kconfig_fixup_done
 endef
 
-$$($(2)_DIR)/.stamp_kconfig_fixup_done: PKG=$(2)
-$$($(2)_DIR)/.stamp_kconfig_fixup_done: $$($(2)_DIR)/$$($(2)_KCONFIG_STAMP_DOTCONFIG)
+$$($(2)_BUILDDIR)/.stamp_kconfig_fixup_done: PKG=$(2)
+$$($(2)_BUILDDIR)/.stamp_kconfig_fixup_done: $$($(2)_BUILDDIR)/$$($(2)_KCONFIG_STAMP_DOTCONFIG)
 	$$($(2)_FIXUP_DOT_CONFIG)
 
 # Before running configure, the configuration file should be present and fixed
-$$($(2)_TARGET_CONFIGURE): $$($(2)_DIR)/.stamp_kconfig_fixup_done
+$$($(2)_TARGET_CONFIGURE): $$($(2)_BUILDDIR)/.stamp_kconfig_fixup_done
 
 # Force olddefconfig again on -reconfigure
 $(1)-clean-for-reconfigure: $(1)-clean-kconfig-for-reconfigure
 
 $(1)-clean-kconfig-for-reconfigure:
-	rm -f $$($(2)_DIR)/$$($(2)_KCONFIG_STAMP_DOTCONFIG)
+	rm -f $$($(2)_BUILDDIR)/$$($(2)_KCONFIG_STAMP_DOTCONFIG)
 
 # Only enable the foo-*config targets when the package is actually enabled.
 # Note: the variable $(2)_KCONFIG_VAR is not related to the kconfig
@@ -236,18 +236,18 @@ $(2)_CONFIGURATOR_MAKE_ENV = \
 # with a stamp-like file which path is in the package build dir, so we
 # end up having a valid @D.
 #
-$$(addprefix $(1)-,$$($(2)_KCONFIG_EDITORS)): $(1)-%: $$($(2)_DIR)/.kconfig_editor_%
-$$($(2)_DIR)/.kconfig_editor_%: PKG=$(2)
-$$($(2)_DIR)/.kconfig_editor_%: $$($(2)_DIR)/.stamp_kconfig_fixup_done
-	$$($(2)_CONFIGURATOR_MAKE_ENV) $$($(2)_MAKE) -C $$($(2)_DIR) \
+$$(addprefix $(1)-,$$($(2)_KCONFIG_EDITORS)): $(1)-%: $$($(2)_BUILDDIR)/.kconfig_editor_%
+$$($(2)_BUILDDIR)/.kconfig_editor_%: PKG=$(2)
+$$($(2)_BUILDDIR)/.kconfig_editor_%: $$($(2)_BUILDDIR)/.stamp_kconfig_fixup_done
+	$$($(2)_CONFIGURATOR_MAKE_ENV) $$($(2)_MAKE) -C $$($(2)_BUILDDIR) \
 		$$(PKG_KCONFIG_COMMON_OPTS) $$($(2)_KCONFIG_OPTS) $$(*)
-	rm -f $$($(2)_DIR)/.stamp_{kconfig_fixup_done,configured,built}
-	rm -f $$($(2)_DIR)/.stamp_{target,staging,images}_installed
+	rm -f $$($(2)_BUILDDIR)/.stamp_{kconfig_fixup_done,configured,built}
+	rm -f $$($(2)_BUILDDIR)/.stamp_{target,staging,images}_installed
 	$$($(2)_FIXUP_DOT_CONFIG)
 
 # Saving back the configuration
 #
-# Ideally, that should directly depend on $$($(2)_DIR)/.stamp_kconfig_fixup_done,
+# Ideally, that should directly depend on $$($(2)_BUILDDIR)/.stamp_kconfig_fixup_done,
 # but that breaks the use-case in PR-8156 (from a clean tree):
 #   make menuconfig           <- enable kernel, use an in-tree defconfig, save and exit
 #   make linux-menuconfig     <- enable/disable whatever option, save and exit
@@ -262,7 +262,7 @@ $$($(2)_DIR)/.kconfig_editor_%: $$($(2)_DIR)/.stamp_kconfig_fixup_done
 # Instead, we use a PHONY rule that will catch that situation.
 #
 $(1)-check-configuration-done:
-	@if [ ! -f $$($(2)_DIR)/.stamp_kconfig_fixup_done ]; then \
+	@if [ ! -f $$($(2)_BUILDDIR)/.stamp_kconfig_fixup_done ]; then \
 		echo "$(1) is not yet configured"; \
 		exit 1; \
 	fi
@@ -316,7 +316,7 @@ endif # package enabled
 .PHONY: \
 	$(1)-diff-config \
 	$(1)-check-configuration-done \
-	$$($(2)_DIR)/.kconfig_editor_% \
+	$$($(2)_BUILDDIR)/.kconfig_editor_% \
 	$$(addprefix $(1)-,$$($(2)_KCONFIG_EDITORS))
 
 endef # inner-kconfig-package
diff --git a/package/pkg-luarocks.mk b/package/pkg-luarocks.mk
index fd798558785c..abcd525fcf8a 100644
--- a/package/pkg-luarocks.mk
+++ b/package/pkg-luarocks.mk
@@ -96,10 +96,10 @@ $(2)_EXTRACT_DEPENDENCIES += host-luarocks
 #
 ifndef $(2)_EXTRACT_CMDS
 define $(2)_EXTRACT_CMDS
-	mkdir -p $$($(2)_DIR)/luarocks-extract
-	cd $$($(2)_DIR)/luarocks-extract && \
+	mkdir -p $$($(2)_SRCDIR)/luarocks-extract
+	cd $$($(2)_SRCDIR)/luarocks-extract && \
 		$$(LUAROCKS_RUN_CMD) unpack --force $$($(2)_DL_DIR)/$$($(2)_SOURCE)
-	mv $$($(2)_DIR)/luarocks-extract/*/* $$($(2)_DIR)
+	mv $$($(2)_SRCDIR)/luarocks-extract/*/* $$($(2)_SRCDIR)
 endef
 endif
 
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 04/23] boot/boot-wrapper-aarch64: needs LINUX_BUILDDIR
  2026-10-23 21:47 [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR Florian Fainelli via buildroot
                   ` (2 preceding siblings ...)
  2026-10-23 21:47 ` [Buildroot] [PATCH 03/23] package: fix <pkg>_SRCDIR and <pkg>_BUILDDIR values Florian Fainelli via buildroot
@ 2026-10-23 21:47 ` Florian Fainelli via buildroot
  2026-10-23 21:47 ` [Buildroot] [PATCH 05/23] boot/mxs-bootlets: needs (BAREBOX, LINUX, UBOOT)_BUILDDIR Florian Fainelli via buildroot
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:47 UTC (permalink / raw)
  To: buildroot
  Cc: Thomas Petazzoni, Eric Le Bihan, Jérôme Pouiller,
	Florian Fainelli, Gary Bisson, Romain Naour, Bernd Kuhls,
	Thomas Perale, Maxime Chevallier, Refik Tuzakli, Francois Perrad,
	Thomas Petazzoni, Arnout Vandecappelle, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Yann E. MORIN, Mahyar Koshkouei

From: "Yann E. MORIN" <yann.morin.1998@free.fr>

In preparation for the split between the source and build directories,
make boot-wrapper-aarch64 look in the correct location.

boot-wrapper-aarch64 needs access to the kerenl build directory:

    $ ./configure --help
      --with-kernel-dir       specify the root Linux kernel build directory

Make it so.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
(cherry picked from commit f22ee04de55cf7a41368a7be905b15df240aa8ad)
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 boot/boot-wrapper-aarch64/boot-wrapper-aarch64.mk | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/boot/boot-wrapper-aarch64/boot-wrapper-aarch64.mk b/boot/boot-wrapper-aarch64/boot-wrapper-aarch64.mk
index 75be23f24333..f9f8e3cf49d1 100644
--- a/boot/boot-wrapper-aarch64/boot-wrapper-aarch64.mk
+++ b/boot/boot-wrapper-aarch64/boot-wrapper-aarch64.mk
@@ -19,7 +19,7 @@ BOOT_WRAPPER_AARCH64_AUTORECONF = YES
 BOOT_WRAPPER_AARCH64_DTB = $(LINUX_DIR)/arch/arm64/boot/dts/$(basename $(call qstrip,$(BR2_TARGET_BOOT_WRAPPER_AARCH64_DTS))).dtb
 
 BOOT_WRAPPER_AARCH64_CONF_OPTS = \
-	--with-kernel-dir=$(LINUX_DIR) \
+	--with-kernel-dir=$(LINUX_BUILDDIR) \
 	--with-dtb=$(BOOT_WRAPPER_AARCH64_DTB) \
 	--with-cmdline=$(BR2_TARGET_BOOT_WRAPPER_AARCH64_BOOTARGS)
 
@@ -39,9 +39,9 @@ endif
 # AC_CHECK_FILE tests, which are always disabled in cross-compilation
 # situations.
 BOOT_WRAPPER_AARCH64_CONF_ENV = \
-	$(call AUTOCONF_AC_CHECK_FILE_VAL,$(LINUX_DIR))=yes \
-	$(call AUTOCONF_AC_CHECK_FILE_VAL,$(LINUX_DIR)$(BOOT_WRAPPER_AARCH64_DTB))=yes \
-	$(call AUTOCONF_AC_CHECK_FILE_VAL,$(LINUX_DIR)/arch/arm64/boot/Image)=yes
+	$(call AUTOCONF_AC_CHECK_FILE_VAL,$(LINUX_BUILDDIR))=yes \
+	$(call AUTOCONF_AC_CHECK_FILE_VAL,$(LINUX_BUILDDIR)$(BOOT_WRAPPER_AARCH64_DTB))=yes \
+	$(call AUTOCONF_AC_CHECK_FILE_VAL,$(LINUX_BUILDDIR)/arch/arm64/boot/Image)=yes
 
 define BOOT_WRAPPER_AARCH64_INSTALL_IMAGES_CMDS
 	cp $(@D)/linux-system.axf $(BINARIES_DIR)
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 05/23] boot/mxs-bootlets: needs (BAREBOX, LINUX, UBOOT)_BUILDDIR
  2026-10-23 21:47 [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR Florian Fainelli via buildroot
                   ` (3 preceding siblings ...)
  2026-10-23 21:47 ` [Buildroot] [PATCH 04/23] boot/boot-wrapper-aarch64: needs LINUX_BUILDDIR Florian Fainelli via buildroot
@ 2026-10-23 21:47 ` Florian Fainelli via buildroot
  2026-10-23 21:47 ` [Buildroot] [PATCH 06/23] linux/extensions: point to proper _SRCDIR and @D Florian Fainelli via buildroot
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:47 UTC (permalink / raw)
  To: buildroot
  Cc: Gary Bisson, Thomas Petazzoni, Petr Vorel, Spenser Gilliland,
	Florian Fainelli, Maxime Chevallier, Francois Perrad,
	Arnout Vandecappelle, Luca Ceresoli, Thomas Perale, Eric Le Bihan,
	Mahyar Koshkouei, Yann E. MORIN, Romain Naour, Pascal de Bruijn,
	Thomas Petazzoni, Jérôme Pouiller, Bernd Kuhls,
	Maxime Ripard, Refik Tuzakli, Giulio Benetti

From: "Yann E. MORIN" <yann.morin.1998@free.fr>

In preparation for the split between the source and build directories,
make mxs-bootlets look in the correct locations.

mxs-bootlets wants to access the generated images, so it must look in
the build directory of each package.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
(cherry picked from commit 23a452e42840d5536dc1a24cae859da608003e29)
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 boot/mxs-bootlets/mxs-bootlets.mk | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/boot/mxs-bootlets/mxs-bootlets.mk b/boot/mxs-bootlets/mxs-bootlets.mk
index adc22767f7e3..e2dc14e90ac0 100644
--- a/boot/mxs-bootlets/mxs-bootlets.mk
+++ b/boot/mxs-bootlets/mxs-bootlets.mk
@@ -56,7 +56,7 @@ endif
 
 ifeq ($(BR2_TARGET_MXS_BOOTLETS_BAREBOX),y)
 define MXS_BOOTLETS_SED_BAREBOX
-	sed -i 's,[^ *]barebox.*;,\tbarebox="$(BAREBOX_DIR)/barebox";,' $(@D)/$(MXS_BOOTLETS_BOOTDESC)
+	sed -i 's,[^ *]barebox.*;,\tbarebox="$(BAREBOX_BUILDDIR)/barebox";,' $(@D)/$(MXS_BOOTLETS_BOOTDESC)
 endef
 endif
 
@@ -67,13 +67,13 @@ define MXS_BOOTLETS_BUILD_LINUX_PREP
 endef
 define MXS_BOOTLETS_SED_LINUX
 	sed -i 's,[^ *]linux_prep.*;,\tlinux_prep="$(@D)/linux_prep/output-target/linux_prep";,' $(@D)/$(MXS_BOOTLETS_BOOTDESC)
-	sed -i 's,[^ *]zImage.*;,\tzImage="$(LINUX_DIR)/arch/arm/boot/zImage";,' $(@D)/$(MXS_BOOTLETS_BOOTDESC)
+	sed -i 's,[^ *]zImage.*;,\tzImage="$(LINUX_BUILDDIR)/arch/arm/boot/zImage";,' $(@D)/$(MXS_BOOTLETS_BOOTDESC)
 endef
 endif
 
 ifeq ($(BR2_TARGET_MXS_BOOTLETS_UBOOT),y)
 define MXS_BOOTLETS_SED_UBOOT
-	sed -i 's,[^ *]u_boot.*;,\tu_boot="$(UBOOT_DIR)/u-boot";,' $(@D)/$(MXS_BOOTLETS_BOOTDESC)
+	sed -i 's,[^ *]u_boot.*;,\tu_boot="$(UBOOT_BUILDDIR)/u-boot";,' $(@D)/$(MXS_BOOTLETS_BOOTDESC)
 endef
 endif
 
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 06/23] linux/extensions: point to proper _SRCDIR and @D
  2026-10-23 21:47 [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR Florian Fainelli via buildroot
                   ` (4 preceding siblings ...)
  2026-10-23 21:47 ` [Buildroot] [PATCH 05/23] boot/mxs-bootlets: needs (BAREBOX, LINUX, UBOOT)_BUILDDIR Florian Fainelli via buildroot
@ 2026-10-23 21:47 ` Florian Fainelli via buildroot
  2026-10-23 21:47 ` [Buildroot] [PATCH 07/23] linux/linux: LINUX_VERSION_PROBED should run from build directory Florian Fainelli via buildroot
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:47 UTC (permalink / raw)
  To: buildroot
  Cc: Gary Bisson, Thomas Petazzoni, Petr Vorel, Spenser Gilliland,
	Mahyar Koshkouei, Florian Fainelli, Maxime Chevallier,
	Francois Perrad, Arnout Vandecappelle, Luca Ceresoli,
	Thomas Perale, Eric Le Bihan, David Lechner, Yann E. MORIN,
	Giulio Benetti, Pascal de Bruijn, Thomas Petazzoni,
	Jérôme Pouiller, Bernd Kuhls, Refik Tuzakli,
	Romain Naour

From: "Yann E. MORIN" <yann.morin.1998@free.fr>

In preparation for the split between the source and build directories,
make the linux extensions look in the correct locations.

The patches or scripts are located in the source direcotries of the
extensions, so look there.

Also, the externsions are run as part of the various infra hooks, so
they have access to @D, so use that instead of LINUX_DIR.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc Christian Stewart <christian@paral.in>
Cc: David Lechner <david@lechnology.com>
(cherry picked from commit 301dfb34380dfaeb5c32e71758aa1c3706140301)
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 linux/linux-ext-rtai.mk    | 8 ++++----
 linux/linux-ext-xenomai.mk | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/linux/linux-ext-rtai.mk b/linux/linux-ext-rtai.mk
index 50f79f8d5047..d7f55cf55f41 100644
--- a/linux/linux-ext-rtai.mk
+++ b/linux/linux-ext-rtai.mk
@@ -18,10 +18,10 @@ endif
 
 # Prepare kernel patch
 define RTAI_PREPARE_KERNEL
-	kver=`$(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) --no-print-directory -s kernelversion` ; \
-	if test -f $(RTAI_DIR)/base/arch/$(RTAI_ARCH)/patches/hal-linux-$${kver}-*patch ; then \
-		$(APPLY_PATCHES) $(LINUX_DIR) \
-			$(RTAI_DIR)/base/arch/$(RTAI_ARCH)/patches/ \
+	kver=`$(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) --no-print-directory -s kernelversion` ; \
+	if test -f $(RTAI_SRCDIR)/base/arch/$(RTAI_ARCH)/patches/hal-linux-$${kver}-*patch ; then \
+		$(APPLY_PATCHES) $(@D) \
+			$(RTAI_SRCDIR)/base/arch/$(RTAI_ARCH)/patches/ \
 			hal-linux-$${kver}-*patch ; \
 	else \
 		echo "No RTAI patch for your kernel version" ; \
diff --git a/linux/linux-ext-xenomai.mk b/linux/linux-ext-xenomai.mk
index 5ec6891bbf20..0ebb771d8940 100644
--- a/linux/linux-ext-xenomai.mk
+++ b/linux/linux-ext-xenomai.mk
@@ -27,8 +27,8 @@ endif
 
 # Prepare kernel patch
 define XENOMAI_PREPARE_KERNEL
-	$(XENOMAI_DIR)/scripts/prepare-kernel.sh \
-		--linux=$(LINUX_DIR) \
+	$(XENOMAI_SRCDIR)/scripts/prepare-kernel.sh \
+		--linux=$(@D) \
 		--arch=$(KERNEL_ARCH) \
 		$(XENOMAI_ADEOS_OPTS) \
 		--verbose
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 07/23] linux/linux: LINUX_VERSION_PROBED should run from build directory
  2026-10-23 21:47 [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR Florian Fainelli via buildroot
                   ` (5 preceding siblings ...)
  2026-10-23 21:47 ` [Buildroot] [PATCH 06/23] linux/extensions: point to proper _SRCDIR and @D Florian Fainelli via buildroot
@ 2026-10-23 21:47 ` Florian Fainelli via buildroot
  2026-10-23 21:51 ` Florian Fainelli via buildroot
  2026-10-24 20:44 ` [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR Thomas Petazzoni via buildroot
  8 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:47 UTC (permalink / raw)
  To: buildroot
  Cc: Thomas Petazzoni, Eric Le Bihan, Jérôme Pouiller,
	Florian Fainelli, Gary Bisson, Romain Naour, Bernd Kuhls,
	Thomas Perale, Maxime Chevallier, Refik Tuzakli, Francois Perrad,
	Thomas Petazzoni, Arnout Vandecappelle, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Yann E. MORIN, Mahyar Koshkouei

From: "Yann E. MORIN" <yann.morin.1998@free.fr>

LINUX_VERSION_PROBED would be constructed from some configuration
options, like CONFIG_LOCALVERSION, so it needs to run from the build
directory, where Linux' .config is.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
(cherry picked from commit 0323ef5ceb5b5968eb9f6f00cbe26cf089a4d252)
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 linux/linux.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux/linux.mk b/linux/linux.mk
index 75294cff1842..a90e09afe906 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -197,7 +197,7 @@ endif
 # Get the real Linux version, which tells us where kernel modules are
 # going to be installed in the target filesystem.
 # Filter out 'w' from MAKEFLAGS, to workaround a bug in make 4.1 (#13141)
-LINUX_VERSION_PROBED = `MAKEFLAGS='$(filter-out w,$(MAKEFLAGS))' $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) --no-print-directory -s kernelrelease 2>/dev/null`
+LINUX_VERSION_PROBED = `MAKEFLAGS='$(filter-out w,$(MAKEFLAGS))' $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_BUILDDIR) --no-print-directory -s kernelrelease 2>/dev/null`
 
 LINUX_DTS_NAME += $(call qstrip,$(BR2_LINUX_KERNEL_INTREE_DTS_NAME))
 LINUX_DTSO_NAMES += $(call qstrip,$(BR2_LINUX_KERNEL_INTREE_DTSO_NAMES))
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 07/23] linux/linux: LINUX_VERSION_PROBED should run from build directory
  2026-10-23 21:47 [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR Florian Fainelli via buildroot
                   ` (6 preceding siblings ...)
  2026-10-23 21:47 ` [Buildroot] [PATCH 07/23] linux/linux: LINUX_VERSION_PROBED should run from build directory Florian Fainelli via buildroot
@ 2026-10-23 21:51 ` Florian Fainelli via buildroot
  2026-10-23 21:51   ` [Buildroot] [PATCH 08/23] package: use <pkg>_SRCSUBDIR where <pkg>_SRCDIR used to include _SUBDIR Florian Fainelli via buildroot
                     ` (15 more replies)
  2026-10-24 20:44 ` [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR Thomas Petazzoni via buildroot
  8 siblings, 16 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:51 UTC (permalink / raw)
  To: buildroot
  Cc: Thomas Petazzoni, Eric Le Bihan, Jérôme Pouiller,
	Florian Fainelli, Gary Bisson, Romain Naour, Bernd Kuhls,
	Thomas Perale, Maxime Chevallier, Refik Tuzakli, Francois Perrad,
	Thomas Petazzoni, Arnout Vandecappelle, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Yann E. MORIN, Mahyar Koshkouei

From: "Yann E. MORIN" <yann.morin.1998@free.fr>

LINUX_VERSION_PROBED would be constructed from some configuration
options, like CONFIG_LOCALVERSION, so it needs to run from the build
directory, where Linux' .config is.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
(cherry picked from commit 0323ef5ceb5b5968eb9f6f00cbe26cf089a4d252)
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 linux/linux.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux/linux.mk b/linux/linux.mk
index 75294cff1842..a90e09afe906 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -197,7 +197,7 @@ endif
 # Get the real Linux version, which tells us where kernel modules are
 # going to be installed in the target filesystem.
 # Filter out 'w' from MAKEFLAGS, to workaround a bug in make 4.1 (#13141)
-LINUX_VERSION_PROBED = `MAKEFLAGS='$(filter-out w,$(MAKEFLAGS))' $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) --no-print-directory -s kernelrelease 2>/dev/null`
+LINUX_VERSION_PROBED = `MAKEFLAGS='$(filter-out w,$(MAKEFLAGS))' $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_BUILDDIR) --no-print-directory -s kernelrelease 2>/dev/null`
 
 LINUX_DTS_NAME += $(call qstrip,$(BR2_LINUX_KERNEL_INTREE_DTS_NAME))
 LINUX_DTSO_NAMES += $(call qstrip,$(BR2_LINUX_KERNEL_INTREE_DTSO_NAMES))
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 08/23] package: use <pkg>_SRCSUBDIR where <pkg>_SRCDIR used to include _SUBDIR
  2026-10-23 21:51 ` Florian Fainelli via buildroot
@ 2026-10-23 21:51   ` Florian Fainelli via buildroot
  2026-10-23 21:51   ` [Buildroot] [PATCH 09/23] linux: build out of tree when LINUX_OVERRIDE_SRCDIR is set Florian Fainelli via buildroot
                     ` (14 subsequent siblings)
  15 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:51 UTC (permalink / raw)
  To: buildroot
  Cc: Eric Le Bihan, Gary Bisson, Jérôme Pouiller,
	Florian Fainelli, Bernd Kuhls, Thomas Perale, Maxime Chevallier,
	Refik Tuzakli, Francois Perrad, Thomas Petazzoni,
	Arnout Vandecappelle, Petr Vorel, Spenser Gilliland,
	Giulio Benetti, Pascal de Bruijn, Luca Ceresoli, Romain Naour,
	Mahyar Koshkouei

With <pkg>_SRCDIR no longer including <pkg>_SUBDIR, convert the
infrastructures and packages that relied on the old meaning (cargo,
hare, luarocks, meson, perl, waf, gcc-final) to <pkg>_SRCSUBDIR.

Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 package/gcc/gcc-final/gcc-final.mk |  2 +-
 package/pkg-cargo.mk               |  8 ++++----
 package/pkg-hare.mk                |  8 ++++----
 package/pkg-luarocks.mk            |  4 ++--
 package/pkg-meson.mk               | 26 +++++++++++++-------------
 package/pkg-perl.mk                | 12 ++++++------
 package/pkg-waf.mk                 |  8 ++++----
 7 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/package/gcc/gcc-final/gcc-final.mk b/package/gcc/gcc-final/gcc-final.mk
index 97a64ae2fabf..570636a81dfe 100644
--- a/package/gcc/gcc-final/gcc-final.mk
+++ b/package/gcc/gcc-final/gcc-final.mk
@@ -51,7 +51,7 @@ HOST_GCC_FINAL_PRE_CONFIGURE_HOOKS += HOST_GCC_CONFIGURE_SYMLINK
 # So we must completely override the generic commands and provide our own.
 #
 define HOST_GCC_FINAL_CONFIGURE_CMDS
-	(cd $(HOST_GCC_FINAL_SRCDIR) && rm -rf config.cache; \
+	(cd $(HOST_GCC_FINAL_SRCSUBDIR) && rm -rf config.cache; \
 		$(HOST_CONFIGURE_OPTS) \
 		CFLAGS="$(HOST_CFLAGS)" \
 		LDFLAGS="$(HOST_LDFLAGS)" \
diff --git a/package/pkg-cargo.mk b/package/pkg-cargo.mk
index 47a6353f2592..aae6eb9b61aa 100644
--- a/package/pkg-cargo.mk
+++ b/package/pkg-cargo.mk
@@ -234,7 +234,7 @@ endif
 ifndef $(2)_BUILD_CMDS
 ifeq ($(4),target)
 define $(2)_BUILD_CMDS
-	cd $$($$(PKG)_SRCDIR) && \
+	cd $$($$(PKG)_SRCSUBDIR) && \
 	$$(TARGET_MAKE_ENV) \
 		$$(TARGET_CONFIGURE_OPTS) \
 		$$(PKG_CARGO_ENV) \
@@ -248,7 +248,7 @@ define $(2)_BUILD_CMDS
 endef
 else # ifeq ($(4),target)
 define $(2)_BUILD_CMDS
-	cd $$($$(PKG)_SRCDIR) && \
+	cd $$($$(PKG)_SRCSUBDIR) && \
 	$$(HOST_MAKE_ENV) \
 		$$(HOST_CONFIGURE_OPTS) \
 		$$(HOST_PKG_CARGO_ENV) \
@@ -269,7 +269,7 @@ endif # ifndef $(2)_BUILD_CMDS
 #
 ifndef $(2)_INSTALL_TARGET_CMDS
 define $(2)_INSTALL_TARGET_CMDS
-	cd $$($$(PKG)_SRCDIR) && \
+	cd $$($$(PKG)_SRCSUBDIR) && \
 	$$(TARGET_MAKE_ENV) \
 		$$(TARGET_CONFIGURE_OPTS) \
 		$$(PKG_CARGO_ENV) \
@@ -289,7 +289,7 @@ endif
 
 ifndef $(2)_INSTALL_CMDS
 define $(2)_INSTALL_CMDS
-	cd $$($$(PKG)_SRCDIR) && \
+	cd $$($$(PKG)_SRCSUBDIR) && \
 	$$(HOST_MAKE_ENV) \
 		$$(HOST_CONFIGURE_OPTS) \
 		$$(HOST_PKG_CARGO_ENV) \
diff --git a/package/pkg-hare.mk b/package/pkg-hare.mk
index 15dc769311a8..a263b4d42ef3 100644
--- a/package/pkg-hare.mk
+++ b/package/pkg-hare.mk
@@ -48,10 +48,10 @@ ifndef $(2)_BUILD_CMDS
 # https://harelang.org/documentation/usage/project-structure.html#makefiles
 # but in real world, the target "all" is not always the default one
 define $(2)_BUILD_CMDS
-	if grep "^all:" $$($(2)_SRCDIR)Makefile > /dev/null; then \
+	if grep "^all:" $$($(2)_SRCSUBDIR)Makefile > /dev/null; then \
 		target=all ; \
 	fi ; \
-	$(MAKE) -C $$($(2)_SRCDIR) HARE="$$(HARE_RUN_CMD)" HAREFLAGS="$$(HARE_ARCH_OPT) $$(HARE_LIBDIR_OPT)" $${target}
+	$(MAKE) -C $$($(2)_SRCSUBDIR) HARE="$$(HARE_RUN_CMD)" HAREFLAGS="$$(HARE_ARCH_OPT) $$(HARE_LIBDIR_OPT)" $${target}
 endef
 endif
 
@@ -61,7 +61,7 @@ endif
 #
 ifndef $(2)_INSTALL_STAGING_CMDS
 define $(2)_INSTALL_STAGING_CMDS
-	$(MAKE) -C $$($(2)_SRCDIR) PREFIX=/usr DESTDIR="$$(STAGING_DIR)" install
+	$(MAKE) -C $$($(2)_SRCSUBDIR) PREFIX=/usr DESTDIR="$$(STAGING_DIR)" install
 endef
 endif
 
@@ -71,7 +71,7 @@ endif
 #
 ifndef $(2)_INSTALL_TARGET_CMDS
 define $(2)_INSTALL_TARGET_CMDS
-	$(MAKE) -C $$($(2)_SRCDIR) PREFIX=/usr DESTDIR="$$(TARGET_DIR)" install
+	$(MAKE) -C $$($(2)_SRCSUBDIR) PREFIX=/usr DESTDIR="$$(TARGET_DIR)" install
 endef
 endif
 
diff --git a/package/pkg-luarocks.mk b/package/pkg-luarocks.mk
index abcd525fcf8a..9c12ed627b60 100644
--- a/package/pkg-luarocks.mk
+++ b/package/pkg-luarocks.mk
@@ -108,7 +108,7 @@ endif
 #
 ifndef $(2)_INSTALL_TARGET_CMDS
 define $(2)_INSTALL_TARGET_CMDS
-	cd $$($(2)_SRCDIR) && \
+	cd $$($(2)_SRCSUBDIR) && \
 		LUAROCKS_CONFIG=$$(LUAROCKS_CONFIG_FILE) \
 		$$(LUAROCKS_RUN_CMD) make --keep --deps-mode none \
 			--tree "$$(TARGET_DIR)/usr" \
@@ -125,7 +125,7 @@ endif
 
 ifndef $(2)_INSTALL_CMDS
 define $(2)_INSTALL_CMDS
-	cd $$($(2)_SRCDIR) && \
+	cd $$($(2)_SRCSUBDIR) && \
 		LUAROCKS_CONFIG=$$(HOST_LUAROCKS_CONFIG_FILE) \
 		$$(LUAROCKS_RUN_CMD) make --keep --deps-mode none \
 			DEPS_DIR="$$(HOST_DIR)" \
diff --git a/package/pkg-meson.mk b/package/pkg-meson.mk
index f2efbae2eb72..350f597b7018 100644
--- a/package/pkg-meson.mk
+++ b/package/pkg-meson.mk
@@ -147,12 +147,12 @@ $(2)_CXXFLAGS ?= $$(TARGET_CXXFLAGS)
 #
 #
 define $(2)_CONFIGURE_CMDS
-	rm -rf $$($$(PKG)_SRCDIR)/buildroot-build
-	mkdir -p $$($$(PKG)_SRCDIR)/buildroot-build
+	rm -rf $$($$(PKG)_SRCSUBDIR)/buildroot-build
+	mkdir -p $$($$(PKG)_SRCSUBDIR)/buildroot-build
 	sed -e "/^\[binaries\]$$$$/s:$$$$:$$(foreach x,$$($(2)_MESON_EXTRA_BINARIES),\n$$(x)):" \
 	    -e "/^\[properties\]$$$$/s:$$$$:$$(foreach x,$$($(2)_MESON_EXTRA_PROPERTIES),\n$$(x)):" \
 	    $$(call PKG_MESON_CROSSCONFIG_SED,$(2)_CFLAGS,$(2)_CXXFLAGS,$(2)_LDFLAGS,$(2)_FCFLAGS) \
-	    > $$($$(PKG)_SRCDIR)/buildroot-build/cross-compilation.conf
+	    > $$($$(PKG)_SRCSUBDIR)/buildroot-build/cross-compilation.conf
 	PATH=$$(BR_PATH) \
 	CC_FOR_BUILD="$$(HOSTCC)" \
 	CXX_FOR_BUILD="$$(HOSTCXX)" \
@@ -162,21 +162,21 @@ define $(2)_CONFIGURE_CMDS
 		--libdir=lib \
 		--default-library=$(PKG_MESON_DEFAULT_LIBRARY) \
 		--buildtype=$(if $(BR2_ENABLE_RUNTIME_DEBUG),debug,release) \
-		--cross-file=$$($$(PKG)_SRCDIR)/buildroot-build/cross-compilation.conf \
+		--cross-file=$$($$(PKG)_SRCSUBDIR)/buildroot-build/cross-compilation.conf \
 		-Db_pie=false \
 		-Db_staticpic=$(if $(BR2_m68k_cf),false,true) \
 		-Dstrip=false \
 		-Dbuild.pkg_config_path=$$(HOST_DIR)/lib/pkgconfig \
 		-Dbuild.cmake_prefix_path=$$(HOST_DIR)/lib/cmake \
 		$$($$(PKG)_CONF_OPTS) \
-		$$($$(PKG)_SRCDIR) $$($$(PKG)_SRCDIR)/buildroot-build
+		$$($$(PKG)_SRCSUBDIR) $$($$(PKG)_SRCSUBDIR)/buildroot-build
 endef
 else
 
 # Configure package for host
 define $(2)_CONFIGURE_CMDS
-	rm -rf $$($$(PKG)_SRCDIR)/buildroot-build
-	mkdir -p $$($$(PKG)_SRCDIR)/buildroot-build
+	rm -rf $$($$(PKG)_SRCSUBDIR)/buildroot-build
+	mkdir -p $$($$(PKG)_SRCSUBDIR)/buildroot-build
 	$$(HOST_CONFIGURE_OPTS) \
 	$$($$(PKG)_CONF_ENV) $$(MESON) setup \
 		--prefix=$$(HOST_DIR) \
@@ -188,7 +188,7 @@ define $(2)_CONFIGURE_CMDS
 		--wrap-mode=nodownload \
 		-Dstrip=true \
 		$$($$(PKG)_CONF_OPTS) \
-		$$($$(PKG)_SRCDIR) $$($$(PKG)_SRCDIR)/buildroot-build
+		$$($$(PKG)_SRCSUBDIR) $$($$(PKG)_SRCSUBDIR)/buildroot-build
 endef
 endif
 endif
@@ -203,12 +203,12 @@ ifndef $(2)_BUILD_CMDS
 ifeq ($(4),target)
 define $(2)_BUILD_CMDS
 	$$(TARGET_MAKE_ENV) $$($$(PKG)_NINJA_ENV) \
-		$$(NINJA) $$(NINJA_OPTS) $$($$(PKG)_NINJA_OPTS) -C $$($$(PKG)_SRCDIR)/buildroot-build
+		$$(NINJA) $$(NINJA_OPTS) $$($$(PKG)_NINJA_OPTS) -C $$($$(PKG)_SRCSUBDIR)/buildroot-build
 endef
 else
 define $(2)_BUILD_CMDS
 	$$(HOST_MAKE_ENV) $$($$(PKG)_NINJA_ENV) \
-		$$(NINJA) $$(NINJA_OPTS) $$($$(PKG)_NINJA_OPTS) -C $$($$(PKG)_SRCDIR)/buildroot-build
+		$$(NINJA) $$(NINJA_OPTS) $$($$(PKG)_NINJA_OPTS) -C $$($$(PKG)_SRCSUBDIR)/buildroot-build
 endef
 endif
 endif
@@ -220,7 +220,7 @@ endif
 ifndef $(2)_INSTALL_CMDS
 define $(2)_INSTALL_CMDS
 	$$(HOST_MAKE_ENV) $$($$(PKG)_NINJA_ENV) \
-		$$(NINJA) $$(NINJA_OPTS) -C $$($$(PKG)_SRCDIR)/buildroot-build install
+		$$(NINJA) $$(NINJA_OPTS) -C $$($$(PKG)_SRCSUBDIR)/buildroot-build install
 endef
 endif
 
@@ -231,7 +231,7 @@ endif
 ifndef $(2)_INSTALL_STAGING_CMDS
 define $(2)_INSTALL_STAGING_CMDS
 	$$(TARGET_MAKE_ENV) $$($$(PKG)_NINJA_ENV) DESTDIR=$$(STAGING_DIR) \
-		$$(NINJA) $$(NINJA_OPTS) -C $$($$(PKG)_SRCDIR)/buildroot-build install
+		$$(NINJA) $$(NINJA_OPTS) -C $$($$(PKG)_SRCSUBDIR)/buildroot-build install
 endef
 endif
 
@@ -242,7 +242,7 @@ endif
 ifndef $(2)_INSTALL_TARGET_CMDS
 define $(2)_INSTALL_TARGET_CMDS
 	$$(TARGET_MAKE_ENV) $$($$(PKG)_NINJA_ENV) DESTDIR=$$(TARGET_DIR) \
-		$$(NINJA) $$(NINJA_OPTS) -C $$($$(PKG)_SRCDIR)/buildroot-build install
+		$$(NINJA) $$(NINJA_OPTS) -C $$($$(PKG)_SRCSUBDIR)/buildroot-build install
 endef
 endif
 
diff --git a/package/pkg-perl.mk b/package/pkg-perl.mk
index 1ecf31eff9ca..1fbfb00e3796 100644
--- a/package/pkg-perl.mk
+++ b/package/pkg-perl.mk
@@ -67,7 +67,7 @@ ifeq ($(4),target)
 
 # Configure package for target
 define $(2)_CONFIGURE_CMDS
-	cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \
+	cd $$($$(PKG)_SRCSUBDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \
 		$$($(2)_CONF_ENV) \
 		PERL_MM_USE_DEFAULT=1 \
 		$$(PERL_RUN) Build.PL \
@@ -118,7 +118,7 @@ else
 
 # Configure package for host
 define $(2)_CONFIGURE_CMDS
-	cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \
+	cd $$($$(PKG)_SRCSUBDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \
 		$$($(2)_CONF_ENV) \
 		PERL_MM_USE_DEFAULT=1 \
 		$$(PERL_RUN) Build.PL \
@@ -144,7 +144,7 @@ ifeq ($(4),target)
 
 # Build package for target
 define $(2)_BUILD_CMDS
-	cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \
+	cd $$($$(PKG)_SRCSUBDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \
 		$$(PERL_RUN) Build $$($(2)_BUILD_OPTS) build; \
 	else \
 		$$(MAKE1) \
@@ -156,7 +156,7 @@ else
 
 # Build package for host
 define $(2)_BUILD_CMDS
-	cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \
+	cd $$($$(PKG)_SRCSUBDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \
 		$$(PERL_RUN) Build $$($(2)_BUILD_OPTS) build; \
 	else \
 		$$(MAKE1) $$($(2)_BUILD_OPTS) pure_all; \
@@ -171,7 +171,7 @@ endif
 #
 ifndef $(2)_INSTALL_CMDS
 define $(2)_INSTALL_CMDS
-	cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \
+	cd $$($$(PKG)_SRCSUBDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \
 		$$(PERL_RUN) Build $$($(2)_INSTALL_TARGET_OPTS) install; \
 	else \
 		$$(MAKE1) $$($(2)_INSTALL_TARGET_OPTS) pure_install; \
@@ -185,7 +185,7 @@ endif
 #
 ifndef $(2)_INSTALL_TARGET_CMDS
 define $(2)_INSTALL_TARGET_CMDS
-	cd $$($$(PKG)_SRCDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \
+	cd $$($$(PKG)_SRCSUBDIR) && if [ -f Build.PL ] && [ $$($(2)_PREFER_INSTALLER) != "EUMM" ] ; then \
 		$$(PERL_RUN) Build $$($(2)_INSTALL_TARGET_OPTS) install; \
 	else \
 		$$(MAKE1) $$($(2)_INSTALL_TARGET_OPTS) pure_install; \
diff --git a/package/pkg-waf.mk b/package/pkg-waf.mk
index 0529bb6ddaf2..c41d7314a132 100644
--- a/package/pkg-waf.mk
+++ b/package/pkg-waf.mk
@@ -65,7 +65,7 @@ endif
 #
 ifndef $(2)_CONFIGURE_CMDS
 define $(2)_CONFIGURE_CMDS
-	cd $$($$(PKG)_SRCDIR) && \
+	cd $$($$(PKG)_SRCSUBDIR) && \
 	$$(TARGET_CONFIGURE_OPTS) \
 	$$($(2)_CONF_ENV) \
 	$$(HOST_DIR)/bin/python3 $$($(2)_WAF) configure \
@@ -82,7 +82,7 @@ endif
 #
 ifndef $(2)_BUILD_CMDS
 define $(2)_BUILD_CMDS
-	cd $$($$(PKG)_SRCDIR) && \
+	cd $$($$(PKG)_SRCSUBDIR) && \
 	$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$(HOST_DIR)/bin/python3 $$($(2)_WAF) \
 		build $$(WAF_OPTS) $$($(2)_BUILD_OPTS) \
 		$$($(2)_WAF_OPTS)
@@ -95,7 +95,7 @@ endif
 #
 ifndef $(2)_INSTALL_STAGING_CMDS
 define $(2)_INSTALL_STAGING_CMDS
-	cd $$($$(PKG)_SRCDIR) && \
+	cd $$($$(PKG)_SRCSUBDIR) && \
 	$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$(HOST_DIR)/bin/python3 $$($(2)_WAF) \
 		install --destdir=$$(STAGING_DIR) \
 		$$($(2)_INSTALL_STAGING_OPTS) \
@@ -109,7 +109,7 @@ endif
 #
 ifndef $(2)_INSTALL_TARGET_CMDS
 define $(2)_INSTALL_TARGET_CMDS
-	cd $$($$(PKG)_SRCDIR) && \
+	cd $$($$(PKG)_SRCSUBDIR) && \
 	$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$(HOST_DIR)/bin/python3 $$($(2)_WAF) \
 		install --destdir=$$(TARGET_DIR) \
 		$$($(2)_INSTALL_TARGET_OPTS) \
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 09/23] linux: build out of tree when LINUX_OVERRIDE_SRCDIR is set
  2026-10-23 21:51 ` Florian Fainelli via buildroot
  2026-10-23 21:51   ` [Buildroot] [PATCH 08/23] package: use <pkg>_SRCSUBDIR where <pkg>_SRCDIR used to include _SUBDIR Florian Fainelli via buildroot
@ 2026-10-23 21:51   ` Florian Fainelli via buildroot
  2026-10-23 21:51   ` [Buildroot] [PATCH 10/23] packages: sync host and target patch hooks Florian Fainelli via buildroot
                     ` (13 subsequent siblings)
  15 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:51 UTC (permalink / raw)
  To: buildroot
  Cc: Eric Le Bihan, Gary Bisson, Jérôme Pouiller,
	Florian Fainelli, Bernd Kuhls, Thomas Perale, Maxime Chevallier,
	Refik Tuzakli, Francois Perrad, Thomas Petazzoni,
	Arnout Vandecappelle, Petr Vorel, Spenser Gilliland,
	Giulio Benetti, Pascal de Bruijn, Luca Ceresoli, Romain Naour,
	Mahyar Koshkouei

Introduce <pkg>_SUPPORTS_OUT_OF_TREE. For a package that sets it and
has <pkg>_OVERRIDE_SRCDIR defined:

 - <pkg>_SRCDIR is the overridden directory, used in place: nothing is
   rsynced into $(BUILD_DIR), only the pre/post rsync hooks still run;
 - the source-related stamp files (rsynced, patched, ...) live in the
   build directory so that nothing is created in the user's tree;
 - kconfig packages start from the source directory with O=<builddir>,
   which makes kbuild generate its wrapper Makefile in the build
   directory, so that all the existing -C $(LINUX_DIR) invocations keep
   working unmodified.

Enable it for the Linux kernel. The source tree must be clean (no
in-tree .config, include/config, arch/*/include/generated).

Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 linux/linux.mk         |  4 ++++
 package/pkg-generic.mk | 30 ++++++++++++++++++++++--------
 package/pkg-kconfig.mk |  6 +++++-
 3 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/linux/linux.mk b/linux/linux.mk
index a90e09afe906..ffec32154222 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -6,6 +6,10 @@
 
 LINUX_VERSION = $(call qstrip,$(BR2_LINUX_KERNEL_VERSION))
 LINUX_LICENSE = GPL-2.0
+
+# When LINUX_OVERRIDE_SRCDIR is set, build out of tree: no rsync of the
+# sources, the kernel is built in $(BUILD_DIR)/linux-custom with O=.
+LINUX_SUPPORTS_OUT_OF_TREE = YES
 LINUX_LICENSE_FILES = $(call qstrip,$(BR2_LINUX_KERNEL_LICENSE_FILES))
 
 LINUX_CPE_ID_VENDOR = linux
diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index 138fe9ccef4f..c8f532e1c3e6 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -221,11 +221,11 @@ $(SRC_DIR)/%/.stamp_extracted:
 # used.
 $(SRC_DIR)/%/.stamp_rsynced:
 	@$(call step_start,rsync)
-	@$(call MESSAGE,"Syncing from source dir $(SRCDIR)")
+	@$(call MESSAGE,"$(if $($(PKG)_OUT_OF_TREE),Using out-of-tree source dir,Syncing from source dir) $(SRCDIR)")
 	@mkdir -p $(@D)
 	$(foreach hook,$($(PKG)_PRE_RSYNC_HOOKS),$(call $(hook))$(sep))
 	@test -d $(SRCDIR) || (echo "ERROR: $(SRCDIR) does not exist" ; exit 1)
-	rsync -au --chmod=u=rwX,go=rX $($(PKG)_OVERRIDE_SRCDIR_RSYNC_EXCLUSIONS) $(RSYNC_VCS_EXCLUSIONS) $(call qstrip,$(SRCDIR))/ $(@D)
+	$(if $($(PKG)_OUT_OF_TREE),,rsync -au --chmod=u=rwX,go=rX $($(PKG)_OVERRIDE_SRCDIR_RSYNC_EXCLUSIONS) $(RSYNC_VCS_EXCLUSIONS) $(call qstrip,$(SRCDIR))/ $(@D))
 	$(foreach hook,$($(PKG)_POST_RSYNC_HOOKS),$(call $(hook))$(sep))
 	@$(call step_end,rsync)
 	$(Q)touch $@
@@ -559,13 +559,27 @@ ifndef $(2)_STRIP_COMPONENTS
 endif
 
 $(2)_SRCDIR = $$($(2)_DIR)
-$(2)_BUILDDIR = $$($(2)_DIR)
+$(2)_BUILDDIR ?= $$($(2)_DIR)
 $(2)_SRCSUBDIR = $$($(2)_SRCDIR)/$$($(2)_SUBDIR)
 
 ifneq ($$($(2)_OVERRIDE_SRCDIR),)
 $(2)_VERSION = custom
 endif
 
+# Packages that set <pkg>_SUPPORTS_OUT_OF_TREE = YES can be built out of
+# tree when their source directory is overridden: the sources are used
+# where they are (no rsync), and only the build directory lives in
+# $(BUILD_DIR). The source-related stamp files must then not be created
+# in the (user-owned) source directory, so they live in the build directory.
+$(2)_STAMP_SRCDIR = $$($(2)_SRCDIR)
+ifneq ($$($(2)_OVERRIDE_SRCDIR),)
+ifeq ($$($(3)_SUPPORTS_OUT_OF_TREE),YES)
+$(2)_OUT_OF_TREE = YES
+$(2)_SRCDIR = $$(abspath $$(call qstrip,$$($(2)_OVERRIDE_SRCDIR)))
+$(2)_STAMP_SRCDIR = $$($(2)_BUILDDIR)
+endif
+endif
+
 ifndef $(2)_SOURCE
  ifdef $(3)_SOURCE
   $(2)_SOURCE = $$($(3)_SOURCE)
@@ -844,11 +858,11 @@ $(2)_TARGET_INSTALL_IMAGES =	$$($(2)_BUILDDIR)/.stamp_images_installed
 $(2)_TARGET_INSTALL_HOST =	$$($(2)_BUILDDIR)/.stamp_host_installed
 $(2)_TARGET_BUILD =		$$($(2)_BUILDDIR)/.stamp_built
 $(2)_TARGET_CONFIGURE =		$$($(2)_BUILDDIR)/.stamp_configured
-$(2)_TARGET_RSYNC =		$$($(2)_SRCDIR)/.stamp_rsynced
-$(2)_TARGET_PATCH =		$$($(2)_SRCDIR)/.stamp_patched
-$(2)_TARGET_EXTRACT =		$$($(2)_SRCDIR)/.stamp_extracted
-$(2)_TARGET_SOURCE =		$$($(2)_SRCDIR)/.stamp_downloaded
-$(2)_TARGET_ACTUAL_SOURCE =	$$($(2)_SRCDIR)/.stamp_actual_downloaded
+$(2)_TARGET_RSYNC =		$$($(2)_STAMP_SRCDIR)/.stamp_rsynced
+$(2)_TARGET_PATCH =		$$($(2)_STAMP_SRCDIR)/.stamp_patched
+$(2)_TARGET_EXTRACT =		$$($(2)_STAMP_SRCDIR)/.stamp_extracted
+$(2)_TARGET_SOURCE =		$$($(2)_STAMP_SRCDIR)/.stamp_downloaded
+$(2)_TARGET_ACTUAL_SOURCE =	$$($(2)_STAMP_SRCDIR)/.stamp_actual_downloaded
 $(2)_TARGET_DIRCLEAN =		$$($(2)_BUILDDIR)/.stamp_dircleaned
 
 # default extract command
diff --git a/package/pkg-kconfig.mk b/package/pkg-kconfig.mk
index 8a63d55be033..5e46c62c58e6 100644
--- a/package/pkg-kconfig.mk
+++ b/package/pkg-kconfig.mk
@@ -147,8 +147,12 @@ $$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES): | $(1)-patch
 		fi; \
 	done
 
+# For an out-of-tree build, the first kconfig run is what creates the
+# wrapper Makefile in the build directory, so it must be started from
+# the source directory.
 $(2)_KCONFIG_MAKE = \
-	$$($(2)_MAKE_ENV) $$($(2)_MAKE) -C $$($(2)_BUILDDIR) \
+	$$($(2)_MAKE_ENV) $$($(2)_MAKE) \
+	$$(if $$($(2)_OUT_OF_TREE),-C $$($(2)_SRCDIR) O=$$($(2)_BUILDDIR),-C $$($(2)_BUILDDIR)) \
 		$$(PKG_KCONFIG_COMMON_OPTS) $$($(2)_KCONFIG_OPTS)
 
 # The specified source configuration file and any additional configuration file
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 10/23] packages: sync host and target patch hooks
  2026-10-23 21:51 ` Florian Fainelli via buildroot
  2026-10-23 21:51   ` [Buildroot] [PATCH 08/23] package: use <pkg>_SRCSUBDIR where <pkg>_SRCDIR used to include _SUBDIR Florian Fainelli via buildroot
  2026-10-23 21:51   ` [Buildroot] [PATCH 09/23] linux: build out of tree when LINUX_OVERRIDE_SRCDIR is set Florian Fainelli via buildroot
@ 2026-10-23 21:51   ` Florian Fainelli via buildroot
  2026-10-23 21:51   ` [Buildroot] [PATCH 11/23] omniorb: avoid target-only patch hook Florian Fainelli via buildroot
                     ` (12 subsequent siblings)
  15 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:51 UTC (permalink / raw)
  To: buildroot
  Cc: Thomas Petazzoni, Eric Le Bihan, Jérôme Pouiller,
	Florian Fainelli, Gary Bisson, Romain Naour, Bernd Kuhls,
	Thomas Perale, Maxime Chevallier, Refik Tuzakli, Francois Perrad,
	Thomas Petazzoni, Arnout Vandecappelle, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Yann E. MORIN, Mahyar Koshkouei

From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

In preparation for the introduction of out-of-tree package build, it
is important that we don't do different things in the patch hooks for
the target and host variant of a given package, because the source
tree will be shared between the target and host builds.

For the gawk, icu, python and python3 packages touched by this patch,
there is no problem in running the target-only post-patch hook that
already exists to the host variant, so we simply do that.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
(cherry picked from commit 7d6a8f1ace39bbc96a1deab5c5c41d6c16ebf36a)
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 package/icu/icu.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/package/icu/icu.mk b/package/icu/icu.mk
index 9b97011f5587..d17b610aeea4 100644
--- a/package/icu/icu.mk
+++ b/package/icu/icu.mk
@@ -67,6 +67,7 @@ define ICU_COPY_CUSTOM_DATA
 	cp $(ICU_CUSTOM_DATA_PATH) $(@D)/source/data/in/
 endef
 ICU_POST_PATCH_HOOKS += ICU_COPY_CUSTOM_DATA
+HOST_ICU_POST_PATCH_HOOKS += ICU_COPY_CUSTOM_DATA
 endif
 
 define ICU_REMOVE_DEV_FILES
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 11/23] omniorb: avoid target-only patch hook
  2026-10-23 21:51 ` Florian Fainelli via buildroot
                     ` (2 preceding siblings ...)
  2026-10-23 21:51   ` [Buildroot] [PATCH 10/23] packages: sync host and target patch hooks Florian Fainelli via buildroot
@ 2026-10-23 21:51   ` Florian Fainelli via buildroot
  2026-10-23 21:51   ` [Buildroot] [PATCH 12/23] lua: rework post-patch hook usage Florian Fainelli via buildroot
                     ` (11 subsequent siblings)
  15 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:51 UTC (permalink / raw)
  To: buildroot
  Cc: Gary Bisson, Thomas Petazzoni, Petr Vorel, Spenser Gilliland,
	Florian Fainelli, Maxime Chevallier, Francois Perrad,
	Arnout Vandecappelle, Luca Ceresoli, Thomas Perale, Eric Le Bihan,
	Mahyar Koshkouei, Yann E. MORIN, Matt Weber, Giulio Benetti,
	Pascal de Bruijn, Thomas Petazzoni, Jérôme Pouiller,
	Bernd Kuhls, Refik Tuzakli, Romain Naour

From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

In preparation for the introduction of out-of-tree package build, it
is important that we don't do different things in the patch hooks for
the target and host variant of a given package, because the source
tree will be shared between the target and host builds.

The omniorb package was doing exactly this: when
BR2_PACKAGE_OMNIORB_WITH_APPS was enabled, it was patching the source
code, but only for the target package.

We replace this solution by adding a patch to OmniORB, which allows to
conditionally enable or disabled the compilation of the apps and
services, which is then used by BR2_PACKAGE_OMNIORB_WITH_APPS in a
post configure hook.

Cc: Matt Weber <mlweber1@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
[yann.morin.1998@free.fr: renumber patch]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
(cherry picked from commit c5fe01e3c525babdc6ad1939fb3f98eae91f7c9f)
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 .../omniorb/0002-optional-appl-services.patch | 29 +++++++++++++++++++
 package/omniorb/omniorb.mk                    | 26 ++++++++---------
 2 files changed, 42 insertions(+), 13 deletions(-)
 create mode 100644 package/omniorb/0002-optional-appl-services.patch

diff --git a/package/omniorb/0002-optional-appl-services.patch b/package/omniorb/0002-optional-appl-services.patch
new file mode 100644
index 000000000000..9e3177465e27
--- /dev/null
+++ b/package/omniorb/0002-optional-appl-services.patch
@@ -0,0 +1,29 @@
+Add support for EmbeddedSystemWithApps
+
+The EmbeddedSystem option allows to disable building a lot of things
+from omniorb: tools, apps, services, python bindings, and more.
+
+However, there are situations where we want to disable all of these
+things, except apps and services. Therefore, as a quick workaround,
+this patch adds support for a EmbeddedSystemWithApps, which when
+defined, will build apps and services even if EmbeddedSystem is
+defined.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+Upstream: N/A (Buildroot specific)
+
+Index: b/src/dir.mk
+===================================================================
+--- a/src/dir.mk
++++ b/src/dir.mk
+@@ -16,6 +16,10 @@
+ SUBDIRS += appl services
+ endif
+ 
++ifdef EmbeddedSystemWithApps
++SUBDIRS += appl services
++endif
++
+ all::
+ 	@echo
+ 	@echo 'No "all" rule here.  If you want to build and export everything'
diff --git a/package/omniorb/omniorb.mk b/package/omniorb/omniorb.mk
index b61c7c3537bc..866d8d76b085 100644
--- a/package/omniorb/omniorb.mk
+++ b/package/omniorb/omniorb.mk
@@ -34,19 +34,6 @@ ifeq ($(BR2_PACKAGE_ZLIB),y)
 OMNIORB_DEPENDENCIES += zlib
 endif
 
-# The EmbeddedSystem define (set below in OMNIORB_ADJUST_TOOLDIR)
-# enables building of just the lib and disables building of
-# tools/apps/services.  In some cases the apps/services are still
-# required.  The tools however are host related and should never
-# be required on target.
-define OMNIORB_ENABLE_EXTRA_APPS
-	$(SED) 's:SUBDIRS += lib:SUBDIRS += lib appl services:g' $(@D)/src/dir.mk
-endef
-
-ifeq ($(BR2_PACKAGE_OMNIORB_WITH_APPS),y)
-OMNIORB_POST_PATCH_HOOKS += OMNIORB_ENABLE_EXTRA_APPS
-endif
-
 ifeq ($(BR2_STATIC_LIBS),y)
 define OMNIORB_DISABLE_SHARED
 	echo "BuildSharedLibrary =" >> $(@D)/mk/beforeauto.mk
@@ -67,5 +54,18 @@ define OMNIORB_ADJUST_TOOLDIR
 endef
 OMNIORB_POST_CONFIGURE_HOOKS += OMNIORB_ADJUST_TOOLDIR
 
+ifeq ($(BR2_PACKAGE_OMNIORB_WITH_APPS),y)
+# The EmbeddedSystem define (set above in OMNIORB_ADJUST_TOOLDIR)
+# enables building of just the lib and disables building of
+# tools/apps/services.  In some cases the apps/services are still
+# required.  The tools however are host related and should never
+# be required on target.
+define OMNIORB_ENABLE_EXTRA_APPS
+	echo "EmbeddedSystemWithApps=1" >> $(@D)/mk/beforeauto.mk
+endef
+
+OMNIORB_POST_CONFIGURE_HOOKS += OMNIORB_ENABLE_EXTRA_APPS
+endif
+
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 12/23] lua: rework post-patch hook usage
  2026-10-23 21:51 ` Florian Fainelli via buildroot
                     ` (3 preceding siblings ...)
  2026-10-23 21:51   ` [Buildroot] [PATCH 11/23] omniorb: avoid target-only patch hook Florian Fainelli via buildroot
@ 2026-10-23 21:51   ` Florian Fainelli via buildroot
  2026-10-24 10:46     ` François PERRAD
  2026-10-23 21:51   ` [Buildroot] [PATCH 13/23] infra: host packages inherit the target extra downloads Florian Fainelli via buildroot
                     ` (10 subsequent siblings)
  15 siblings, 1 reply; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:51 UTC (permalink / raw)
  To: buildroot
  Cc: Gary Bisson, Thomas Petazzoni, Petr Vorel, Spenser Gilliland,
	Francois Perrad, Florian Fainelli, Maxime Chevallier,
	Francois Perrad, Arnout Vandecappelle, Luca Ceresoli,
	Thomas Perale, Eric Le Bihan, Mahyar Koshkouei, Yann E. MORIN,
	Romain Naour, Pascal de Bruijn, Thomas Petazzoni,
	Jérôme Pouiller, Bernd Kuhls, Refik Tuzakli,
	Giulio Benetti

From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

WIP: YEM: try to see if we can make that a post-configure hook

In preparation for the introduction of out-of-tree package build, it
is important that we don't do different things in the patch hooks for
the target and host variant of a given package, because the source
tree will be shared between the target and host builds.

For lua, the post patch hook was modifying luaconf.h before the build
to get a 32 bits Lua build. However, passing just -DLUA_32BITS like we
do for other Lua compile time options is not sufficient since
LUA_32BITS should also be defined in the installed luaconf.h so that
other packages linking against lua get this defined as well. So, this
patch changes the post-patch hook to passing -DLUA_32BITS in
LUA_CFLAGS *and* changing the installed luaconf.h in a
post-install-staging hook.

Cc: Francois Perrad <fperrad@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
(cherry picked from commit 827ed461ba2b00acfebcbd01e53d93a148594833)
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 package/lua/lua.mk | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/package/lua/lua.mk b/package/lua/lua.mk
index 6dbdc950021b..92910f8fe746 100644
--- a/package/lua/lua.mk
+++ b/package/lua/lua.mk
@@ -66,11 +66,16 @@ endif
 endif
 
 ifeq ($(BR2_PACKAGE_LUA_32BITS),y)
+# We adjust the CFLAGS for the build of Lua itself, and then the
+# installed luaconf.h so that package using Lua also see LUA_32BITS
+# defined.
+LUA_CFLAGS += -DLUA_32BITS
 define LUA_32BITS_LUACONF
-	$(SED) 's/\/\* #define LUA_32BITS \*\//#define LUA_32BITS/' $(@D)/src/luaconf.h
+	$(SED) 's/\/\* #define LUA_32BITS \*\//#define LUA_32BITS/' \
+		$(STAGING_DIR)/usr/include/luaconf.h
 endef
 
-LUA_POST_PATCH_HOOKS += LUA_32BITS_LUACONF
+LUA_POST_INSTALL_STAGING_HOOKS += LUA_32BITS_LUACONF
 endif
 
 define HOST_LUA_LUACONF
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 13/23] infra: host packages inherit the target extra downloads
  2026-10-23 21:51 ` Florian Fainelli via buildroot
                     ` (4 preceding siblings ...)
  2026-10-23 21:51   ` [Buildroot] [PATCH 12/23] lua: rework post-patch hook usage Florian Fainelli via buildroot
@ 2026-10-23 21:51   ` Florian Fainelli via buildroot
  2026-10-23 21:51   ` [Buildroot] [PATCH 14/23] package/libtool: use post-patch hooks Florian Fainelli via buildroot
                     ` (9 subsequent siblings)
  15 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:51 UTC (permalink / raw)
  To: buildroot
  Cc: Thomas Petazzoni, Eric Le Bihan, Jérôme Pouiller,
	Florian Fainelli, Gary Bisson, Romain Naour, Bernd Kuhls,
	Thomas Perale, Maxime Chevallier, Refik Tuzakli, Francois Perrad,
	Thomas Petazzoni, Arnout Vandecappelle, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Yann E. MORIN, Mahyar Koshkouei

From: "Yann E. MORIN" <yann.morin.1998@free.fr>

Some packages need extra downloads, which are then extracted in their
source trees. Up until now, this was only used by target packages.

For example, perl will need perl-cross.

But with the upcoming merge of the host and target soruce trees, we
will also need those extra downloads for the host variants.

Update the three packages that already duplicated the host extra
downloads from the target ones.

There are three packages left that define host extra downloads, but
those packages  do not have a target variant, so we can leave them
as-is.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
(cherry picked from commit 01540f0ee0cf07f77ef0dbf99d3d74f95b17f121)
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 package/android-tools/android-tools.mk | 1 -
 package/binutils/binutils.mk           | 1 -
 package/gdb/gdb.mk                     | 1 -
 package/pkg-generic.mk                 | 6 ++++++
 4 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/package/android-tools/android-tools.mk b/package/android-tools/android-tools.mk
index 20e26839f977..e30fce8ab7e3 100644
--- a/package/android-tools/android-tools.mk
+++ b/package/android-tools/android-tools.mk
@@ -8,7 +8,6 @@ ANDROID_TOOLS_SITE = https://launchpad.net/ubuntu/+archive/primary/+files
 ANDROID_TOOLS_VERSION = 4.2.2+git20130218
 ANDROID_TOOLS_SOURCE = android-tools_$(ANDROID_TOOLS_VERSION).orig.tar.xz
 ANDROID_TOOLS_EXTRA_DOWNLOADS = android-tools_$(ANDROID_TOOLS_VERSION)-3ubuntu41.debian.tar.gz
-HOST_ANDROID_TOOLS_EXTRA_DOWNLOADS = $(ANDROID_TOOLS_EXTRA_DOWNLOADS)
 ANDROID_TOOLS_LICENSE = Apache-2.0
 ANDROID_TOOLS_LICENSE_FILES = debian/copyright
 ANDROID_TOOLS_DEPENDENCIES = host-pkgconf
diff --git a/package/binutils/binutils.mk b/package/binutils/binutils.mk
index c6a6380be99e..4b376f393bbd 100644
--- a/package/binutils/binutils.mk
+++ b/package/binutils/binutils.mk
@@ -137,7 +137,6 @@ endef
 BINUTILS_POST_EXTRACT_HOOKS += BINUTILS_XTENSA_OVERLAY_EXTRACT
 BINUTILS_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL)
 HOST_BINUTILS_POST_EXTRACT_HOOKS += BINUTILS_XTENSA_OVERLAY_EXTRACT
-HOST_BINUTILS_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL)
 endif
 
 # Hardlinks between binaries in different directories cause a problem
diff --git a/package/gdb/gdb.mk b/package/gdb/gdb.mk
index cfec0585da9d..f33cc2ed7c57 100644
--- a/package/gdb/gdb.mk
+++ b/package/gdb/gdb.mk
@@ -39,7 +39,6 @@ endef
 GDB_POST_EXTRACT_HOOKS += GDB_XTENSA_OVERLAY_EXTRACT
 GDB_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL)
 HOST_GDB_POST_EXTRACT_HOOKS += GDB_XTENSA_OVERLAY_EXTRACT
-HOST_GDB_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL)
 endif
 
 ifeq ($(GDB_FROM_GIT),y)
diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index c8f532e1c3e6..066396332099 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -602,6 +602,12 @@ ifndef $(2)_PATCH
  endif
 endif
 
+ifndef $(2)_EXTRA_DOWNLOADS
+ ifdef $(3)_EXTRA_DOWNLOADS
+  $(2)_EXTRA_DOWNLOADS = $$($(3)_EXTRA_DOWNLOADS)
+ endif
+endif
+
 $(2)_MAIN_DOWNLOAD = \
 	$$(if $$($(2)_SOURCE),$$($(2)_SITE_METHOD)+$$($(2)_SITE)/$$($(2)_SOURCE))
 
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 14/23] package/libtool: use post-patch hooks
  2026-10-23 21:51 ` Florian Fainelli via buildroot
                     ` (5 preceding siblings ...)
  2026-10-23 21:51   ` [Buildroot] [PATCH 13/23] infra: host packages inherit the target extra downloads Florian Fainelli via buildroot
@ 2026-10-23 21:51   ` Florian Fainelli via buildroot
  2026-10-23 21:51   ` [Buildroot] [PATCH 15/23] package/libtool: also apply libtool-patch to host libtool Florian Fainelli via buildroot
                     ` (8 subsequent siblings)
  15 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:51 UTC (permalink / raw)
  To: buildroot
  Cc: Thomas Petazzoni, Eric Le Bihan, Jérôme Pouiller,
	Florian Fainelli, Gary Bisson, Romain Naour, Bernd Kuhls,
	Thomas Perale, Maxime Chevallier, Refik Tuzakli, Francois Perrad,
	Thomas Petazzoni, Arnout Vandecappelle, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Yann E. MORIN, Mahyar Koshkouei

From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

Run the autoreconf-avoidance tweaks from a post-patch hook, rather than
a pre-configure one, both for the target and host variants.

This will ease migrating to a shared host/target source tree.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
[yann.morin.1998@free.fr: remove FIXME, actually do the migration]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>

---
The hooks are still not the same, because we do not yet apply the
libtool patch on the host variant. This will be handled in a followup
patch

(cherry picked from commit b49cb508257ff7f075b4409101d98a589eb8d446)
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 package/libtool/libtool.mk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/package/libtool/libtool.mk b/package/libtool/libtool.mk
index ecadc3e696f4..45441e1e4676 100644
--- a/package/libtool/libtool.mk
+++ b/package/libtool/libtool.mk
@@ -45,8 +45,8 @@ define LIBTOOL_AVOID_AUTORECONF_HOOK
 	find $(@D) -name configure -exec touch '{}' \;
 	find $(@D) -name Makefile.in -exec touch '{}' \;
 endef
-LIBTOOL_PRE_CONFIGURE_HOOKS += LIBTOOL_AVOID_AUTORECONF_HOOK
-HOST_LIBTOOL_PRE_CONFIGURE_HOOKS += LIBTOOL_AVOID_AUTORECONF_HOOK
+LIBTOOL_POST_PATCH_HOOKS += LIBTOOL_AVOID_AUTORECONF_HOOK
+HOST_LIBTOOL_POST_PATCH_HOOKS += LIBTOOL_AVOID_AUTORECONF_HOOK
 
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 15/23] package/libtool: also apply libtool-patch to host libtool
  2026-10-23 21:51 ` Florian Fainelli via buildroot
                     ` (6 preceding siblings ...)
  2026-10-23 21:51   ` [Buildroot] [PATCH 14/23] package/libtool: use post-patch hooks Florian Fainelli via buildroot
@ 2026-10-23 21:51   ` Florian Fainelli via buildroot
  2026-10-23 21:51   ` [Buildroot] [PATCH 16/23] package/{ffmpeg, libvpx}: use $(@D) instead of $(pkg_SRCDIR) when possible Florian Fainelli via buildroot
                     ` (7 subsequent siblings)
  15 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:51 UTC (permalink / raw)
  To: buildroot
  Cc: Thomas Petazzoni, Eric Le Bihan, Jérôme Pouiller,
	Florian Fainelli, Gary Bisson, Romain Naour, Bernd Kuhls,
	Thomas Perale, Maxime Chevallier, Refik Tuzakli, Francois Perrad,
	Thomas Petazzoni, Arnout Vandecappelle, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Yann E. MORIN, Mahyar Koshkouei

From: "Yann E. MORIN" <yann.morin.1998@free.fr>

Currently, we avoid applying our libtool patch to the host variant of
libtool. This is mostly historical.

However, this means that the host and target sources are not the same,
and this is an hindrance to out-of-tree build.

It turns out that we in fact can apply our hook. We just need to do like
for the target variant to avoid building the documentation.

However, that has a direct impact on the autotools package infra. When a
package is using libtool, and gets autoreconf-ed, the libtool-installed
ltmain.sh is copied to the package source tree. This lt-main.sh is what
our LIBTOOL_PATCH_HOOK hook would patch. But that lt-main.sh file is the
one that was already patched in, and installed by, the host-libtool
package.

So, we no longer need to apply the libtool patch to packages that get
autoreconf-ed, as they will automatically get the correct, patched
version now.

Note that for packages that we do not autoreconf, we still need to
use the libtool patch, as is currently done, to patch the lt-main.sh in
the package source

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
(cherry picked from commit 70fa1fb72eef8325263df640f7781710875f6ad3)
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 package/libtool/libtool.mk | 1 -
 package/pkg-autotools.mk   | 4 ----
 2 files changed, 5 deletions(-)

diff --git a/package/libtool/libtool.mk b/package/libtool/libtool.mk
index 45441e1e4676..98ca31d549a4 100644
--- a/package/libtool/libtool.mk
+++ b/package/libtool/libtool.mk
@@ -26,7 +26,6 @@ HOST_LIBTOOL_LICENSE = GPL-2.0+ (libtool), LGPL-2.1+ (libltdl)
 HOST_LIBTOOL_LICENSE_FILES = COPYING $(LIBTOOL_SUBDIR)/COPYING.LIB
 
 HOST_LIBTOOL_CONF_ENV = HELP2MAN=true MAKEINFO=true
-HOST_LIBTOOL_LIBTOOL_PATCH = NO
 
 # We have a patch that affects libtool.m4, which triggers an autoreconf
 # in the build step. Normally we would set AUTORECONF = YES, but this
diff --git a/package/pkg-autotools.mk b/package/pkg-autotools.mk
index 58b63317cb60..89894b9b6cfc 100644
--- a/package/pkg-autotools.mk
+++ b/package/pkg-autotools.mk
@@ -243,10 +243,6 @@ else
 $(2)_AUTORECONF_ENV += AUTOPOINT=/bin/true
 endif
 $(2)_PRE_CONFIGURE_HOOKS += AUTORECONF_HOOK
-# default values are not evaluated yet, so don't rely on this defaulting to YES
-ifneq ($$($(2)_LIBTOOL_PATCH),NO)
-$(2)_PRE_CONFIGURE_HOOKS += LIBTOOL_PATCH_HOOK
-endif
 $(2)_DEPENDENCIES += host-automake host-autoconf host-libtool
 
 else # ! AUTORECONF = YES
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 16/23] package/{ffmpeg, libvpx}: use $(@D) instead of $(pkg_SRCDIR) when possible
  2026-10-23 21:51 ` Florian Fainelli via buildroot
                     ` (7 preceding siblings ...)
  2026-10-23 21:51   ` [Buildroot] [PATCH 15/23] package/libtool: also apply libtool-patch to host libtool Florian Fainelli via buildroot
@ 2026-10-23 21:51   ` Florian Fainelli via buildroot
  2026-10-23 21:51   ` [Buildroot] [PATCH 17/23] package/perl: apply the perl-cross even for the host variant Florian Fainelli via buildroot
                     ` (6 subsequent siblings)
  15 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:51 UTC (permalink / raw)
  To: buildroot
  Cc: Thomas Petazzoni, Eric Le Bihan, Jérôme Pouiller,
	Florian Fainelli, Gary Bisson, Romain Naour, Bernd Kuhls,
	Thomas Perale, Maxime Chevallier, Refik Tuzakli, Francois Perrad,
	Thomas Petazzoni, Arnout Vandecappelle, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Yann E. MORIN, Mahyar Koshkouei

From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

$(@D) points to the package build directory, i.e
$(O)/build/<name>-<version>/. $(pkg_SRCDIR) is identical, except when
$(pkg_SUBDIR) is used, in which case $(pkg_SRCDIR) is
$(O)/build/<name>-<version>/$(pkg_SUBDIR).

When possible use $(@D), like we're doing in all packages. This will
facilitate future changes in the package infrastructure.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
(cherry picked from commit b1791fe7c10bc312328926b45108553dbc674254)
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 package/ffmpeg/ffmpeg.mk | 2 +-
 package/libvpx/libvpx.mk | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/package/ffmpeg/ffmpeg.mk b/package/ffmpeg/ffmpeg.mk
index 4ce129132d9e..a6815c15b6d1 100644
--- a/package/ffmpeg/ffmpeg.mk
+++ b/package/ffmpeg/ffmpeg.mk
@@ -604,7 +604,7 @@ FFMPEG_CONF_OPTS += $(call qstrip,$(BR2_PACKAGE_FFMPEG_EXTRACONF))
 
 # Override FFMPEG_CONFIGURE_CMDS: FFmpeg does not support --target and others
 define FFMPEG_CONFIGURE_CMDS
-	(cd $(FFMPEG_SRCDIR) && rm -rf config.cache && \
+	(cd $(@D) && rm -rf config.cache && \
 	$(TARGET_CONFIGURE_OPTS) \
 	$(TARGET_CONFIGURE_ARGS) \
 	$(FFMPEG_CONF_ENV) \
diff --git a/package/libvpx/libvpx.mk b/package/libvpx/libvpx.mk
index d6b84ffec37f..2523e7ca9931 100644
--- a/package/libvpx/libvpx.mk
+++ b/package/libvpx/libvpx.mk
@@ -30,7 +30,7 @@ endif
 
 # This is not a true autotools package.  It is based on the ffmpeg build system
 define LIBVPX_CONFIGURE_CMDS
-	(cd $(LIBVPX_SRCDIR) && rm -rf config.cache && \
+	(cd $(@D) && rm -rf config.cache && \
 	$(TARGET_CONFIGURE_OPTS) \
 	$(TARGET_CONFIGURE_ARGS) \
 	$(LIBVPX_CONF_ENV) \
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 17/23] package/perl: apply the perl-cross even for the host variant
  2026-10-23 21:51 ` Florian Fainelli via buildroot
                     ` (8 preceding siblings ...)
  2026-10-23 21:51   ` [Buildroot] [PATCH 16/23] package/{ffmpeg, libvpx}: use $(@D) instead of $(pkg_SRCDIR) when possible Florian Fainelli via buildroot
@ 2026-10-23 21:51   ` Florian Fainelli via buildroot
  2026-10-24 10:20     ` François PERRAD
  2026-10-23 21:51   ` [Buildroot] [PATCH 18/23] infra/autotools: warn for package that autoreconf without libtool patch Florian Fainelli via buildroot
                     ` (5 subsequent siblings)
  15 siblings, 1 reply; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:51 UTC (permalink / raw)
  To: buildroot
  Cc: Gary Bisson, Thomas Petazzoni, Petr Vorel, Spenser Gilliland,
	Florian Fainelli, Maxime Chevallier, Francois Perrad,
	Arnout Vandecappelle, Luca Ceresoli, Thomas Perale, Eric Le Bihan,
	Mahyar Koshkouei, Yann E. MORIN, Francois Perrad, Giulio Benetti,
	Pascal de Bruijn, Thomas Petazzoni, Jérôme Pouiller,
	Bernd Kuhls, Refik Tuzakli, Romain Naour

From: "Yann E. MORIN" <yann.morin.1998@free.fr>

Currently, ther host and target variants have diffeerent source tree,
because the target variant extracts perl-cross, while the host variant
does not.

This goes against having a single source tree for both, to ease
out-of-tree builds.

However, extracting the perl-cross archive has no impact of the standard
build; it only ever adds new files that are not used by the original,
native-only buildsystem.

So, we can extrat perl-cross for the host variant as well, by re-using
the same hook. We also need to apply the config.{sub,guess} hook.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Francois Perrad <francois.perrad@gadz.org>
cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
(cherry picked from commit d2ad97e0eeff39fc89a58b589f19094824402756)
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 package/perl/perl.mk | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/package/perl/perl.mk b/package/perl/perl.mk
index 43820cfcc33a..e5d8689776f4 100644
--- a/package/perl/perl.mk
+++ b/package/perl/perl.mk
@@ -31,6 +31,7 @@ define PERL_CROSS_EXTRACT
 	mv $(@D)/cnf/diffs/perl5-5.42.0 $(@D)/cnf/diffs/perl5-5.42.3
 endef
 PERL_POST_EXTRACT_HOOKS += PERL_CROSS_EXTRACT
+HOST_PERL_POST_EXTRACT_HOOKS += PERL_CROSS_EXTRACT
 
 # We need to patch perl-cross, but perl-cross is extracted over the
 # target perl sources only (and not the host variant). So we apply the
@@ -46,6 +47,7 @@ PERL_POST_PATCH_HOOKS += PERL_CROSS_PATCH
 # on newer host architectures, so we borrow the hook which updates them from the
 # autotools infrastructure.
 PERL_POST_PATCH_HOOKS += UPDATE_CONFIG_HOOK
+HOST_PERL_POST_PATCH_HOOKS += UPDATE_CONFIG_HOOK
 
 ifeq ($(BR2_PACKAGE_BERKELEYDB),y)
 PERL_DEPENDENCIES += berkeleydb
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 18/23] infra/autotools: warn for package that autoreconf without libtool patch
  2026-10-23 21:51 ` Florian Fainelli via buildroot
                     ` (9 preceding siblings ...)
  2026-10-23 21:51   ` [Buildroot] [PATCH 17/23] package/perl: apply the perl-cross even for the host variant Florian Fainelli via buildroot
@ 2026-10-23 21:51   ` Florian Fainelli via buildroot
  2026-10-23 21:51   ` [Buildroot] [PATCH 19/23] packages: replace $(PKG)_DIR with @D where possible Florian Fainelli via buildroot
                     ` (4 subsequent siblings)
  15 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:51 UTC (permalink / raw)
  To: buildroot
  Cc: Thomas Petazzoni, Eric Le Bihan, Jérôme Pouiller,
	Florian Fainelli, Gary Bisson, Romain Naour, Bernd Kuhls,
	Thomas Perale, Maxime Chevallier, Refik Tuzakli, Francois Perrad,
	Thomas Petazzoni, Arnout Vandecappelle, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Yann E. MORIN, Mahyar Koshkouei

From: "Yann E. MORIN" <yann.morin.1998@free.fr>

The libtool patch is now implicit because it gets installed for any
package that gets autoreconf-ed, so refusing the libtool patch in that
case is moot anyway.

Error out when this is the case.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
(cherry picked from commit 59aeba1caa1dba75962726904fe712aa6c3e9146)
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 package/pkg-autotools.mk | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/package/pkg-autotools.mk b/package/pkg-autotools.mk
index 89894b9b6cfc..8e1b1b6d40a4 100644
--- a/package/pkg-autotools.mk
+++ b/package/pkg-autotools.mk
@@ -120,6 +120,10 @@ endef
 
 define inner-autotools-package
 
+ifeq ($$($(2)_AUTORECONF)-$$($(2)_LIBTOOL_PATCH),YES-NO)
+$$(error $(1) must be autoreconf-ed, but refuses the libtool patch)
+endif
+
 ifndef $(2)_LIBTOOL_PATCH
  ifdef $(3)_LIBTOOL_PATCH
   $(2)_LIBTOOL_PATCH = $$($(3)_LIBTOOL_PATCH)
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 19/23] packages: replace $(PKG)_DIR with @D where possible
  2026-10-23 21:51 ` Florian Fainelli via buildroot
                     ` (10 preceding siblings ...)
  2026-10-23 21:51   ` [Buildroot] [PATCH 18/23] infra/autotools: warn for package that autoreconf without libtool patch Florian Fainelli via buildroot
@ 2026-10-23 21:51   ` Florian Fainelli via buildroot
  2026-10-23 21:51   ` [Buildroot] [PATCH 20/23] linux: support custom logo and devicetree files in out-of-tree builds Florian Fainelli via buildroot
                     ` (3 subsequent siblings)
  15 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:51 UTC (permalink / raw)
  To: buildroot
  Cc: Thomas Petazzoni, Eric Le Bihan, Jérôme Pouiller,
	Florian Fainelli, Gary Bisson, Romain Naour, Bernd Kuhls,
	Thomas Perale, Maxime Chevallier, Refik Tuzakli, Francois Perrad,
	Thomas Petazzoni, Arnout Vandecappelle, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Yann E. MORIN, Mahyar Koshkouei

From: "Yann E. MORIN" <yann.morin.1998@free.fr>

Currently, packages that use $(FOO_DIR) (with FOO as the package name)
expect it to be unspecifically either the source or build directory,
with some packages even expecting that it is both. Because it currently
is both.

But when we introduce out-of-tree build and shared host-target source
trees, FOO_DIR will no longer exist, because it can no longer be both.

So, In preparation of that, replace all occurences of $(FOO_DIR) with
@(@D) which is always the dorectory that is the destination of the
current rule.

Note that in some cases, $(@D) is used as the source of a copy or a sed,
and expected to be from the source directory. This will have to be
carefully identified when source and build dirs are separated.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
[yann.morin.1998@free.fr:
  - reabse on master, convert new packages, drop old ones
  - add a commit log
]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
(cherry picked from commit a7e38cf17ada495c3abc1f9bbb377c883a9b4c5a)
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 package/linux-backports/linux-backports.mk | 2 +-
 package/ncftp/ncftp.mk                     | 2 +-
 package/pciutils/pciutils.mk               | 2 +-
 package/php/php.mk                         | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/package/linux-backports/linux-backports.mk b/package/linux-backports/linux-backports.mk
index 8513a84487a8..e14cd4a1706b 100644
--- a/package/linux-backports/linux-backports.mk
+++ b/package/linux-backports/linux-backports.mk
@@ -33,7 +33,7 @@ LINUX_BACKPORTS_DEPENDENCIES = \
 	$(BR2_FLEX_HOST_DEPENDENCY)
 
 ifeq ($(BR2_PACKAGE_LINUX_BACKPORTS_USE_DEFCONFIG),y)
-LINUX_BACKPORTS_KCONFIG_FILE = $(LINUX_BACKPORTS_DIR)/defconfigs/$(call qstrip,$(BR2_PACKAGE_LINUX_BACKPORTS_DEFCONFIG))
+LINUX_BACKPORTS_KCONFIG_FILE = $(LINUX_BACKPORTS_SRCDIR)/defconfigs/$(call qstrip,$(BR2_PACKAGE_LINUX_BACKPORTS_DEFCONFIG))
 else ifeq ($(BR2_PACKAGE_LINUX_BACKPORTS_USE_CUSTOM_CONFIG),y)
 LINUX_BACKPORTS_KCONFIG_FILE = $(call qstrip,$(BR2_PACKAGE_LINUX_BACKPORTS_CUSTOM_CONFIG_FILE))
 endif
diff --git a/package/ncftp/ncftp.mk b/package/ncftp/ncftp.mk
index 4075449c53e1..1f33270adb92 100644
--- a/package/ncftp/ncftp.mk
+++ b/package/ncftp/ncftp.mk
@@ -37,7 +37,7 @@ NCFTP_DEPENDENCIES += ncurses
 endif
 
 define NCFTP_INSTALL_TARGET_CMDS
-	$(INSTALL) -m 0755 $(addprefix $(NCFTP_DIR)/bin/, $(NCFTP_TARGET_BINS)) $(TARGET_DIR)/usr/bin
+	$(INSTALL) -m 0755 $(addprefix $(@D)/bin/, $(NCFTP_TARGET_BINS)) $(TARGET_DIR)/usr/bin
 	$(NCFTP_INSTALL_NCFTP_BATCH)
 endef
 
diff --git a/package/pciutils/pciutils.mk b/package/pciutils/pciutils.mk
index ad32713d579f..52f92db78505 100644
--- a/package/pciutils/pciutils.mk
+++ b/package/pciutils/pciutils.mk
@@ -46,7 +46,7 @@ PCIUTILS_MAKE_OPTS += SHARED=yes
 endif
 
 define PCIUTILS_CONFIGURE_CMDS
-	$(SED) 's/wget --no-timestamping/wget/' $(PCIUTILS_DIR)/update-pciids.sh
+	$(SED) 's/wget --no-timestamping/wget/' $(@D)/update-pciids.sh
 endef
 
 define PCIUTILS_BUILD_CMDS
diff --git a/package/php/php.mk b/package/php/php.mk
index 1bb25d086370..1dd979d7a2a4 100644
--- a/package/php/php.mk
+++ b/package/php/php.mk
@@ -343,7 +343,7 @@ PHP_POST_INSTALL_TARGET_HOOKS += PHP_EXTENSIONS_FIXUP
 define PHP_INSTALL_FIXUP
 	rm -rf $(TARGET_DIR)/usr/lib/php/build
 	rm -f $(TARGET_DIR)/usr/bin/phpize
-	$(INSTALL) -D -m 0755 $(PHP_DIR)/php.ini-production \
+	$(INSTALL) -D -m 0755 $(@D)/php.ini-production \
 		$(TARGET_DIR)/etc/php.ini
 	$(SED) 's%;date.timezone =.*%date.timezone = $(PHP_LOCALTIME)%' \
 		$(TARGET_DIR)/etc/php.ini
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 20/23] linux: support custom logo and devicetree files in out-of-tree builds
  2026-10-23 21:51 ` Florian Fainelli via buildroot
                     ` (11 preceding siblings ...)
  2026-10-23 21:51   ` [Buildroot] [PATCH 19/23] packages: replace $(PKG)_DIR with @D where possible Florian Fainelli via buildroot
@ 2026-10-23 21:51   ` Florian Fainelli via buildroot
  2026-10-23 21:51   ` [Buildroot] [PATCH 21/23] package/linux-tools: support an out-of-tree kernel build Florian Fainelli via buildroot
                     ` (2 subsequent siblings)
  15 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:51 UTC (permalink / raw)
  To: buildroot
  Cc: Eric Le Bihan, Gary Bisson, Jérôme Pouiller,
	Florian Fainelli, Bernd Kuhls, Thomas Perale, Maxime Chevallier,
	Refik Tuzakli, Francois Perrad, Thomas Petazzoni,
	Arnout Vandecappelle, Petr Vorel, Spenser Gilliland,
	Giulio Benetti, Pascal de Bruijn, Luca Ceresoli, Romain Naour,
	Mahyar Koshkouei

A custom logo and custom devicetree files are added to the kernel
sources, which must not be done in a source directory we do not own.

When either is configured for an out-of-tree build, build from a shadow
of the source directory instead: a tree of real directories containing
symlinks to the files (support/scripts/symlink-tree), where files can
be replaced or added without touching the original. Packages opt in by
setting <pkg>_OUT_OF_TREE_SRCDIR.

Custom files are copied with --remove-destination so that a symlink is
replaced rather than written through.

Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 linux/linux.mk               | 34 ++++++++++++++++-----
 package/pkg-generic.mk       |  5 +++-
 support/scripts/symlink-tree | 58 ++++++++++++++++++++++++++++++++++++
 3 files changed, 89 insertions(+), 8 deletions(-)
 create mode 100755 support/scripts/symlink-tree

diff --git a/linux/linux.mk b/linux/linux.mk
index ffec32154222..ab1ab4efe400 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -226,7 +226,7 @@ LINUX_DTSO_NAMES += $(basename $(LINUX_DTSO_LIST))
 define LINUX_COPY_CUSTOM_DTS_FILES
 	$(foreach d, $(LINUX_KERNEL_CUSTOM_DTS_DIR), \
 		@$(call MESSAGE,"Copying devicetree overlay $(d)")$(sep) \
-		$(Q)$(call SYSTEM_RSYNC,$(d),$(LINUX_ARCH_PATH)/boot/dts/)$(sep))
+		$(Q)$(call SYSTEM_RSYNC,$(d),$(LINUX_SRC_ARCH_PATH)/boot/dts/)$(sep))
 endef
 endif
 
@@ -290,14 +290,18 @@ endif
 # for bzImage, arch/i386 and arch/x86_64 do not exist when copying the
 # defconfig file.
 ifeq ($(KERNEL_ARCH),i386)
-LINUX_ARCH_PATH = $(LINUX_DIR)/arch/x86
+LINUX_ARCH_SUBDIR = arch/x86
 else ifeq ($(KERNEL_ARCH),x86_64)
-LINUX_ARCH_PATH = $(LINUX_DIR)/arch/x86
+LINUX_ARCH_SUBDIR = arch/x86
 else ifeq ($(KERNEL_ARCH),sparc64)
-LINUX_ARCH_PATH = $(LINUX_DIR)/arch/sparc
+LINUX_ARCH_SUBDIR = arch/sparc
 else
-LINUX_ARCH_PATH = $(LINUX_DIR)/arch/$(KERNEL_ARCH)
+LINUX_ARCH_SUBDIR = arch/$(KERNEL_ARCH)
 endif
+# Build products (images, dtbs) are in the build directory, but the sources
+# of the kernel, to which custom files are added, may be elsewhere.
+LINUX_ARCH_PATH = $(LINUX_DIR)/$(LINUX_ARCH_SUBDIR)
+LINUX_SRC_ARCH_PATH = $(LINUX_SRCDIR)/$(LINUX_ARCH_SUBDIR)
 
 ifeq ($(BR2_LINUX_KERNEL_VMLINUX),y)
 LINUX_IMAGE_PATH = $(LINUX_DIR)/$(LINUX_IMAGE_NAME)
@@ -355,13 +359,29 @@ LINUX_KERNEL_CUSTOM_LOGO_PATH = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_LOGO_PAT
 ifneq ($(LINUX_KERNEL_CUSTOM_LOGO_PATH),)
 LINUX_DEPENDENCIES += host-imagemagick
 define LINUX_KERNEL_CUSTOM_LOGO_CONVERT
+	rm -f $(LINUX_SRCDIR)/drivers/video/logo/logo_linux_clut224.ppm
 	$(HOST_DIR)/bin/convert $(LINUX_KERNEL_CUSTOM_LOGO_PATH) \
 		-dither None -colors 224 -compress none \
-		$(LINUX_DIR)/drivers/video/logo/logo_linux_clut224.ppm
+		$(LINUX_SRCDIR)/drivers/video/logo/logo_linux_clut224.ppm
 endef
 LINUX_PRE_BUILD_HOOKS += LINUX_KERNEL_CUSTOM_LOGO_CONVERT
 endif
 
+# A custom logo or custom devicetree files are added to the kernel sources,
+# which we must not do in a source directory we do not own. In an out-of-tree
+# build, use a shadow of that directory instead: a tree of real directories
+# containing symlinks to the files, so that those can be replaced or added.
+ifneq ($(LINUX_OVERRIDE_SRCDIR),)
+ifneq ($(LINUX_KERNEL_CUSTOM_LOGO_PATH)$(LINUX_KERNEL_CUSTOM_DTS_DIR)$(LINUX_CUSTOM_DTS_PATH),)
+LINUX_OUT_OF_TREE_SRCDIR = $(BUILD_DIR)/linux-custom-src
+define LINUX_SHADOW_SRCDIR
+	@$(call MESSAGE,"Shadowing $(LINUX_OVERRIDE_SRCDIR) for custom files")
+	support/scripts/symlink-tree -F -l .git $(call qstrip,$(LINUX_OVERRIDE_SRCDIR)) $(LINUX_OUT_OF_TREE_SRCDIR)
+endef
+LINUX_PRE_RSYNC_HOOKS += LINUX_SHADOW_SRCDIR
+endif
+endif
+
 ifeq ($(BR2_LINUX_KERNEL_USE_DEFCONFIG),y)
 LINUX_KCONFIG_DEFCONFIG = $(call qstrip,$(BR2_LINUX_KERNEL_DEFCONFIG))_defconfig
 else ifeq ($(BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG),y)
@@ -560,7 +580,7 @@ endif
 define LINUX_BUILD_CMDS
 	$(call KCONFIG_DISABLE_OPT,CONFIG_GCC_PLUGINS)
 	$(foreach dts,$(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH)), \
-		cp -f $(dts) $(LINUX_ARCH_PATH)/boot/dts/
+		cp -f --remove-destination $(dts) $(LINUX_SRC_ARCH_PATH)/boot/dts/
 	)
 	$(LINUX_COPY_CUSTOM_DTS_FILES)
 	$(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) all
diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index 066396332099..38a254af1edb 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -575,7 +575,10 @@ $(2)_STAMP_SRCDIR = $$($(2)_SRCDIR)
 ifneq ($$($(2)_OVERRIDE_SRCDIR),)
 ifeq ($$($(3)_SUPPORTS_OUT_OF_TREE),YES)
 $(2)_OUT_OF_TREE = YES
-$(2)_SRCDIR = $$(abspath $$(call qstrip,$$($(2)_OVERRIDE_SRCDIR)))
+# A package may need to add files to its sources, which must not be done in
+# the overridden directory: it can then set <pkg>_OUT_OF_TREE_SRCDIR to
+# a shadow of the sources (see support/scripts/symlink-tree).
+$(2)_SRCDIR = $$(or $$($(3)_OUT_OF_TREE_SRCDIR),$$(abspath $$(call qstrip,$$($(2)_OVERRIDE_SRCDIR))))
 $(2)_STAMP_SRCDIR = $$($(2)_BUILDDIR)
 endif
 endif
diff --git a/support/scripts/symlink-tree b/support/scripts/symlink-tree
new file mode 100755
index 000000000000..6c51022dddad
--- /dev/null
+++ b/support/scripts/symlink-tree
@@ -0,0 +1,58 @@
+#!/usr/bin/env bash
+
+# Create a "shadow" of a source tree: a tree of real directories whose
+# files are symlinks to the files of the original tree. Files can then be
+# added to, or replaced in, the shadow, and objects can be built inside it,
+# without ever modifying the original tree.
+#
+# Usage: symlink-tree [-F] [-f NAME]... [-l NAME]... SRC DST
+#
+#   -F       shadow every top-level entry of SRC (default: a single symlink
+#            for each top-level entry)
+#   -f NAME  shadow the top-level directory NAME
+#   -l NAME  only symlink the top-level entry NAME, even with -F
+#
+# DST is wiped and re-created.
+
+set -e
+
+all=false
+farm=" "
+link=" "
+while getopts "Ff:l:" opt; do
+    case "${opt}" in
+    F) all=true ;;
+    f) farm="${farm}${OPTARG} " ;;
+    l) link="${link}${OPTARG} " ;;
+    *) exit 1 ;;
+    esac
+done
+shift $((OPTIND - 1))
+[ $# -eq 2 ] || { echo "usage: ${0##*/} [-F] [-f NAME]... [-l NAME]... SRC DST" >&2; exit 1; }
+
+src="$(readlink -f "${1}")"
+dst="${2}"
+
+# Refuse to wipe anything that does not look like a previous shadow, or
+# that could be (part of) the source tree.
+dst_abs="$(readlink -m "${dst}")"
+case "${src}/" in
+"${dst_abs}"/*) echo "${0##*/}: ${dst} contains the source tree" >&2; exit 1 ;;
+esac
+case "${dst_abs}/" in
+"${src}"/*) echo "${0##*/}: ${dst} is inside the source tree" >&2; exit 1 ;;
+esac
+
+rm -rf "${dst}"
+mkdir -p "${dst}"
+
+for path in "${src}"/* "${src}"/.[!.]* "${src}"/..?*; do
+    [ -e "${path}" ] || [ -L "${path}" ] || continue
+    name="${path##*/}"
+    if [ -d "${path}" ] && [ ! -L "${path}" ] && [[ "${link}" != *" ${name} "* ]] &&
+       { ${all} || [[ "${farm}" == *" ${name} "* ]]; }; then
+        cp -rs "${path}" "${dst}/"
+    else
+        ln -s "${path}" "${dst}/${name}"
+    fi
+done
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 21/23] package/linux-tools: support an out-of-tree kernel build
  2026-10-23 21:51 ` Florian Fainelli via buildroot
                     ` (12 preceding siblings ...)
  2026-10-23 21:51   ` [Buildroot] [PATCH 20/23] linux: support custom logo and devicetree files in out-of-tree builds Florian Fainelli via buildroot
@ 2026-10-23 21:51   ` Florian Fainelli via buildroot
  2026-10-23 21:51   ` [Buildroot] [PATCH 22/23] package: read kernel headers from LINUX_SRCDIR Florian Fainelli via buildroot
  2026-10-23 21:51   ` [Buildroot] [PATCH 23/23] docs/manual: document out-of-tree package builds and the new srcdir variables Florian Fainelli via buildroot
  15 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:51 UTC (permalink / raw)
  To: buildroot
  Cc: Eric Le Bihan, Gary Bisson, Jérôme Pouiller,
	Florian Fainelli, Bernd Kuhls, Thomas Perale, Maxime Chevallier,
	Refik Tuzakli, Francois Perrad, Thomas Petazzoni,
	Arnout Vandecappelle, Petr Vorel, Spenser Gilliland,
	Giulio Benetti, Pascal de Bruijn, Luca Ceresoli, Romain Naour,
	Mahyar Koshkouei

The kernel build directory no longer contains the kernel sources, so:

 - check which tools the kernel provides against $(LINUX_SRCDIR)/tools
   rather than $(LINUX_DIR)/tools;
 - build the tools, which build in-tree, in a shadow of the kernel
   sources so that the original sources are not modified. When the kernel
   is built in-tree, nothing changes.

Also: stop python from writing bytecode next to the real perf scripts,
and make the selftests find the headers installed in the kernel build
directory, which fixes a cold-build failure. The host-built net ynl
selftests are excluded from the target architecture check.

Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 package/linux-tools/linux-tool-cpupower.mk.in |  8 ++---
 package/linux-tools/linux-tool-gpio.mk.in     |  6 ++--
 package/linux-tools/linux-tool-hv.mk.in       |  6 ++--
 package/linux-tools/linux-tool-iio.mk.in      |  6 ++--
 package/linux-tools/linux-tool-mm.mk.in       | 10 +++----
 package/linux-tools/linux-tool-pci.mk.in      | 12 ++++----
 package/linux-tools/linux-tool-perf.mk.in     | 29 +++++++++++--------
 package/linux-tools/linux-tool-rtla.mk.in     | 10 +++----
 .../linux-tools/linux-tool-selftests.mk.in    | 15 ++++++----
 package/linux-tools/linux-tool-tmon.mk.in     |  8 ++---
 package/linux-tools/linux-tool-usbtools.mk.in |  6 ++--
 package/linux-tools/linux-tools.mk            | 20 ++++++++++++-
 12 files changed, 82 insertions(+), 54 deletions(-)

diff --git a/package/linux-tools/linux-tool-cpupower.mk.in b/package/linux-tools/linux-tool-cpupower.mk.in
index 2a2d3e01dd5a..aca57ff02bcb 100644
--- a/package/linux-tools/linux-tool-cpupower.mk.in
+++ b/package/linux-tools/linux-tool-cpupower.mk.in
@@ -15,26 +15,26 @@ CPUPOWER_MAKE_OPTS = CROSS=$(TARGET_CROSS) \
 	DEBUG=false
 
 define CPUPOWER_BUILD_CMDS
-	$(Q)if test ! -f $(LINUX_DIR)/tools/power/cpupower/Makefile ; then \
+	$(Q)if test ! -f $(LINUX_TOOLS_KSRC)/power/cpupower/Makefile ; then \
 		echo "Your kernel version is too old and does not have the cpupower tool." ; \
 		echo "At least kernel 3.4 must be used." ; \
 		exit 1 ; \
 	fi
 
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_TOOLS_KDIR)/tools \
 		$(CPUPOWER_MAKE_OPTS) \
 		cpupower
 endef
 
 define CPUPOWER_INSTALL_STAGING_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_TOOLS_KDIR)/tools \
 		$(CPUPOWER_MAKE_OPTS) \
 		DESTDIR=$(STAGING_DIR) \
 		cpupower_install
 endef
 
 define CPUPOWER_INSTALL_TARGET_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_TOOLS_KDIR)/tools \
 		$(CPUPOWER_MAKE_OPTS) \
 		DESTDIR=$(TARGET_DIR) \
 		cpupower_install
diff --git a/package/linux-tools/linux-tool-gpio.mk.in b/package/linux-tools/linux-tool-gpio.mk.in
index e825db1b1127..32e3343fc1aa 100644
--- a/package/linux-tools/linux-tool-gpio.mk.in
+++ b/package/linux-tools/linux-tool-gpio.mk.in
@@ -9,19 +9,19 @@ LINUX_TOOLS += gpio
 GPIO_MAKE_OPTS = $(LINUX_MAKE_FLAGS) LDFLAGS="$(TARGET_LDFLAGS)"
 
 define GPIO_BUILD_CMDS
-	$(Q)if ! grep install $(LINUX_DIR)/tools/gpio/Makefile >/dev/null 2>&1 ; then \
+	$(Q)if ! grep install $(LINUX_TOOLS_KSRC)/gpio/Makefile >/dev/null 2>&1 ; then \
 		echo "Your kernel version is too old and does not have the gpio tools." ; \
 		echo "At least kernel 4.8 must be used." ; \
 		exit 1 ; \
 	fi
 
-	$(TARGET_MAKE_ENV) $(MAKE1) -C $(LINUX_DIR)/tools \
+	$(TARGET_MAKE_ENV) $(MAKE1) -C $(LINUX_TOOLS_KDIR)/tools \
 		$(GPIO_MAKE_OPTS) \
 		gpio
 endef
 
 define GPIO_INSTALL_TARGET_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE1) -C $(LINUX_DIR)/tools \
+	$(TARGET_MAKE_ENV) $(MAKE1) -C $(LINUX_TOOLS_KDIR)/tools \
 		$(GPIO_MAKE_OPTS) \
 		DESTDIR=$(TARGET_DIR) \
 		gpio_install
diff --git a/package/linux-tools/linux-tool-hv.mk.in b/package/linux-tools/linux-tool-hv.mk.in
index e638fecfc63e..73c20e3ed542 100644
--- a/package/linux-tools/linux-tool-hv.mk.in
+++ b/package/linux-tools/linux-tool-hv.mk.in
@@ -20,13 +20,13 @@ HV_MAKE_OPTS = CC="$(TARGET_CC)" CFLAGS="$(filter-out -g%,$(TARGET_CFLAGS))"
 
 define HV_BUILD_CMDS
 	$(Q)for prog in $(HV_PROGS_y); do \
-		if test ! -f $(LINUX_DIR)/tools/hv/$${prog}.c ; then \
+		if test ! -f $(LINUX_TOOLS_KSRC)/hv/$${prog}.c ; then \
 			printf "Your kernel version is too old and does not have the HyperV %s tool." "$${prog}" ; \
 			exit 1 ; \
 		fi; \
 	done
 
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/hv \
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_TOOLS_KDIR)/tools/hv \
 		$(HV_MAKE_OPTS) \
 		$(HV_PROGS_y)
 endef
@@ -40,7 +40,7 @@ endif
 
 define HV_INSTALL_TARGET_CMDS
 	$(foreach prog,$(HV_PROGS_y), \
-		$(INSTALL) -m 0755 -D $(LINUX_DIR)/tools/hv/$(prog) \
+		$(INSTALL) -m 0755 -D $(LINUX_TOOLS_KDIR)/tools/hv/$(prog) \
 			$(TARGET_DIR)/usr/sbin/$(HV_$(prog))
 	)
 	$(HV_KVP_HELPER)
diff --git a/package/linux-tools/linux-tool-iio.mk.in b/package/linux-tools/linux-tool-iio.mk.in
index 27ab0ed7ed63..b975a548e473 100644
--- a/package/linux-tools/linux-tool-iio.mk.in
+++ b/package/linux-tools/linux-tool-iio.mk.in
@@ -9,19 +9,19 @@ LINUX_TOOLS += iio
 IIO_MAKE_OPTS = $(LINUX_MAKE_FLAGS) LDFLAGS="$(TARGET_LDFLAGS)"
 
 define IIO_BUILD_CMDS
-	$(Q)if ! grep install $(LINUX_DIR)/tools/iio/Makefile >/dev/null 2>&1 ; then \
+	$(Q)if ! grep install $(LINUX_TOOLS_KSRC)/iio/Makefile >/dev/null 2>&1 ; then \
 		echo "Your kernel version is too old and does not have install section in the iio tools." ; \
 		echo "At least kernel 4.7 must be used." ; \
 		exit 1 ; \
 	fi
 
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/iio \
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_TOOLS_KDIR)/tools/iio \
 		$(IIO_MAKE_OPTS)
 endef
 
 # DESTDIR used since kernel version 4.14
 define IIO_INSTALL_TARGET_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/iio \
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_TOOLS_KDIR)/tools/iio \
 		$(IIO_MAKE_OPTS) \
 		INSTALL_ROOT=$(TARGET_DIR) \
 		DESTDIR=$(TARGET_DIR) \
diff --git a/package/linux-tools/linux-tool-mm.mk.in b/package/linux-tools/linux-tool-mm.mk.in
index b2ec090fc086..703d3681ae43 100644
--- a/package/linux-tools/linux-tool-mm.mk.in
+++ b/package/linux-tools/linux-tool-mm.mk.in
@@ -7,16 +7,16 @@
 LINUX_TOOLS += mm
 
 define MM_BUILD_CMDS
-	$(Q)if test -f $(LINUX_DIR)/tools/vm/Makefile ; then \
+	$(Q)if test -f $(LINUX_TOOLS_KSRC)/vm/Makefile ; then \
 		MM_SUBDIR=vm; \
-	elif test -f $(LINUX_DIR)/tools/mm/Makefile ; then \
+	elif test -f $(LINUX_TOOLS_KSRC)/mm/Makefile ; then \
 		MM_SUBDIR=mm; \
 	else \
 		echo "Your kernel version is too old and does not have the mm tool." ; \
 		echo "At least kernel 3.4 must be used." ; \
 		exit 1 ; \
 	fi ; \
-	$(TARGET_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR)/tools \
+	$(TARGET_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_TOOLS_KDIR)/tools \
 		$(MM_MAKE_OPTS) $${MM_SUBDIR}
 endef
 
@@ -24,12 +24,12 @@ endef
 # exists, because that was checked at build time already; we just
 # need to find which of the two: if not one, then the other.
 define MM_INSTALL_TARGET_CMDS
-	$(Q)if test -f $(LINUX_DIR)/tools/vm/Makefile ; then \
+	$(Q)if test -f $(LINUX_TOOLS_KSRC)/vm/Makefile ; then \
 		MM_SUBDIR=vm; \
 	else \
 		MM_SUBDIR=mm; \
 	fi ; \
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_TOOLS_KDIR)/tools \
 		$(LINUX_MAKE_FLAGS) \
 		INSTALL_ROOT=$(TARGET_DIR) \
 		DESTDIR=$(TARGET_DIR) \
diff --git a/package/linux-tools/linux-tool-pci.mk.in b/package/linux-tools/linux-tool-pci.mk.in
index 52d7639bb102..a6f6ef265643 100644
--- a/package/linux-tools/linux-tool-pci.mk.in
+++ b/package/linux-tools/linux-tool-pci.mk.in
@@ -7,11 +7,13 @@
 LINUX_TOOLS += pci
 
 # Linux 6.14 moved the PCI endpoint tests into Kselftests.
-PCI_SRCDIR = $(strip $(if $(wildcard $(LINUX_DIR)/tools/testing/selftests/pci_endpoint/Makefile),\
-	$(LINUX_DIR)/tools/testing/selftests/pci_endpoint,$(LINUX_DIR)/tools/pci))
+PCI_SUBDIR = $(strip $(if $(wildcard $(LINUX_TOOLS_KSRC)/testing/selftests/pci_endpoint/Makefile),\
+	testing/selftests/pci_endpoint,pci))
+PCI_SRCDIR = $(LINUX_TOOLS_KSRC)/$(PCI_SUBDIR)
+PCI_BUILDDIR = $(LINUX_TOOLS_KDIR)/tools/$(PCI_SUBDIR)
 
 PCI_MAKE_OPTS = $(LINUX_MAKE_FLAGS) \
-	OUTPUT=$(PCI_SRCDIR)/ \
+	OUTPUT=$(PCI_BUILDDIR)/ \
 	LDFLAGS="$(TARGET_LDFLAGS)" \
 	LDLIBS="-lrt -lm"
 
@@ -22,12 +24,12 @@ define PCI_BUILD_CMDS
 		exit 1 ; \
 	fi
 
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(PCI_SRCDIR) \
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(PCI_BUILDDIR) \
 		$(PCI_MAKE_OPTS)
 endef
 
 define PCI_INSTALL_TARGET_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(PCI_SRCDIR) \
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(PCI_BUILDDIR) \
 		$(PCI_MAKE_OPTS) \
 		DESTDIR=$(TARGET_DIR) \
 		INSTALL_PATH=$(TARGET_DIR)/usr/lib/kselftests/pci_endpoint \
diff --git a/package/linux-tools/linux-tool-perf.mk.in b/package/linux-tools/linux-tool-perf.mk.in
index 8c91c2cc6b0f..a2218263a208 100644
--- a/package/linux-tools/linux-tool-perf.mk.in
+++ b/package/linux-tools/linux-tool-perf.mk.in
@@ -18,6 +18,11 @@ else
 PERF_ARCH=$(NORMALIZED_ARCH)
 endif
 
+# The python scripts run by the perf build are run through symlinks when
+# building out of tree: do not let python write its bytecode next to the
+# real script, in the kernel sources.
+PERF_MAKE_ENV = PYTHONDONTWRITEBYTECODE=1
+
 PERF_MAKE_FLAGS = \
 	$(LINUX_MAKE_FLAGS) \
 	JOBS=$(PARALLEL_JOBS) \
@@ -142,25 +147,25 @@ endif
 # We name it 'GNUmakefile' so that GNU make will use it instead of
 # the existing 'Makefile'.
 define PERF_DISABLE_DOCUMENTATION
-	if [ -f $(LINUX_DIR)/tools/perf/Documentation/Makefile ]; then \
-		printf "%%:\n\t@:\n" >$(LINUX_DIR)/tools/perf/Documentation/GNUmakefile; \
+	if [ -f $(LINUX_TOOLS_KDIR)/tools/perf/Documentation/Makefile ]; then \
+		printf "%%:\n\t@:\n" >$(LINUX_TOOLS_KDIR)/tools/perf/Documentation/GNUmakefile; \
 	fi
 endef
-LINUX_TOOLS_POST_PATCH_HOOKS += PERF_DISABLE_DOCUMENTATION
+LINUX_TOOLS_PRE_CONFIGURE_HOOKS += PERF_DISABLE_DOCUMENTATION
 
 # O must be redefined here to overwrite the one used by Buildroot for
-# out of tree build. We build perf in $(LINUX_DIR)/tools/perf/ and not just
+# out of tree build. We build perf in $(LINUX_TOOLS_KDIR)/tools/perf/ and not just
 # $(LINUX_DIR) so that it isn't built in the root directory of the kernel
 # sources.
 define PERF_BUILD_CMDS
-	$(Q)if test ! -f $(LINUX_DIR)/tools/perf/Makefile ; then \
+	$(Q)if test ! -f $(LINUX_TOOLS_KSRC)/perf/Makefile ; then \
 		echo "Your kernel version is too old and does not have the perf tool." ; \
 		echo "At least kernel 2.6.31 must be used." ; \
 		exit 1 ; \
 	fi
 	$(Q)if test "$(BR2_PACKAGE_ELFUTILS)" = "" ; then \
-		if ! grep -q NO_LIBELF $(LINUX_DIR)/tools/perf/Makefile* ; then \
-			if ! test -r $(LINUX_DIR)/tools/perf/config/Makefile ; then \
+		if ! grep -q NO_LIBELF $(LINUX_TOOLS_KSRC)/perf/Makefile* ; then \
+			if ! test -r $(LINUX_TOOLS_KSRC)/perf/config/Makefile ; then \
 				echo "The perf tool in your kernel cannot be built without libelf." ; \
 				echo "Either upgrade your kernel to >= 3.7, or enable the elfutils package." ; \
 				exit 1 ; \
@@ -168,14 +173,14 @@ define PERF_BUILD_CMDS
 		fi \
 	fi
 	$(Q)if test "$(BR2_PACKAGE_LINUX_TOOLS_PERF_TUI)" = "y" ; then \
-		if ! grep -q NO_SLANG $(LINUX_DIR)/tools/perf/Makefile* ; then \
+		if ! grep -q NO_SLANG $(LINUX_TOOLS_KSRC)/perf/Makefile* ; then \
 			echo "The perf tool in your kernel cannot be build with the TUI." ; \
 			echo "Either upgrade your kernel to >= 3.10, or disable the TUI." ; \
 			exit 1 ; \
 		fi \
 	fi
-	$(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \
-		-C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/
+	$(TARGET_MAKE_ENV) $(PERF_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \
+		-C $(LINUX_TOOLS_KDIR)/tools/perf O=$(LINUX_TOOLS_KDIR)/tools/perf/
 endef
 
 # After installation, we remove the Perl and Python scripts from the
@@ -191,8 +196,8 @@ LINUX_TOOLS_BIN_ARCH_EXCLUDE += \
 endif
 
 define PERF_INSTALL_TARGET_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \
-		-C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/ install
+	$(TARGET_MAKE_ENV) $(PERF_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \
+		-C $(LINUX_TOOLS_KDIR)/tools/perf O=$(LINUX_TOOLS_KDIR)/tools/perf/ install
 	$(PERF_INSTALL_REMOVE_SCRIPTS)
 endef
 
diff --git a/package/linux-tools/linux-tool-rtla.mk.in b/package/linux-tools/linux-tool-rtla.mk.in
index d9bdcc3016e7..aef4343010c8 100644
--- a/package/linux-tools/linux-tool-rtla.mk.in
+++ b/package/linux-tools/linux-tool-rtla.mk.in
@@ -16,7 +16,7 @@ RTLA_MAKE_OPTS = $(LINUX_MAKE_FLAGS) \
 
 ifeq ($(BR2_TOOLCHAIN_HAS_SSP),)
 define RTLA_DISABLE_STACK_PROTECTOR
-	$(SED) 's/-fstack-protector.* //' $(LINUX_DIR)/tools/tracing/rtla/Makefile
+	$(SED) 's/-fstack-protector.* //' $(LINUX_TOOLS_KDIR)/tools/tracing/rtla/Makefile
 endef
 endif
 
@@ -27,14 +27,14 @@ define RTLA_LINUX_CONFIG_FIXUPS
 endef
 
 define RTLA_BUILD_CMDS
-	$(Q)if ! grep install $(LINUX_DIR)/tools/tracing/rtla/Makefile >/dev/null 2>&1 ; then \
+	$(Q)if ! grep install $(LINUX_TOOLS_KSRC)/tracing/rtla/Makefile >/dev/null 2>&1 ; then \
 		echo "Your kernel version is too old and does not implement the rtla tool." ; \
 		echo "At least kernel 5.19 must be used." ; \
 		exit 1 ; \
 	fi
 	$(RTLA_DISABLE_STACK_PROTECTOR)
 	$(TARGET_MAKE_ENV) $(MAKE) $(RTLA_MAKE_OPTS) \
-		-C $(LINUX_DIR)/tools/tracing rtla
+		-C $(LINUX_TOOLS_KDIR)/tools/tracing rtla
 endef
 
 # make rtla_install build and install by default documentation using rst2man
@@ -42,12 +42,12 @@ endef
 # folder so let's simply install the resulting rtla binary and create symlinks
 # like Linux does in its tools/tracing/rtla/Makefile
 define RTLA_INSTALL_TARGET_CMDS
-	$(INSTALL) -m 0755 -D $(LINUX_DIR)/tools/tracing/rtla/rtla $(TARGET_DIR)/usr/bin
+	$(INSTALL) -m 0755 -D $(LINUX_TOOLS_KDIR)/tools/tracing/rtla/rtla $(TARGET_DIR)/usr/bin
 	ln -sf rtla $(TARGET_DIR)/usr/bin/osnoise
 	ln -sf rtla $(TARGET_DIR)/usr/bin/timerlat
 
 	# Check if hwnoise is provided or not
-	if grep -q hwnoise $(LINUX_DIR)/tools/tracing/rtla/Makefile; then \
+	if grep -q hwnoise $(LINUX_TOOLS_KSRC)/tracing/rtla/Makefile; then \
 		ln -sf rtla $(TARGET_DIR)/usr/bin/hwnoise ; \
 	fi
 endef
diff --git a/package/linux-tools/linux-tool-selftests.mk.in b/package/linux-tools/linux-tool-selftests.mk.in
index 032a71e32000..4f25c4a922c1 100644
--- a/package/linux-tools/linux-tool-selftests.mk.in
+++ b/package/linux-tools/linux-tool-selftests.mk.in
@@ -27,11 +27,14 @@ SELFTESTS_MAKE_FLAGS = \
 	KHDR_DIR=$(LINUX_DIR)/usr/include \
 	KHDR_INCLUDES="-isystem $(LINUX_DIR)/usr/include"
 
+# The ynl library of the net selftests is built with the host compiler
 LINUX_TOOLS_BIN_ARCH_EXCLUDE += \
-	/usr/lib/kselftests/tc-testing/
+	/usr/lib/kselftests/tc-testing/ \
+	/usr/lib/kselftests/net/lib/ynl/ \
+	/usr/lib/kselftests/drivers/net/
 
 # O must be redefined here to overwrite the one used by Buildroot for
-# out of tree build. We build the selftests in $(LINUX_DIR)/tools/selftests and
+# out of tree build. We build the selftests in $(LINUX_TOOLS_KDIR)/tools/selftests and
 # not just $(LINUX_DIR) so that it isn't built in the root directory of the kernel
 # sources.
 #
@@ -43,12 +46,12 @@ LINUX_TOOLS_BIN_ARCH_EXCLUDE += \
 define SELFTESTS_BUILD_CMDS
 	$(TARGET_MAKE_ENV) $(MAKE1) -C $(LINUX_DIR) $(SELFTESTS_MAKE_FLAGS) \
 		headers_install
-	$(TARGET_MAKE_ENV) $(MAKE1) -C $(LINUX_DIR)/tools/testing/selftests \
-		$(SELFTESTS_MAKE_FLAGS) O=$(LINUX_DIR)/tools/testing/selftests
+	$(TARGET_MAKE_ENV) $(MAKE1) -C $(LINUX_TOOLS_KDIR)/tools/testing/selftests \
+		$(SELFTESTS_MAKE_FLAGS) O=$(LINUX_TOOLS_KDIR)/tools/testing/selftests
 endef
 
 define SELFTESTS_INSTALL_TARGET_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE1) -C $(LINUX_DIR)/tools/testing/selftests \
-		$(SELFTESTS_MAKE_FLAGS) O=$(LINUX_DIR)/tools/testing/selftests \
+	$(TARGET_MAKE_ENV) $(MAKE1) -C $(LINUX_TOOLS_KDIR)/tools/testing/selftests \
+		$(SELFTESTS_MAKE_FLAGS) O=$(LINUX_TOOLS_KDIR)/tools/testing/selftests \
 		INSTALL_PATH=$(TARGET_DIR)/usr/lib/kselftests install
 endef
diff --git a/package/linux-tools/linux-tool-tmon.mk.in b/package/linux-tools/linux-tool-tmon.mk.in
index 56c328c51fd7..cb071f5fee12 100644
--- a/package/linux-tools/linux-tool-tmon.mk.in
+++ b/package/linux-tools/linux-tool-tmon.mk.in
@@ -14,24 +14,24 @@ TMON_MAKE_OPTS = $(LINUX_MAKE_FLAGS) \
 
 ifeq ($(BR2_TOOLCHAIN_HAS_SSP),)
 define TMON_DISABLE_STACK_PROTECTOR
-	$(SED) 's%-fstack-protector%%' $(LINUX_DIR)/tools/thermal/tmon/Makefile
+	$(SED) 's%-fstack-protector%%' $(LINUX_TOOLS_KDIR)/tools/thermal/tmon/Makefile
 endef
 endif
 
 define TMON_BUILD_CMDS
-	$(Q)if ! grep install $(LINUX_DIR)/tools/thermal/tmon/Makefile >/dev/null 2>&1 ; then \
+	$(Q)if ! grep install $(LINUX_TOOLS_KSRC)/thermal/tmon/Makefile >/dev/null 2>&1 ; then \
 		echo "Your kernel version is too old and does not have the tmon tool." ; \
 		echo "At least kernel 3.13 must be used." ; \
 		exit 1 ; \
 	fi
 	$(TMON_DISABLE_STACK_PROTECTOR)
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_TOOLS_KDIR)/tools \
 		$(TMON_MAKE_OPTS) \
 		tmon
 endef
 
 define TMON_INSTALL_TARGET_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_TOOLS_KDIR)/tools \
 		$(TMON_MAKE_OPTS) \
 		INSTALL_ROOT=$(TARGET_DIR) \
 		tmon_install
diff --git a/package/linux-tools/linux-tool-usbtools.mk.in b/package/linux-tools/linux-tool-usbtools.mk.in
index 797758adce51..6e72fe6de79a 100644
--- a/package/linux-tools/linux-tool-usbtools.mk.in
+++ b/package/linux-tools/linux-tool-usbtools.mk.in
@@ -13,20 +13,20 @@ LINUX_TOOLS_USBTOOLS_LIST = \
 	$(if $(BR2_PACKAGE_LINUX_TOOLS_USBTOOLS_FFSTEST),ffs-test)
 
 define USBTOOLS_BUILD_CMDS
-	$(Q)if ! grep install $(LINUX_DIR)/tools/usb/Makefile >/dev/null 2>&1 ; then \
+	$(Q)if ! grep install $(LINUX_TOOLS_KSRC)/usb/Makefile >/dev/null 2>&1 ; then \
 		echo "Your kernel version is too old to build the USB tools." ; \
 		echo "At least kernel 5.9 must be used." ; \
 		exit 1 ; \
 	fi
 
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/usb \
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_TOOLS_KDIR)/tools/usb \
 		ALL_TARGETS="$(LINUX_TOOLS_USBTOOLS_LIST)" \
 		$(USBTOOLS_MAKE_OPTS) \
 		all
 endef
 
 define USBTOOLS_INSTALL_TARGET_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/usb \
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_TOOLS_KDIR)/tools/usb \
 		ALL_TARGETS="$(LINUX_TOOLS_USBTOOLS_LIST)" \
 		$(USBTOOLS_MAKE_OPTS) \
 		DESTDIR=$(TARGET_DIR) \
diff --git a/package/linux-tools/linux-tools.mk b/package/linux-tools/linux-tools.mk
index 49e73a9ca4ec..c1b13af0dd4c 100644
--- a/package/linux-tools/linux-tools.mk
+++ b/package/linux-tools/linux-tools.mk
@@ -8,7 +8,25 @@
 # Instead, we directly build in the sources of the linux package. We can do
 # that, because we're not building in the same location and the same files.
 #
-# So, all tools refer to $(LINUX_DIR) instead of $(@D).
+# So, all tools refer to $(LINUX_TOOLS_KDIR) to build, instead of $(@D).
+#
+# Which tools can be built, though, is checked against the kernel sources
+# in $(LINUX_SRCDIR), which is not $(LINUX_DIR), the kernel build directory,
+# when the kernel is built out of tree.
+#
+# The tools build in-tree, and we do not want to pollute the kernel sources
+# of an out-of-tree build. So in that case, we build in a shadow of the
+# kernel sources, which is a tree of real directories with symlinks to the
+# files.
+LINUX_TOOLS_KSRC = $(LINUX_SRCDIR)/tools
+LINUX_TOOLS_KDIR = $(if $(LINUX_OUT_OF_TREE),$(LINUX_TOOLS_BUILDDIR)/linux,$(LINUX_DIR))
+
+define LINUX_TOOLS_SHADOW_SOURCES
+	$(if $(LINUX_OUT_OF_TREE),\
+		support/scripts/symlink-tree -f tools $(LINUX_SRCDIR) $(LINUX_TOOLS_KDIR))
+endef
+# Must come first, before the hooks that tweak the kernel sources
+LINUX_TOOLS_PRE_CONFIGURE_HOOKS += LINUX_TOOLS_SHADOW_SOURCES
 
 # Note: we need individual tools makefiles to be included *before* we build
 # the list of build and install hooks below to guarantee that each tool has
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 22/23] package: read kernel headers from LINUX_SRCDIR
  2026-10-23 21:51 ` Florian Fainelli via buildroot
                     ` (13 preceding siblings ...)
  2026-10-23 21:51   ` [Buildroot] [PATCH 21/23] package/linux-tools: support an out-of-tree kernel build Florian Fainelli via buildroot
@ 2026-10-23 21:51   ` Florian Fainelli via buildroot
  2026-10-23 21:51   ` [Buildroot] [PATCH 23/23] docs/manual: document out-of-tree package builds and the new srcdir variables Florian Fainelli via buildroot
  15 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:51 UTC (permalink / raw)
  To: buildroot
  Cc: Eric Le Bihan, Gary Bisson, Jérôme Pouiller,
	Florian Fainelli, Bernd Kuhls, Thomas Perale, Maxime Chevallier,
	Refik Tuzakli, Francois Perrad, Thomas Petazzoni,
	Arnout Vandecappelle, Petr Vorel, Spenser Gilliland,
	Giulio Benetti, Pascal de Bruijn, Luca Ceresoli, Romain Naour,
	Mahyar Koshkouei

When the kernel is built out of tree, LINUX_DIR is the build directory and
does not contain the source headers.

Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 package/a10disp/a10disp.mk                                     | 2 +-
 package/freescale-imx/imx-alsa-plugins/imx-alsa-plugins.mk     | 2 +-
 package/freescale-imx/imx-lib/imx-lib.mk                       | 2 +-
 package/gstreamer1/gst1-imx/gst1-imx.mk                        | 2 +-
 package/x11r7/xdriver_xf86-video-imx/xdriver_xf86-video-imx.mk | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/package/a10disp/a10disp.mk b/package/a10disp/a10disp.mk
index c919202329c4..a7ba85fb5a42 100644
--- a/package/a10disp/a10disp.mk
+++ b/package/a10disp/a10disp.mk
@@ -12,7 +12,7 @@ A10DISP_LICENSE_FILES = a10disp.c
 A10DISP_DEPENDENCIES = linux
 
 define A10DISP_BUILD_CMDS
-	cp -f $(LINUX_DIR)/include/video/sunxi_disp_ioctl.h $(@D)/
+	cp -f $(LINUX_SRCDIR)/include/video/sunxi_disp_ioctl.h $(@D)/
 	$(TARGET_CC) $(TARGET_CFLAGS) $(@D)/a10disp.c -o $(@D)/a10disp
 endef
 
diff --git a/package/freescale-imx/imx-alsa-plugins/imx-alsa-plugins.mk b/package/freescale-imx/imx-alsa-plugins/imx-alsa-plugins.mk
index 912cc7c68bcb..e153738a5ef4 100644
--- a/package/freescale-imx/imx-alsa-plugins/imx-alsa-plugins.mk
+++ b/package/freescale-imx/imx-alsa-plugins/imx-alsa-plugins.mk
@@ -15,6 +15,6 @@ IMX_ALSA_PLUGINS_AUTORECONF = YES
 
 # needs access to imx-specific kernel headers
 IMX_ALSA_PLUGINS_DEPENDENCIES += linux
-IMX_ALSA_PLUGINS_CONF_ENV += CPPFLAGS="$(TARGET_CPPFLAGS) -idirafter $(LINUX_DIR)/include/uapi"
+IMX_ALSA_PLUGINS_CONF_ENV += CPPFLAGS="$(TARGET_CPPFLAGS) -idirafter $(LINUX_SRCDIR)/include/uapi"
 
 $(eval $(autotools-package))
diff --git a/package/freescale-imx/imx-lib/imx-lib.mk b/package/freescale-imx/imx-lib/imx-lib.mk
index f06453e8a6be..3048deb96053 100644
--- a/package/freescale-imx/imx-lib/imx-lib.mk
+++ b/package/freescale-imx/imx-lib/imx-lib.mk
@@ -15,7 +15,7 @@ IMX_LIB_INSTALL_STAGING = YES
 # imx-lib needs access to imx-specific kernel headers
 IMX_LIB_DEPENDENCIES += linux
 IMX_LIB_INCLUDE = \
-	-idirafter $(LINUX_DIR)/include/uapi
+	-idirafter $(LINUX_SRCDIR)/include/uapi
 
 IMX_LIB_MAKE_ENV = \
 	$(TARGET_MAKE_ENV) \
diff --git a/package/gstreamer1/gst1-imx/gst1-imx.mk b/package/gstreamer1/gst1-imx/gst1-imx.mk
index f091b4f9832b..ebeccc3bd66f 100644
--- a/package/gstreamer1/gst1-imx/gst1-imx.mk
+++ b/package/gstreamer1/gst1-imx/gst1-imx.mk
@@ -23,7 +23,7 @@ GST1_IMX_CONF_OPTS = --prefix="/usr"
 ifeq ($(BR2_LINUX_KERNEL),y)
 # IPU and PXP need access to imx-specific kernel headers
 GST1_IMX_DEPENDENCIES += linux
-GST1_IMX_CONF_OPTS += --kernel-headers="$(LINUX_DIR)/include"
+GST1_IMX_CONF_OPTS += --kernel-headers="$(LINUX_SRCDIR)/include"
 endif
 
 ifeq ($(BR2_PACKAGE_IMX_CODEC),y)
diff --git a/package/x11r7/xdriver_xf86-video-imx/xdriver_xf86-video-imx.mk b/package/x11r7/xdriver_xf86-video-imx/xdriver_xf86-video-imx.mk
index b80c6b77335e..3f2602268d36 100644
--- a/package/x11r7/xdriver_xf86-video-imx/xdriver_xf86-video-imx.mk
+++ b/package/x11r7/xdriver_xf86-video-imx/xdriver_xf86-video-imx.mk
@@ -9,6 +9,6 @@ XDRIVER_XF86_VIDEO_IMX_SOURCE = xserver-xorg-video-imx-$(XDRIVER_XF86_VIDEO_IMX_
 XDRIVER_XF86_VIDEO_IMX_SITE = $(FREESCALE_IMX_SITE)
 XDRIVER_XF86_VIDEO_IMX_DEPENDENCIES = linux libz160 xserver_xorg-server \
 	xorgproto
-XDRIVER_XF86_VIDEO_IMX_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -I$(LINUX_DIR)/include"
+XDRIVER_XF86_VIDEO_IMX_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -I$(LINUX_SRCDIR)/include"
 
 $(eval $(autotools-package))
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [Buildroot] [PATCH 23/23] docs/manual: document out-of-tree package builds and the new srcdir variables
  2026-10-23 21:51 ` Florian Fainelli via buildroot
                     ` (14 preceding siblings ...)
  2026-10-23 21:51   ` [Buildroot] [PATCH 22/23] package: read kernel headers from LINUX_SRCDIR Florian Fainelli via buildroot
@ 2026-10-23 21:51   ` Florian Fainelli via buildroot
  15 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-23 21:51 UTC (permalink / raw)
  To: buildroot
  Cc: Eric Le Bihan, Gary Bisson, Jérôme Pouiller,
	Florian Fainelli, Bernd Kuhls, Thomas Perale, Maxime Chevallier,
	Refik Tuzakli, Francois Perrad, Thomas Petazzoni,
	Arnout Vandecappelle, Petr Vorel, Spenser Gilliland,
	Giulio Benetti, Pascal de Bruijn, Luca Ceresoli, Romain Naour,
	Mahyar Koshkouei

Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 docs/manual/adding-packages-generic.adoc     | 11 +++++++
 docs/manual/using-buildroot-development.adoc | 30 ++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/docs/manual/adding-packages-generic.adoc b/docs/manual/adding-packages-generic.adoc
index e7547460fd50..9c0e9baa117a 100644
--- a/docs/manual/adding-packages-generic.adoc
+++ b/docs/manual/adding-packages-generic.adoc
@@ -666,6 +666,17 @@ In the action definitions, you can use the following variables:
 * +$(@D)+, which contains the directory in which the package source
   code has been uncompressed.
 
+* +$(LIBFOO_SRCDIR)+ is the directory containing the package sources,
+  +$(LIBFOO_SRCSUBDIR)+ is the same directory with +LIBFOO_SUBDIR+
+  appended, and +$(LIBFOO_BUILDDIR)+ is the directory in which the package
+  is built. By default, these all point to +$(@D)+, but they can differ:
+  build systems that build out of source set +$(LIBFOO_BUILDDIR)+ to a
+  sub-directory, and a package built out of tree from an
+  +LIBFOO_OVERRIDE_SRCDIR+ has its sources in the overridden directory. A
+  recipe that only reads the package sources (for example to copy a header)
+  should use +$(LIBFOO_SRCDIR)+ rather than +$(@D)+, which is the build
+  directory. See xref:outoftree-build[] for more details.
+
 * +$(LIBFOO_DL_DIR)+ contains the path to the directory where all the downloads
   made by Buildroot for +libfoo+ are stored in.
 
diff --git a/docs/manual/using-buildroot-development.adoc b/docs/manual/using-buildroot-development.adoc
index 72628e0a6f99..bc9ad5d7ab94 100644
--- a/docs/manual/using-buildroot-development.adoc
+++ b/docs/manual/using-buildroot-development.adoc
@@ -119,3 +119,33 @@ cost of a slower speed, add these directories back:
 ----
 LINUX_OVERRIDE_SRCDIR_RSYNC_EXCLUSIONS = --include .git
 ----
+
+[[outoftree-build]]
+===== Building out of tree with +<pkg>_OVERRIDE_SRCDIR+
+
+A package can opt in to being built out of tree by setting
++LIBFOO_SUPPORTS_OUT_OF_TREE = YES+. For such a package, when
++LIBFOO_OVERRIDE_SRCDIR+ is set, Buildroot does not _rsync_ the sources to
++output/build/<package>-custom/+. Instead, the package is built from the
+overridden directory, with all the generated files, including the stamp
+files, stored in +output/build/<package>-custom/+. The overridden directory
+is therefore not modified by the build. The +<pkg>_PRE_RSYNC_HOOKS+ and
++<pkg>_POST_RSYNC_HOOKS+ hooks are still run, but +$(@D)+ then does not
+contain the sources: hooks should use +$(LIBFOO_SRCDIR)+ to access them.
+
+Currently the +linux+ package supports this. The kernel source tree must be
+clean (no +.config+, +include/config+ or +arch/*/include/generated+, as
+required by the kernel when using +O=+); run +make mrproper+ in it if
+needed. The kernel is configured and built with +O=+ pointing to
++output/build/linux-custom/+.
+
+When a custom logo (+BR2_LINUX_KERNEL_CUSTOM_LOGO_PATH+) or custom device
+tree files (+BR2_LINUX_KERNEL_CUSTOM_DTS_PATH+) are used, or when
++linux-tools+ are enabled, Buildroot has to add files to, or build inside,
+the kernel sources. To avoid modifying the overridden directory, it then
+builds from a _shadow_ copy: a tree of real directories containing
+symbolic links to the files of the original tree, created by
++support/scripts/symlink-tree+.
+
+Packages that read files from the kernel sources, such as headers, must use
++$(LINUX_SRCDIR)+ and not +$(LINUX_DIR)+.
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 17/23] package/perl: apply the perl-cross even for the host variant
  2026-10-23 21:51   ` [Buildroot] [PATCH 17/23] package/perl: apply the perl-cross even for the host variant Florian Fainelli via buildroot
@ 2026-10-24 10:20     ` François PERRAD
  2026-10-27 16:44       ` Florian Fainelli via buildroot
  0 siblings, 1 reply; 47+ messages in thread
From: François PERRAD @ 2026-10-24 10:20 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: buildroot


[-- Attachment #1.1: Type: text/plain, Size: 2382 bytes --]

The recent commit "package/perl: apply perl-cross patch only on target
perl"
https://gitlab.com/buildroot.org/buildroot/-/commit/8dea6e7c089cb5d4fa7bd788fc6e07c9f19f70a8
must be reverted.
It introduces a third hook PERL_POST_PATCH_HOOKS which becomes useless as
the host & target tree source are now the same.

Francois

Le ven. 23 oct. 2026 à 23:52, Florian Fainelli <
florian.fainelli@broadcom.com> a écrit :

> From: "Yann E. MORIN" <yann.morin.1998@free.fr>
>
> Currently, ther host and target variants have diffeerent source tree,
> because the target variant extracts perl-cross, while the host variant
> does not.
>
> This goes against having a single source tree for both, to ease
> out-of-tree builds.
>
> However, extracting the perl-cross archive has no impact of the standard
> build; it only ever adds new files that are not used by the original,
> native-only buildsystem.
>
> So, we can extrat perl-cross for the host variant as well, by re-using
> the same hook. We also need to apply the config.{sub,guess} hook.
>
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Francois Perrad <francois.perrad@gadz.org>
> cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> (cherry picked from commit d2ad97e0eeff39fc89a58b589f19094824402756)
> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
> ---
>  package/perl/perl.mk | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/package/perl/perl.mk b/package/perl/perl.mk
> index 43820cfcc33a..e5d8689776f4 100644
> --- a/package/perl/perl.mk
> +++ b/package/perl/perl.mk
> @@ -31,6 +31,7 @@ define PERL_CROSS_EXTRACT
>         mv $(@D)/cnf/diffs/perl5-5.42.0 $(@D)/cnf/diffs/perl5-5.42.3
>  endef
>  PERL_POST_EXTRACT_HOOKS += PERL_CROSS_EXTRACT
> +HOST_PERL_POST_EXTRACT_HOOKS += PERL_CROSS_EXTRACT
>
>  # We need to patch perl-cross, but perl-cross is extracted over the
>  # target perl sources only (and not the host variant). So we apply the
> @@ -46,6 +47,7 @@ PERL_POST_PATCH_HOOKS += PERL_CROSS_PATCH
>  # on newer host architectures, so we borrow the hook which updates them
> from the
>  # autotools infrastructure.
>  PERL_POST_PATCH_HOOKS += UPDATE_CONFIG_HOOK
> +HOST_PERL_POST_PATCH_HOOKS += UPDATE_CONFIG_HOOK
>
>  ifeq ($(BR2_PACKAGE_BERKELEYDB),y)
>  PERL_DEPENDENCIES += berkeleydb
> --
> 2.34.1
>
>

[-- Attachment #1.2: Type: text/html, Size: 3648 bytes --]

[-- Attachment #2: Type: text/plain, Size: 150 bytes --]

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 12/23] lua: rework post-patch hook usage
  2026-10-23 21:51   ` [Buildroot] [PATCH 12/23] lua: rework post-patch hook usage Florian Fainelli via buildroot
@ 2026-10-24 10:46     ` François PERRAD
  2026-10-27 16:43       ` Florian Fainelli via buildroot
  0 siblings, 1 reply; 47+ messages in thread
From: François PERRAD @ 2026-10-24 10:46 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: buildroot


[-- Attachment #1.1: Type: text/plain, Size: 2558 bytes --]

There is another hook which alters also luaconf.h on host tree source.
It was introduced by commit "package/lua: allow host-lua to find installed
modules"
https://gitlab.com/buildroot.org/buildroot/-/commit/4be3fd6fdb73085a35e89c2c1218c1e0b1e74a79

François

Le ven. 23 oct. 2026 à 23:58, Florian Fainelli <
florian.fainelli@broadcom.com> a écrit :

> From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
>
> WIP: YEM: try to see if we can make that a post-configure hook
>
> In preparation for the introduction of out-of-tree package build, it
> is important that we don't do different things in the patch hooks for
> the target and host variant of a given package, because the source
> tree will be shared between the target and host builds.
>
> For lua, the post patch hook was modifying luaconf.h before the build
> to get a 32 bits Lua build. However, passing just -DLUA_32BITS like we
> do for other Lua compile time options is not sufficient since
> LUA_32BITS should also be defined in the installed luaconf.h so that
> other packages linking against lua get this defined as well. So, this
> patch changes the post-patch hook to passing -DLUA_32BITS in
> LUA_CFLAGS *and* changing the installed luaconf.h in a
> post-install-staging hook.
>
> Cc: Francois Perrad <fperrad@gmail.com>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> (cherry picked from commit 827ed461ba2b00acfebcbd01e53d93a148594833)
> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
> ---
>  package/lua/lua.mk | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/package/lua/lua.mk b/package/lua/lua.mk
> index 6dbdc950021b..92910f8fe746 100644
> --- a/package/lua/lua.mk
> +++ b/package/lua/lua.mk
> @@ -66,11 +66,16 @@ endif
>  endif
>
>  ifeq ($(BR2_PACKAGE_LUA_32BITS),y)
> +# We adjust the CFLAGS for the build of Lua itself, and then the
> +# installed luaconf.h so that package using Lua also see LUA_32BITS
> +# defined.
> +LUA_CFLAGS += -DLUA_32BITS
>  define LUA_32BITS_LUACONF
> -       $(SED) 's/\/\* #define LUA_32BITS \*\//#define LUA_32BITS/'
> $(@D)/src/luaconf.h
> +       $(SED) 's/\/\* #define LUA_32BITS \*\//#define LUA_32BITS/' \
> +               $(STAGING_DIR)/usr/include/luaconf.h
>  endef
>
> -LUA_POST_PATCH_HOOKS += LUA_32BITS_LUACONF
> +LUA_POST_INSTALL_STAGING_HOOKS += LUA_32BITS_LUACONF
>  endif
>
>  define HOST_LUA_LUACONF
> --
> 2.34.1
>
>

[-- Attachment #1.2: Type: text/html, Size: 3867 bytes --]

[-- Attachment #2: Type: text/plain, Size: 150 bytes --]

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR
  2026-10-23 21:47 [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR Florian Fainelli via buildroot
                   ` (7 preceding siblings ...)
  2026-10-23 21:51 ` Florian Fainelli via buildroot
@ 2026-10-24 20:44 ` Thomas Petazzoni via buildroot
  2026-10-26 21:49   ` Florian Fainelli via buildroot
  8 siblings, 1 reply; 47+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-10-24 20:44 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: buildroot, Eric Le Bihan, Gary Bisson, Jérôme Pouiller,
	Bernd Kuhls, Thomas Perale, Maxime Chevallier, Refik Tuzakli,
	Francois Perrad, Arnout Vandecappelle, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Romain Naour, Mahyar Koshkouei

Hello Florian,

Wow, blast from the past here. Tough (but interesting!) topic.

On Fri, Oct 23, 2026 at 02:47:44PM -0700, Florian Fainelli via buildroot wrote:

> Patch 9, the kernel:
>   - add <pkg>_SUPPORTS_OUT_OF_TREE. When it is YES and <pkg>_OVERRIDE_SRCDIR
>     is set, the rsync step is skipped, the stamp files go in the build
>     directory and kconfig is called with -C $(SRCDIR) O=$(BUILDDIR);
>   - opt linux in, in the same patch. Kbuild requires a clean source tree
>     for O=: a tree with a stale .config, include/config or
>     arch/*/include/generated is rejected by kbuild itself.

So it means out of tree build is only used when <pkg>_OVERRIDE_SRCDIR
is used, and for a "normal" build, you still use in-tree build? (Note:
I didn't check the patches yet).

If we were to merge something like this, we would need to switch to
out-of-tree build completely, not just for the specific
<pkg>_OVERRIDE_SRCDIR situation.

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR
  2026-10-24 20:44 ` [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR Thomas Petazzoni via buildroot
@ 2026-10-26 21:49   ` Florian Fainelli via buildroot
  2026-10-27  8:14     ` Arnout Vandecappelle via buildroot
  2026-10-27 12:44     ` Thomas Petazzoni via buildroot
  0 siblings, 2 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-26 21:49 UTC (permalink / raw)
  To: Thomas Petazzoni
  Cc: buildroot, Eric Le Bihan, Gary Bisson, Jérôme Pouiller,
	Bernd Kuhls, Thomas Perale, Maxime Chevallier, Refik Tuzakli,
	Francois Perrad, Arnout Vandecappelle, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Romain Naour, Mahyar Koshkouei

On 10/24/26 13:44, Thomas Petazzoni wrote:
> Hello Florian,
> 
> Wow, blast from the past here. Tough (but interesting!) topic.

Indeed, this had been bugging me for a long time, so here we go again.

> 
> On Fri, Oct 23, 2026 at 02:47:44PM -0700, Florian Fainelli via buildroot wrote:
> 
>> Patch 9, the kernel:
>>    - add <pkg>_SUPPORTS_OUT_OF_TREE. When it is YES and <pkg>_OVERRIDE_SRCDIR
>>      is set, the rsync step is skipped, the stamp files go in the build
>>      directory and kconfig is called with -C $(SRCDIR) O=$(BUILDDIR);
>>    - opt linux in, in the same patch. Kbuild requires a clean source tree
>>      for O=: a tree with a stale .config, include/config or
>>      arch/*/include/generated is rejected by kbuild itself.
> 
> So it means out of tree build is only used when <pkg>_OVERRIDE_SRCDIR
> is used, and for a "normal" build, you still use in-tree build? (Note:
> I didn't check the patches yet).

Correct. Out-of-tree is only used when <pkg>_OVERRIDE_SRCDIR is set and 
the package opts in with <pkg>_SUPPORTS_OUT_OF_TREE = YES (only linux 
for now).

For a normal build the tarball is extracted into the build directory as 
before, and _SRCDIR, _BUILDDIR and _DIR are all the same directory, so 
there is no change for any package. The goal is to avoid the rsync of a 
developer's source tree, which does not exist for a downloaded tarball. 
Other packages could opt in later with the same variable if there is 
interest.

> 
> If we were to merge something like this, we would need to switch to
> out-of-tree build completely, not just for the specific
> <pkg>_OVERRIDE_SRCDIR situation.

I wonder if this makes sense however, not arguing about it, but trying 
to think whether it brings anything?
-- 
Florian
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR
  2026-10-26 21:49   ` Florian Fainelli via buildroot
@ 2026-10-27  8:14     ` Arnout Vandecappelle via buildroot
  2026-10-27  8:26       ` Thomas Petazzoni via buildroot
  2026-10-27 12:44     ` Thomas Petazzoni via buildroot
  1 sibling, 1 reply; 47+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2026-10-27  8:14 UTC (permalink / raw)
  To: Florian Fainelli, Thomas Petazzoni
  Cc: buildroot, Eric Le Bihan, Gary Bisson, Jérôme Pouiller,
	Bernd Kuhls, Thomas Perale, Maxime Chevallier, Refik Tuzakli,
	Francois Perrad, Petr Vorel, Spenser Gilliland, Giulio Benetti,
	Pascal de Bruijn, Luca Ceresoli, Romain Naour, Mahyar Koshkouei


On 26/10/2026 22:49, Florian Fainelli wrote:
> On 10/24/26 13:44, Thomas Petazzoni wrote:
>> Hello Florian,
>>
[snip]>> If we were to merge something like this, we would need to switch to
>> out-of-tree build completely, not just for the specific
>> <pkg>_OVERRIDE_SRCDIR situation.
> 
> I wonder if this makes sense however, not arguing about it, but trying to think 
> whether it brings anything?

  Testability. In its current form, this feature is not going to get tested at 
all other than in a runtime test. For linux that's fine, but if we're going to 
do the same for more packages, then we don't want a runtime test for all of them.

  Also if it's always done then we have the possibility to share the source 
between the host and target build. Not a super big deal.

  That said, neither of these reasons is very strong I think. So if it makes 
things simpler to do it only for the OVERRIDE_SRCDIR case, it's fine. But I 
actually expect that doing it only for the OVERRIDE_SRCDIR case makes things 
slightly more complex instead.

  BTW, the original idea was to always have a separate source and build 
directory (where the source would be under output/source and the build remains 
under output/build). For the (hopefully few) packages that _don't_ support 
out-of-tree build, we'd rsync from source to build.


  Regards,
  Arnout

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR
  2026-10-27  8:14     ` Arnout Vandecappelle via buildroot
@ 2026-10-27  8:26       ` Thomas Petazzoni via buildroot
  2026-10-27  8:43         ` Arnout Vandecappelle via buildroot
  0 siblings, 1 reply; 47+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-10-27  8:26 UTC (permalink / raw)
  To: Arnout Vandecappelle
  Cc: Florian Fainelli, buildroot, Eric Le Bihan, Gary Bisson,
	Jérôme Pouiller, Bernd Kuhls, Thomas Perale,
	Maxime Chevallier, Refik Tuzakli, Francois Perrad, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Romain Naour, Mahyar Koshkouei

On Tue, Oct 27, 2026 at 09:14:26AM +0100, Arnout Vandecappelle wrote:

>  BTW, the original idea was to always have a separate source and build
> directory (where the source would be under output/source and the build
> remains under output/build). For the (hopefully few) packages that _don't_
> support out-of-tree build, we'd rsync from source to build.

That was the original idea indeed.

That being said, I don't think the number of packages that don't
support out of tree build will be just "a few". I suspect that the
significant majority of generic-package packages will not support out
of tree build. So for those, we would now rsync, while we currently do
not have to.

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR
  2026-10-27  8:26       ` Thomas Petazzoni via buildroot
@ 2026-10-27  8:43         ` Arnout Vandecappelle via buildroot
  2026-10-27 12:41           ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 47+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2026-10-27  8:43 UTC (permalink / raw)
  To: Thomas Petazzoni
  Cc: Florian Fainelli, buildroot, Eric Le Bihan, Gary Bisson,
	Jérôme Pouiller, Bernd Kuhls, Thomas Perale,
	Maxime Chevallier, Refik Tuzakli, Francois Perrad, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Romain Naour, Mahyar Koshkouei



On 27/10/2026 09:26, Thomas Petazzoni wrote:
> On Tue, Oct 27, 2026 at 09:14:26AM +0100, Arnout Vandecappelle wrote:
> 
>>   BTW, the original idea was to always have a separate source and build
>> directory (where the source would be under output/source and the build
>> remains under output/build). For the (hopefully few) packages that _don't_
>> support out-of-tree build, we'd rsync from source to build.
> 
> That was the original idea indeed.
> 
> That being said, I don't think the number of packages that don't
> support out of tree build will be just "a few". I suspect that the
> significant majority of generic-package packages will not support out
> of tree build. So for those, we would now rsync, while we currently do
> not have to.
  We only have 612 generic packages. And the biggest of those (boost, flutter, 
any others?) probably do support out-of-tree build.


  Regards,
  Arnout
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR
  2026-10-27  8:43         ` Arnout Vandecappelle via buildroot
@ 2026-10-27 12:41           ` Thomas Petazzoni via buildroot
  0 siblings, 0 replies; 47+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-10-27 12:41 UTC (permalink / raw)
  To: Arnout Vandecappelle
  Cc: Florian Fainelli, buildroot, Eric Le Bihan, Gary Bisson,
	Jérôme Pouiller, Bernd Kuhls, Thomas Perale,
	Maxime Chevallier, Refik Tuzakli, Francois Perrad, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Romain Naour, Mahyar Koshkouei

On Tue, Oct 27, 2026 at 09:43:42AM +0100, Arnout Vandecappelle wrote:

> > That being said, I don't think the number of packages that don't
> > support out of tree build will be just "a few". I suspect that the
> > significant majority of generic-package packages will not support out
> > of tree build. So for those, we would now rsync, while we currently do
> > not have to.
>  We only have 612 generic packages. And the biggest of those (boost,
> flutter, any others?) probably do support out-of-tree build.

I don't find 612 to be "only" :-)

But yes I agree that with some efforts the biggest ones should
probably be convertible to out of tree build.

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR
  2026-10-26 21:49   ` Florian Fainelli via buildroot
  2026-10-27  8:14     ` Arnout Vandecappelle via buildroot
@ 2026-10-27 12:44     ` Thomas Petazzoni via buildroot
  2026-10-27 13:53       ` Arnout Vandecappelle via buildroot
  1 sibling, 1 reply; 47+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-10-27 12:44 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: buildroot, Eric Le Bihan, Gary Bisson, Jérôme Pouiller,
	Bernd Kuhls, Thomas Perale, Maxime Chevallier, Refik Tuzakli,
	Francois Perrad, Arnout Vandecappelle, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Romain Naour, Mahyar Koshkouei

On Mon, Oct 26, 2026 at 02:49:53PM -0700, Florian Fainelli wrote:

> > If we were to merge something like this, we would need to switch to
> > out-of-tree build completely, not just for the specific
> > <pkg>_OVERRIDE_SRCDIR situation.
> 
> I wonder if this makes sense however, not arguing about it, but trying to
> think whether it brings anything?

For me, it's mostly a matter of consistency, i.e all packages and
workflows work the same "way". I'd find it odd that specifically for
the Linux kernel package, specifically for <pkg>_OVERRIDE_SRCDIR,
there is "special" mechanism in place.

You're focused on the Linux kernel package because this is what you
and your colleagues are primarily hacking one, but I would imagine
that another very significant use case of <pkg>_OVERRIDE_SRCDIR is the
development of end-user applications, for which the Buildroot users
have the same need of quickly iterating between making changes to the
code, building and testing on the target. They use
<pkg>_OVERRIDE_SRCDIR for that, and would also benefit from
out-of-tree build. Even though I admit the size of the Linux kernel
code base makes out-of-tree build even more appealing. But I would
find it strange that users experience a different behavior of
Buildroot depending on the package for which they use
<pkg>_OVERRIDE_SRCDIR.

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR
  2026-10-27 12:44     ` Thomas Petazzoni via buildroot
@ 2026-10-27 13:53       ` Arnout Vandecappelle via buildroot
  2026-10-27 16:53         ` Florian Fainelli via buildroot
  0 siblings, 1 reply; 47+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2026-10-27 13:53 UTC (permalink / raw)
  To: Thomas Petazzoni, Florian Fainelli
  Cc: buildroot, Eric Le Bihan, Gary Bisson, Jérôme Pouiller,
	Bernd Kuhls, Thomas Perale, Maxime Chevallier, Refik Tuzakli,
	Francois Perrad, Petr Vorel, Spenser Gilliland, Giulio Benetti,
	Pascal de Bruijn, Luca Ceresoli, Romain Naour, Mahyar Koshkouei



On 27/10/2026 13:44, Thomas Petazzoni wrote:
> On Mon, Oct 26, 2026 at 02:49:53PM -0700, Florian Fainelli wrote:
> 
>>> If we were to merge something like this, we would need to switch to
>>> out-of-tree build completely, not just for the specific
>>> <pkg>_OVERRIDE_SRCDIR situation.
>>
>> I wonder if this makes sense however, not arguing about it, but trying to
>> think whether it brings anything?
> 
> For me, it's mostly a matter of consistency, i.e all packages and
> workflows work the same "way". I'd find it odd that specifically for
> the Linux kernel package, specifically for <pkg>_OVERRIDE_SRCDIR,
> there is "special" mechanism in place.
> 
> You're focused on the Linux kernel package because this is what you
> and your colleagues are primarily hacking one, but I would imagine
> that another very significant use case of <pkg>_OVERRIDE_SRCDIR is the
> development of end-user applications, for which the Buildroot users
> have the same need of quickly iterating between making changes to the
> code, building and testing on the target. They use
> <pkg>_OVERRIDE_SRCDIR for that, and would also benefit from
> out-of-tree build.

  This series provides exactly that: if they set FOO_SUPPORTS_OUT_OF_TREE = YES 
in the .mk file, then FOO_OVERRIDE_SRCDIR will skip the rsync. At least that's 
what the manual says.

  The only inconsistency that FOO_SUPPORTS_OUT_OF_TREE is only used if 
FOO_OVERRIDE_SRCDIR is also set, not for "normal" builds.

  Regards,
  Arnout

> Even though I admit the size of the Linux kernel
> code base makes out-of-tree build even more appealing. But I would
> find it strange that users experience a different behavior of
> Buildroot depending on the package for which they use
> <pkg>_OVERRIDE_SRCDIR.
> 
> Thomas

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 12/23] lua: rework post-patch hook usage
  2026-10-24 10:46     ` François PERRAD
@ 2026-10-27 16:43       ` Florian Fainelli via buildroot
  0 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-27 16:43 UTC (permalink / raw)
  To: François PERRAD; +Cc: buildroot

On 10/24/26 03:46, François PERRAD wrote:
> 
> There is another hook which alters also luaconf.h on host tree source.
> It was introduced by commit "package/lua: allow host-lua to find 
> installed modules" https://gitlab.com/buildroot.org/buildroot/-/ 
> commit/4be3fd6fdb73085a35e89c2c1218c1e0b1e74a79 <https://gitlab.com/ 
> buildroot.org/buildroot/-/commit/4be3fd6fdb73085a35e89c2c1218c1e0b1e74a79>

Thanks, incorporated that change.
-- 
Florian
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 17/23] package/perl: apply the perl-cross even for the host variant
  2026-10-24 10:20     ` François PERRAD
@ 2026-10-27 16:44       ` Florian Fainelli via buildroot
  0 siblings, 0 replies; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-27 16:44 UTC (permalink / raw)
  To: François PERRAD; +Cc: buildroot

On 10/24/26 03:20, François PERRAD wrote:
> The recent commit "package/perl: apply perl-cross patch only on target 
> perl" https://gitlab.com/buildroot.org/buildroot/-/ 
> commit/8dea6e7c089cb5d4fa7bd788fc6e07c9f19f70a8 <https://gitlab.com/ 
> buildroot.org/buildroot/-/ 
> commit/8dea6e7c089cb5d4fa7bd788fc6e07c9f19f70a8> must be reverted.
> It introduces a third hook PERL_POST_PATCH_HOOKS which becomes useless 
> as the host & target tree source are now the same.

And incorporated that change, too.
-- 
Florian
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR
  2026-10-27 13:53       ` Arnout Vandecappelle via buildroot
@ 2026-10-27 16:53         ` Florian Fainelli via buildroot
  2026-10-27 19:22           ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-27 16:53 UTC (permalink / raw)
  To: Arnout Vandecappelle, Thomas Petazzoni
  Cc: buildroot, Eric Le Bihan, Gary Bisson, Jérôme Pouiller,
	Bernd Kuhls, Thomas Perale, Maxime Chevallier, Refik Tuzakli,
	Francois Perrad, Petr Vorel, Spenser Gilliland, Giulio Benetti,
	Pascal de Bruijn, Luca Ceresoli, Romain Naour, Mahyar Koshkouei

On 10/27/26 06:53, Arnout Vandecappelle wrote:
> 
> 
> On 27/10/2026 13:44, Thomas Petazzoni wrote:
>> On Mon, Oct 26, 2026 at 02:49:53PM -0700, Florian Fainelli wrote:
>>
>>>> If we were to merge something like this, we would need to switch to
>>>> out-of-tree build completely, not just for the specific
>>>> <pkg>_OVERRIDE_SRCDIR situation.
>>>
>>> I wonder if this makes sense however, not arguing about it, but 
>>> trying to
>>> think whether it brings anything?
>>
>> For me, it's mostly a matter of consistency, i.e all packages and
>> workflows work the same "way". I'd find it odd that specifically for
>> the Linux kernel package, specifically for <pkg>_OVERRIDE_SRCDIR,
>> there is "special" mechanism in place.
>>
>> You're focused on the Linux kernel package because this is what you
>> and your colleagues are primarily hacking one, but I would imagine
>> that another very significant use case of <pkg>_OVERRIDE_SRCDIR is the
>> development of end-user applications, for which the Buildroot users
>> have the same need of quickly iterating between making changes to the
>> code, building and testing on the target. They use
>> <pkg>_OVERRIDE_SRCDIR for that, and would also benefit from
>> out-of-tree build.
> 
>   This series provides exactly that: if they set 
> FOO_SUPPORTS_OUT_OF_TREE = YES in the .mk file, then FOO_OVERRIDE_SRCDIR 
> will skip the rsync. At least that's what the manual says.

That is correct.

> 
>   The only inconsistency that FOO_SUPPORTS_OUT_OF_TREE is only used if 
> FOO_OVERRIDE_SRCDIR is also set, not for "normal" builds.

That is a good point, FOO_SUPPORTS_OUT_OF_TREE is capability being 
advertised, it should be unconditional.

Is the direction we want to be putting the sources in a separate 
directory all of the time?

FWIW, yes, the primary use case is the Linux kernel but we tend to work 
on adjacent software as well: tcpdump, libpcap, ethtool, etc. so the use 
of FOO_OVERRIDE_SRCDIR is frequent.

Thanks
-- 
Florian
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR
  2026-10-27 16:53         ` Florian Fainelli via buildroot
@ 2026-10-27 19:22           ` Thomas Petazzoni via buildroot
  2026-10-27 19:56             ` Florian Fainelli via buildroot
  2026-10-27 20:32             ` Fiona Klute via buildroot
  0 siblings, 2 replies; 47+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-10-27 19:22 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Arnout Vandecappelle, buildroot, Eric Le Bihan, Gary Bisson,
	Jérôme Pouiller, Bernd Kuhls, Thomas Perale,
	Maxime Chevallier, Refik Tuzakli, Francois Perrad, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Romain Naour, Mahyar Koshkouei

On Tue, Oct 27, 2026 at 09:53:07AM -0700, Florian Fainelli wrote:

> >   The only inconsistency that FOO_SUPPORTS_OUT_OF_TREE is only used if
> > FOO_OVERRIDE_SRCDIR is also set, not for "normal" builds.
> 
> That is a good point, FOO_SUPPORTS_OUT_OF_TREE is capability being
> advertised, it should be unconditional.
> 
> Is the direction we want to be putting the sources in a separate directory
> all of the time?

That was the direction I initially wanted to take with this
out-of-tree build work. I'm not saying we must absolutely stick to
this initial direction, just stating what my initial intention was.

I really like when things are consistent, and so for me this
out-of-tree thing had to be an all or nothing thing. But maybe I'm too
psychorigid :-)

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR
  2026-10-27 19:22           ` Thomas Petazzoni via buildroot
@ 2026-10-27 19:56             ` Florian Fainelli via buildroot
  2026-10-28 18:16               ` Thomas Petazzoni via buildroot
  2026-10-27 20:32             ` Fiona Klute via buildroot
  1 sibling, 1 reply; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-27 19:56 UTC (permalink / raw)
  To: Thomas Petazzoni
  Cc: Arnout Vandecappelle, buildroot, Eric Le Bihan, Gary Bisson,
	Jérôme Pouiller, Bernd Kuhls, Thomas Perale,
	Maxime Chevallier, Refik Tuzakli, Francois Perrad, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Romain Naour, Mahyar Koshkouei

On 10/27/26 12:22, Thomas Petazzoni wrote:
> On Tue, Oct 27, 2026 at 09:53:07AM -0700, Florian Fainelli wrote:
> 
>>>    The only inconsistency that FOO_SUPPORTS_OUT_OF_TREE is only used if
>>> FOO_OVERRIDE_SRCDIR is also set, not for "normal" builds.
>>
>> That is a good point, FOO_SUPPORTS_OUT_OF_TREE is capability being
>> advertised, it should be unconditional.
>>
>> Is the direction we want to be putting the sources in a separate directory
>> all of the time?
> 
> That was the direction I initially wanted to take with this
> out-of-tree build work. I'm not saying we must absolutely stick to
> this initial direction, just stating what my initial intention was.

Do we have any preference on where that directory should be, and how it 
should be named? output/*/sources/?

> 
> I really like when things are consistent, and so for me this
> out-of-tree thing had to be an all or nothing thing. But maybe I'm too
> psychorigid :-)

Consistency is important!
-- 
Florian
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR
  2026-10-27 19:22           ` Thomas Petazzoni via buildroot
  2026-10-27 19:56             ` Florian Fainelli via buildroot
@ 2026-10-27 20:32             ` Fiona Klute via buildroot
  2026-10-28 18:18               ` Thomas Petazzoni via buildroot
  1 sibling, 1 reply; 47+ messages in thread
From: Fiona Klute via buildroot @ 2026-10-27 20:32 UTC (permalink / raw)
  To: Thomas Petazzoni, Florian Fainelli
  Cc: Arnout Vandecappelle, buildroot, Eric Le Bihan, Gary Bisson,
	Jérôme Pouiller, Bernd Kuhls, Thomas Perale,
	Maxime Chevallier, Refik Tuzakli, Francois Perrad, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Romain Naour, Mahyar Koshkouei

Am 27.10.26 um 20:22 schrieb Thomas Petazzoni via buildroot:
> On Tue, Oct 27, 2026 at 09:53:07AM -0700, Florian Fainelli wrote:
> 
>>>    The only inconsistency that FOO_SUPPORTS_OUT_OF_TREE is only used if
>>> FOO_OVERRIDE_SRCDIR is also set, not for "normal" builds.
>>
>> That is a good point, FOO_SUPPORTS_OUT_OF_TREE is capability being
>> advertised, it should be unconditional.
>>
>> Is the direction we want to be putting the sources in a separate directory
>> all of the time?
> 
> That was the direction I initially wanted to take with this
> out-of-tree build work. I'm not saying we must absolutely stick to
> this initial direction, just stating what my initial intention was.
> 
> I really like when things are consistent, and so for me this
> out-of-tree thing had to be an all or nothing thing. But maybe I'm too
> psychorigid :-)
I like consistency too, but also real packages are a mess. As you know 
I've been working on package/dracut lately. It's built as 
"host-autotools-package". Autotools has out-of-tree build support (it's 
been a while since I tested that, but it worked well). Except… Dracut 
isn't actually an autotools package. Just close enough that it mostly 
works that way (i.e. it has a ./configure script; but it doesn't 
preserve all the flags, see 45acb281caa9fa30799426ba7ef4694c0b61fa85 
"package/dracut: pass HOST_CONFIGURE_OPTS to make").

I fear we might stumble upon more of that kind if we try to make all 
autotools packages build out of tree, whether "not actually autotools" 
or "autotools with weird custom hacks". Doesn't mean I'm fundamentally 
against trying, but we need to be prepared for issues like that. If you 
don't like making it opt-in, maybe opt-out so there is a quick fix for 
troublesome packages? Except for "generic", ironically. I don't see any 
generic solution there.

Best regards,
Fiona

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR
  2026-10-27 19:56             ` Florian Fainelli via buildroot
@ 2026-10-28 18:16               ` Thomas Petazzoni via buildroot
  2026-10-28 18:35                 ` Florian Fainelli via buildroot
  0 siblings, 1 reply; 47+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-10-28 18:16 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Arnout Vandecappelle, buildroot, Eric Le Bihan, Gary Bisson,
	Jérôme Pouiller, Bernd Kuhls, Thomas Perale,
	Maxime Chevallier, Refik Tuzakli, Francois Perrad, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Romain Naour, Mahyar Koshkouei

On Tue, Oct 27, 2026 at 12:56:20PM -0700, Florian Fainelli wrote:

> Do we have any preference on where that directory should be, and how it
> should be named? output/*/sources/?

Wasn't this already in my (very) old patch series? I think it was
output/sources/<pkg>/ or something like this?

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR
  2026-10-27 20:32             ` Fiona Klute via buildroot
@ 2026-10-28 18:18               ` Thomas Petazzoni via buildroot
  2026-10-28 18:34                 ` Florian Fainelli via buildroot
  0 siblings, 1 reply; 47+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-10-28 18:18 UTC (permalink / raw)
  To: Fiona Klute
  Cc: Florian Fainelli, Arnout Vandecappelle, buildroot, Eric Le Bihan,
	Gary Bisson, Jérôme Pouiller, Bernd Kuhls,
	Thomas Perale, Maxime Chevallier, Refik Tuzakli, Francois Perrad,
	Petr Vorel, Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Romain Naour, Mahyar Koshkouei

On Tue, Oct 27, 2026 at 09:32:55PM +0100, Fiona Klute wrote:

> I like consistency too, but also real packages are a mess. As you know I've
> been working on package/dracut lately. It's built as
> "host-autotools-package". Autotools has out-of-tree build support (it's been
> a while since I tested that, but it worked well). Except… Dracut isn't
> actually an autotools package. Just close enough that it mostly works that
> way (i.e. it has a ./configure script; but it doesn't preserve all the
> flags, see 45acb281caa9fa30799426ba7ef4694c0b61fa85 "package/dracut: pass
> HOST_CONFIGURE_OPTS to make").
> 
> I fear we might stumble upon more of that kind if we try to make all
> autotools packages build out of tree, whether "not actually autotools" or
> "autotools with weird custom hacks". Doesn't mean I'm fundamentally against
> trying, but we need to be prepared for issues like that. If you don't like
> making it opt-in, maybe opt-out so there is a quick fix for troublesome
> packages? Except for "generic", ironically. I don't see any generic solution
> there.

Two aspects:

- Packages that use the autotools-package infrastructure but are not
  truly autotools-based should in most cases probably not use
  autotools-package.

- In any case, even pure autotools-based packages can potentially have
  out-of-tree build issues. So my idea was that
  package/pkg-autotools.mk would by default enabled out-of-tree build
  for packages that use autotools-package but still allow each
  individual package to disable out-of-tree build. The logic would be
  the opposite for generic-package: the infrastructure would assume
  out-of-tree is not supported by the package, and generic-package
  packages supporting out-of-tree would have to explicitly enable it.

Best regards,

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR
  2026-10-28 18:18               ` Thomas Petazzoni via buildroot
@ 2026-10-28 18:34                 ` Florian Fainelli via buildroot
  2026-10-28 19:26                   ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-28 18:34 UTC (permalink / raw)
  To: Thomas Petazzoni, Fiona Klute
  Cc: Arnout Vandecappelle, buildroot, Eric Le Bihan, Gary Bisson,
	Jérôme Pouiller, Bernd Kuhls, Thomas Perale,
	Maxime Chevallier, Refik Tuzakli, Francois Perrad, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Romain Naour, Mahyar Koshkouei

On 10/28/26 11:18, Thomas Petazzoni wrote:
> On Tue, Oct 27, 2026 at 09:32:55PM +0100, Fiona Klute wrote:
> 
>> I like consistency too, but also real packages are a mess. As you know I've
>> been working on package/dracut lately. It's built as
>> "host-autotools-package". Autotools has out-of-tree build support (it's been
>> a while since I tested that, but it worked well). Except… Dracut isn't
>> actually an autotools package. Just close enough that it mostly works that
>> way (i.e. it has a ./configure script; but it doesn't preserve all the
>> flags, see 45acb281caa9fa30799426ba7ef4694c0b61fa85 "package/dracut: pass
>> HOST_CONFIGURE_OPTS to make").
>>
>> I fear we might stumble upon more of that kind if we try to make all
>> autotools packages build out of tree, whether "not actually autotools" or
>> "autotools with weird custom hacks". Doesn't mean I'm fundamentally against
>> trying, but we need to be prepared for issues like that. If you don't like
>> making it opt-in, maybe opt-out so there is a quick fix for troublesome
>> packages? Except for "generic", ironically. I don't see any generic solution
>> there.
> 
> Two aspects:
> 
> - Packages that use the autotools-package infrastructure but are not
>    truly autotools-based should in most cases probably not use
>    autotools-package.
> 
> - In any case, even pure autotools-based packages can potentially have
>    out-of-tree build issues. So my idea was that
>    package/pkg-autotools.mk would by default enabled out-of-tree build
>    for packages that use autotools-package but still allow each
>    individual package to disable out-of-tree build. The logic would be
>    the opposite for generic-package: the infrastructure would assume
>    out-of-tree is not supported by the package, and generic-package
>    packages supporting out-of-tree would have to explicitly enable it.
> 

For generic-package, it already works the way you describe it, with the 
need to add <PKG>_SUPPORTS_OUT_OF_TREE = YES to get out of tree builds, 
only Linux does that for now.

For autotools-package, we could add this hook:

$(2)_SUPPORTS_OUT_OF_TREE ?= YES

and a package can opt-out with setting that to no, however I would 
probably take that as a second step, rather than as part of this patch 
series in the interest of keeping it easier to review and test.
-- 
Florian
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR
  2026-10-28 18:16               ` Thomas Petazzoni via buildroot
@ 2026-10-28 18:35                 ` Florian Fainelli via buildroot
  2026-10-28 19:26                   ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 47+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-28 18:35 UTC (permalink / raw)
  To: Thomas Petazzoni
  Cc: Arnout Vandecappelle, buildroot, Eric Le Bihan, Gary Bisson,
	Jérôme Pouiller, Bernd Kuhls, Thomas Perale,
	Maxime Chevallier, Refik Tuzakli, Francois Perrad, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Romain Naour, Mahyar Koshkouei

On 10/28/26 11:16, Thomas Petazzoni wrote:
> On Tue, Oct 27, 2026 at 12:56:20PM -0700, Florian Fainelli wrote:
> 
>> Do we have any preference on where that directory should be, and how it
>> should be named? output/*/sources/?
> 
> Wasn't this already in my (very) old patch series? I think it was
> output/sources/<pkg>/ or something like this?

Currently it's output/source/<pkg>-<version> and it is set in Makefile 
in one location, so we can certainly change that to sources (plural).
-- 
Florian
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR
  2026-10-28 18:35                 ` Florian Fainelli via buildroot
@ 2026-10-28 19:26                   ` Thomas Petazzoni via buildroot
  0 siblings, 0 replies; 47+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-10-28 19:26 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Arnout Vandecappelle, buildroot, Eric Le Bihan, Gary Bisson,
	Jérôme Pouiller, Bernd Kuhls, Thomas Perale,
	Maxime Chevallier, Refik Tuzakli, Francois Perrad, Petr Vorel,
	Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Romain Naour, Mahyar Koshkouei

On Wed, Oct 28, 2026 at 11:35:56AM -0700, Florian Fainelli wrote:

> Currently it's output/source/<pkg>-<version> and it is set in Makefile in
> one location, so we can certainly change that to sources (plural).

No big preference on this, I think it's really a minor detail in the
whole story.

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR
  2026-10-28 18:34                 ` Florian Fainelli via buildroot
@ 2026-10-28 19:26                   ` Thomas Petazzoni via buildroot
  0 siblings, 0 replies; 47+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-10-28 19:26 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Fiona Klute, Arnout Vandecappelle, buildroot, Eric Le Bihan,
	Gary Bisson, Jérôme Pouiller, Bernd Kuhls,
	Thomas Perale, Maxime Chevallier, Refik Tuzakli, Francois Perrad,
	Petr Vorel, Spenser Gilliland, Giulio Benetti, Pascal de Bruijn,
	Luca Ceresoli, Romain Naour, Mahyar Koshkouei

On Wed, Oct 28, 2026 at 11:34:32AM -0700, Florian Fainelli wrote:

> For generic-package, it already works the way you describe it, with the need
> to add <PKG>_SUPPORTS_OUT_OF_TREE = YES to get out of tree builds, only
> Linux does that for now.
> 
> For autotools-package, we could add this hook:
> 
> $(2)_SUPPORTS_OUT_OF_TREE ?= YES
> 
> and a package can opt-out with setting that to no, however I would probably
> take that as a second step, rather than as part of this patch series in the
> interest of keeping it easier to review and test.

Yes, sounds good to me.

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 47+ messages in thread

end of thread, other threads:[~2026-10-28 19:27 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-23 21:47 [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR Florian Fainelli via buildroot
2026-10-23 21:47 ` [Buildroot] [PATCH 01/23] package: prepare removal of <pkg>_DIR Florian Fainelli via buildroot
2026-10-23 21:47 ` [Buildroot] [PATCH 02/23] infra: introduce a global SRC_DIR variable Florian Fainelli via buildroot
2026-10-23 21:47 ` [Buildroot] [PATCH 03/23] package: fix <pkg>_SRCDIR and <pkg>_BUILDDIR values Florian Fainelli via buildroot
2026-10-23 21:47 ` [Buildroot] [PATCH 04/23] boot/boot-wrapper-aarch64: needs LINUX_BUILDDIR Florian Fainelli via buildroot
2026-10-23 21:47 ` [Buildroot] [PATCH 05/23] boot/mxs-bootlets: needs (BAREBOX, LINUX, UBOOT)_BUILDDIR Florian Fainelli via buildroot
2026-10-23 21:47 ` [Buildroot] [PATCH 06/23] linux/extensions: point to proper _SRCDIR and @D Florian Fainelli via buildroot
2026-10-23 21:47 ` [Buildroot] [PATCH 07/23] linux/linux: LINUX_VERSION_PROBED should run from build directory Florian Fainelli via buildroot
2026-10-23 21:51 ` Florian Fainelli via buildroot
2026-10-23 21:51   ` [Buildroot] [PATCH 08/23] package: use <pkg>_SRCSUBDIR where <pkg>_SRCDIR used to include _SUBDIR Florian Fainelli via buildroot
2026-10-23 21:51   ` [Buildroot] [PATCH 09/23] linux: build out of tree when LINUX_OVERRIDE_SRCDIR is set Florian Fainelli via buildroot
2026-10-23 21:51   ` [Buildroot] [PATCH 10/23] packages: sync host and target patch hooks Florian Fainelli via buildroot
2026-10-23 21:51   ` [Buildroot] [PATCH 11/23] omniorb: avoid target-only patch hook Florian Fainelli via buildroot
2026-10-23 21:51   ` [Buildroot] [PATCH 12/23] lua: rework post-patch hook usage Florian Fainelli via buildroot
2026-10-24 10:46     ` François PERRAD
2026-10-27 16:43       ` Florian Fainelli via buildroot
2026-10-23 21:51   ` [Buildroot] [PATCH 13/23] infra: host packages inherit the target extra downloads Florian Fainelli via buildroot
2026-10-23 21:51   ` [Buildroot] [PATCH 14/23] package/libtool: use post-patch hooks Florian Fainelli via buildroot
2026-10-23 21:51   ` [Buildroot] [PATCH 15/23] package/libtool: also apply libtool-patch to host libtool Florian Fainelli via buildroot
2026-10-23 21:51   ` [Buildroot] [PATCH 16/23] package/{ffmpeg, libvpx}: use $(@D) instead of $(pkg_SRCDIR) when possible Florian Fainelli via buildroot
2026-10-23 21:51   ` [Buildroot] [PATCH 17/23] package/perl: apply the perl-cross even for the host variant Florian Fainelli via buildroot
2026-10-24 10:20     ` François PERRAD
2026-10-27 16:44       ` Florian Fainelli via buildroot
2026-10-23 21:51   ` [Buildroot] [PATCH 18/23] infra/autotools: warn for package that autoreconf without libtool patch Florian Fainelli via buildroot
2026-10-23 21:51   ` [Buildroot] [PATCH 19/23] packages: replace $(PKG)_DIR with @D where possible Florian Fainelli via buildroot
2026-10-23 21:51   ` [Buildroot] [PATCH 20/23] linux: support custom logo and devicetree files in out-of-tree builds Florian Fainelli via buildroot
2026-10-23 21:51   ` [Buildroot] [PATCH 21/23] package/linux-tools: support an out-of-tree kernel build Florian Fainelli via buildroot
2026-10-23 21:51   ` [Buildroot] [PATCH 22/23] package: read kernel headers from LINUX_SRCDIR Florian Fainelli via buildroot
2026-10-23 21:51   ` [Buildroot] [PATCH 23/23] docs/manual: document out-of-tree package builds and the new srcdir variables Florian Fainelli via buildroot
2026-10-24 20:44 ` [Buildroot] [PATCH 00/23] Support building the Linux kernel out of tree with LINUX_OVERRIDE_SRCDIR Thomas Petazzoni via buildroot
2026-10-26 21:49   ` Florian Fainelli via buildroot
2026-10-27  8:14     ` Arnout Vandecappelle via buildroot
2026-10-27  8:26       ` Thomas Petazzoni via buildroot
2026-10-27  8:43         ` Arnout Vandecappelle via buildroot
2026-10-27 12:41           ` Thomas Petazzoni via buildroot
2026-10-27 12:44     ` Thomas Petazzoni via buildroot
2026-10-27 13:53       ` Arnout Vandecappelle via buildroot
2026-10-27 16:53         ` Florian Fainelli via buildroot
2026-10-27 19:22           ` Thomas Petazzoni via buildroot
2026-10-27 19:56             ` Florian Fainelli via buildroot
2026-10-28 18:16               ` Thomas Petazzoni via buildroot
2026-10-28 18:35                 ` Florian Fainelli via buildroot
2026-10-28 19:26                   ` Thomas Petazzoni via buildroot
2026-10-27 20:32             ` Fiona Klute via buildroot
2026-10-28 18:18               ` Thomas Petazzoni via buildroot
2026-10-28 18:34                 ` Florian Fainelli via buildroot
2026-10-28 19:26                   ` Thomas Petazzoni via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox