All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Fainelli via buildroot <buildroot@buildroot.org>
To: buildroot@buildroot.org
Cc: "Gary Bisson" <bisson.gary@gmail.com>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Petr Vorel" <petr.vorel@gmail.com>,
	"Spenser Gilliland" <spenser@gillilanding.com>,
	"Francois Perrad" <fperrad@gmail.com>,
	"Florian Fainelli" <florian.fainelli@broadcom.com>,
	"Maxime Chevallier" <maxime.chevallier@bootlin.com>,
	"Francois Perrad" <francois.perrad.86@gmail.com>,
	"Arnout Vandecappelle" <arnout@rnout.be>,
	"Luca Ceresoli" <luca.ceresoli@bootlin.com>,
	"Thomas Perale" <thomas.perale@mind.be>,
	"Eric Le Bihan" <eric.le.bihan.dev@free.fr>,
	"Mahyar Koshkouei" <mahyar.koshkouei@gmail.com>,
	"Yann E. MORIN" <yann.morin.1998@free.fr>,
	"Romain Naour" <romain.naour@gmail.com>,
	"Pascal de Bruijn" <p.debruijn@unilogic.nl>,
	"Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>,
	"Jérôme Pouiller" <jezz@sysmic.org>,
	"Bernd Kuhls" <bernd@kuhls.net>,
	"Refik Tuzakli" <tuzakli.refik@gmail.com>,
	"Giulio Benetti" <giulio.benetti@benettiengineering.com>
Subject: [Buildroot] [PATCH v2 12/23] lua: rework post-patch hook usage
Date: Wed, 28 Oct 2026 14:37:33 -0700	[thread overview]
Message-ID: <20261028213744.511429-13-florian.fainelli@broadcom.com> (raw)
In-Reply-To: <20261028213744.511429-1-florian.fainelli@broadcom.com>

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 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.

The host variant also modified luaconf.h, to set LUA_ROOT to the host
directory. Since the host and target variants share the same sources,
this can not be done in a hook for the host variant only. Instead, the
Buildroot patch that sets LUA_ROOT now allows it to be overridden on the
compiler command line, which the host variant does with its CFLAGS, and
the installed host luaconf.h is adjusted in a post-install 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/5.1.5/0001-root-path.patch | 24 +++++++++---------------
 package/lua/5.3.6/0001-root-path.patch | 15 +++++++++++----
 package/lua/5.4.9/0001-root-path.patch | 11 +++++++++--
 package/lua/lua.mk                     | 18 ++++++++++++++----
 4 files changed, 43 insertions(+), 25 deletions(-)

diff --git a/package/lua/5.1.5/0001-root-path.patch b/package/lua/5.1.5/0001-root-path.patch
index 41de4ba2b938..81c5eefa3d90 100644
--- a/package/lua/5.1.5/0001-root-path.patch
+++ b/package/lua/5.1.5/0001-root-path.patch
@@ -1,31 +1,25 @@
-Adjust installation location to /usr.
+Adjust installation location to /usr, and allow LUA_ROOT to be overridden
+from the compiler command line.
+
+The host variant needs a different LUA_ROOT than the target variant. As
+both variants share the same sources, it can not be set by modifying
+luaconf.h, so it is passed in the CFLAGS instead.
 
 Upstream: N/A specific for Buildroot build
 Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
 
-Index: b/etc/lua.pc
-===================================================================
---- a/etc/lua.pc
-+++ b/etc/lua.pc
-@@ -8,7 +8,7 @@
- R= 5.1.5
- 
- # grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/'
--prefix= /usr/local
-+prefix= /usr
- INSTALL_BIN= ${prefix}/bin
- INSTALL_INC= ${prefix}/include
- INSTALL_LIB= ${prefix}/lib
 Index: b/src/luaconf.h
 ===================================================================
 --- a/src/luaconf.h
 +++ b/src/luaconf.h
