[PATCH v2 05/30] pylibfdt: Allow building on Windows

Simon Glass sjg at chromium.org
Sun Apr 30 03:29:38 CEST 2023


Handle the different shared-object extension with MSYS2 by creating a new
SOEXT variable.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v2:
- Use LIBEXT instead of SOEXT

 Makefile                      | 11 +++++++++++
 scripts/dtc/pylibfdt/Makefile | 16 +++++++++-------
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 166acba27032..2453a80eca62 100644
--- a/Makefile
+++ b/Makefile
@@ -39,6 +39,17 @@ else ifeq ("riscv64", $(MK_ARCH))
 endif
 undefine MK_ARCH
 
+# Building on Windows with MSYS2
+export MSYS_VERSION = $(if $(findstring Msys, $(shell uname -o)),$(word 1, $(subst ., ,$(shell uname -r))),0)
+# $(info The version of MSYS you are running is $(MSYS_VERSION) (0 meaning not MSYS at all))
+
+# Sets the extension to use for shared-object files
+ifeq ($(MSYS_VERSION),0)
+export LIBEXT := so
+else
+export LIBEXT := dll
+endif
+
 # Avoid funny character set dependencies
 unexport LC_ALL
 LC_COLLATE=C
diff --git a/scripts/dtc/pylibfdt/Makefile b/scripts/dtc/pylibfdt/Makefile
index e442d5c24201..314ef91e527b 100644
--- a/scripts/dtc/pylibfdt/Makefile
+++ b/scripts/dtc/pylibfdt/Makefile
@@ -7,6 +7,8 @@ LIBFDT_srcdir = $(abspath $(srctree)/$(src)/../libfdt)
 
 include $(LIBFDT_srcdir)/Makefile.libfdt
 
+LIBFILE := _libfdt.$(LIBEXT)
+
 # Unfortunately setup.py (or actually the Python distutil implementation) puts
 # files into the same directory as the .i file. We cannot touch the source
 # directory, so we "ship" .i file into the objtree.
@@ -29,16 +31,16 @@ quiet_cmd_pymod = PYMOD   $@
 rebuild: $(src)/setup.py $(PYLIBFDT_srcs)
 	@# Remove the library since otherwise Python doesn't seem to regenerate
 	@# the libfdt.py file if it is missing.
-	@rm -f $(obj)/_libfdt*.so
+	@rm -f $(obj)/_libfdt*.$(LIBEXT)
 	$(call if_changed,pymod)
-	@# Rename the file to _libfdt.so so this Makefile doesn't run every time
-	@if [ ! -e $(obj)/_libfdt.so ]; then \
-		mv $(obj)/_libfdt*.so $(obj)/_libfdt.so; \
+	@# Rename the file to $(LIBFILE) so this Makefile doesn't run every time
+	@if [ ! -e $(obj)/$(LIBFILE) ]; then \
+		mv $(obj)/_libfdt*.$(LIBEXT) $(obj)/$(LIBFILE); \
 	fi
 
-$(obj)/_libfdt.so $(obj)/libfdt.py &: rebuild
+$(obj)/$(LIBFILE) $(obj)/libfdt.py &: rebuild
 	@:
 
-always += _libfdt.so libfdt.py
+always += $(LIBFILE) libfdt.py
 
-clean-files += libfdt.i _libfdt.so libfdt.py libfdt_wrap.c
+clean-files += libfdt.i $(LIBFILE) libfdt.py libfdt_wrap.c
-- 
2.40.1.495.gc816e09b53d-goog



More information about the U-Boot mailing list