[PATCH 06/31] pylibfdt: Allow building on Windows

Pali Rohár pali at kernel.org
Tue Apr 25 18:18:00 CEST 2023


On Monday 24 April 2023 17:08:11 Simon Glass wrote:
> Handle the different shared-object extension with MSYS2 by creating a new
> SOEXT variable.

LIBEXT would be a better name as "SO" name refers to ELF.
I saw that variable LIBEXT is used in more projects for this purpose.

> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
> 
>  Makefile                      | 11 +++++++++++
>  scripts/dtc/pylibfdt/Makefile | 16 +++++++++-------
>  2 files changed, 20 insertions(+), 7 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index eaaf7d267d31..dd3fcd1782e5 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 SOEXT := so
> +else
> +export SOEXT := 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..feca0bb9abb1 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.$(SOEXT)
> +
>  # 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*.$(SOEXT)
>  	$(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*.$(SOEXT) $(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.0.634.g4ca3ef3211-goog
> 


More information about the U-Boot mailing list