diff options
author | Marco Felsch <m.felsch@pengutronix.de> | 2023-10-18 16:40:38 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-11-01 09:52:36 +0100 |
commit | 066a6b11456547471e5b1f949b3e9ca0865d79f6 (patch) | |
tree | b734bc319e2733b68327cb147b452d1b81eb0927 /scripts | |
parent | d5f934878f05245e3279d137b7cff240e9659278 (diff) | |
download | barebox-066a6b11456547471e5b1f949b3e9ca0865d79f6.tar.gz barebox-066a6b11456547471e5b1f949b3e9ca0865d79f6.tar.xz |
scripts: imx: add Makefile.mingw64
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>
Link: https://lore.barebox.org/20231018144038.504641-1-m.felsch@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/imx/Makefile.mingw64 | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/scripts/imx/Makefile.mingw64 b/scripts/imx/Makefile.mingw64 new file mode 100644 index 0000000000..e012d833f1 --- /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) |