kumquat-buildroot/linux
Yann E. MORIN a1feef1a0d package/linux: fix LINUX_PKGDIR with br2-external linux-extensions
When 'make' includes a new Makefile, it appends its path to the MAKEFILE_LIST
variable. From that variable, we construct a few set of derivative
variables:
    pkgdir = $(dir $(lastword $(MAKEFILE_LIST)))
    pkgname = $(lastword $(subst /, ,$(pkgdir)))

Essentially, pkgdir is the full directory where the package is located
(either relative to Buildroot's top directory for in-tree packages, or
absolute for packages in br2-external trees), while pkgname is the last
component of that directory.

pkgdir is in turn used to seed FOO_PKGDIR.

This all happens when we eventually call the package-generic infra,
later down in the file.

When they are parsed, the Makefiles for each linux-extensions are
appended to MAKEFILE_LIST, after the linux.mk one. But since they are
located in the same directory as the main linux.mk, the last component
of MAKEFILE_LIST, which is no longer the main linux.mk, will still yield
the correct values for the linux package.

This is a tough assumption we made there and then.

When we added the support for br2-external linux extensions, we where
very cautious to explicitly scan them from a directory named 'linux', so
that this would yield the correct package name.

And that worked well so far, until someone needed to build an older
kernel, for which our conditional patch is needed, and which just
failed:

    /bin/bash: [...]/buildroot-external-linux-test/linux//0001-timeconst.pl-Eliminate-Perl-warning.patch.conditional: No such file or directory

When we scan linux extensions from a br2-external tree, the last
component of MAKEFILE_LIST is no longer in the same directory as the
main linux.mk, and thus the assumption above falls to pieces...

Again, when we added support for linux extensions from br2-external,
although we cared about the package name (pkgname), we completely missed
out on the package directory, and the LINUX_PKGDIR variable.

We do not have a very clean way out of this mess, but we have a nice
dirty trick: Scan the linux extensions from a br2-external tree before we
scan the in-tree ones. That way, the last component of MAKEFILE_LIST is
back to one that is in the same directory as the main linux.mk, and
we're back on tracks.

This is still very fragile, though, but short of a complete overhaul on
how packages are parsed and evaluated, this is the best we can come in
short order.

Reported-by: Heiko Thiery <heiko.thiery@gmail.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Heiko Thiery <heiko.thiery@gmail.com>
Cc: Arnout Vandecappelle <arnout@mind.be>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Heiko Thiery <heiko.thiery@gmail.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2020-01-25 12:00:50 +01:00
..
0001-timeconst.pl-Eliminate-Perl-warning.patch.conditional linux: add conditional patch for timeconst.pl 2016-02-10 08:12:57 +01:00
Config.ext.in linux/linux-ext-xenomai: allow URL for the ADEOS/IPIPE patch 2019-05-20 21:21:42 +02:00
Config.in {linux, linux-headers}: bump 4.{4, 9, 14, 19}.x / 5.4.x series 2020-01-20 20:02:14 +01:00
linux-ext-aufs.mk linux/linux-ext-*.mk: fit file header into one line 2018-04-01 08:43:07 +02:00
linux-ext-ev3dev-linux-drivers.mk linux/linux-ext-*.mk: fit file header into one line 2018-04-01 08:43:07 +02:00
linux-ext-fbtft.mk linux/linux-ext-*.mk: fit file header into one line 2018-04-01 08:43:07 +02:00
linux-ext-rtai.mk linux/linux*.mk: fix code style 2018-04-01 08:43:42 +02:00
linux-ext-xenomai.mk linux/linux-ext-xenomai: add check-package exclusion comment 2019-06-08 22:59:32 +02:00
linux.hash {linux, linux-headers}: bump 4.{4, 9, 14, 19}.x / 5.4.x series 2020-01-20 20:02:14 +01:00
linux.mk package/linux: fix LINUX_PKGDIR with br2-external linux-extensions 2020-01-25 12:00:50 +01:00