mk: use _file_content instead of echo | cat

Use _file_content function to retrieve port hash instead of 'echo | cat'
construct that lead to 'Broken pipe' erros in GNU Make 4.4.

issue #4725
This commit is contained in:
Sebastian Sumpf 2023-01-19 15:36:47 +01:00 committed by Christian Helmuth
parent d33139c40a
commit 437fd21ba0

View File

@ -20,6 +20,12 @@ $(eval $2 += $1)
$1
endef
#
# Utility to read content from a file if it exists and the given file name
# is not empty.
#
_file_content = $(if $(wildcard $1),$(shell cat $1),)
#
# Lookup port directory by a given port name
#
@ -29,16 +35,13 @@ endef
# its contained hash number to construct the path to the corresponding
# subdirectory within CONTRIB_DIR. Finally, we check if the path exists.
#
# When reading the hash file in the '_hash_of_port' function, we feed stdin
# to 'cat' to prevent 'cat' from blocking if the hash file is missing.
#
# As a side effect of calling 'select_from_ports' we log the used hash file
# in the 'PORT_HASH_FILES' variable. This enables us incorporate the hash file
# as dependency for all object files.
#
_lookup_port_hash_file = $(wildcard $(addsuffix /ports/$1.hash,$(REPOSITORIES)))
_capture_port_hash_file = $(call _capture,$(call _lookup_port_hash_file,$1),PORT_HASH_FILES)
_hash_of_port = $(shell echo | cat $(call _capture_port_hash_file,$1))
_hash_of_port = $(call _file_content,$(call _capture_port_hash_file,$1))
_port_dir = $(wildcard $(CONTRIB_DIR)/$1-$(call _hash_of_port,$1))
#