On Fri, May 1, 2020 at 10:53 AM Marek Behún <marek.behun@xxxxxx> wrote: > > 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@xxxxxx> > Cc: Pavel Modilaynen <pavel.modilaynen@xxxxxxxx> > Cc: Rob Herring <robh+dt@xxxxxxxxxx> > --- Is it possible to fix the .pc file instead? This is ugly, and I do not know what is the point of pkg-config if it cannot detect the pkg correctly. > 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 > -- Best Regards Masahiro Yamada