From: Masahiro Yamada Date: Tue, 5 May 2020 10:03:19 +0000 (+0900) Subject: scripts/dtc: use pkg-config to include in non-standard path X-Git-Tag: baikal/mips/sdk5.9~13394^2~1 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=d5d0dabbdbd7a62c4cc0455f40bb45ef5bcc5091;p=kernel.git scripts/dtc: use pkg-config to include in non-standard path Commit 09f68c6e793f ("dtc: Use pkg-config to locate libyaml") added 'pkg-config --libs' to link libyaml installed in a non-standard location. yamltree.c includes , but that commit did not add the search path for . If /usr/include/yaml.h does not exist, it fails to build. A user can explicitly pass HOSTCFLAGS to work around it, but the policy is not consistent. There are two ways to deal with libraries in a non-default location. [1] Use HOSTCFLAGS and HOSTLDFLAGS for additional search paths for headers and libraries. They are documented in Documentation/kbuild/kbuild.rst $ make HOSTCFLAGS='-I /include' HOSTLDFLAGS='-L /lib' [2] Use pkg-config 'pkg-config --cflags' for querying the header search path 'pkg-config --libs' for querying the lib and its path If we go with pkg-config, use [2] consistently. Do not mix up [1] and [2]. Signed-off-by: Masahiro Yamada Signed-off-by: Rob Herring --- diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile index ef85f8b7d4a76..0b44917f981c7 100644 --- a/scripts/dtc/Makefile +++ b/scripts/dtc/Makefile @@ -20,6 +20,9 @@ endif HOST_EXTRACFLAGS += -DNO_YAML else dtc-objs += yamltree.o +# To include installed in a non-default path +HOSTCFLAGS_yamltree.o := $(shell pkg-config --cflags yaml-0.1) +# To link libyaml installed in a non-default path HOSTLDLIBS_dtc := $(shell pkg-config yaml-0.1 --libs) endif