-@@ -94,7 +94,7 @@
+@@ -94,7 +94,9 @@
  	".\\?.dll;"  LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
  
  #else
 -#define LUA_ROOT	"/usr/local/"
++#if !defined(LUA_ROOT)
 +#define LUA_ROOT	"/usr/"
++#endif
  #define LUA_LDIR	LUA_ROOT "share/lua/5.1/"
  #define LUA_CDIR	LUA_ROOT "lib/lua/5.1/"
  #define LUA_PATH_DEFAULT  \
diff --git a/package/lua/5.3.6/0001-root-path.patch b/package/lua/5.3.6/0001-root-path.patch
index b41df3ecb74c..f6273349be27 100644
--- a/package/lua/5.3.6/0001-root-path.patch
+++ b/package/lua/5.3.6/0001-root-path.patch
@@ -1,4 +1,9 @@
-Adjust installation location to /usr.
+Adjust installation location to /usr, and allow LUA_ROOT to be overridden
+from the compiler command line.
+
+The host variant needs a different LUA_ROOT than the target variant. As
+both variants share the same sources, it can not be set by modifying
+luaconf.h, so it is passed in the CFLAGS instead.
 
 Upstream: N/A specific for Buildroot build
 Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
@@ -7,12 +12,14 @@ Index: b/src/luaconf.h
 ===================================================================
 --- a/src/luaconf.h
 +++ b/src/luaconf.h
-@@ -200,7 +200,7 @@
-
+@@ -200,7 +200,9 @@
+ 
  #else			/* }{ */
-
+ 
 -#define LUA_ROOT	"/usr/local/"
++#if !defined(LUA_ROOT)
 +#define LUA_ROOT	"/usr/"
++#endif
  #define LUA_LDIR	LUA_ROOT "share/lua/" LUA_VDIR "/"
  #define LUA_CDIR	LUA_ROOT "lib/lua/" LUA_VDIR "/"
  #define LUA_PATH_DEFAULT  \
diff --git a/package/lua/5.4.9/0001-root-path.patch b/package/lua/5.4.9/0001-root-path.patch
index cec9066eee98..69d142a8f242 100644
--- a/package/lua/5.4.9/0001-root-path.patch
+++ b/package/lua/5.4.9/0001-root-path.patch
@@ -1,4 +1,9 @@
-Adjust installation location to /usr.
+Adjust installation location to /usr, and allow LUA_ROOT to be overridden
+from the compiler command line.
+
+The host variant needs a different LUA_ROOT than the target variant. As
+both variants share the same sources, it can not be set by modifying
+luaconf.h, so it is passed in the CFLAGS instead.
 
 Upstream: N/A specific for Buildroot build
 Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
@@ -7,12 +12,14 @@ Index: b/src/luaconf.h
 ===================================================================
 --- a/src/luaconf.h
 +++ b/src/luaconf.h
-@@ -223,7 +223,7 @@
+@@ -223,7 +223,9 @@
  
  #else			/* }{ */
  
 -#define LUA_ROOT	"/usr/local/"
++#if !defined(LUA_ROOT)
 +#define LUA_ROOT	"/usr/"
++#endif
  #define LUA_LDIR	LUA_ROOT "share/lua/" LUA_VDIR "/"
  #define LUA_CDIR	LUA_ROOT "lib/lua/" LUA_VDIR "/"
  
diff --git a/package/lua/lua.mk b/package/lua/lua.mk
index 6dbdc950021b..752b67b45333 100644
--- a/package/lua/lua.mk
+++ b/package/lua/lua.mk
@@ -66,19 +66,29 @@ 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
 
+# The host and target variants share the same sources, so the sources can
+# not be modified for the host variant only. LUA_ROOT is overridden in the
+# CFLAGS when building host-lua, and in the installed luaconf.h.
 define HOST_LUA_LUACONF
-	$(SED) 's|#define LUA_ROOT.*|#define LUA_ROOT "$(HOST_DIR)/"|' $(@D)/src/luaconf.h
+	$(SED) 's|#define LUA_ROOT.*|#define LUA_ROOT "$(HOST_DIR)/"|' \
+		$(HOST_DIR)/include/luaconf.h
 endef
