Linux I2C development
 help / color / mirror / Atom feed
* [PATCH] i2c-tools: Enable cross compilation
@ 2026-07-06  8:02 Brigham Campbell
  2026-07-07 20:25 ` Wolfram Sang
  0 siblings, 1 reply; 2+ messages in thread
From: Brigham Campbell @ 2026-07-06  8:02 UTC (permalink / raw)
  To: linux-i2c, Jean Delvare; +Cc: Wolfram Sang, Brigham Campbell

Currently, the Makefile fails to change CC, AR, and STRIP variables from
their default values[^1] because it uses the conditional variable
assignment operator. The Makefile also doesn't allow for cross
compilation without modification.

Modify the Makefile to use unconditional assignment and allow the user
to cross compile the software via the CROSS_COMPILE variable.

[^1]: https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html

Signed-off-by: Brigham Campbell <me@brighamcampbell.com>
---
 Makefile | 9 ++++++---
 README   | 3 +++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index a0d4269..2a51485 100644
--- a/Makefile
+++ b/Makefile
@@ -24,9 +24,12 @@ INSTALL_PROGRAM	:= $(INSTALL) -m 755
 LN		:= ln -sf
 RM		:= rm -f
 
-CC	?= gcc
-AR	?= ar
-STRIP	?= strip
+# Use CROSS_COMPILE to specify the toolchain prefix. E.g.
+# make CROSS_COMPILE=aarch64-linux-gnu-
+
+CC	= $(CROSS_COMPILE)gcc
+AR	= $(CROSS_COMPILE)ar
+STRIP	= $(CROSS_COMPILE)strip
 
 CFLAGS		?= -O2
 # When debugging, use the following instead
diff --git a/README b/README
index 502132f..1c83561 100644
--- a/README
+++ b/README
@@ -80,6 +80,9 @@ If you want to compile the tools against the static version of the library
 you can do:
   $ make USE_STATIC_LIB=1
 
+To compile for another platform, use the CROSS_COMPILE toolchain prefix option:
+  $ make CROSS_COMPILE=aarch64-linux-gnu-
+
 Optionally, you can run "make strip" prior to "make install" if you want
 smaller binaries. However, be aware that this will prevent any further
 attempt to debug the library and tools.

---
base-commit: 5852f5375eea6ca9dabf31f4772cb8b8ecc905d8
change-id: 20260706-cross-compile-36f904256481

Thanks!
-- 
Brigham Campbell
https://brighamcampbell.com


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

* Re: [PATCH] i2c-tools: Enable cross compilation
  2026-07-06  8:02 [PATCH] i2c-tools: Enable cross compilation Brigham Campbell
@ 2026-07-07 20:25 ` Wolfram Sang
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2026-07-07 20:25 UTC (permalink / raw)
  To: Brigham Campbell; +Cc: linux-i2c, Jean Delvare

[-- Attachment #1: Type: text/plain, Size: 632 bytes --]

On Mon, Jul 06, 2026 at 02:02:39AM -0600, Brigham Campbell wrote:
> Currently, the Makefile fails to change CC, AR, and STRIP variables from
> their default values[^1] because it uses the conditional variable
> assignment operator. The Makefile also doesn't allow for cross
> compilation without modification.
> 
> Modify the Makefile to use unconditional assignment and allow the user
> to cross compile the software via the CROSS_COMPILE variable.
> 
> [^1]: https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
> 
> Signed-off-by: Brigham Campbell <me@brighamcampbell.com>

Applied, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2026-07-07 20:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06  8:02 [PATCH] i2c-tools: Enable cross compilation Brigham Campbell
2026-07-07 20:25 ` Wolfram Sang

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