@@ -12,15 +12,24 @@ dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o
# Source files need to get at the userspace version of libfdt_env.h to compile
HOST_EXTRACFLAGS := -I $(srctree)/$(src)/libfdt
-ifeq ($(shell pkg-config --exists yaml-0.1 2>/dev/null && echo yes),)
+_yaml_libs = $(shell pkg-config --libs yaml-0.1 2>/dev/null)
+_cmd_has_yaml = \
+ { echo "\#include <yaml.h>" ; \
+ echo "int main(){" ; \
+ echo "yaml_get_version(NULL,NULL,NULL);" ; \
+ echo "}" ; } | \
+ $(HOSTCC) -xc - -o /dev/null $(_yaml_libs) 2>/dev/null && echo yes
+_has_yaml = $(shell $(_cmd_has_yaml))
+
+ifeq ($(_has_yaml),yes)
+dtc-objs += yamltree.o
+HOSTLDLIBS_dtc := $(_yaml_libs)
+else
ifneq ($(CHECK_DT_BINDING)$(CHECK_DTBS),)
$(error dtc needs libyaml for DT schema validation support. \
Install the necessary libyaml development package.)
endif
HOST_EXTRACFLAGS += -DNO_YAML
-else
-dtc-objs += yamltree.o
-HOSTLDLIBS_dtc := $(shell pkg-config yaml-0.1 --libs)
endif
# Generated files need one more search path to include headers in source tree
The current check for libyaml based on pkg-config may succeed even if yaml.h header is missing. Try to determine if the header is also present by compiling a simple program. Fixes: 067c650c456e ("dtc: Use pkg-config to locate libyaml") Signed-off-by: Marek BehĂșn <marek.behun@nic.cz> Cc: Pavel Modilaynen <pavel.modilaynen@axis.com> Cc: Rob Herring <robh+dt@kernel.org> --- scripts/dtc/Makefile | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)