-HOST_LUA_POST_PATCH_HOOKS += HOST_LUA_LUACONF
+HOST_LUA_POST_INSTALL_HOOKS += HOST_LUA_LUACONF
 
 HOST_LUA_CFLAGS = -Wall -fPIC -DLUA_USE_DLOPEN -DLUA_USE_POSIX
+HOST_LUA_CFLAGS += -DLUA_ROOT='\"$(HOST_DIR)/\"'
 ifeq ($(BR2_PACKAGE_LUA_5_3),y)
 HOST_LUA_CFLAGS += -DLUA_COMPAT_5_2
 endif
-- 
2.34.1

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

  parent reply	other threads:[~2026-10-28 21:39 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28 21:37 [Buildroot] [PATCH v2 00/23] Support building the Linux kernel out of tree Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 01/23] package: prepare removal of <pkg>_DIR Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 02/23] infra: introduce a global SRC_DIR variable Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 03/23] package: fix <pkg>_SRCDIR and <pkg>_BUILDDIR values Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 04/23] boot/boot-wrapper-aarch64: needs LINUX_BUILDDIR Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 05/23] boot/mxs-bootlets: needs (BAREBOX, LINUX, UBOOT)_BUILDDIR Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 06/23] linux/extensions: point to proper _SRCDIR and @D Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 07/23] linux/linux: LINUX_VERSION_PROBED should run from build directory Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 08/23] package: use <pkg>_SRCSUBDIR where <pkg>_SRCDIR used to include _SUBDIR Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 09/23] linux: build out of tree Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 10/23] packages: sync host and target patch hooks Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 11/23] omniorb: avoid target-only patch hook Florian Fainelli via buildroot
2026-10-28 21:37 ` Florian Fainelli via buildroot [this message]
2026-10-28 21:37 ` [Buildroot] [PATCH v2 13/23] infra: host packages inherit the target extra downloads Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 14/23] package/libtool: use post-patch hooks Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 15/23] package/libtool: also apply libtool-patch to host libtool Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 16/23] package/{ffmpeg, libvpx}: use $(@D) instead of $(pkg_SRCDIR) when possible Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 17/23] package/perl: apply the perl-cross even for the host variant Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 18/23] infra/autotools: warn for package that autoreconf without libtool patch Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 19/23] packages: replace $(PKG)_DIR with @D where possible Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 20/23] linux: support custom logo and devicetree files in out-of-tree builds Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 21/23] package/linux-tools: support an out-of-tree kernel build Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 22/23] package: read kernel headers from LINUX_SRCDIR Florian Fainelli via buildroot
2026-10-28 21:37 ` [Buildroot] [PATCH v2 23/23] docs/manual: document out-of-tree package builds and the new srcdir variables Florian Fainelli via buildroot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261028213744.511429-13-florian.fainelli@broadcom.com \
    --to=buildroot@buildroot.org \
    --cc=arnout@rnout.be \
    --cc=bernd@kuhls.net \
    --cc=bisson.gary@gmail.com \
    --cc=eric.le.bihan.dev@free.fr \
    --cc=florian.fainelli@broadcom.com \
    --cc=fperrad@gmail.com \
    --cc=francois.perrad.86@gmail.com \
    --cc=giulio.benetti@benettiengineering.com \
    --cc=jezz@sysmic.org \
    --cc=luca.ceresoli@bootlin.com \
    --cc=mahyar.koshkouei@gmail.com \
    --cc=maxime.chevallier@bootlin.com \
    --cc=p.debruijn@unilogic.nl \
    --cc=petr.vorel@gmail.com \
    --cc=romain.naour@gmail.com \
    --cc=spenser@gillilanding.com \
    --cc=thomas.perale@mind.be \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=thomas.petazzoni@free-electrons.com \
    --cc=tuzakli.refik@gmail.com \
    --cc=yann.morin.1998@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.