devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dtc: Use better check for libyaml
@ 2020-05-01  1:51 Marek Behún
  2020-05-01  5:27 ` Masahiro Yamada
  2020-05-01 19:37 ` [PATCH v2] " Marek Behún
  0 siblings, 2 replies; 7+ messages in thread
From: Marek Behún @ 2020-05-01  1:51 UTC (permalink / raw)
  To: devicetree; +Cc: Marek Behún, Pavel Modilaynen, Rob Herring

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(-)

diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile
index ef85f8b7d4a7..75045787f897 100644
--- a/scripts/dtc/Makefile
+++ b/scripts/dtc/Makefile
@@ -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
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-05-04  1:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-01  1:51 [PATCH] dtc: Use better check for libyaml Marek Behún
2020-05-01  5:27 ` Masahiro Yamada
2020-05-01 15:08   ` Marek Behun
2020-05-02 17:56     ` Masahiro Yamada
2020-05-02 18:16       ` Marek Behun
2020-05-04  1:34         ` Masahiro Yamada
2020-05-01 19:37 ` [PATCH v2] " Marek Behún

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).