mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] scripts: imx: add Makefile.mingw64
@ 2023-10-18 14:40 Marco Felsch
  2023-11-01  8:52 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Marco Felsch @ 2023-10-18 14:40 UTC (permalink / raw)
  To: barebox

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




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

* Re: [PATCH] scripts: imx: add Makefile.mingw64
  2023-10-18 14:40 [PATCH] scripts: imx: add Makefile.mingw64 Marco Felsch
@ 2023-11-01  8:52 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2023-11-01  8:52 UTC (permalink / raw)
  To: Marco Felsch; +Cc: barebox

On Wed, Oct 18, 2023 at 04:40:38PM +0200, Marco Felsch wrote:
> 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

Applied, thanks

Sascha

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

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

end of thread, other threads:[~2023-11-01  8:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-18 14:40 [PATCH] scripts: imx: add Makefile.mingw64 Marco Felsch
2023-11-01  8:52 ` Sascha Hauer

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