[PATCH] scripts: imx: add Makefile.mingw64

Sascha Hauer sha at pengutronix.de
Wed Nov 1 01:52:46 PDT 2023


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



More information about the barebox mailing list