pylibfdt: compile pylibfdt only when dtoc/binman is necessary

Currently, pylibfdt is always compiled if swig is installed on your
machine.  It is really annoying because most of targets (excepts
x86, sunxi, rockchip) do not use dtoc or binman.

"checkbinman" and "checkdtoc" are wrong.  It is odd that the final
build stage checks if we have built necessary tools.  If your platform
depends on dtoc/binman, you must be able to build pylibfdt.  If swig
is not installed, it should fail immediately.

I added PYLIBFDT, DTOC, BINMAN entries to Kconfig.  They should be
property select:ed by platforms that need them.  Kbuild will descend
into scripts/dtc/pylibfdt/ only when CONFIG_PYLIBFDT is enabled.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Masahiro Yamada 2017-10-17 13:42:44 +09:00 committed by Tom Rini
parent 15b97f5c5e
commit d6a0c78a4e
6 changed files with 20 additions and 29 deletions

View file

@ -1135,7 +1135,7 @@ cmd_ldr = $(LD) $(LDFLAGS_$(@F)) \
u-boot.rom: u-boot-x86-16bit.bin u-boot.bin \ u-boot.rom: u-boot-x86-16bit.bin u-boot.bin \
$(if $(CONFIG_SPL_X86_16BIT_INIT),spl/u-boot-spl.bin) \ $(if $(CONFIG_SPL_X86_16BIT_INIT),spl/u-boot-spl.bin) \
$(if $(CONFIG_HAVE_REFCODE),refcode.bin) checkbinman FORCE $(if $(CONFIG_HAVE_REFCODE),refcode.bin) FORCE
$(call if_changed,binman) $(call if_changed,binman)
OBJCOPYFLAGS_u-boot-x86-16bit.bin := -O binary -j .start16 -j .resetvec OBJCOPYFLAGS_u-boot-x86-16bit.bin := -O binary -j .start16 -j .resetvec
@ -1144,8 +1144,7 @@ u-boot-x86-16bit.bin: u-boot FORCE
endif endif
ifneq ($(CONFIG_ARCH_SUNXI),) ifneq ($(CONFIG_ARCH_SUNXI),)
u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.img u-boot.dtb \ u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.img u-boot.dtb FORCE
checkbinman FORCE
$(call if_changed,binman) $(call if_changed,binman)
endif endif
@ -1379,18 +1378,6 @@ $(version_h): include/config/uboot.release FORCE
$(timestamp_h): $(srctree)/Makefile FORCE $(timestamp_h): $(srctree)/Makefile FORCE
$(call filechk,timestamp.h) $(call filechk,timestamp.h)
checkbinman: tools
@if ! ( echo 'import libfdt' | ( PYTHONPATH=scripts/dtc/pylibfdt $(PYTHON) )); then \
echo >&2; \
echo >&2 '*** binman needs the Python libfdt library.'; \
echo >&2 '*** Either install it on your system, or try:'; \
echo >&2 '***'; \
echo >&2 '*** sudo apt-get install swig libpython-dev'; \
echo >&2 '***'; \
echo >&2 '*** to have U-Boot build its own version.'; \
false; \
fi
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
quiet_cmd_cpp_lds = LDS $@ quiet_cmd_cpp_lds = LDS $@
cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) \ cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) \

View file

@ -675,6 +675,7 @@ config ARCH_SOCFPGA
config ARCH_SUNXI config ARCH_SUNXI
bool "Support sunxi (Allwinner) SoCs" bool "Support sunxi (Allwinner) SoCs"
select BINMAN
select CMD_GPIO select CMD_GPIO
select CMD_MMC if MMC select CMD_MMC if MMC
select CMD_USB if DISTRO_DEFAULTS select CMD_USB if DISTRO_DEFAULTS

View file

@ -152,6 +152,7 @@ config SMM_TSEG_SIZE
config X86_RESET_VECTOR config X86_RESET_VECTOR
bool bool
default n default n
select BINMAN
# The following options control where the 16-bit and 32-bit init lies # The following options control where the 16-bit and 32-bit init lies
# If SPL is enabled then it normally holds this init code, and U-Boot proper # If SPL is enabled then it normally holds this init code, and U-Boot proper

View file

@ -8,6 +8,17 @@ config SUPPORT_OF_CONTROL
config DTC config DTC
bool bool
config PYLIBFDT
bool
config DTOC
bool
select PYLIBFDT
config BINMAN
bool
select DTOC
menu "Device Tree Control" menu "Device Tree Control"
depends on SUPPORT_OF_CONTROL depends on SUPPORT_OF_CONTROL
@ -231,6 +242,7 @@ config OF_SPL_REMOVE_PROPS
config SPL_OF_PLATDATA config SPL_OF_PLATDATA
bool "Generate platform data for use in SPL" bool "Generate platform data for use in SPL"
depends on SPL_OF_CONTROL depends on SPL_OF_CONTROL
select DTOC
help help
For very constrained SPL environments the overhead of decoding For very constrained SPL environments the overhead of decoding
device tree nodes and converting their contents into platform data device tree nodes and converting their contents into platform data
@ -252,6 +264,7 @@ config SPL_OF_PLATDATA
config TPL_OF_PLATDATA config TPL_OF_PLATDATA
bool "Generate platform data for use in TPL" bool "Generate platform data for use in TPL"
depends on TPL_OF_CONTROL depends on TPL_OF_CONTROL
select DTOC
help help
For very constrained SPL environments the overhead of decoding For very constrained SPL environments the overhead of decoding
device tree nodes and converting their contents into platform data device tree nodes and converting their contents into platform data

View file

@ -276,10 +276,10 @@ PHONY += dts_dir
dts_dir: dts_dir:
$(shell [ -d $(obj)/dts ] || mkdir -p $(obj)/dts) $(shell [ -d $(obj)/dts ] || mkdir -p $(obj)/dts)
include/generated/dt-structs-gen.h: $(obj)/$(SPL_BIN).dtb dts_dir checkdtoc include/generated/dt-structs-gen.h: $(obj)/$(SPL_BIN).dtb dts_dir FORCE
$(call if_changed,dtoch) $(call if_changed,dtoch)
$(obj)/dts/dt-platdata.c: $(obj)/$(SPL_BIN).dtb dts_dir checkdtoc $(obj)/dts/dt-platdata.c: $(obj)/$(SPL_BIN).dtb dts_dir FORCE
$(call if_changed,dtocc) $(call if_changed,dtocc)
ifdef CONFIG_SAMSUNG ifdef CONFIG_SAMSUNG
@ -380,17 +380,6 @@ ifneq ($(cmd_files),)
include $(cmd_files) include $(cmd_files)
endif endif
checkdtoc: tools
@if ! ( echo 'import libfdt' | ( PYTHONPATH=scripts/dtc/pylibfdt $(PYTHON) )); then \
echo '*** dtoc needs the Python libfdt library. Either '; \
echo '*** install it on your system, or try:'; \
echo '***'; \
echo '*** sudo apt-get install swig libpython-dev'; \
echo '***'; \
echo '*** to have U-Boot build its own version.'; \
false; \
fi
PHONY += FORCE PHONY += FORCE
FORCE: FORCE:

View file

@ -31,4 +31,4 @@ $(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h
clean-files := dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h clean-files := dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h
# Added for U-Boot # Added for U-Boot
subdir-y += pylibfdt subdir-$(CONFIG_PYLIBFDT) += pylibfdt