kbuild: Bump the build system to 6.1
Our last sync with the kernel was 5.1. We are so out of sync now, that tracking the patches and backporting them one by one makes little sense and it's going to take ages. This is an attempt to sync up Makefiles to 6.1. Unfortunately due to sheer amount of patches this is not easy to review, but that's what we decided during a community call for the bump to 5.1, so we are following the same guidelines here. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>a #rebased on -next
This commit is contained in:
+52
-182
@@ -1,3 +1,4 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
####
|
||||
# kbuild: Generic definitions
|
||||
|
||||
@@ -15,7 +16,11 @@ pound := \#
|
||||
dot-target = $(dir $@).$(notdir $@)
|
||||
|
||||
###
|
||||
# The temporary file to save gcc -MD generated dependencies must not
|
||||
# Name of target with a '.tmp_' as filename prefix. foo/bar.o => foo/.tmp_bar.o
|
||||
tmp-target = $(dir $@).tmp_$(notdir $@)
|
||||
|
||||
###
|
||||
# The temporary file to save gcc -MMD generated dependencies must not
|
||||
# contain a comma
|
||||
depfile = $(subst $(comma),_,$(dot-target).d)
|
||||
|
||||
@@ -23,10 +28,6 @@ depfile = $(subst $(comma),_,$(dot-target).d)
|
||||
# filename of target with directory and extension stripped
|
||||
basetarget = $(basename $(notdir $@))
|
||||
|
||||
###
|
||||
# filename of first prerequisite with directory and extension stripped
|
||||
baseprereq = $(basename $(notdir $<))
|
||||
|
||||
###
|
||||
# real prerequisites without phony targets
|
||||
real-prereqs = $(filter-out $(PHONY), $^)
|
||||
@@ -36,8 +37,8 @@ real-prereqs = $(filter-out $(PHONY), $^)
|
||||
escsq = $(subst $(squote),'\$(squote)',$1)
|
||||
|
||||
###
|
||||
# real prerequisites without phony targets
|
||||
real-prereqs = $(filter-out $(PHONY), $^)
|
||||
# Quote a string to pass it to C files. foo => '"foo"'
|
||||
stringify = $(squote)$(quote)$1$(quote)$(squote)
|
||||
|
||||
###
|
||||
# Easy method for doing a status message
|
||||
@@ -49,6 +50,7 @@ kecho := $($(quiet)kecho)
|
||||
###
|
||||
# filechk is used to check if the content of a generated file is updated.
|
||||
# Sample usage:
|
||||
#
|
||||
# filechk_sample = echo $(KERNELRELEASE)
|
||||
# version.h: FORCE
|
||||
# $(call filechk,sample)
|
||||
@@ -58,141 +60,24 @@ kecho := $($(quiet)kecho)
|
||||
# - If no file exist it is created
|
||||
# - If the content differ the new file is used
|
||||
# - If they are equal no change, and no timestamp update
|
||||
# - stdin is piped in from the first prerequisite ($<) so one has
|
||||
# to specify a valid file as first prerequisite (often the kbuild file)
|
||||
define filechk
|
||||
$(Q)set -e; \
|
||||
mkdir -p $(dir $@); \
|
||||
$(filechk_$(1)) < $< > $@.tmp; \
|
||||
if [ -r $@ ] && cmp -s $@ $@.tmp; then \
|
||||
rm -f $@.tmp; \
|
||||
else \
|
||||
$(kecho) ' UPD $@'; \
|
||||
mv -f $@.tmp $@; \
|
||||
$(check-FORCE)
|
||||
$(Q)set -e; \
|
||||
mkdir -p $(dir $@); \
|
||||
trap "rm -f $(dot-target).tmp" EXIT; \
|
||||
{ $(filechk_$(1)); } > $(dot-target).tmp; \
|
||||
if [ ! -r $@ ] || ! cmp -s $@ $(dot-target).tmp; then \
|
||||
$(kecho) ' UPD $@'; \
|
||||
mv -f $(dot-target).tmp $@; \
|
||||
fi
|
||||
endef
|
||||
|
||||
######
|
||||
# gcc support functions
|
||||
# See documentation in Documentation/kbuild/makefiles.txt
|
||||
|
||||
# cc-cross-prefix
|
||||
# Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-)
|
||||
# Return first prefix where a prefix$(CC) is found in PATH.
|
||||
# If no $(CC) found in PATH with listed prefixes return nothing
|
||||
cc-cross-prefix = \
|
||||
$(word 1, $(foreach c,$(1), \
|
||||
$(shell set -e; \
|
||||
if (which $(strip $(c))$(CC)) > /dev/null 2>&1 ; then \
|
||||
echo $(c); \
|
||||
fi)))
|
||||
|
||||
# output directory for tests below
|
||||
TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
|
||||
|
||||
# try-run
|
||||
# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
|
||||
# Exit code chooses option. "$$TMP" is can be used as temporary file and
|
||||
# is automatically cleaned up.
|
||||
# modifed for U-Boot: prevent cc-option from leaving .*.su files
|
||||
try-run = $(shell set -e; \
|
||||
TMP="$(TMPOUT).$$$$.tmp"; \
|
||||
TMPO="$(TMPOUT).$$$$.o"; \
|
||||
TMPSU="$(TMPOUT).$$$$.su"; \
|
||||
if ($(1)) >/dev/null 2>&1; \
|
||||
then echo "$(2)"; \
|
||||
else echo "$(3)"; \
|
||||
fi; \
|
||||
rm -f "$$TMP" "$$TMPO" "$$TMPSU")
|
||||
|
||||
# as-option
|
||||
# Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
|
||||
|
||||
as-option = $(call try-run,\
|
||||
$(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2))
|
||||
|
||||
# as-instr
|
||||
# Usage: cflags-y += $(call as-instr,instr,option1,option2)
|
||||
|
||||
as-instr = $(call try-run,\
|
||||
printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
|
||||
|
||||
# __cc-option
|
||||
# Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
|
||||
__cc-option = $(call try-run,\
|
||||
$(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4))
|
||||
|
||||
# cc-option
|
||||
# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
|
||||
cc-option = $(call __cc-option, $(CC),\
|
||||
$(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS),$(1),$(2))
|
||||
|
||||
# hostcc-option
|
||||
# Usage: cflags-y += $(call hostcc-option,-march=winchip-c6,-march=i586)
|
||||
hostcc-option = $(call __cc-option, $(HOSTCC),\
|
||||
$(HOSTCFLAGS) $(HOST_EXTRACFLAGS),$(1),$(2))
|
||||
|
||||
# cc-option-yn
|
||||
# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
|
||||
cc-option-yn = $(call try-run,\
|
||||
$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
|
||||
|
||||
# cc-disable-warning
|
||||
# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
|
||||
cc-disable-warning = $(call try-run,\
|
||||
$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
|
||||
|
||||
# cc-name
|
||||
# Expands to either gcc or clang
|
||||
cc-name = $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc)
|
||||
|
||||
# cc-version
|
||||
cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC))
|
||||
|
||||
# cc-ifversion
|
||||
# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
|
||||
cc-ifversion = $(shell [ $(cc-version) $(1) $(2) ] && echo $(3) || echo $(4))
|
||||
|
||||
# added for U-Boot
|
||||
binutils-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/binutils-version.sh $(AS))
|
||||
dtc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/dtc-version.sh $(DTC))
|
||||
|
||||
# cc-ldoption
|
||||
# Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)
|
||||
cc-ldoption = $(call try-run,\
|
||||
$(CC) $(1) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
|
||||
|
||||
# ld-option
|
||||
# Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)
|
||||
ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3))
|
||||
|
||||
# ar-option
|
||||
# Usage: KBUILD_ARFLAGS := $(call ar-option,D)
|
||||
# Important: no spaces around options
|
||||
ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2))
|
||||
|
||||
# ld-version
|
||||
# Note this is mainly for HJ Lu's 3 number binutil versions
|
||||
ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh)
|
||||
|
||||
# ld-ifversion
|
||||
# Usage: $(call ld-ifversion, -ge, 22252, y)
|
||||
ld-ifversion = $(shell [ $(ld-version) $(1) $(2) ] && echo $(3) || echo $(4))
|
||||
|
||||
######
|
||||
|
||||
###
|
||||
# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
|
||||
# Usage:
|
||||
# $(Q)$(MAKE) $(build)=dir
|
||||
build := -f $(srctree)/scripts/Makefile.build obj
|
||||
|
||||
###
|
||||
# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj=
|
||||
# Usage:
|
||||
# $(Q)$(MAKE) $(modbuiltin)=dir
|
||||
modbuiltin := -f $(srctree)/scripts/Makefile.modbuiltin obj
|
||||
|
||||
###
|
||||
# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.dtbinst obj=
|
||||
# Usage:
|
||||
@@ -205,30 +90,18 @@ dtbinst := -f $(srctree)/scripts/Makefile.dtbinst obj
|
||||
# $(Q)$(MAKE) $(clean)=dir
|
||||
clean := -f $(srctree)/scripts/Makefile.clean obj
|
||||
|
||||
###
|
||||
# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.headersinst obj=
|
||||
# Usage:
|
||||
# $(Q)$(MAKE) $(hdr-inst)=dir
|
||||
hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
|
||||
|
||||
# Prefix -I with $(srctree) if it is not an absolute path.
|
||||
# skip if -I has no parameter
|
||||
addtree = $(if $(patsubst -I%,%,$(1)), \
|
||||
$(if $(filter-out -I/% -I./% -I../%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1)),$(1))
|
||||
|
||||
# Find all -I options and call addtree
|
||||
flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
|
||||
|
||||
# echo command.
|
||||
# Short version is used, if $(quiet) equals `quiet_', otherwise full one.
|
||||
echo-cmd = $(if $($(quiet)cmd_$(1)),\
|
||||
echo ' $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';)
|
||||
|
||||
# printing commands
|
||||
cmd = @set -e; $(echo-cmd) $(cmd_$(1))
|
||||
# sink stdout for 'make -s'
|
||||
redirect :=
|
||||
quiet_redirect :=
|
||||
silent_redirect := exec >/dev/null;
|
||||
|
||||
# Add $(obj)/ for paths that are not absolute
|
||||
objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
|
||||
# printing commands
|
||||
cmd = @set -e; $(echo-cmd) $($(quiet)redirect) $(cmd_$(1))
|
||||
|
||||
###
|
||||
# if_changed - execute command if any prerequisite is newer than
|
||||
@@ -236,15 +109,15 @@ objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
|
||||
# if_changed_dep - as if_changed, but uses fixdep to reveal dependencies
|
||||
# including used config symbols
|
||||
# if_changed_rule - as if_changed but execute rule instead
|
||||
# See doc/develop/makefiles.rst for more info
|
||||
# See Documentation/kbuild/makefiles.rst for more info
|
||||
|
||||
ifneq ($(KBUILD_NOCMDDEP),1)
|
||||
# Check if both arguments are the same including their order. Result is empty
|
||||
# Check if both commands are the same including their order. Result is empty
|
||||
# string if equal. User may override this check using make KBUILD_NOCMDDEP=1
|
||||
arg-check = $(filter-out $(subst $(space),$(space_escape),$(strip $(cmd_$@))), \
|
||||
cmd-check = $(filter-out $(subst $(space),$(space_escape),$(strip $(cmd_$@))), \
|
||||
$(subst $(space),$(space_escape),$(strip $(cmd_$1))))
|
||||
else
|
||||
arg-check = $(if $(strip $(cmd_$@)),,1)
|
||||
cmd-check = $(if $(strip $(cmd_$@)),,1)
|
||||
endif
|
||||
|
||||
# Replace >$< with >$$< to preserve $ when reloading the .cmd file
|
||||
@@ -255,32 +128,41 @@ endif
|
||||
# (needed for the shell)
|
||||
make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1)))))
|
||||
|
||||
# Find any prerequisites that is newer than target or that does not exist.
|
||||
# Find any prerequisites that are newer than target or that do not exist.
|
||||
# (This is not true for now; $? should contain any non-existent prerequisites,
|
||||
# but it does not work as expected when .SECONDARY is present. This seems a bug
|
||||
# of GNU Make.)
|
||||
# PHONY targets skipped in both cases.
|
||||
any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
|
||||
newer-prereqs = $(filter-out $(PHONY),$?)
|
||||
|
||||
# It is a typical mistake to forget the FORCE prerequisite. Check it here so
|
||||
# no more breakage will slip in.
|
||||
check-FORCE = $(if $(filter FORCE, $^),,$(warning FORCE prerequisite is missing))
|
||||
|
||||
if-changed-cond = $(newer-prereqs)$(cmd-check)$(check-FORCE)
|
||||
|
||||
# Execute command if command has changed or prerequisite(s) are updated.
|
||||
#
|
||||
if_changed = $(if $(strip $(any-prereq) $(arg-check)), \
|
||||
@set -e; \
|
||||
$(echo-cmd) $(cmd_$(1)); \
|
||||
printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
|
||||
if_changed = $(if $(if-changed-cond),$(cmd_and_savecmd),@:)
|
||||
|
||||
cmd_and_savecmd = \
|
||||
$(cmd); \
|
||||
printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd
|
||||
|
||||
# Execute the command and also postprocess generated .d dependencies file.
|
||||
if_changed_dep = $(if $(strip $(any-prereq) $(arg-check)),$(cmd_and_fixdep),@:)
|
||||
if_changed_dep = $(if $(if-changed-cond),$(cmd_and_fixdep),@:)
|
||||
|
||||
cmd_and_fixdep = \
|
||||
$(cmd); \
|
||||
cmd_and_fixdep = \
|
||||
$(cmd); \
|
||||
scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).cmd;\
|
||||
rm -f $(depfile)
|
||||
|
||||
# Usage: $(call if_changed_rule,foo)
|
||||
# Will check if $(cmd_foo) or any of the prerequisites changed,
|
||||
# and if so will execute $(rule_foo).
|
||||
if_changed_rule = $(if $(strip $(any-prereq) $(arg-check)),$(rule_$(1)),@:)
|
||||
if_changed_rule = $(if $(if-changed-cond),$(rule_$(1)),@:)
|
||||
|
||||
###
|
||||
# why - tell why a a target got build
|
||||
# why - tell why a target got built
|
||||
# enabled by make V=2
|
||||
# Output (listed in the order they are checked):
|
||||
# (1) - due to target is PHONY
|
||||
@@ -302,8 +184,8 @@ ifeq ($(KBUILD_VERBOSE),2)
|
||||
why = \
|
||||
$(if $(filter $@, $(PHONY)),- due to target is PHONY, \
|
||||
$(if $(wildcard $@), \
|
||||
$(if $(strip $(any-prereq)),- due to: $(any-prereq), \
|
||||
$(if $(arg-check), \
|
||||
$(if $(newer-prereqs),- due to: $(newer-prereqs), \
|
||||
$(if $(cmd-check), \
|
||||
$(if $(cmd_$@),- due to command line change, \
|
||||
$(if $(filter $@, $(targets)), \
|
||||
- due to missing .cmd file, \
|
||||
@@ -319,22 +201,10 @@ why = \
|
||||
echo-why = $(call escsq, $(strip $(why)))
|
||||
endif
|
||||
|
||||
###############################################################################
|
||||
|
||||
# delete partially updated (i.e. corrupted) files on error
|
||||
.DELETE_ON_ERROR:
|
||||
|
||||
# do not delete intermediate files automatically
|
||||
.SECONDARY:
|
||||
|
||||
ifeq ($(CONFIG_SPL_BUILD),y)
|
||||
PHASE_ := SPL_
|
||||
else
|
||||
ifeq ($(CONFIG_VPL_BUILD),y)
|
||||
PHASE_ := VPL_
|
||||
else
|
||||
ifeq ($(CONFIG_TPL_BUILD),y)
|
||||
PHASE_ := TPL_
|
||||
else
|
||||
PHASE_ :=
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
####
|
||||
# kbuild.uboot: U-Boot specific kbuild definitions
|
||||
|
||||
include $(srctree)/scripts/Kbuild.include
|
||||
|
||||
# Prefix -I with $(srctree) if it is not an absolute path.
|
||||
# skip if -I has no parameter
|
||||
addtree = $(if $(patsubst -I%,%,$(1)), \
|
||||
$(if $(filter-out -I/% -I./% -I../%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1)),$(1))
|
||||
|
||||
# Find all -I options and call addtree
|
||||
flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
|
||||
|
||||
# Add $(obj)/ for paths that are not absolute
|
||||
objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
|
||||
|
||||
# echo command.
|
||||
# Short version is used, if $(quiet) equals `quiet_', otherwise full one.
|
||||
echo-cmd = $(if $($(quiet)cmd_$(1)),\
|
||||
echo ' $(call escsq,$($(quiet)cmd_$(1)))$(why)';)
|
||||
|
||||
# added for U-Boot
|
||||
|
||||
# cc-name
|
||||
# Expands to either gcc or clang
|
||||
cc-name = $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc)
|
||||
|
||||
# cc-version
|
||||
cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC))
|
||||
|
||||
binutils-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/binutils-version.sh $(AS))
|
||||
dtc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/dtc-version.sh $(DTC))
|
||||
|
||||
ifeq ($(CONFIG_SPL_BUILD),y)
|
||||
PHASE_ := SPL_
|
||||
else
|
||||
ifeq ($(CONFIG_VPL_BUILD),y)
|
||||
PHASE_ := VPL_
|
||||
else
|
||||
ifeq ($(CONFIG_TPL_BUILD),y)
|
||||
PHASE_ := TPL_
|
||||
else
|
||||
PHASE_ :=
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
+1
-3
@@ -4,9 +4,7 @@
|
||||
# the kernel for the build process.
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
hostprogs-$(CONFIG_BUILD_BIN2C) += bin2c
|
||||
|
||||
always := $(hostprogs-y)
|
||||
hostprogs-always-$(CONFIG_BUILD_BIN2C) += bin2c
|
||||
|
||||
# Let clean descend into subdirs
|
||||
subdir- += basic kconfig dtc
|
||||
|
||||
@@ -24,7 +24,9 @@ endif
|
||||
|
||||
include include/config/auto.conf
|
||||
|
||||
include scripts/Kbuild.include
|
||||
# include scripts/Kbuild.include
|
||||
include scripts/Kbuild.uboot
|
||||
include scripts/Makefile.compiler
|
||||
|
||||
# Need to define CC and CPP again here in case the top Makefile did not
|
||||
# include config.mk. Some architectures expect CROSS_COMPILE to be defined
|
||||
@@ -36,7 +38,7 @@ include config.mk
|
||||
|
||||
UBOOTINCLUDE := \
|
||||
-Iinclude \
|
||||
$(if $(KBUILD_SRC), -I$(srctree)/include) \
|
||||
$(if $(building_out_of_srctree), -I$(srctree)/include) \
|
||||
-I$(srctree)/arch/$(ARCH)/include \
|
||||
-include $(srctree)/include/linux/kconfig.h
|
||||
|
||||
@@ -129,14 +131,14 @@ include/config.h: scripts/Makefile.autoconf create_symlink FORCE
|
||||
PHONY += create_symlink
|
||||
create_symlink:
|
||||
ifdef CONFIG_CREATE_ARCH_SYMLINK
|
||||
ifneq ($(KBUILD_SRC),)
|
||||
ifdef building_out_of_srctree
|
||||
$(Q)mkdir -p include/asm
|
||||
$(Q)if [ -d $(KBUILD_SRC)/arch/$(ARCH)/mach-$(SOC)/include/mach ]; then \
|
||||
$(Q)if [ -d $(srctree)/arch/$(ARCH)/mach-$(SOC)/include/mach ]; then \
|
||||
dest=arch/$(ARCH)/mach-$(SOC)/include/mach; \
|
||||
else \
|
||||
dest=arch/$(ARCH)/include/asm/arch-$(if $(SOC),$(SOC),$(CPU)); \
|
||||
fi; \
|
||||
ln -fsn $(KBUILD_SRC)/$$dest include/asm/arch
|
||||
ln -fsn $(srctree)/$$dest include/asm/arch
|
||||
else
|
||||
$(Q)if [ -d arch/$(ARCH)/mach-$(SOC)/include/mach ]; then \
|
||||
dest=../../mach-$(SOC)/include/mach; \
|
||||
|
||||
+188
-203
@@ -28,7 +28,8 @@ obj-y :=
|
||||
obj-m :=
|
||||
lib-y :=
|
||||
lib-m :=
|
||||
always :=
|
||||
always-y :=
|
||||
always-m :=
|
||||
targets :=
|
||||
subdir-y :=
|
||||
subdir-m :=
|
||||
@@ -38,6 +39,7 @@ EXTRA_CPPFLAGS :=
|
||||
EXTRA_LDFLAGS :=
|
||||
asflags-y :=
|
||||
ccflags-y :=
|
||||
rustflags-y :=
|
||||
cppflags-y :=
|
||||
ldflags-y :=
|
||||
|
||||
@@ -49,51 +51,70 @@ subdir-ccflags-y :=
|
||||
-include include/config/auto.conf
|
||||
-include $(prefix)/include/autoconf.mk
|
||||
|
||||
include scripts/Kbuild.include
|
||||
# include scripts/Kbuild.include
|
||||
include scripts/Kbuild.uboot
|
||||
include scripts/Makefile.compiler
|
||||
|
||||
# The filename Kbuild has precedence over Makefile
|
||||
kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
|
||||
kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
|
||||
include $(kbuild-file)
|
||||
include $(or $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Makefile)
|
||||
|
||||
# Added for U-Boot
|
||||
asflags-y += $(PLATFORM_CPPFLAGS)
|
||||
ccflags-y += $(PLATFORM_CPPFLAGS)
|
||||
cppflags-y += $(PLATFORM_CPPFLAGS)
|
||||
|
||||
include scripts/Makefile.lib
|
||||
include $(srctree)/scripts/Makefile.lib
|
||||
|
||||
# Do not include host rules unless needed
|
||||
ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
|
||||
include scripts/Makefile.host
|
||||
# Do not include hostprogs rules unless needed.
|
||||
# $(sort ...) is used here to remove duplicated words and excessive spaces.
|
||||
hostprogs := $(sort $(hostprogs))
|
||||
ifneq ($(hostprogs),)
|
||||
include $(srctree)/scripts/Makefile.host
|
||||
endif
|
||||
|
||||
# Do not include userprogs rules unless needed.
|
||||
# $(sort ...) is used here to remove duplicated words and excessive spaces.
|
||||
userprogs := $(sort $(userprogs))
|
||||
ifneq ($(userprogs),)
|
||||
include $(srctree)/scripts/Makefile.userprogs
|
||||
endif
|
||||
|
||||
ifndef obj
|
||||
$(warning kbuild: Makefile.build is included improperly)
|
||||
endif
|
||||
|
||||
ifeq ($(need-modorder),)
|
||||
ifneq ($(obj-m),)
|
||||
$(warning $(patsubst %.o,'%.ko',$(obj-m)) will not be built even though obj-m is specified.)
|
||||
$(warning You cannot use subdir-y/m to visit a module Makefile. Use obj-y/m instead.)
|
||||
endif
|
||||
endif
|
||||
|
||||
# ===========================================================================
|
||||
|
||||
# subdir-builtin and subdir-modorder may contain duplications. Use $(sort ...)
|
||||
subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y)))
|
||||
subdir-modorder := $(sort $(filter %/modules.order, $(obj-m)))
|
||||
|
||||
targets-for-builtin := $(extra-y)
|
||||
|
||||
ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),)
|
||||
lib-target := $(obj)/lib.a
|
||||
# Modified for U-Boot
|
||||
# real-obj-y += $(obj)/lib-ksyms.o
|
||||
targets-for-builtin += $(obj)/lib.a
|
||||
endif
|
||||
|
||||
ifneq ($(strip $(real-obj-y) $(need-builtin)),)
|
||||
builtin-target := $(obj)/built-in.a
|
||||
ifdef need-builtin
|
||||
targets-for-builtin += $(obj)/built-in.a
|
||||
endif
|
||||
|
||||
ifdef CONFIG_MODULES
|
||||
modorder-target := $(obj)/modules.order
|
||||
targets-for-modules := $(foreach x, o mod $(if $(CONFIG_TRIM_UNUSED_KSYMS), usyms), \
|
||||
$(patsubst %.o, %.$x, $(filter %.o, $(obj-m))))
|
||||
|
||||
ifdef need-modorder
|
||||
targets-for-modules += $(obj)/modules.order
|
||||
endif
|
||||
|
||||
# We keep a list of all modules in $(MODVERDIR)
|
||||
|
||||
__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
|
||||
$(if $(KBUILD_MODULES),$(obj-m) $(modorder-target)) \
|
||||
$(subdir-ym) $(always)
|
||||
@:
|
||||
targets += $(targets-for-builtin) $(targets-for-modules)
|
||||
|
||||
# Linus' kernel sanity checking tool
|
||||
ifeq ($(KBUILD_CHECKSRC),1)
|
||||
@@ -104,30 +125,15 @@ else ifeq ($(KBUILD_CHECKSRC),2)
|
||||
cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $<
|
||||
endif
|
||||
|
||||
ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),)
|
||||
ifneq ($(KBUILD_EXTRA_WARN),)
|
||||
cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $<
|
||||
endif
|
||||
|
||||
# Do section mismatch analysis for each module/built-in.a
|
||||
ifdef CONFIG_DEBUG_SECTION_MISMATCH
|
||||
cmd_secanalysis = ; scripts/mod/modpost $@
|
||||
endif
|
||||
|
||||
# Compile C sources (.c)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Default is built-in, unless we know otherwise
|
||||
$(foreach x, i ll lst o s symtypes, $(patsubst %.o,%.$(x),$(real-obj-m))): \
|
||||
part-of-module := y
|
||||
|
||||
modkern_cflags = \
|
||||
$(if $(part-of-module), \
|
||||
$(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
|
||||
$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
|
||||
quiet_modtag = $(if $(part-of-module),[M], )
|
||||
|
||||
quiet_cmd_cc_s_c = CC $(quiet_modtag) $@
|
||||
cmd_cc_s_c = $(CC) $(filter-out $(DEBUG_CFLAGS), $(c_flags)) $(DISABLE_LTO) -fverbose-asm -S -o $@ $<
|
||||
cmd_cc_s_c = $(CC) $(filter-out $(DEBUG_CFLAGS) $(CC_FLAGS_LTO), $(c_flags)) -fverbose-asm -S -o $@ $<
|
||||
|
||||
$(obj)/%.s: $(src)/%.c FORCE
|
||||
$(call if_changed_dep,cc_s_c)
|
||||
@@ -138,18 +144,16 @@ cmd_cpp_i_c = $(CPP) $(c_flags) -o $@ $<
|
||||
$(obj)/%.i: $(src)/%.c FORCE
|
||||
$(call if_changed_dep,cpp_i_c)
|
||||
|
||||
genksyms = scripts/genksyms/genksyms \
|
||||
$(if $(1), -T $(2)) \
|
||||
$(if $(KBUILD_PRESERVE), -p) \
|
||||
-r $(or $(wildcard $(2:.symtypes=.symref)), /dev/null)
|
||||
|
||||
# These mirror gensymtypes_S and co below, keep them in synch.
|
||||
cmd_gensymtypes_c = \
|
||||
$(CPP) -D__GENKSYMS__ $(c_flags) $< | \
|
||||
scripts/genksyms/genksyms $(if $(1), -T $(2)) \
|
||||
$(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \
|
||||
$(if $(KBUILD_PRESERVE),-p) \
|
||||
-r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null))
|
||||
cmd_gensymtypes_c = $(CPP) -D__GENKSYMS__ $(c_flags) $< | $(genksyms)
|
||||
|
||||
quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@
|
||||
cmd_cc_symtypes_c = \
|
||||
$(call cmd_gensymtypes_c,true,$@) >/dev/null; \
|
||||
test -s $@ || rm -f $@
|
||||
cmd_cc_symtypes_c = $(call cmd_gensymtypes_c,true,$@) >/dev/null
|
||||
|
||||
$(obj)/%.symtypes : $(src)/%.c FORCE
|
||||
$(call cmd,cc_symtypes_c)
|
||||
@@ -166,8 +170,18 @@ $(obj)/%.ll: $(src)/%.c FORCE
|
||||
# The C file is compiled and updated dependency information is generated.
|
||||
# (See cmd_cc_o_c + relevant part of rule_cc_o_c)
|
||||
|
||||
is-single-obj-m = $(and $(part-of-module),$(filter $@, $(obj-m)),y)
|
||||
|
||||
# When a module consists of a single object, there is no reason to keep LLVM IR.
|
||||
# Make $(LD) covert LLVM IR to ELF here.
|
||||
ifdef CONFIG_LTO_CLANG
|
||||
cmd_ld_single_m = $(if $(is-single-obj-m), ; $(LD) $(ld_flags) -r -o $(tmp-target) $@; mv $(tmp-target) $@)
|
||||
endif
|
||||
|
||||
quiet_cmd_cc_o_c = CC $(quiet_modtag) $@
|
||||
cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
|
||||
cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< \
|
||||
$(cmd_ld_single_m) \
|
||||
$(cmd_objtool)
|
||||
|
||||
ifdef CONFIG_MODVERSIONS
|
||||
# When module versioning is enabled the following steps are executed:
|
||||
@@ -175,27 +189,21 @@ ifdef CONFIG_MODVERSIONS
|
||||
# o if <file>.o doesn't contain a __ksymtab version, i.e. does
|
||||
# not export symbols, it's done.
|
||||
# o otherwise, we calculate symbol versions using the good old
|
||||
# genksyms on the preprocessed source and postprocess them in a way
|
||||
# that they are usable as a linker script
|
||||
# o generate .tmp_<file>.o from <file>.o using the linker to
|
||||
# replace the unresolved symbols __crc_exported_symbol with
|
||||
# the actual value of the checksum generated by genksyms
|
||||
# o remove .tmp_<file>.o to <file>.o
|
||||
# genksyms on the preprocessed source and dump them into the .cmd file.
|
||||
# o modpost will extract versions from that file and create *.c files that will
|
||||
# be compiled and linked to the kernel and/or modules.
|
||||
|
||||
cmd_modversions_c = \
|
||||
if $(OBJDUMP) -h $@ | grep -q __ksymtab; then \
|
||||
$(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
|
||||
> $(@D)/.tmp_$(@F:.o=.ver); \
|
||||
\
|
||||
$(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ \
|
||||
-T $(@D)/.tmp_$(@F:.o=.ver); \
|
||||
mv -f $(@D)/.tmp_$(@F) $@; \
|
||||
rm -f $(@D)/.tmp_$(@F:.o=.ver); \
|
||||
gen_symversions = \
|
||||
if $(NM) $@ 2>/dev/null | grep -q __ksymtab; then \
|
||||
$(call cmd_gensymtypes_$(1),$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
|
||||
>> $(dot-target).cmd; \
|
||||
fi
|
||||
|
||||
cmd_gen_symversions_c = $(call gen_symversions,c)
|
||||
|
||||
endif
|
||||
|
||||
ifdef CONFIG_FTRACE_MCOUNT_RECORD
|
||||
ifndef CC_USING_RECORD_MCOUNT
|
||||
ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
|
||||
# compiler will not generate __mcount_loc use recordmcount or recordmcount.pl
|
||||
ifdef BUILD_C_RECORDMCOUNT
|
||||
ifeq ("$(origin RECORDMCOUNT_WARN)", "command line")
|
||||
@@ -222,87 +230,60 @@ recordmcount_source := $(srctree)/scripts/recordmcount.pl
|
||||
endif # BUILD_C_RECORDMCOUNT
|
||||
cmd_record_mcount = $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)), \
|
||||
$(sub_cmd_record_mcount))
|
||||
endif # CC_USING_RECORD_MCOUNT
|
||||
endif # CONFIG_FTRACE_MCOUNT_RECORD
|
||||
|
||||
ifdef CONFIG_STACK_VALIDATION
|
||||
ifneq ($(SKIP_STACK_VALIDATION),1)
|
||||
|
||||
__objtool_obj := $(objtree)/tools/objtool/objtool
|
||||
|
||||
objtool_args = $(if $(CONFIG_UNWINDER_ORC),orc generate,check)
|
||||
|
||||
objtool_args += $(if $(part-of-module), --module,)
|
||||
|
||||
ifndef CONFIG_FRAME_POINTER
|
||||
objtool_args += --no-fp
|
||||
endif
|
||||
ifdef CONFIG_GCOV_KERNEL
|
||||
objtool_args += --no-unreachable
|
||||
endif
|
||||
ifdef CONFIG_RETPOLINE
|
||||
objtool_args += --retpoline
|
||||
endif
|
||||
endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
|
||||
|
||||
# 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
|
||||
# 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
|
||||
# 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
|
||||
cmd_objtool = $(if $(patsubst y%,, \
|
||||
$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
|
||||
$(__objtool_obj) $(objtool_args) $@)
|
||||
objtool_obj = $(if $(patsubst y%,, \
|
||||
$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
|
||||
$(__objtool_obj))
|
||||
|
||||
endif # SKIP_STACK_VALIDATION
|
||||
endif # CONFIG_STACK_VALIDATION
|
||||
is-standard-object = $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y)
|
||||
|
||||
# Rebuild all objects when objtool changes, or is enabled/disabled.
|
||||
objtool_dep = $(objtool_obj) \
|
||||
$(wildcard include/config/orc/unwinder.h \
|
||||
include/config/stack/validation.h)
|
||||
$(obj)/%.o: objtool-enabled = $(if $(is-standard-object),$(if $(delay-objtool),$(is-single-obj-m),y))
|
||||
|
||||
ifdef CONFIG_TRIM_UNUSED_KSYMS
|
||||
cmd_gen_ksymdeps = \
|
||||
$(CONFIG_SHELL) $(srctree)/scripts/gen_ksymdeps.sh $@ >> $(dot-target).cmd
|
||||
endif
|
||||
|
||||
cmd_check_local_export = $(srctree)/scripts/check-local-export $@
|
||||
|
||||
define rule_cc_o_c
|
||||
$(call cmd,checksrc)
|
||||
$(call cmd_and_fixdep,cc_o_c)
|
||||
$(call cmd,gen_ksymdeps)
|
||||
$(call cmd,check_local_export)
|
||||
$(call cmd,checksrc)
|
||||
$(call cmd,checkdoc)
|
||||
$(call cmd,objtool)
|
||||
$(call cmd,modversions_c)
|
||||
$(call cmd,gen_objtooldep)
|
||||
$(call cmd,gen_symversions_c)
|
||||
$(call cmd,record_mcount)
|
||||
endef
|
||||
|
||||
define rule_as_o_S
|
||||
$(call cmd_and_fixdep,as_o_S)
|
||||
$(call cmd,gen_ksymdeps)
|
||||
$(call cmd,objtool)
|
||||
$(call cmd,modversions_S)
|
||||
$(call cmd,check_local_export)
|
||||
$(call cmd,gen_objtooldep)
|
||||
$(call cmd,gen_symversions_S)
|
||||
endef
|
||||
|
||||
# List module undefined symbols (or empty line if not enabled)
|
||||
ifdef CONFIG_TRIM_UNUSED_KSYMS
|
||||
cmd_undef_syms = $(NM) $@ | sed -n 's/^ *U //p' | xargs echo
|
||||
else
|
||||
cmd_undef_syms = echo
|
||||
endif
|
||||
|
||||
# Built-in and composite module parts
|
||||
$(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE
|
||||
$(call cmd,force_checksrc)
|
||||
$(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE
|
||||
$(call if_changed_rule,cc_o_c)
|
||||
|
||||
# Single-part modules are special since we need to mark them in $(MODVERDIR)
|
||||
|
||||
$(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE
|
||||
$(call cmd,force_checksrc)
|
||||
$(call if_changed_rule,cc_o_c)
|
||||
@{ echo $(@:.o=.ko); echo $@; \
|
||||
$(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod)
|
||||
|
||||
# To make this rule robust against "Argument list too long" error,
|
||||
# ensure to add $(obj)/ prefix by a shell command.
|
||||
cmd_mod = printf '%s\n' $(call real-search, $*.o, .o, -objs -y -m) | \
|
||||
$(AWK) '!x[$$0]++ { print("$(obj)/"$$0) }' > $@
|
||||
|
||||
$(obj)/%.mod: FORCE
|
||||
$(call if_changed,mod)
|
||||
|
||||
# List module undefined symbols
|
||||
cmd_undefined_syms = $(NM) $< | sed -n 's/^ *U //p' > $@
|
||||
|
||||
$(obj)/%.usyms: $(obj)/%.o FORCE
|
||||
$(call if_changed,undefined_syms)
|
||||
|
||||
quiet_cmd_cc_lst_c = MKLST $@
|
||||
cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
|
||||
@@ -315,11 +296,6 @@ $(obj)/%.lst: $(src)/%.c FORCE
|
||||
# Compile assembler sources (.S)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL)
|
||||
|
||||
$(real-obj-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
|
||||
$(real-obj-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
|
||||
|
||||
# .S file exports must have their C prototypes defined in asm/asm-prototypes.h
|
||||
# or a file that it includes, in order to get versioned symbols. We build a
|
||||
# dummy C file that includes asm-prototypes and the EXPORT_SYMBOL lines from
|
||||
@@ -337,16 +313,10 @@ cmd_gensymtypes_S = \
|
||||
$(CPP) $(a_flags) $< | \
|
||||
grep "\<___EXPORT_SYMBOL\>" | \
|
||||
sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ; } | \
|
||||
$(CPP) -D__GENKSYMS__ $(c_flags) -xc - | \
|
||||
scripts/genksyms/genksyms $(if $(1), -T $(2)) \
|
||||
$(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \
|
||||
$(if $(KBUILD_PRESERVE),-p) \
|
||||
-r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null))
|
||||
$(CPP) -D__GENKSYMS__ $(c_flags) -xc - | $(genksyms)
|
||||
|
||||
quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@
|
||||
cmd_cc_symtypes_S = \
|
||||
$(call cmd_gensymtypes_S,true,$@) >/dev/null; \
|
||||
test -s $@ || rm -f $@
|
||||
cmd_cc_symtypes_S = $(call cmd_gensymtypes_S,true,$@) >/dev/null
|
||||
|
||||
$(obj)/%.symtypes : $(src)/%.S FORCE
|
||||
$(call cmd,cc_symtypes_S)
|
||||
@@ -359,36 +329,23 @@ $(obj)/%.s: $(src)/%.S FORCE
|
||||
$(call if_changed_dep,cpp_s_S)
|
||||
|
||||
quiet_cmd_as_o_S = AS $(quiet_modtag) $@
|
||||
cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
|
||||
cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< $(cmd_objtool)
|
||||
|
||||
ifdef CONFIG_MODVERSIONS
|
||||
|
||||
ASM_PROTOTYPES := $(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/asm-prototypes.h)
|
||||
|
||||
ifneq ($(ASM_PROTOTYPES),)
|
||||
ifdef CONFIG_ASM_MODVERSIONS
|
||||
|
||||
# versioning matches the C process described above, with difference that
|
||||
# we parse asm-prototypes.h C header to get function definitions.
|
||||
|
||||
cmd_modversions_S = \
|
||||
if $(OBJDUMP) -h $@ | grep -q __ksymtab; then \
|
||||
$(call cmd_gensymtypes_S,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
|
||||
> $(@D)/.tmp_$(@F:.o=.ver); \
|
||||
\
|
||||
$(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ \
|
||||
-T $(@D)/.tmp_$(@F:.o=.ver); \
|
||||
mv -f $(@D)/.tmp_$(@F) $@; \
|
||||
rm -f $(@D)/.tmp_$(@F:.o=.ver); \
|
||||
fi
|
||||
endif
|
||||
cmd_gen_symversions_S = $(call gen_symversions,S)
|
||||
|
||||
endif
|
||||
|
||||
$(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE
|
||||
$(obj)/%.o: $(src)/%.S FORCE
|
||||
$(call if_changed_rule,as_o_S)
|
||||
|
||||
targets += $(filter-out $(subdir-obj-y), $(real-obj-y)) $(real-obj-m) $(lib-y)
|
||||
targets += $(extra-y) $(MAKECMDGOALS) $(always)
|
||||
targets += $(real-dtb-y) $(lib-y) $(always-y)
|
||||
targets += $(filter-out $(subdir-builtin), $(real-obj-y))
|
||||
targets += $(filter-out $(subdir-modorder), $(real-obj-m))
|
||||
targets += $(real-dtb-y) $(lib-y) $(always-y) $(MAKECMDGOALS)
|
||||
|
||||
# Linker scripts preprocessor (.lds.S -> .lds)
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -401,9 +358,9 @@ $(obj)/%.lds: $(src)/%.lds.S FORCE
|
||||
|
||||
# ASN.1 grammar
|
||||
# ---------------------------------------------------------------------------
|
||||
quiet_cmd_asn1_compiler = ASN.1 $@
|
||||
quiet_cmd_asn1_compiler = ASN.1 $(basename $@).[ch]
|
||||
cmd_asn1_compiler = $(objtree)/tools/asn1_compiler $< \
|
||||
$(subst .h,.c,$@) $(subst .c,.h,$@)
|
||||
$(basename $@).c $(basename $@).h
|
||||
|
||||
$(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/tools/asn1_compiler
|
||||
$(call cmd,asn1_compiler)
|
||||
@@ -412,79 +369,59 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/tools/asn1_compiler
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# To build objects in subdirs, we need to descend into the directories
|
||||
$(sort $(subdir-obj-y)): $(subdir-ym) ;
|
||||
$(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ;
|
||||
$(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;
|
||||
|
||||
#
|
||||
# Rule to compile a set of .o files into one .a file (without symbol table)
|
||||
#
|
||||
ifdef builtin-target
|
||||
# To make this rule robust against "Argument list too long" error,
|
||||
# remove $(obj)/ prefix, and restore it by a shell command.
|
||||
|
||||
quiet_cmd_ar_builtin = AR $@
|
||||
# Modified for U-Boot, we create thin archives directly, instead of using the kernel script
|
||||
# Check f49821ee32b76 and 6358d6e8b98 in kernel
|
||||
cmd_ar_builtin = rm -f $@; $(AR) rcTP$(KBUILD_ARFLAGS) $@ $(real-prereqs)
|
||||
cmd_ar_builtin = rm -f $@; $(AR) rcTP $@ $(real-prereqs)
|
||||
|
||||
$(builtin-target): $(real-obj-y) FORCE
|
||||
$(obj)/built-in.a: $(real-obj-y) FORCE
|
||||
$(call if_changed,ar_builtin)
|
||||
|
||||
targets += $(builtin-target)
|
||||
endif # builtin-target
|
||||
|
||||
#
|
||||
# Rule to create modules.order file
|
||||
#
|
||||
# Create commands to either record .ko file or cat modules.order from
|
||||
# a subdirectory
|
||||
modorder-cmds = \
|
||||
$(foreach m, $(modorder), \
|
||||
$(if $(filter %/modules.order, $m), \
|
||||
cat $m;, echo kernel/$m;))
|
||||
# Add $(obj-m) as the prerequisite to avoid updating the timestamp of
|
||||
# modules.order unless contained modules are updated.
|
||||
|
||||
$(modorder-target): $(subdir-ym) FORCE
|
||||
$(Q)(cat /dev/null; $(modorder-cmds)) > $@
|
||||
cmd_modules_order = { $(foreach m, $(real-prereqs), \
|
||||
$(if $(filter %/modules.order, $m), cat $m, echo $(patsubst %.o,%.ko,$m));) :; } \
|
||||
| $(AWK) '!x[$$0]++' - > $@
|
||||
|
||||
$(obj)/modules.order: $(obj-m) FORCE
|
||||
$(call if_changed,modules_order)
|
||||
|
||||
#
|
||||
# Rule to compile a set of .o files into one .a file (with symbol table)
|
||||
#
|
||||
ifdef lib-target
|
||||
|
||||
$(lib-target): $(lib-y) FORCE
|
||||
$(obj)/lib.a: $(lib-y) FORCE
|
||||
$(call if_changed,ar)
|
||||
|
||||
targets += $(lib-target)
|
||||
quiet_cmd_ld_multi_m = LD [M] $@
|
||||
cmd_ld_multi_m = $(LD) $(ld_flags) -r -o $@ @$(patsubst %.o,%.mod,$@) $(cmd_objtool)
|
||||
|
||||
dummy-object = $(obj)/.lib_exports.o
|
||||
ksyms-lds = $(dot-target).lds
|
||||
define rule_ld_multi_m
|
||||
$(call cmd_and_savecmd,ld_multi_m)
|
||||
$(call cmd,gen_objtooldep)
|
||||
endef
|
||||
|
||||
quiet_cmd_export_list = EXPORTS $@
|
||||
cmd_export_list = $(OBJDUMP) -h $< | \
|
||||
sed -ne '/___ksymtab/s/.*+\([^ ]*\).*/EXTERN(\1)/p' >$(ksyms-lds);\
|
||||
rm -f $(dummy-object);\
|
||||
echo | $(CC) $(a_flags) -c -o $(dummy-object) -x assembler -;\
|
||||
$(LD) $(ld_flags) -r -o $@ -T $(ksyms-lds) $(dummy-object);\
|
||||
rm $(dummy-object) $(ksyms-lds)
|
||||
$(multi-obj-m): objtool-enabled := $(delay-objtool)
|
||||
$(multi-obj-m): part-of-module := y
|
||||
$(multi-obj-m): %.o: %.mod FORCE
|
||||
$(call if_changed_rule,ld_multi_m)
|
||||
$(call multi_depend, $(multi-obj-m), .o, -objs -y -m)
|
||||
|
||||
$(obj)/lib-ksyms.o: $(lib-target) FORCE
|
||||
$(call if_changed,export_list)
|
||||
|
||||
targets += $(obj)/lib-ksyms.o
|
||||
|
||||
endif
|
||||
|
||||
# NOTE:
|
||||
# Do not replace $(filter %.o,^) with $(real-prereqs). When a single object
|
||||
# module is turned into a multi object module, $^ will contain header file
|
||||
# dependencies recorded in the .*.cmd file.
|
||||
quiet_cmd_link_multi-m = LD [M] $@
|
||||
cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^) $(cmd_secanalysis)
|
||||
|
||||
$(multi-used-m): FORCE
|
||||
$(call if_changed,link_multi-m)
|
||||
@{ echo $(@:.o=.ko); echo $(filter %.o,$^); \
|
||||
$(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod)
|
||||
$(call multi_depend, $(multi-used-m), .o, -objs -y -m)
|
||||
|
||||
targets += $(multi-used-m)
|
||||
targets := $(filter-out $(PHONY), $(targets))
|
||||
|
||||
# Add intermediate targets:
|
||||
@@ -502,12 +439,60 @@ targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \
|
||||
$(call intermediate_targets, .lex.o, .lex.c) \
|
||||
$(call intermediate_targets, .tab.o, .tab.c .tab.h)
|
||||
|
||||
# Build
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
ifdef single-build
|
||||
|
||||
KBUILD_SINGLE_TARGETS := $(filter $(obj)/%, $(KBUILD_SINGLE_TARGETS))
|
||||
|
||||
curdir-single := $(sort $(foreach x, $(KBUILD_SINGLE_TARGETS), \
|
||||
$(if $(filter $(x) $(basename $(x)).o, $(targets)), $(x))))
|
||||
|
||||
# Handle single targets without any rule: show "Nothing to be done for ..." or
|
||||
# "No rule to make target ..." depending on whether the target exists.
|
||||
unknown-single := $(filter-out $(addsuffix /%, $(subdir-ym)), \
|
||||
$(filter-out $(curdir-single), $(KBUILD_SINGLE_TARGETS)))
|
||||
|
||||
single-subdirs := $(foreach d, $(subdir-ym), \
|
||||
$(if $(filter $(d)/%, $(KBUILD_SINGLE_TARGETS)), $(d)))
|
||||
|
||||
__build: $(curdir-single) $(single-subdirs)
|
||||
ifneq ($(unknown-single),)
|
||||
$(Q)$(MAKE) -f /dev/null $(unknown-single)
|
||||
endif
|
||||
@:
|
||||
|
||||
ifeq ($(curdir-single),)
|
||||
# Nothing to do in this directory. Do not include any .*.cmd file for speed-up
|
||||
targets :=
|
||||
else
|
||||
targets += $(curdir-single)
|
||||
endif
|
||||
|
||||
else
|
||||
|
||||
__build: $(if $(KBUILD_BUILTIN), $(targets-for-builtin)) \
|
||||
$(if $(KBUILD_MODULES), $(targets-for-modules)) \
|
||||
$(subdir-ym) $(always-y)
|
||||
@:
|
||||
# @echo "My hostprogs => $(hostprogs)"
|
||||
# @echo "My obj=$(obj)"
|
||||
# @echo "My src=$(src)"
|
||||
# @echo "My target-stem=$(target-stem)"
|
||||
# @echo "My need-builtin=$(need-builtin)"
|
||||
|
||||
endif
|
||||
|
||||
# Descending
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
PHONY += $(subdir-ym)
|
||||
$(subdir-ym):
|
||||
$(Q)$(MAKE) $(build)=$@ need-builtin=$(if $(findstring $@,$(subdir-obj-y)),1)
|
||||
$(Q)$(MAKE) $(build)=$@ \
|
||||
$(if $(filter $@/, $(KBUILD_SINGLE_TARGETS)),single-build=) \
|
||||
need-builtin=$(if $(filter $@/built-in.a, $(subdir-builtin)),1) \
|
||||
need-modorder=$(if $(filter $@/modules.order, $(subdir-modorder)),1)
|
||||
|
||||
# Add FORCE to the prequisites of a target to force it to be always rebuilt.
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -526,7 +511,7 @@ existing-targets := $(wildcard $(sort $(targets)))
|
||||
-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
|
||||
|
||||
# Create directories for object files if they do not exist
|
||||
obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets))))
|
||||
obj-dirs := $(sort $(patsubst %/,%, $(dir $(targets))))
|
||||
# If targets exist, their directories apparently exist. Skip mkdir.
|
||||
existing-dirs := $(sort $(patsubst %/,%, $(dir $(existing-targets))))
|
||||
obj-dirs := $(strip $(filter-out $(existing-dirs), $(obj-dirs)))
|
||||
|
||||
+17
-40
@@ -8,26 +8,20 @@ src := $(obj)
|
||||
PHONY := __clean
|
||||
__clean:
|
||||
|
||||
include scripts/Kbuild.include
|
||||
# include scripts/Kbuild.include
|
||||
include scripts/Kbuild.uboot
|
||||
include scripts/Makefile.compiler
|
||||
|
||||
# The filename Kbuild has precedence over Makefile
|
||||
kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
|
||||
include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)
|
||||
include $(or $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Makefile)
|
||||
|
||||
|
||||
# Figure out what we need to build from the various variables
|
||||
# ==========================================================================
|
||||
|
||||
__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y)))
|
||||
subdir-y += $(__subdir-y)
|
||||
__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m)))
|
||||
subdir-m += $(__subdir-m)
|
||||
__subdir- := $(patsubst %/,%,$(filter %/, $(obj-)))
|
||||
subdir- += $(__subdir-)
|
||||
|
||||
# Subdirectories we need to descend into
|
||||
|
||||
subdir-ym := $(sort $(subdir-y) $(subdir-m))
|
||||
subdir-ymn := $(sort $(subdir-ym) $(subdir-))
|
||||
subdir-ymn := $(sort $(subdir-y) $(subdir-m) $(subdir-) \
|
||||
$(patsubst %/,%, $(filter %/, $(obj-y) $(obj-m) $(obj-))))
|
||||
|
||||
# Add subdir path
|
||||
|
||||
@@ -41,42 +35,25 @@ subdir-ymn := $(foreach f, $(subdir-ymn), \
|
||||
# build a list of files to remove, usually relative to the current
|
||||
# directory
|
||||
|
||||
__clean-files := $(extra-y) $(extra-m) $(extra-) \
|
||||
$(always) $(targets) $(clean-files) \
|
||||
$(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
|
||||
$(hostlibs-y) $(hostlibs-m) $(hostlibs-) \
|
||||
$(hostcxxlibs-y) $(hostcxxlibs-m)
|
||||
__clean-files := \
|
||||
$(clean-files) $(targets) $(hostprogs) $(userprogs) \
|
||||
$(extra-y) $(extra-m) $(extra-) \
|
||||
$(always-y) $(always-m) $(always-) \
|
||||
$(hostprogs-always-y) $(hostprogs-always-m) $(hostprogs-always-) \
|
||||
$(userprogs-always-y) $(userprogs-always-m) $(userprogs-always-)
|
||||
|
||||
__clean-files := $(filter-out $(no-clean-files), $(__clean-files))
|
||||
|
||||
# clean-files is given relative to the current directory, unless it
|
||||
# starts with $(objtree)/ (which means "./", so do not add "./" unless
|
||||
# you want to delete a file from the toplevel object directory).
|
||||
|
||||
__clean-files := $(wildcard \
|
||||
$(addprefix $(obj)/, $(filter-out $(objtree)/%, $(__clean-files))) \
|
||||
$(filter $(objtree)/%, $(__clean-files)))
|
||||
|
||||
# same as clean-files
|
||||
|
||||
__clean-dirs := $(wildcard \
|
||||
$(addprefix $(obj)/, $(filter-out $(objtree)/%, $(clean-dirs))) \
|
||||
$(filter $(objtree)/%, $(clean-dirs)))
|
||||
__clean-files := $(wildcard $(addprefix $(obj)/, $(__clean-files)))
|
||||
|
||||
# ==========================================================================
|
||||
|
||||
quiet_cmd_clean = CLEAN $(obj)
|
||||
cmd_clean = rm -f $(__clean-files)
|
||||
quiet_cmd_cleandir = CLEAN $(__clean-dirs)
|
||||
cmd_cleandir = rm -rf $(__clean-dirs)
|
||||
|
||||
quiet_cmd_clean = CLEAN $(obj)
|
||||
cmd_clean = rm -rf $(__clean-files)
|
||||
|
||||
__clean: $(subdir-ymn)
|
||||
ifneq ($(strip $(__clean-files)),)
|
||||
+$(call cmd,clean)
|
||||
endif
|
||||
ifneq ($(strip $(__clean-dirs)),)
|
||||
+$(call cmd,cleandir)
|
||||
$(call cmd,clean)
|
||||
endif
|
||||
@:
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
# cc-cross-prefix
|
||||
# Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-)
|
||||
# Return first <prefix> where a <prefix>gcc is found in PATH.
|
||||
# If no gcc found in PATH with listed prefixes return nothing
|
||||
#
|
||||
# Note: '2>/dev/null' is here to force Make to invoke a shell. Otherwise, it
|
||||
# would try to directly execute the shell builtin 'command'. This workaround
|
||||
# should be kept for a long time since this issue was fixed only after the
|
||||
# GNU Make 4.2.1 release.
|
||||
cc-cross-prefix = $(firstword $(foreach c, $(1), \
|
||||
$(if $(shell command -v -- $(c)gcc 2>/dev/null), $(c))))
|
||||
|
||||
# output directory for tests below
|
||||
TMPOUT = $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_$$$$
|
||||
|
||||
# try-run
|
||||
# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
|
||||
# Exit code chooses option. "$$TMP" serves as a temporary file and is
|
||||
# automatically cleaned up.
|
||||
try-run = $(shell set -e; \
|
||||
TMP=$(TMPOUT)/tmp; \
|
||||
trap "rm -rf $(TMPOUT)" EXIT; \
|
||||
mkdir -p $(TMPOUT); \
|
||||
if ($(1)) >/dev/null 2>&1; \
|
||||
then echo "$(2)"; \
|
||||
else echo "$(3)"; \
|
||||
fi)
|
||||
|
||||
# as-option
|
||||
# Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
|
||||
|
||||
as-option = $(call try-run,\
|
||||
$(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2))
|
||||
|
||||
# as-instr
|
||||
# Usage: cflags-y += $(call as-instr,instr,option1,option2)
|
||||
|
||||
as-instr = $(call try-run,\
|
||||
printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
|
||||
|
||||
# __cc-option
|
||||
# Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
|
||||
__cc-option = $(call try-run,\
|
||||
$(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4))
|
||||
|
||||
# cc-option
|
||||
# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
|
||||
|
||||
cc-option = $(call __cc-option, $(CC),\
|
||||
$(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS),$(1),$(2))
|
||||
|
||||
# cc-option-yn
|
||||
# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
|
||||
cc-option-yn = $(call try-run,\
|
||||
$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
|
||||
|
||||
# cc-disable-warning
|
||||
# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
|
||||
cc-disable-warning = $(call try-run,\
|
||||
$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
|
||||
|
||||
# cc-ifversion
|
||||
# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
|
||||
cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || echo $(4))
|
||||
|
||||
# ld-option
|
||||
# Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)
|
||||
ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3))
|
||||
|
||||
# ld-ifversion
|
||||
# Usage: $(call ld-ifversion, -ge, 22252, y)
|
||||
ld-ifversion = $(shell [ $(CONFIG_LD_VERSION)0 $(1) $(2)0 ] && echo $(3) || echo $(4))
|
||||
@@ -13,11 +13,20 @@
|
||||
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
|
||||
|
||||
# backward compatibility
|
||||
KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)
|
||||
|
||||
ifeq ("$(origin W)", "command line")
|
||||
KBUILD_EXTRA_WARN := $(W)
|
||||
endif
|
||||
|
||||
export KBUILD_EXTRA_WARN
|
||||
|
||||
KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror
|
||||
KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y)
|
||||
|
||||
ifeq ("$(origin W)", "command line")
|
||||
export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)
|
||||
KBUILD_EXTRA_WARN := $(W)
|
||||
endif
|
||||
|
||||
ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS
|
||||
|
||||
+42
-81
@@ -1,5 +1,22 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# ==========================================================================
|
||||
|
||||
# LEX
|
||||
# ---------------------------------------------------------------------------
|
||||
quiet_cmd_flex = LEX $@
|
||||
cmd_flex = $(LEX) -o$@ -L $<
|
||||
|
||||
$(obj)/%.lex.c: $(src)/%.l FORCE
|
||||
$(call if_changed,flex)
|
||||
|
||||
# YACC
|
||||
# ---------------------------------------------------------------------------
|
||||
quiet_cmd_bison = YACC $(basename $@).[ch]
|
||||
cmd_bison = $(YACC) -o $(basename $@).c --defines=$(basename $@).h -t -l $<
|
||||
|
||||
$(obj)/%.tab.c $(obj)/%.tab.h: $(src)/%.y FORCE
|
||||
$(call if_changed,bison)
|
||||
|
||||
|
||||
# Building binaries on the host system
|
||||
# Binaries are used during the compilation of the kernel, for example
|
||||
# to preprocess a data file.
|
||||
@@ -7,83 +24,65 @@
|
||||
# Both C and C++ are supported, but preferred language is C for such utilities.
|
||||
#
|
||||
# Sample syntax (see Documentation/kbuild/makefiles.txt for reference)
|
||||
# hostprogs-y := bin2hex
|
||||
# hostprogs := bin2hex
|
||||
# Will compile bin2hex.c and create an executable named bin2hex
|
||||
#
|
||||
# hostprogs-y := lxdialog
|
||||
# hostprogs := lxdialog
|
||||
# lxdialog-objs := checklist.o lxdialog.o
|
||||
# Will compile lxdialog.c and checklist.c, and then link the executable
|
||||
# lxdialog, based on checklist.o and lxdialog.o
|
||||
#
|
||||
# hostprogs-y := qconf
|
||||
# hostprogs := qconf
|
||||
# qconf-cxxobjs := qconf.o
|
||||
# qconf-objs := menu.o
|
||||
# Will compile qconf as a C++ program, and menu as a C program.
|
||||
# They are linked as C++ code to the executable qconf
|
||||
|
||||
__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
|
||||
host-cshlib := $(sort $(hostlibs-y) $(hostlibs-m))
|
||||
host-cxxshlib := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
|
||||
|
||||
# C code
|
||||
# Executables compiled from a single .c file
|
||||
host-csingle := $(foreach m,$(__hostprogs), \
|
||||
$(if $($(m)-objs)$($(m)-cxxobjs)$($(m)-sharedobjs),,$(m)))
|
||||
host-csingle := $(foreach m,$(hostprogs), \
|
||||
$(if $($(m)-objs)$($(m)-cxxobjs),,$(m)))
|
||||
|
||||
# C executables linked based on several .o files
|
||||
host-cmulti := $(foreach m,$(__hostprogs),\
|
||||
host-cmulti := $(foreach m,$(hostprogs),\
|
||||
$(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m))))
|
||||
|
||||
# Shared object libraries
|
||||
host-shared := $(foreach m,$(__hostprogs),\
|
||||
$(if $($(m)-sharedobjs),$(m))))
|
||||
|
||||
# Object (.o) files compiled from .c files
|
||||
host-cobjs := $(sort $(foreach m,$(__hostprogs),$($(m)-objs)))
|
||||
host-cobjs := $(sort $(foreach m,$(hostprogs),$($(m)-objs)))
|
||||
|
||||
# C++ code
|
||||
# C++ executables compiled from at least one .cc file
|
||||
# and zero or more .c files
|
||||
host-cxxmulti := $(foreach m,$(__hostprogs),$(if $($(m)-cxxobjs),$(m)))
|
||||
host-cxxmulti := $(foreach m,$(hostprogs),$(if $($(m)-cxxobjs),$(m)))
|
||||
|
||||
# C++ Object (.o) files compiled from .cc files
|
||||
host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
|
||||
|
||||
# Object (.o) files used by the shared libaries
|
||||
host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
|
||||
host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
|
||||
|
||||
host-csingle := $(addprefix $(obj)/,$(host-csingle))
|
||||
host-cmulti := $(addprefix $(obj)/,$(host-cmulti))
|
||||
host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
|
||||
host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
|
||||
host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
|
||||
host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
|
||||
host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
|
||||
host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
|
||||
host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
|
||||
host-shared := $(addprefix $(obj)/,$(host-shared))
|
||||
|
||||
#####
|
||||
# Handle options to gcc. Support building with separate output directory
|
||||
|
||||
_hostc_flags = $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
|
||||
$(HOSTCFLAGS_$(basetarget).o)
|
||||
$(HOSTCFLAGS_$(target-stem).o)
|
||||
_hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
|
||||
$(HOSTCXXFLAGS_$(basetarget).o)
|
||||
|
||||
__hostc_flags = $(_hostc_flags)
|
||||
__hostcxx_flags = $(_hostcxx_flags)
|
||||
$(HOSTCXXFLAGS_$(target-stem).o)
|
||||
|
||||
# $(objtree)/$(obj) for including generated headers from checkin source files
|
||||
ifeq ($(KBUILD_EXTMOD),)
|
||||
ifneq ($(KBUILD_SRC),)
|
||||
__hostc_flags = -I$(obj) $(call flags,_hostc_flags)
|
||||
__hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags)
|
||||
ifdef building_out_of_srctree
|
||||
# $(error objtree=$(objtree), obj=$(obj))
|
||||
_hostc_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj)
|
||||
_hostcxx_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj)
|
||||
endif
|
||||
endif
|
||||
|
||||
hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags)
|
||||
hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags)
|
||||
hostc_flags = -Wp,-MMD,$(depfile) $(_hostc_flags)
|
||||
hostcxx_flags = -Wp,-MMD,$(depfile) $(_hostcxx_flags)
|
||||
|
||||
#####
|
||||
# Compile programs on the host
|
||||
@@ -92,7 +91,7 @@ hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags)
|
||||
# host-csingle -> Executable
|
||||
quiet_cmd_host-csingle = HOSTCC $@
|
||||
cmd_host-csingle = $(HOSTCC) $(hostc_flags) $(KBUILD_HOSTLDFLAGS) -o $@ $< \
|
||||
$(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F))
|
||||
$(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem))
|
||||
$(host-csingle): $(obj)/%: $(src)/%.c FORCE
|
||||
$(call if_changed_dep,host-csingle)
|
||||
|
||||
@@ -100,8 +99,8 @@ $(host-csingle): $(obj)/%: $(src)/%.c FORCE
|
||||
# host-cmulti -> executable
|
||||
quiet_cmd_host-cmulti = HOSTLD $@
|
||||
cmd_host-cmulti = $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -o $@ \
|
||||
$(addprefix $(obj)/,$($(@F)-objs)) \
|
||||
$(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F))
|
||||
$(addprefix $(obj)/, $($(target-stem)-objs)) \
|
||||
$(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem))
|
||||
$(host-cmulti): FORCE
|
||||
$(call if_changed,host-cmulti)
|
||||
$(call multi_depend, $(host-cmulti), , -objs)
|
||||
@@ -118,8 +117,8 @@ $(host-cobjs): $(obj)/%.o: $(src)/%.c FORCE
|
||||
quiet_cmd_host-cxxmulti = HOSTLD $@
|
||||
cmd_host-cxxmulti = $(HOSTCXX) $(KBUILD_HOSTLDFLAGS) -o $@ \
|
||||
$(foreach o,objs cxxobjs,\
|
||||
$(addprefix $(obj)/,$($(@F)-$(o)))) \
|
||||
$(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F))
|
||||
$(addprefix $(obj)/, $($(target-stem)-$(o)))) \
|
||||
$(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem))
|
||||
$(host-cxxmulti): FORCE
|
||||
$(call if_changed,host-cxxmulti)
|
||||
$(call multi_depend, $(host-cxxmulti), , -objs -cxxobjs)
|
||||
@@ -130,43 +129,5 @@ quiet_cmd_host-cxxobjs = HOSTCXX $@
|
||||
$(host-cxxobjs): $(obj)/%.o: $(src)/%.cc FORCE
|
||||
$(call if_changed_dep,host-cxxobjs)
|
||||
|
||||
# Compile .c file, create position independent .o file
|
||||
# host-cshobjs -> .o
|
||||
quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
|
||||
cmd_host-cshobjs = $(HOSTCC) $(hostc_flags) -fPIC -c -o $@ $<
|
||||
$(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
|
||||
$(call if_changed_dep,host-cshobjs)
|
||||
|
||||
# Compile .c file, create position independent .o file
|
||||
# Note that plugin capable gcc versions can be either C or C++ based
|
||||
# therefore plugin source files have to be compilable in both C and C++ mode.
|
||||
# This is why a C++ compiler is invoked on a .c file.
|
||||
# host-cxxshobjs -> .o
|
||||
quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
|
||||
cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
|
||||
$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
|
||||
$(call if_changed_dep,host-cxxshobjs)
|
||||
|
||||
# Link a shared library, based on position independent .o files
|
||||
# *.o -> .so shared library (host-cshlib)
|
||||
quiet_cmd_host-cshlib = HOSTLLD -shared $@
|
||||
cmd_host-cshlib = $(HOSTCC) $(HOSTLDFLAGS) -shared -o $@ \
|
||||
$(addprefix $(obj)/,$($(@F:.so=-objs))) \
|
||||
$(HOST_LOADLIBES) $(HOSTLDLIBS_$(@F))
|
||||
$(host-cshlib): FORCE
|
||||
$(call if_changed,host-cshlib)
|
||||
$(call multi_depend, $(host-cshlib), .so, -objs)
|
||||
|
||||
# Link a shared library, based on position independent .o files
|
||||
# *.o -> .so shared library (host-cxxshlib)
|
||||
quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
|
||||
cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
|
||||
$(addprefix $(obj)/,$($(@F:.so=-objs))) \
|
||||
$(HOST_LOADLIBES) $(HOSTLDLIBS_$(@F))
|
||||
$(host-cxxshlib): FORCE
|
||||
$(call if_changed,host-cxxshlib)
|
||||
$(call multi_depend, $(host-cxxshlib), .so, -objs)
|
||||
|
||||
targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
|
||||
$(host-cxxmulti) $(host-cxxobjs) $(host-shared) \
|
||||
$(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
|
||||
targets += $(host-csingle) $(host-cmulti) $(host-cobjs) \
|
||||
$(host-cxxmulti) $(host-cxxobjs)
|
||||
|
||||
+217
-142
@@ -20,26 +20,29 @@ obj-m := $(filter-out $(obj-y),$(obj-m))
|
||||
# Filter out objects already built-in
|
||||
lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))
|
||||
|
||||
# Determine modorder.
|
||||
# Unfortunately, we don't have information about ordering between -y
|
||||
# and -m subdirs. Just put -y's first.
|
||||
modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko))
|
||||
|
||||
# Handle objects in subdirs
|
||||
# ---------------------------------------------------------------------------
|
||||
# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.a
|
||||
# and add the directory to the list of dirs to descend into: $(subdir-y)
|
||||
# o if we encounter foo/ in $(obj-m), remove it from $(obj-m)
|
||||
# and add the directory to the list of dirs to descend into: $(subdir-m)
|
||||
__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y)))
|
||||
subdir-y += $(__subdir-y)
|
||||
__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m)))
|
||||
subdir-m += $(__subdir-m)
|
||||
obj-y := $(patsubst %/, %/built-in.a, $(obj-y))
|
||||
obj-m := $(filter-out %/, $(obj-m))
|
||||
|
||||
# Subdirectories we need to descend into
|
||||
subdir-ym := $(sort $(subdir-y) $(subdir-m))
|
||||
subdir-ym := $(sort $(subdir-y) $(subdir-m) \
|
||||
$(patsubst %/,%, $(filter %/, $(obj-y) $(obj-m))))
|
||||
|
||||
# Handle objects in subdirs:
|
||||
# - If we encounter foo/ in $(obj-y), replace it by foo/built-in.a and
|
||||
# foo/modules.order
|
||||
# - If we encounter foo/ in $(obj-m), replace it by foo/modules.order
|
||||
#
|
||||
# Generate modules.order to determine modorder. Unfortunately, we don't have
|
||||
# information about ordering between -y and -m subdirs. Just put -y's first.
|
||||
|
||||
ifdef need-modorder
|
||||
obj-m := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m))
|
||||
else
|
||||
obj-m := $(filter-out %/, $(obj-m))
|
||||
endif
|
||||
|
||||
ifdef need-builtin
|
||||
obj-y := $(patsubst %/, %/built-in.a, $(obj-y))
|
||||
else
|
||||
obj-y := $(filter-out %/, $(obj-y))
|
||||
endif
|
||||
|
||||
# Expand $(foo-objs) $(foo-y) etc. by replacing their individuals
|
||||
suffix-search = $(strip $(foreach s, $3, $($(1:%$(strip $2)=%$s))))
|
||||
@@ -48,16 +51,28 @@ multi-search = $(sort $(foreach m, $1, $(if $(call suffix-search, $m, $2, $3 -),
|
||||
# List primitive targets that are compiled from source files
|
||||
real-search = $(foreach m, $1, $(if $(call suffix-search, $m, $2, $3 -), $(call suffix-search, $m, $2, $3), $m))
|
||||
|
||||
# if $(foo-objs), $(foo-y), or $(foo-m) exists, foo.o is a composite object
|
||||
multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
|
||||
multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))), $(m))))
|
||||
multi-used := $(multi-used-y) $(multi-used-m)
|
||||
single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m)))
|
||||
# If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object
|
||||
multi-obj-y := $(call multi-search, $(obj-y), .o, -objs -y)
|
||||
multi-obj-m := $(call multi-search, $(obj-m), .o, -objs -y -m)
|
||||
multi-obj-ym := $(multi-obj-y) $(multi-obj-m)
|
||||
|
||||
# Build list of the parts of our composite objects, our composite
|
||||
# objects depend on those (obviously)
|
||||
multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y)))
|
||||
multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y)))
|
||||
# Replace multi-part objects by their individual parts,
|
||||
# including built-in.a from subdirectories
|
||||
real-obj-y := $(call real-search, $(obj-y), .o, -objs -y)
|
||||
real-obj-m := $(call real-search, $(obj-m), .o, -objs -y -m)
|
||||
|
||||
always-y += $(always-m)
|
||||
|
||||
# hostprogs-always-y += foo
|
||||
# ... is a shorthand for
|
||||
# hostprogs += foo
|
||||
# always-y += foo
|
||||
hostprogs += $(hostprogs-always-y) $(hostprogs-always-m)
|
||||
always-y += $(hostprogs-always-y) $(hostprogs-always-m)
|
||||
|
||||
# userprogs-always-y is likewise.
|
||||
userprogs += $(userprogs-always-y) $(userprogs-always-m)
|
||||
always-y += $(userprogs-always-y) $(userprogs-always-m)
|
||||
|
||||
# Composite DTB (i.e. DTB constructed by overlay)
|
||||
multi-dtb-y := $(call multi-search, $(dtb-y), .dtb, -dtbs)
|
||||
@@ -66,20 +81,12 @@ real-dtb-y := $(call real-search, $(dtb-y), .dtb, -dtbs)
|
||||
# Base DTB that overlay is applied onto (each first word of $(*-dtbs) expansion)
|
||||
base-dtb-y := $(foreach m, $(multi-dtb-y), $(firstword $(call suffix-search, $m, .dtb, -dtbs)))
|
||||
|
||||
# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to
|
||||
# tell kbuild to descend
|
||||
subdir-obj-y := $(filter %/built-in.a, $(obj-y))
|
||||
|
||||
# Replace multi-part objects by their individual parts,
|
||||
# including built-in.a from subdirectories
|
||||
real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
|
||||
real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m)))
|
||||
|
||||
# DTB
|
||||
# If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built
|
||||
extra-y += $(dtb-y)
|
||||
extra-$(CONFIG_OF_ALL_DTBS) += $(dtb-)
|
||||
|
||||
# U-Boot specific
|
||||
ifneq ($(CHECK_DTBS),)
|
||||
extra-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y))
|
||||
extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-))
|
||||
@@ -88,47 +95,49 @@ endif
|
||||
# Add subdir path
|
||||
|
||||
extra-y := $(addprefix $(obj)/,$(extra-y))
|
||||
always-y := $(addprefix $(obj)/,$(always-y))
|
||||
always := $(addprefix $(obj)/,$(always))
|
||||
always-y := $(addprefix $(obj)/,$(always-y))
|
||||
targets := $(addprefix $(obj)/,$(targets))
|
||||
modorder := $(addprefix $(obj)/,$(modorder))
|
||||
obj-y := $(addprefix $(obj)/,$(obj-y))
|
||||
obj-m := $(addprefix $(obj)/,$(obj-m))
|
||||
lib-y := $(addprefix $(obj)/,$(lib-y))
|
||||
subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y))
|
||||
real-obj-y := $(addprefix $(obj)/,$(real-obj-y))
|
||||
real-obj-m := $(addprefix $(obj)/,$(real-obj-m))
|
||||
single-used-m := $(addprefix $(obj)/,$(single-used-m))
|
||||
multi-used-y := $(addprefix $(obj)/,$(multi-used-y))
|
||||
multi-used-m := $(addprefix $(obj)/,$(multi-used-m))
|
||||
multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y))
|
||||
multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m))
|
||||
multi-dtb-y := $(addprefix $(obj)/,$(multi-dtb-y))
|
||||
real-dtb-y := $(addprefix $(obj)/,$(real-dtb-y))
|
||||
multi-obj-m := $(addprefix $(obj)/, $(multi-obj-m))
|
||||
multi-dtb-y := $(addprefix $(obj)/, $(multi-dtb-y))
|
||||
real-dtb-y := $(addprefix $(obj)/, $(real-dtb-y))
|
||||
subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
|
||||
|
||||
# Finds the multi-part object the current object will be linked into.
|
||||
# If the object belongs to two or more multi-part objects, all of them are
|
||||
# concatenated with a colon separator.
|
||||
modname-multi = $(subst $(space),:,$(sort $(foreach m,$(multi-used),\
|
||||
$(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=)))))
|
||||
# If the object belongs to two or more multi-part objects, list them all.
|
||||
modname-multi = $(sort $(foreach m,$(multi-obj-ym),\
|
||||
$(if $(filter $*.o, $(call suffix-search, $m, .o, -objs -y -m)),$(m:.o=))))
|
||||
|
||||
modname = $(if $(modname-multi),$(modname-multi),$(basetarget))
|
||||
__modname = $(or $(modname-multi),$(basetarget))
|
||||
|
||||
modname = $(subst $(space),:,$(__modname))
|
||||
modfile = $(addprefix $(obj)/,$(__modname))
|
||||
|
||||
# target with $(obj)/ and its suffix stripped
|
||||
target-stem = $(basename $(patsubst $(obj)/%,%,$@))
|
||||
|
||||
# These flags are needed for modversions and compiling, so we define them here
|
||||
# $(modname_flags) defines KBUILD_MODNAME as the name of the module it will
|
||||
# end up in (or would, if it gets compiled in)
|
||||
name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote)
|
||||
name-fix-token = $(subst $(comma),_,$(subst -,_,$1))
|
||||
name-fix = $(call stringify,$(call name-fix-token,$1))
|
||||
basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
|
||||
modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname))
|
||||
modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) \
|
||||
-D__KBUILD_MODNAME=kmod_$(call name-fix-token,$(modname))
|
||||
modfile_flags = -DKBUILD_MODFILE=$(call stringify,$(modfile))
|
||||
|
||||
orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \
|
||||
$(ccflags-y) $(CFLAGS_$(basetarget).o)
|
||||
_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
|
||||
orig_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) \
|
||||
$(asflags-y) $(AFLAGS_$(basetarget).o)
|
||||
_a_flags = $(filter-out $(AFLAGS_REMOVE_$(basetarget).o), $(orig_a_flags))
|
||||
_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F))
|
||||
_c_flags = $(filter-out $(CFLAGS_REMOVE_$(target-stem).o), \
|
||||
$(filter-out $(ccflags-remove-y), \
|
||||
$(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(ccflags-y)) \
|
||||
$(CFLAGS_$(target-stem).o))
|
||||
_a_flags = $(filter-out $(AFLAGS_REMOVE_$(target-stem).o), \
|
||||
$(filter-out $(asflags-remove-y), \
|
||||
$(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(asflags-y)) \
|
||||
$(AFLAGS_$(target-stem).o))
|
||||
_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(target-stem).lds)
|
||||
|
||||
#
|
||||
# Enable gcov profiling flags for a file, directory or for all files depending
|
||||
@@ -146,10 +155,12 @@ endif
|
||||
# we don't want to check (depends on variables KASAN_SANITIZE_obj.o, KASAN_SANITIZE)
|
||||
#
|
||||
ifeq ($(CONFIG_KASAN),y)
|
||||
ifneq ($(CONFIG_KASAN_HW_TAGS),y)
|
||||
_c_flags += $(if $(patsubst n%,, \
|
||||
$(KASAN_SANITIZE_$(basetarget).o)$(KASAN_SANITIZE)y), \
|
||||
$(CFLAGS_KASAN), $(CFLAGS_KASAN_NOSANITIZE))
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_UBSAN),y)
|
||||
_c_flags += $(if $(patsubst n%,, \
|
||||
@@ -163,34 +174,55 @@ _c_flags += $(if $(patsubst n%,, \
|
||||
$(CFLAGS_KCOV))
|
||||
endif
|
||||
|
||||
__c_flags = $(_c_flags)
|
||||
__a_flags = $(_a_flags)
|
||||
__cpp_flags = $(_cpp_flags)
|
||||
#
|
||||
# Enable KCSAN flags except some files or directories we don't want to check
|
||||
# (depends on variables KCSAN_SANITIZE_obj.o, KCSAN_SANITIZE)
|
||||
#
|
||||
ifeq ($(CONFIG_KCSAN),y)
|
||||
_c_flags += $(if $(patsubst n%,, \
|
||||
$(KCSAN_SANITIZE_$(basetarget).o)$(KCSAN_SANITIZE)y), \
|
||||
$(CFLAGS_KCSAN))
|
||||
# Some uninstrumented files provide implied barriers required to avoid false
|
||||
# positives: set KCSAN_INSTRUMENT_BARRIERS for barrier instrumentation only.
|
||||
_c_flags += $(if $(patsubst n%,, \
|
||||
$(KCSAN_INSTRUMENT_BARRIERS_$(basetarget).o)$(KCSAN_INSTRUMENT_BARRIERS)n), \
|
||||
-D__KCSAN_INSTRUMENT_BARRIERS__)
|
||||
endif
|
||||
|
||||
# If building the kernel in a separate objtree expand all occurrences
|
||||
# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
|
||||
# $(srctree)/$(src) for including checkin headers from generated source files
|
||||
# $(objtree)/$(obj) for including generated headers from checkin source files
|
||||
ifeq ($(KBUILD_EXTMOD),)
|
||||
ifneq ($(KBUILD_SRC),)
|
||||
# -I$(obj) locates generated .h files
|
||||
# $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files
|
||||
# and locates generated .h files
|
||||
# FIXME: Replace both with specific CFLAGS* statements in the makefiles
|
||||
__c_flags = $(if $(obj),$(call addtree,-I$(src)) -I$(obj)) \
|
||||
$(call flags,_c_flags)
|
||||
__a_flags = $(call flags,_a_flags)
|
||||
__cpp_flags = $(call flags,_cpp_flags)
|
||||
ifdef building_out_of_srctree
|
||||
_c_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj)
|
||||
_a_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj)
|
||||
_cpp_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj)
|
||||
endif
|
||||
endif
|
||||
|
||||
part-of-module = $(if $(filter $(basename $@).o, $(real-obj-m)),y)
|
||||
quiet_modtag = $(if $(part-of-module),[M], )
|
||||
|
||||
modkern_cflags = \
|
||||
$(if $(part-of-module), \
|
||||
$(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
|
||||
$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL) $(modfile_flags))
|
||||
|
||||
modkern_aflags = $(if $(part-of-module), \
|
||||
$(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE), \
|
||||
$(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL))
|
||||
|
||||
|
||||
# Modified for U-Boot: LINUXINCLUDE -> UBOOTINCLUDE
|
||||
c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \
|
||||
$(__c_flags) $(modkern_cflags) \
|
||||
# removed the inclusion of compiler_types.h for sandbox build
|
||||
c_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \
|
||||
$(_c_flags) $(modkern_cflags) \
|
||||
$(basename_flags) $(modname_flags)
|
||||
|
||||
a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \
|
||||
$(__a_flags) $(modkern_aflags)
|
||||
a_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \
|
||||
$(_a_flags) $(modkern_aflags)
|
||||
|
||||
cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \
|
||||
$(__cpp_flags)
|
||||
cpp_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \
|
||||
$(_cpp_flags)
|
||||
|
||||
ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F))
|
||||
|
||||
@@ -238,48 +270,52 @@ dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \
|
||||
-D__ASSEMBLY__ \
|
||||
-undef -D__DTS__
|
||||
|
||||
# Finds the multi-part object the current object will be linked into
|
||||
modname-multi = $(sort $(foreach m,$(multi-used),\
|
||||
$(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=))))
|
||||
ifdef CONFIG_OBJTOOL
|
||||
|
||||
objtool := $(objtree)/tools/objtool/objtool
|
||||
|
||||
objtool_args = \
|
||||
$(if $(CONFIG_HAVE_JUMP_LABEL_HACK), --hacks=jump_label) \
|
||||
$(if $(CONFIG_HAVE_NOINSTR_HACK), --hacks=noinstr) \
|
||||
$(if $(CONFIG_X86_KERNEL_IBT), --ibt) \
|
||||
$(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount) \
|
||||
$(if $(CONFIG_UNWINDER_ORC), --orc) \
|
||||
$(if $(CONFIG_RETPOLINE), --retpoline) \
|
||||
$(if $(CONFIG_RETHUNK), --rethunk) \
|
||||
$(if $(CONFIG_SLS), --sls) \
|
||||
$(if $(CONFIG_STACK_VALIDATION), --stackval) \
|
||||
$(if $(CONFIG_HAVE_STATIC_CALL_INLINE), --static-call) \
|
||||
$(if $(CONFIG_HAVE_UACCESS_VALIDATION), --uaccess) \
|
||||
$(if $(delay-objtool), --link) \
|
||||
$(if $(part-of-module), --module) \
|
||||
$(if $(CONFIG_GCOV_KERNEL), --no-unreachable)
|
||||
|
||||
delay-objtool := $(or $(CONFIG_LTO_CLANG),$(CONFIG_X86_KERNEL_IBT))
|
||||
|
||||
cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool_args) $@)
|
||||
cmd_gen_objtooldep = $(if $(objtool-enabled), { echo ; echo '$@: $$(wildcard $(objtool))' ; } >> $(dot-target).cmd)
|
||||
|
||||
endif # CONFIG_OBJTOOL
|
||||
|
||||
# Useful for describing the dependency of composite objects
|
||||
# Usage:
|
||||
# $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add)
|
||||
define multi_depend
|
||||
$(foreach m, $(notdir $1), \
|
||||
$(eval $(obj)/$m: \
|
||||
$(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s)))))))
|
||||
$(foreach m, $1, \
|
||||
$(eval $m: \
|
||||
$(addprefix $(obj)/, $(call suffix-search, $(patsubst $(obj)/%,%,$m), $2, $3))))
|
||||
endef
|
||||
|
||||
# LEX
|
||||
# ---------------------------------------------------------------------------
|
||||
quiet_cmd_flex = LEX $@
|
||||
cmd_flex = $(LEX) -o$@ -L $<
|
||||
|
||||
$(obj)/%.lex.c: $(src)/%.l FORCE
|
||||
$(call if_changed,flex)
|
||||
|
||||
# YACC
|
||||
# ---------------------------------------------------------------------------
|
||||
quiet_cmd_bison = YACC $@
|
||||
cmd_bison = $(YACC) -o$@ -t -l $<
|
||||
|
||||
$(obj)/%.tab.c: $(src)/%.y FORCE
|
||||
$(call if_changed,bison)
|
||||
|
||||
quiet_cmd_bison_h = YACC $@
|
||||
cmd_bison_h = $(YACC) -o/dev/null --defines=$@ -t -l $<
|
||||
|
||||
$(obj)/%.tab.h: $(src)/%.y FORCE
|
||||
$(call if_changed,bison_h)
|
||||
|
||||
# Shipped files
|
||||
# Copy a file
|
||||
# ===========================================================================
|
||||
|
||||
quiet_cmd_shipped = SHIPPED $@
|
||||
cmd_shipped = cat $< > $@
|
||||
# 'cp' preserves permissions. If you use it to copy a file in read-only srctree,
|
||||
# the copy would be read-only as well, leading to an error when executing the
|
||||
# rule next time. Use 'cat' instead in order to generate a writable file.
|
||||
quiet_cmd_copy = COPY $@
|
||||
cmd_copy = cat $< > $@
|
||||
|
||||
$(obj)/%: $(src)/%_shipped
|
||||
$(call cmd,shipped)
|
||||
$(call cmd,copy)
|
||||
|
||||
# Commands useful for building a boot image
|
||||
# ===========================================================================
|
||||
@@ -289,7 +325,7 @@ $(obj)/%: $(src)/%_shipped
|
||||
# target: source(s) FORCE
|
||||
# $(if_changed,ld/objcopy/gzip)
|
||||
#
|
||||
# and add target to extra-y so that we know we have to
|
||||
# and add target to 'targets' so that we know we have to
|
||||
# read in the saved command line
|
||||
|
||||
# Linking
|
||||
@@ -302,7 +338,7 @@ quiet_cmd_ld = LD $@
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
quiet_cmd_ar = AR $@
|
||||
cmd_ar = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(real-prereqs)
|
||||
cmd_ar = rm -f $@; $(AR) cDPrsT $@ $(real-prereqs)
|
||||
|
||||
# Objcopy
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -314,14 +350,14 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
quiet_cmd_gzip = GZIP $@
|
||||
cmd_gzip = cat $(real-prereqs) | gzip -n -f -9 > $@
|
||||
cmd_gzip = cat $(real-prereqs) | $(KGZIP) -n -f -9 > $@
|
||||
|
||||
# DTC
|
||||
# ---------------------------------------------------------------------------
|
||||
DTC ?= $(objtree)/scripts/dtc/dtc
|
||||
|
||||
# Disable noisy checks by default
|
||||
ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
|
||||
ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
|
||||
DTC_FLAGS += -Wno-unit_address_vs_reg \
|
||||
-Wno-unit_address_format \
|
||||
-Wno-avoid_unnecessary_addr_size \
|
||||
@@ -336,7 +372,7 @@ DTC_FLAGS += -Wno-pci_bridge \
|
||||
-Wno-pci_device_bus_num
|
||||
endif
|
||||
|
||||
ifneq ($(findstring 2,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
|
||||
ifneq ($(findstring 2,$(KBUILD_EXTRA_WARN)),)
|
||||
DTC_FLAGS += -Wnode_name_chars_strict \
|
||||
-Wproperty_name_chars_strict
|
||||
endif
|
||||
@@ -361,8 +397,8 @@ cmd_dt_S_dtb= \
|
||||
echo '.balign 16'; \
|
||||
} > $@
|
||||
|
||||
$(obj)/%.dtb.S: $(obj)/%.dtb
|
||||
$(call cmd,dt_S_dtb)
|
||||
$(obj)/%.dtb.S: $(obj)/%.dtb FORCE
|
||||
$(call if_changed,dt_S_dtb)
|
||||
|
||||
# Generate an assembly file to wrap the output of the device tree compiler
|
||||
quiet_cmd_dt_S_dtbo= DTBOS $@
|
||||
@@ -572,8 +608,8 @@ $(obj)/dsdt_generated.c: $(src)/dsdt.asl
|
||||
# append the size as a 32-bit littleendian number as gzip does.
|
||||
size_append = printf $(shell \
|
||||
dec_size=0; \
|
||||
for F in $(real-prereqs); do
|
||||
fsize=$$(stat -c "%s" $$F); \
|
||||
for F in $(real-prereqs); do \
|
||||
fsize=$$($(CONFIG_SHELL) $(srctree)/scripts/file-size.sh $$F); \
|
||||
dec_size=$$(expr $$dec_size + $$fsize); \
|
||||
done; \
|
||||
printf "%08x\n" $$dec_size | \
|
||||
@@ -585,20 +621,35 @@ printf "%08x\n" $$dec_size | \
|
||||
} \
|
||||
)
|
||||
|
||||
quiet_cmd_file_size = GEN $@
|
||||
cmd_file_size = $(size_append) > $@
|
||||
|
||||
quiet_cmd_bzip2 = BZIP2 $@
|
||||
cmd_bzip2 = { cat $(real-prereqs) | bzip2 -9 && $(size_append); } > $@
|
||||
cmd_bzip2 = cat $(real-prereqs) | $(KBZIP2) -9 > $@
|
||||
|
||||
quiet_cmd_bzip2_with_size = BZIP2 $@
|
||||
cmd_bzip2_with_size = { cat $(real-prereqs) | $(KBZIP2) -9; $(size_append); } > $@
|
||||
|
||||
# Lzma
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
quiet_cmd_lzma = LZMA $@
|
||||
cmd_lzma = { cat $(real-prereqs) | lzma -9 && $(size_append); } > $@
|
||||
cmd_lzma = cat $(real-prereqs) | $(LZMA) -9 > $@
|
||||
|
||||
quiet_cmd_lzma_with_size = LZMA $@
|
||||
cmd_lzma_with_size = { cat $(real-prereqs) | $(LZMA) -9; $(size_append); } > $@
|
||||
|
||||
quiet_cmd_lzo = LZO $@
|
||||
cmd_lzo = { cat $(real-prereqs) | lzop -9 && $(size_append); } > $@
|
||||
cmd_lzo = cat $(real-prereqs) | $(KLZOP) -9 > $@
|
||||
|
||||
quiet_cmd_lzo_with_size = LZO $@
|
||||
cmd_lzo_with_size = { cat $(real-prereqs) | $(KLZOP) -9; $(size_append); } > $@
|
||||
|
||||
quiet_cmd_lz4 = LZ4 $@
|
||||
cmd_lz4 = { cat $(real-prereqs) | lz4c -l -c1 stdin stdout && \
|
||||
cmd_lz4 = cat $(real-prereqs) | $(LZ4) -l -c1 stdin stdout > $@
|
||||
|
||||
quiet_cmd_lz4_with_size = LZ4 $@
|
||||
cmd_lz4_with_size = { cat $(real-prereqs) | $(LZ4) -l -c1 stdin stdout; \
|
||||
$(size_append); } > $@
|
||||
|
||||
# U-Boot mkimage
|
||||
@@ -609,21 +660,19 @@ MKIMAGE := $(srctree)/scripts/mkuboot.sh
|
||||
# SRCARCH just happens to match slightly more than ARCH (on sparc), so reduces
|
||||
# the number of overrides in arch makefiles
|
||||
UIMAGE_ARCH ?= $(SRCARCH)
|
||||
UIMAGE_COMPRESSION ?= $(if $(2),$(2),none)
|
||||
UIMAGE_COMPRESSION ?= $(or $(2),none)
|
||||
UIMAGE_OPTS-y ?=
|
||||
UIMAGE_TYPE ?= kernel
|
||||
UIMAGE_LOADADDR ?= arch_must_set_this
|
||||
UIMAGE_ENTRYADDR ?= $(UIMAGE_LOADADDR)
|
||||
UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE)'
|
||||
UIMAGE_IN ?= $<
|
||||
UIMAGE_OUT ?= $@
|
||||
|
||||
quiet_cmd_uimage = UIMAGE $(UIMAGE_OUT)
|
||||
cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \
|
||||
quiet_cmd_uimage = UIMAGE $@
|
||||
cmd_uimage = $(BASH) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \
|
||||
-C $(UIMAGE_COMPRESSION) $(UIMAGE_OPTS-y) \
|
||||
-T $(UIMAGE_TYPE) \
|
||||
-a $(UIMAGE_LOADADDR) -e $(UIMAGE_ENTRYADDR) \
|
||||
-n $(UIMAGE_NAME) -d $(UIMAGE_IN) $(UIMAGE_OUT)
|
||||
-n $(UIMAGE_NAME) -d $< $@
|
||||
|
||||
# XZ
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -643,11 +692,39 @@ quiet_cmd_uimage = UIMAGE $(UIMAGE_OUT)
|
||||
# big dictionary would increase the memory usage too much in the multi-call
|
||||
# decompression mode. A BCJ filter isn't used either.
|
||||
quiet_cmd_xzkern = XZKERN $@
|
||||
cmd_xzkern = { cat $(filter-out FORCE,$^) | \
|
||||
sh $(srctree)/scripts/xz_wrap.sh && $(size_append); } > $@
|
||||
cmd_xzkern = cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh > $@
|
||||
|
||||
quiet_cmd_xzkern_with_size = XZKERN $@
|
||||
cmd_xzkern_with_size = { cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh; \
|
||||
$(size_append); } > $@
|
||||
|
||||
quiet_cmd_xzmisc = XZMISC $@
|
||||
cmd_xzmisc = cat $(real-prereqs) | xz --check=crc32 --lzma2=dict=1MiB > $@
|
||||
cmd_xzmisc = cat $(real-prereqs) | $(XZ) --check=crc32 --lzma2=dict=1MiB > $@
|
||||
|
||||
# ZSTD
|
||||
# ---------------------------------------------------------------------------
|
||||
# Appends the uncompressed size of the data using size_append. The .zst
|
||||
# format has the size information available at the beginning of the file too,
|
||||
# but it's in a more complex format and it's good to avoid changing the part
|
||||
# of the boot code that reads the uncompressed size.
|
||||
#
|
||||
# Note that the bytes added by size_append will make the zstd tool think that
|
||||
# the file is corrupt. This is expected.
|
||||
#
|
||||
# zstd uses a maximum window size of 8 MB. zstd22 uses a maximum window size of
|
||||
# 128 MB. zstd22 is used for kernel compression because it is decompressed in a
|
||||
# single pass, so zstd doesn't need to allocate a window buffer. When streaming
|
||||
# decompression is used, like initramfs decompression, zstd22 should likely not
|
||||
# be used because it would require zstd to allocate a 128 MB buffer.
|
||||
|
||||
quiet_cmd_zstd = ZSTD $@
|
||||
cmd_zstd = cat $(real-prereqs) | $(ZSTD) -19 > $@
|
||||
|
||||
quiet_cmd_zstd22 = ZSTD22 $@
|
||||
cmd_zstd22 = cat $(real-prereqs) | $(ZSTD) -22 --ultra > $@
|
||||
|
||||
quiet_cmd_zstd22_with_size = ZSTD22 $@
|
||||
cmd_zstd22_with_size = { cat $(real-prereqs) | $(ZSTD) -22 --ultra; $(size_append); } > $@
|
||||
|
||||
# Additional commands for U-Boot
|
||||
#
|
||||
@@ -718,7 +795,6 @@ quiet_cmd_fdt_rm_props = FDTGREP $@
|
||||
define sed-offsets
|
||||
's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \
|
||||
/^->/{s:->#\(.*\):/* \1 */:; \
|
||||
s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
|
||||
s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
|
||||
s:->::; p;}'
|
||||
endef
|
||||
@@ -726,7 +802,6 @@ endef
|
||||
# Use filechk to avoid rebuilds when a header changes, but the resulting file
|
||||
# does not
|
||||
define filechk_offsets
|
||||
( \
|
||||
echo "#ifndef $2"; \
|
||||
echo "#define $2"; \
|
||||
echo "/*"; \
|
||||
@@ -735,7 +810,7 @@ define filechk_offsets
|
||||
echo " * This file was generated by Kbuild"; \
|
||||
echo " */"; \
|
||||
echo ""; \
|
||||
sed -ne $(sed-offsets); \
|
||||
sed -ne $(sed-offsets) < $<; \
|
||||
echo ""; \
|
||||
echo "#endif" )
|
||||
echo "#endif"
|
||||
endef
|
||||
|
||||
+11
-9
@@ -17,7 +17,9 @@ src := $(obj)
|
||||
# Create output directory if not already present
|
||||
_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
|
||||
|
||||
include $(srctree)/scripts/Kbuild.include
|
||||
include $(srctree)/scripts/Kbuild.uboot
|
||||
|
||||
include scripts/Makefile.compiler
|
||||
|
||||
-include include/config/auto.conf
|
||||
|
||||
@@ -363,7 +365,7 @@ cmd_dtoc = $(DTOC_ARGS) -c $(obj)/dts -C include/generated all
|
||||
quiet_cmd_plat = PLAT $@
|
||||
cmd_plat = $(CC) $(c_flags) -c $< -o $(filter-out $(PHONY),$@)
|
||||
|
||||
$(obj)/dts/dt-%.o: $(obj)/dts/dt-%.c $(platdata-hdr)
|
||||
$(obj)/dts/dt-%.o: $(obj)/dts/dt-%.c $(platdata-hdr) FORCE
|
||||
$(call if_changed,plat)
|
||||
|
||||
# Don't use dts_dir here, since it forces running this expensive rule every time
|
||||
@@ -461,7 +463,7 @@ cmd_sunxi_spl_image_builder = $(objtree)/tools/sunxi-spl-image-builder \
|
||||
-u $(CONFIG_NAND_SUNXI_SPL_USABLE_PAGE_SIZE) \
|
||||
-e $(CONFIG_SYS_NAND_BLOCK_SIZE) \
|
||||
-s -b $< $@
|
||||
$(obj)/sunxi-spl-with-ecc.bin: $(obj)/sunxi-spl.bin
|
||||
$(obj)/sunxi-spl-with-ecc.bin: $(obj)/sunxi-spl.bin FORCE
|
||||
$(call if_changed,sunxi_spl_image_builder)
|
||||
|
||||
|
||||
@@ -493,9 +495,9 @@ quiet_cmd_keep_syms_lto_cc = KSLCC $@
|
||||
cmd_keep_syms_lto_cc = \
|
||||
$(CC) $(filter-out $(LTO_CFLAGS),$(c_flags)) -c -o $@ $<
|
||||
|
||||
$(u-boot-spl-keep-syms-lto_c): $(u-boot-spl-main) $(u-boot-spl-platdata)
|
||||
$(u-boot-spl-keep-syms-lto_c): $(u-boot-spl-main) $(u-boot-spl-platdata) FORCE
|
||||
$(call if_changed,keep_syms_lto)
|
||||
$(u-boot-spl-keep-syms-lto): $(u-boot-spl-keep-syms-lto_c)
|
||||
$(u-boot-spl-keep-syms-lto): $(u-boot-spl-keep-syms-lto_c) FORCE
|
||||
$(call if_changed,keep_syms_lto_cc)
|
||||
else
|
||||
u-boot-spl-keep-syms-lto :=
|
||||
@@ -545,11 +547,11 @@ $(sort $(u-boot-spl-init) $(u-boot-spl-main)): $(u-boot-spl-dirs) ;
|
||||
|
||||
PHONY += $(u-boot-spl-dirs)
|
||||
$(u-boot-spl-dirs): $(u-boot-spl-platdata) prepare
|
||||
$(Q)$(MAKE) $(build)=$@
|
||||
$(Q)$(MAKE) $(build)=$@ need-builtin=1
|
||||
|
||||
PHONY += prepare
|
||||
prepare:
|
||||
$(Q)$(MAKE) $(build)=$(obj)/.
|
||||
$(Q)$(MAKE) $(build)=$(obj)/. need-builtin=1
|
||||
|
||||
quiet_cmd_cpp_lds = LDS $@
|
||||
cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \
|
||||
@@ -572,7 +574,7 @@ PHONY += FORCE
|
||||
FORCE:
|
||||
|
||||
$(obj)/dts/dt-$(SPL_NAME).dtb: dts/dt.dtb
|
||||
$(Q)$(MAKE) $(build)=$(obj)/dts spl_dtbs
|
||||
$(Q)$(MAKE) $(build)=$(obj)/dts spl_dtbs need-builtin=1
|
||||
|
||||
ifeq ($(CONFIG_OF_UPSTREAM),y)
|
||||
ifeq ($(CONFIG_ARM64),y)
|
||||
@@ -594,7 +596,7 @@ $(sort $(dir $(SHRUNK_ARCH_DTB))):
|
||||
$(shell [ -d $@ ] || mkdir -p $@)
|
||||
|
||||
.SECONDEXPANSION:
|
||||
$(SHRUNK_ARCH_DTB): $$(patsubst $(obj)/dts/%, $(dt_dir)/%, $$@) $(dir $(SHRUNK_ARCH_DTB))
|
||||
$(SHRUNK_ARCH_DTB): $$(patsubst $(obj)/dts/%, $(dt_dir)/%, $$@) $(dir $(SHRUNK_ARCH_DTB)) FORCE
|
||||
$(call if_changed,fdtgrep)
|
||||
|
||||
targets += $(SPL_OF_LIST_TARGETS)
|
||||
|
||||
@@ -9,8 +9,4 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
# fixdep: Used to generate dependency information during build process
|
||||
|
||||
hostprogs-y := fixdep
|
||||
always := $(hostprogs-y)
|
||||
|
||||
# fixdep is needed to compile other host programs
|
||||
$(addprefix $(obj)/,$(filter-out fixdep,$(always))): $(obj)/fixdep
|
||||
hostprogs-always-y += fixdep
|
||||
|
||||
Executable
+71
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# Copyright (C) 2022 Masahiro Yamada <masahiroy@kernel.org>
|
||||
#
|
||||
# Exit with error if a local exported symbol is found.
|
||||
# EXPORT_SYMBOL should be used for global symbols.
|
||||
|
||||
set -e
|
||||
|
||||
# catch errors from ${NM}
|
||||
set -o pipefail
|
||||
|
||||
# Run the last element of a pipeline in the current shell.
|
||||
# Without this, the while-loop would be executed in a subshell, and
|
||||
# the changes made to 'symbol_types' and 'export_symbols' would be lost.
|
||||
shopt -s lastpipe
|
||||
|
||||
declare -A symbol_types
|
||||
declare -a export_symbols
|
||||
|
||||
exit_code=0
|
||||
|
||||
# If there is no symbol in the object, ${NM} (both GNU nm and llvm-nm) shows
|
||||
# 'no symbols' diagnostic (but exits with 0). It is harmless and hidden by
|
||||
# '2>/dev/null'. However, it suppresses real error messages as well. Add a
|
||||
# hand-crafted error message here.
|
||||
#
|
||||
# TODO:
|
||||
# Use --quiet instead of 2>/dev/null when we upgrade the minimum version of
|
||||
# binutils to 2.37, llvm to 13.0.0.
|
||||
# Then, the following line will be really simple:
|
||||
# ${NM} --quiet ${1} |
|
||||
|
||||
{ ${NM} ${1} 2>/dev/null || { echo "${0}: ${NM} failed" >&2; false; } } |
|
||||
while read value type name
|
||||
do
|
||||
# Skip the line if the number of fields is less than 3.
|
||||
#
|
||||
# case 1)
|
||||
# For undefined symbols, the first field (value) is empty.
|
||||
# The outout looks like this:
|
||||
# " U _printk"
|
||||
# It is unneeded to record undefined symbols.
|
||||
#
|
||||
# case 2)
|
||||
# For Clang LTO, llvm-nm outputs a line with type 't' but empty name:
|
||||
# "---------------- t"
|
||||
if [[ -z ${name} ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# save (name, type) in the associative array
|
||||
symbol_types[${name}]=${type}
|
||||
|
||||
# append the exported symbol to the array
|
||||
if [[ ${name} == __ksymtab_* ]]; then
|
||||
export_symbols+=(${name#__ksymtab_})
|
||||
fi
|
||||
done
|
||||
|
||||
for name in "${export_symbols[@]}"
|
||||
do
|
||||
# nm(3) says "If lowercase, the symbol is usually local"
|
||||
if [[ ${symbol_types[$name]} =~ [a-z] ]]; then
|
||||
echo "$@: error: local symbol '${name}' was exported" >&2
|
||||
exit_code=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit ${exit_code}
|
||||
@@ -1,15 +1,14 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# scripts/dtc makefile
|
||||
|
||||
hostprogs-y := dtc
|
||||
always := $(hostprogs-y)
|
||||
hostprogs-always-y += dtc
|
||||
|
||||
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$(src)/libfdt
|
||||
HOST_EXTRACFLAGS := -I$(srctree)/$(src)/libfdt
|
||||
|
||||
# Generated files need one more search path to include headers in source tree
|
||||
HOSTCFLAGS_dtc-lexer.lex.o := -I$(src)
|
||||
|
||||
@@ -26,7 +26,7 @@ quiet_cmd_pymod = PYMOD $@
|
||||
SWIG_OPTS="-I$(LIBFDT_srcdir) -I$(LIBFDT_srcdir)/.." \
|
||||
$(PYTHON3) $< --quiet build_ext --inplace
|
||||
|
||||
rebuild: $(src)/setup.py $(PYLIBFDT_srcs)
|
||||
rebuild: $(src)/setup.py $(PYLIBFDT_srcs) FORCE
|
||||
@# Remove the library since otherwise Python doesn't seem to regenerate
|
||||
@# the libfdt.py file if it is missing.
|
||||
@rm -f $(obj)/_libfdt*.so
|
||||
@@ -39,6 +39,6 @@ rebuild: $(src)/setup.py $(PYLIBFDT_srcs)
|
||||
$(obj)/_libfdt.so $(obj)/libfdt.py &: rebuild
|
||||
@:
|
||||
|
||||
always += _libfdt.so libfdt.py
|
||||
always-y += _libfdt.so libfdt.py
|
||||
|
||||
clean-files += libfdt.i _libfdt.so libfdt.py libfdt_wrap.c
|
||||
|
||||
@@ -128,7 +128,7 @@ testconfig: $(obj)/conf
|
||||
$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
|
||||
-o cache_dir=$(abspath $(obj)/tests/.cache) \
|
||||
$(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
|
||||
clean-dirs += tests/.cache
|
||||
clean-files += tests/.cache
|
||||
|
||||
# Help text used by make help
|
||||
help:
|
||||
@@ -162,7 +162,7 @@ help:
|
||||
|
||||
conf-objs := conf.o zconf.tab.o
|
||||
|
||||
hostprogs-y := conf
|
||||
hostprogs += conf
|
||||
|
||||
targets += zconf.lex.c
|
||||
|
||||
@@ -171,7 +171,7 @@ HOSTCFLAGS_zconf.lex.o := -I$(src)
|
||||
HOSTCFLAGS_zconf.tab.o := -I$(src)
|
||||
|
||||
# nconf: Used for the nconfig target based on ncurses
|
||||
hostprogs-y += nconf
|
||||
hostprogs += nconf
|
||||
nconf-objs := nconf.o zconf.tab.o nconf.gui.o
|
||||
|
||||
HOSTLDLIBS_nconf = $(shell . $(obj)/.nconf-cfg && echo $$libs)
|
||||
@@ -181,7 +181,7 @@ HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/.nconf-cfg && echo $$cflags)
|
||||
$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/.nconf-cfg
|
||||
|
||||
# mconf: Used for the menuconfig target based on lxdialog
|
||||
hostprogs-y += mconf
|
||||
hostprogs += mconf
|
||||
lxdialog := checklist.o inputbox.o menubox.o textbox.o util.o yesno.o
|
||||
mconf-objs := mconf.o zconf.tab.o $(addprefix lxdialog/, $(lxdialog))
|
||||
|
||||
@@ -193,7 +193,7 @@ $(obj)/mconf.o: $(obj)/.mconf-cfg
|
||||
$(addprefix $(obj)/lxdialog/, $(lxdialog)): $(obj)/.mconf-cfg
|
||||
|
||||
# qconf: Used for the xconfig target based on Qt
|
||||
hostprogs-y += qconf
|
||||
hostprogs += qconf
|
||||
qconf-cxxobjs := qconf.o
|
||||
qconf-objs := zconf.tab.o
|
||||
|
||||
@@ -209,7 +209,7 @@ $(obj)/%.moc: $(src)/%.h $(obj)/.qconf-cfg
|
||||
$(call cmd,moc)
|
||||
|
||||
# gconf: Used for the gconfig target based on GTK+
|
||||
hostprogs-y += gconf
|
||||
hostprogs += gconf
|
||||
gconf-objs := gconf.o zconf.tab.o
|
||||
|
||||
HOSTLDLIBS_gconf = $(shell . $(obj)/.gconf-cfg && echo $$libs)
|
||||
|
||||
Reference in New Issue
Block a user