From: Brigham Campbell <me@brighamcampbell.com>
To: linux-i2c@vger.kernel.org, Jean Delvare <jdelvare@suse.de>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
Brigham Campbell <me@brighamcampbell.com>
Subject: [PATCH] i2c-tools: Enable cross compilation
Date: Mon, 06 Jul 2026 02:02:39 -0600 [thread overview]
Message-ID: <20260706-cross-compile-v1-1-e3ebdd485ce6@brighamcampbell.com> (raw)
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
next reply other threads:[~2026-07-06 8:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 8:02 Brigham Campbell [this message]
2026-07-07 20:25 ` [PATCH] i2c-tools: Enable cross compilation Wolfram Sang
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=20260706-cross-compile-v1-1-e3ebdd485ce6@brighamcampbell.com \
--to=me@brighamcampbell.com \
--cc=jdelvare@suse.de \
--cc=linux-i2c@vger.kernel.org \
--cc=wsa+renesas@sang-engineering.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox