mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-17 09:14:19 +08:00
f8d8b46cd2
Commit 067c650c45
("dtc: Use pkg-config to locate libyaml") added
'pkg-config --libs' to link libyaml installed in a non-standard
location.
yamltree.c includes <yaml.h>, but that commit did not add the search
path for <yaml.h>. 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 <prefix>/include' HOSTLDFLAGS='-L <prefix>/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 <masahiroy@kernel.org>
Signed-off-by: Rob Herring <robh@kernel.org>
35 lines
1.2 KiB
Makefile
35 lines
1.2 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
# scripts/dtc makefile
|
|
|
|
hostprogs := dtc
|
|
always-$(CONFIG_DTC) += $(hostprogs)
|
|
always-$(CHECK_DT_BINDING) += $(hostprogs)
|
|
|
|
dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \
|
|
srcpos.o checks.o util.o
|
|
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),)
|
|
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
|
|
# To include <yaml.h> 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
|
|
|
|
# Generated files need one more search path to include headers in source tree
|
|
HOSTCFLAGS_dtc-lexer.lex.o := -I $(srctree)/$(src)
|
|
HOSTCFLAGS_dtc-parser.tab.o := -I $(srctree)/$(src)
|
|
|
|
# dependencies on generated files need to be listed explicitly
|
|
$(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h
|