From: Marco Felsch <m.felsch@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] scripts: imx: add Makefile.mingw64
Date: Wed, 18 Oct 2023 16:40:38 +0200 [thread overview]
Message-ID: <20231018144038.504641-1-m.felsch@pengutronix.de> (raw)
Add a small Makfile for building the imx-usb-loader.exe outside the
Kbuild system. The user can compile the tool for windows by:
make -f scripts/imx/Makfile.mingw64 LIBUSB_DIR=~/libusb-1.0.26
or by
make -f scripts/imx/Makfile.mingw64 LIBUSB_DIR=~/libusb-1.0.26 O=win
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
scripts/imx/Makefile.mingw64 | 48 ++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
create mode 100644 scripts/imx/Makefile.mingw64
diff --git a/scripts/imx/Makefile.mingw64 b/scripts/imx/Makefile.mingw64
new file mode 100644
index 000000000000..e012d833f1b4
--- /dev/null
+++ b/scripts/imx/Makefile.mingw64
@@ -0,0 +1,48 @@
+ifeq ($(strip $(LIBUSB_DIR)),)
+$(error Please specify LIBUSB_DIR e.g. LIBUSB_DIR=~/libusb-1.0.26-binaries)
+endif
+
+CC := x86_64-w64-mingw32-gcc
+ifeq ($(shell which $(CC)),)
+$(error "No $(CC) in $(PATH) found")
+endif
+
+LIBUSB_MINGW := $(LIBUSB_DIR)/libusb-MinGW-x64
+ifeq ($(wildcard $(strip $(LIBUSB_MINGW))),)
+$(error "$(LIBUSB_MINGW) not found")
+endif
+
+src := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
+
+# Do we want to change the working directory?
+ifeq ("$(origin O)", "command line")
+ OUTPUT := $(O)
+else
+ OUTPUT := $(src)/imx-usb-loader-windows
+endif # ifneq ($(OUTPUT),)
+
+# Make's built-in functions such as $(abspath ...), $(realpath ...) cannot
+# expand a shell special character '~'. We use a somewhat tedious way here.
+obj := $(shell mkdir -p $(OUTPUT) && cd $(OUTPUT) && pwd)
+$(if $(obj),, \
+ $(error failed to create output directory "$(OUTPUT)"))
+
+# $(realpath ...) resolves symlinks
+obj := $(realpath $(obj))
+
+CPPFLAGS := -I $(LIBUSB_MINGW)/include/libusb-1.0 -I $(src)/../include/ -I $(src)/../../include/mach/
+LDFLAGS := -L $(LIBUSB_MINGW)/lib -lusb-1.0 -static
+
+OBJECTS := $(addprefix $(obj)/, imx.o imx-usb-loader.o)
+
+$(obj)/%.o: $(src)/%.c
+ @$(CC) -c -o $@ $< $(CPPFLAGS)
+
+$(obj)/imx-usb-loader.exe: $(OBJECTS)
+ @$(CC) -o $@ $(OBJECTS) $(LDFLAGS)
+
+all: $(obj)/imx-usb-loader.exe
+
+.PHONY: clean
+clean:
+ @rm -rf $(obj)
--
2.39.2
next reply other threads:[~2023-10-18 14:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-18 14:40 Marco Felsch [this message]
2023-11-01 8:52 ` Sascha Hauer
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=20231018144038.504641-1-m.felsch@pengutronix.de \
--to=m.felsch@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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