2020-05-13 06:37:39 +02:00
|
|
|
## SPDX-License-Identifier: BSD-3-Clause
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2019-09-16 12:25:03 +02:00
|
|
|
ifneq ($(words $(CURDIR)),1)
|
|
|
|
$(error Error: Path to the main directory cannot contain spaces)
|
|
|
|
endif
|
2017-08-23 23:48:13 +02:00
|
|
|
top := $(CURDIR)
|
|
|
|
src := src
|
|
|
|
srck := $(top)/util/kconfig
|
2015-05-07 06:00:10 +02:00
|
|
|
obj ?= build
|
|
|
|
override obj := $(subst $(top)/,,$(abspath $(obj)))
|
2019-07-11 18:44:21 +02:00
|
|
|
xcompile ?= $(obj)/xcompile
|
2017-08-23 23:48:13 +02:00
|
|
|
objutil ?= $(obj)/util
|
|
|
|
objk := $(objutil)/kconfig
|
2015-05-07 06:00:10 +02:00
|
|
|
absobj := $(abspath $(obj))
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2021-03-06 13:12:34 +01:00
|
|
|
additional-dirs :=
|
|
|
|
|
2020-03-09 03:58:37 +01:00
|
|
|
VBOOT_HOST_BUILD ?= $(abspath $(objutil)/vboot_lib)
|
|
|
|
|
2017-08-23 23:48:13 +02:00
|
|
|
COREBOOT_EXPORTS := COREBOOT_EXPORTS
|
|
|
|
COREBOOT_EXPORTS += top src srck obj objutil objk
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2017-08-23 23:48:13 +02:00
|
|
|
DOTCONFIG ?= $(top)/.config
|
|
|
|
KCONFIG_CONFIG = $(DOTCONFIG)
|
2019-01-01 19:03:33 +01:00
|
|
|
KCONFIG_AUTOADS := $(obj)/cb-config.ads
|
2017-08-23 23:48:13 +02:00
|
|
|
KCONFIG_AUTOHEADER := $(obj)/config.h
|
|
|
|
KCONFIG_AUTOCONFIG := $(obj)/auto.conf
|
|
|
|
KCONFIG_DEPENDENCIES := $(obj)/auto.conf.cmd
|
2019-11-22 16:55:58 +01:00
|
|
|
KCONFIG_SPLITCONFIG := $(obj)/config/
|
2017-08-23 23:48:13 +02:00
|
|
|
KCONFIG_TRISTATE := $(obj)/tristate.conf
|
|
|
|
KCONFIG_NEGATIVES := 1
|
|
|
|
KCONFIG_STRICT := 1
|
2019-01-01 19:03:33 +01:00
|
|
|
KCONFIG_PACKAGE := CB.Config
|
2021-11-23 20:39:44 +01:00
|
|
|
KCONFIG_MAKEFILE_REAL ?= $(objk)/Makefile.real
|
2017-08-23 23:48:13 +02:00
|
|
|
|
|
|
|
COREBOOT_EXPORTS += KCONFIG_CONFIG KCONFIG_AUTOHEADER KCONFIG_AUTOCONFIG
|
|
|
|
COREBOOT_EXPORTS += KCONFIG_DEPENDENCIES KCONFIG_SPLITCONFIG KCONFIG_TRISTATE
|
|
|
|
COREBOOT_EXPORTS += KCONFIG_NEGATIVES KCONFIG_STRICT
|
2019-01-01 19:03:33 +01:00
|
|
|
COREBOOT_EXPORTS += KCONFIG_AUTOADS KCONFIG_PACKAGE
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2022-07-01 11:12:25 +02:00
|
|
|
# Make does not offer a recursive wildcard function, so here's one:
|
|
|
|
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
|
|
|
|
SYMLINK_LIST = $(call rwildcard,site-local/,symlink.txt)
|
|
|
|
|
|
|
|
|
2011-03-01 09:09:22 +01:00
|
|
|
# directory containing the toplevel Makefile.inc
|
|
|
|
TOPLEVEL := .
|
|
|
|
|
2009-08-12 17:00:51 +02:00
|
|
|
CONFIG_SHELL := sh
|
|
|
|
KBUILD_DEFCONFIG := configs/defconfig
|
|
|
|
UNAME_RELEASE := $(shell uname -r)
|
2010-12-08 20:58:30 +01:00
|
|
|
HAVE_DOTCONFIG := $(wildcard $(DOTCONFIG))
|
2021-11-23 20:39:44 +01:00
|
|
|
HAVE_KCONFIG_MAKEFILE_REAL := $(wildcard $(KCONFIG_MAKEFILE_REAL))
|
2009-08-12 17:00:51 +02:00
|
|
|
MAKEFLAGS += -rR --no-print-directory
|
|
|
|
|
|
|
|
# Make is silent per default, but 'make V=1' will show all compiler calls.
|
2009-08-25 21:38:46 +02:00
|
|
|
Q:=@
|
2009-08-12 17:00:51 +02:00
|
|
|
ifneq ($(V),1)
|
2009-08-25 21:38:46 +02:00
|
|
|
ifneq ($(Q),)
|
|
|
|
.SILENT:
|
2020-02-16 11:47:52 +01:00
|
|
|
MAKEFLAGS += -s
|
2021-11-21 16:42:04 +01:00
|
|
|
quiet_errors := 2>/dev/null
|
2009-08-25 21:38:46 +02:00
|
|
|
endif
|
2009-08-12 17:00:51 +02:00
|
|
|
endif
|
|
|
|
|
2015-03-13 19:05:07 +01:00
|
|
|
# Disable implicit/built-in rules to make Makefile errors fail fast.
|
|
|
|
.SUFFIXES:
|
|
|
|
|
2012-09-13 22:13:33 +02:00
|
|
|
HOSTCFLAGS := -g
|
|
|
|
HOSTCXXFLAGS := -g
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2022-12-11 13:13:45 +01:00
|
|
|
HOSTPKG_CONFIG ?= pkg-config
|
|
|
|
COREBOOT_EXPORTS += HOSTPKG_CONFIG
|
|
|
|
|
2015-04-04 15:50:20 +02:00
|
|
|
PREPROCESS_ONLY := -E -P -x assembler-with-cpp -undef -I .
|
|
|
|
|
2017-08-23 23:48:13 +02:00
|
|
|
export $(COREBOOT_EXPORTS)
|
|
|
|
|
2011-02-22 15:35:05 +01:00
|
|
|
all: real-all
|
|
|
|
|
2015-11-25 19:50:04 +01:00
|
|
|
help_coreboot help::
|
|
|
|
@echo '*** coreboot platform targets ***'
|
2015-11-18 21:09:23 +01:00
|
|
|
@echo ' Use "make [target] V=1" for extra build debug information'
|
|
|
|
@echo ' all - Build coreboot'
|
|
|
|
@echo ' clean - Remove coreboot build artifacts'
|
|
|
|
@echo ' distclean - Remove build artifacts and config files'
|
2020-05-17 20:04:12 +02:00
|
|
|
@echo ' sphinx - Build sphinx documentation for coreboot'
|
|
|
|
@echo ' sphinx-lint - Build sphinx documenttion for coreboot with warnings as errors'
|
2018-01-28 00:42:43 +01:00
|
|
|
@echo ' filelist - Show files used in current build'
|
2015-11-18 21:09:23 +01:00
|
|
|
@echo ' printall - print makefile info for debugging'
|
2016-01-12 12:45:49 +01:00
|
|
|
@echo ' gitconfig - set up git to submit patches to coreboot'
|
2015-11-18 21:09:23 +01:00
|
|
|
@echo ' ctags / ctags-project - make ctags file for all of coreboot or current board'
|
|
|
|
@echo ' cscope / cscope-project - make cscope.out file for coreboot or current board'
|
|
|
|
@echo
|
|
|
|
|
2011-03-01 09:09:22 +01:00
|
|
|
# This include must come _before_ the pattern rules below!
|
2011-02-22 15:35:05 +01:00
|
|
|
# Order _does_ matter for pattern rules.
|
2019-11-22 16:54:17 +01:00
|
|
|
include $(srck)/Makefile.inc
|
2011-02-22 15:35:05 +01:00
|
|
|
|
2021-11-23 20:39:44 +01:00
|
|
|
# The cases where we don't need fully populated $(obj) lists:
|
2010-04-21 08:36:20 +02:00
|
|
|
# 1. when no .config exists
|
2021-11-23 20:39:44 +01:00
|
|
|
# 2. When no $(obj)/util/kconfig/Makefile.real exists and we're building tools
|
|
|
|
# 3. when make config (in any flavour) is run
|
|
|
|
# 4. when make distclean is run
|
2010-04-21 08:36:20 +02:00
|
|
|
# Don't waste time on reading all Makefile.incs in these cases
|
2009-08-12 17:00:51 +02:00
|
|
|
ifeq ($(strip $(HAVE_DOTCONFIG)),)
|
2010-04-21 08:36:20 +02:00
|
|
|
NOCOMPILE:=1
|
|
|
|
endif
|
2021-11-23 20:39:44 +01:00
|
|
|
ifeq ($(strip $(HAVE_KCONFIG_MAKEFILE_REAL)),)
|
|
|
|
ifneq ($(MAKECMDGOALS),tools)
|
|
|
|
NOCOMPILE:=1
|
|
|
|
endif
|
|
|
|
endif
|
2010-04-21 08:36:20 +02:00
|
|
|
ifneq ($(MAKECMDGOALS),)
|
2020-01-20 15:33:11 +01:00
|
|
|
ifneq ($(filter %config %clean cross% clang iasl lint% help% what-jenkins-does,$(MAKECMDGOALS)),)
|
2010-04-21 08:36:20 +02:00
|
|
|
NOCOMPILE:=1
|
|
|
|
endif
|
2019-07-23 19:13:40 +02:00
|
|
|
ifneq ($(filter %clean lint% help% what-jenkins-does,$(MAKECMDGOALS)),)
|
2012-10-22 10:36:03 +02:00
|
|
|
NOMKDIR:=1
|
2021-04-13 16:07:05 +02:00
|
|
|
UNIT_TEST:=1
|
2012-10-22 10:36:03 +02:00
|
|
|
endif
|
2010-04-21 08:36:20 +02:00
|
|
|
endif
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2021-04-13 16:07:05 +02:00
|
|
|
ifneq ($(filter help%, $(MAKECMDGOALS)), )
|
|
|
|
NOCOMPILE:=1
|
|
|
|
UNIT_TEST:=1
|
|
|
|
else
|
2021-05-11 17:56:48 +02:00
|
|
|
ifneq ($(filter %-test %-tests %coverage-report, $(MAKECMDGOALS)),)
|
|
|
|
ifneq ($(filter-out %-test %-tests %coverage-report, $(MAKECMDGOALS)),)
|
2020-03-28 00:15:03 +01:00
|
|
|
$(error Cannot mix unit-tests targets with other targets)
|
|
|
|
endif
|
|
|
|
UNIT_TEST:=1
|
|
|
|
NOCOMPILE:=
|
|
|
|
endif
|
2021-04-13 16:07:05 +02:00
|
|
|
endif
|
2020-03-28 00:15:03 +01:00
|
|
|
|
2019-07-11 18:44:21 +02:00
|
|
|
$(xcompile): util/xcompile/xcompile
|
2019-07-11 00:46:34 +02:00
|
|
|
rm -f $@
|
|
|
|
$< $(XGCCPATH) > $@.tmp
|
|
|
|
\mv -f $@.tmp $@ 2> /dev/null
|
|
|
|
rm -f $@.tmp
|
|
|
|
|
2010-04-21 08:36:20 +02:00
|
|
|
ifeq ($(NOCOMPILE),1)
|
2020-07-06 17:31:58 +02:00
|
|
|
# We also don't use .xcompile in the no-compile situations, so
|
|
|
|
# provide some reasonable defaults.
|
|
|
|
HOSTCC ?= $(if $(shell type gcc 2>/dev/null),gcc,cc)
|
|
|
|
HOSTCXX ?= g++
|
|
|
|
|
2011-03-01 09:09:22 +01:00
|
|
|
include $(TOPLEVEL)/Makefile.inc
|
2016-03-08 00:38:52 +01:00
|
|
|
include $(TOPLEVEL)/payloads/Makefile.inc
|
2017-07-31 19:52:58 +02:00
|
|
|
include $(TOPLEVEL)/util/testing/Makefile.inc
|
2019-10-04 07:01:13 +02:00
|
|
|
-include $(TOPLEVEL)/site-local/Makefile.inc
|
2021-04-13 16:07:05 +02:00
|
|
|
include $(TOPLEVEL)/tests/Makefile.inc
|
2022-11-28 03:04:16 +01:00
|
|
|
printall real-all:
|
2022-06-23 01:49:31 +02:00
|
|
|
@echo "Error: Trying to build, but NOCOMPILE is set." >&2
|
|
|
|
@echo " Please file a bug with the following information:"
|
|
|
|
@echo "- MAKECMDGOALS: $(MAKECMDGOALS)" >&2
|
|
|
|
@echo "- HAVE_DOTCONFIG: $(HAVE_DOTCONFIG)" >&2
|
|
|
|
@echo "- HAVE_KCONFIG_MAKEFILE_REAL: $(HAVE_KCONFIG_MAKEFILE_REAL)" >&2
|
2017-01-26 18:51:43 +01:00
|
|
|
@exit 1
|
2022-11-28 03:04:16 +01:00
|
|
|
|
2009-08-12 17:00:51 +02:00
|
|
|
else
|
|
|
|
|
2020-03-28 00:15:03 +01:00
|
|
|
ifneq ($(UNIT_TEST),1)
|
2016-07-13 11:00:41 +02:00
|
|
|
include $(DOTCONFIG)
|
2020-03-28 00:15:03 +01:00
|
|
|
endif
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2019-07-11 18:44:21 +02:00
|
|
|
# The toolchain requires xcompile to determine the ARCH_SUPPORTED, so we can't
|
|
|
|
# wait for make to generate the file.
|
|
|
|
$(if $(wildcard $(xcompile)),, $(shell \
|
|
|
|
mkdir -p $(dir $(xcompile)) && \
|
|
|
|
util/xcompile/xcompile $(XGCCPATH) > $(xcompile) || rm -f $(xcompile)))
|
2017-01-19 23:20:14 +01:00
|
|
|
|
2019-07-11 18:44:21 +02:00
|
|
|
include $(xcompile)
|
2015-11-19 15:15:33 +01:00
|
|
|
|
|
|
|
ifneq ($(XCOMPILE_COMPLETE),1)
|
2019-07-11 18:44:21 +02:00
|
|
|
$(shell rm -f $(xcompile))
|
|
|
|
$(error $(xcompile) deleted because it's invalid. \
|
2015-11-19 15:15:33 +01:00
|
|
|
Restarting the build should fix that, or explain the problem)
|
|
|
|
endif
|
2015-06-04 13:18:11 +02:00
|
|
|
|
2021-04-13 15:48:38 +02:00
|
|
|
# reproducible builds
|
|
|
|
LANG:=C
|
|
|
|
LC_ALL:=C
|
|
|
|
TZ:=UTC0
|
|
|
|
ifneq ($(NOCOMPILE),1)
|
|
|
|
SOURCE_DATE_EPOCH := $(shell $(top)/util/genbuild_h/genbuild_h.sh . | sed -n 's/^.define COREBOOT_BUILD_EPOCH\>.*"\(.*\)".*/\1/p')
|
|
|
|
endif
|
|
|
|
# don't use COREBOOT_EXPORTS to ensure build steps outside the coreboot build system
|
|
|
|
# are reproducible
|
|
|
|
export LANG LC_ALL TZ SOURCE_DATE_EPOCH
|
|
|
|
|
2020-03-28 00:15:03 +01:00
|
|
|
ifneq ($(UNIT_TEST),1)
|
2014-05-14 21:05:35 +02:00
|
|
|
include toolchain.inc
|
2020-03-28 00:15:03 +01:00
|
|
|
endif
|
2014-05-14 21:05:35 +02:00
|
|
|
|
2015-11-13 03:42:27 +01:00
|
|
|
strip_quotes = $(strip $(subst ",,$(subst \",,$(1))))
|
2016-01-25 23:59:24 +01:00
|
|
|
# fix makefile syntax highlighting after strip macro \" "))
|
2010-03-16 20:01:32 +01:00
|
|
|
|
2022-12-14 16:26:35 +01:00
|
|
|
ifneq ($(NOCOMPILE),1)
|
|
|
|
$(shell rm -f $(CCACHE_STATSLOG))
|
|
|
|
endif
|
|
|
|
|
2009-08-12 17:00:51 +02:00
|
|
|
# The primary target needs to be here before we include the
|
|
|
|
# other files
|
|
|
|
|
2011-02-22 15:35:05 +01:00
|
|
|
real-all: real-target
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2010-03-27 18:18:39 +01:00
|
|
|
# must come rather early
|
2022-02-26 01:03:10 +01:00
|
|
|
.SECONDARY:
|
2010-03-27 18:18:39 +01:00
|
|
|
.SECONDEXPANSION:
|
2018-08-07 00:13:32 +02:00
|
|
|
.DELETE_ON_ERROR:
|
2010-03-27 18:18:39 +01:00
|
|
|
|
2018-12-11 13:06:40 +01:00
|
|
|
$(KCONFIG_AUTOHEADER): $(KCONFIG_CONFIG) $(objutil)/kconfig/conf
|
2019-11-22 16:55:58 +01:00
|
|
|
$(MAKE) olddefconfig
|
|
|
|
$(MAKE) syncconfig
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2019-01-01 19:03:33 +01:00
|
|
|
$(KCONFIG_AUTOCONFIG): $(KCONFIG_AUTOHEADER)
|
|
|
|
true
|
|
|
|
|
Makefile: Switch to `.config` as input for the Ada `CB.Config`
So, this is odd in multiple ways. First of all, we fix something:
We work around a weirdness in `make oldconfig` that adds spurious
entries into the `auto.conf` for choices that were given a symbol
name.
When introducing the Ada config package, it seemed reasonable to
use `auto.conf` as source, but it turned out that we didn't use it
as input, only `config.h` and the original `.config` were used. As
the syntax for `.config` is the same as for `auto.conf` we use the
former now as input for Ada, too. One question remains: If `.config`
already contains all required information, what is this `auto.conf`
and what does it want?
Alternatively, we could try to fix `oldconfig` or add a linter to
forbid named choices. I thought, our build test would reject the
latter already. But the `oldconfig` behaviour is too subtle.
We keep a dependency on the `oldconfig` step, to make sure it runs
first.
Change-Id: If3fe6bc782251cdbd696395d3069a1c0bb0ae802
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/36320
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2019-10-25 12:47:14 +02:00
|
|
|
$(KCONFIG_AUTOADS): $(KCONFIG_CONFIG) $(KCONFIG_AUTOHEADER) $(objutil)/kconfig/toada
|
2019-01-01 19:03:33 +01:00
|
|
|
$(objutil)/kconfig/toada CB.Config <$< >$@
|
|
|
|
|
2019-01-01 22:06:01 +01:00
|
|
|
$(obj)/%/$(notdir $(KCONFIG_AUTOADS)): $(KCONFIG_AUTOADS)
|
|
|
|
cp $< $@
|
|
|
|
|
2011-02-17 21:47:49 +01:00
|
|
|
# Add a new class of source/object files to the build system
|
|
|
|
add-class= \
|
|
|
|
$(eval $(1)-srcs:=) \
|
|
|
|
$(eval $(1)-objs:=) \
|
|
|
|
$(eval classes+=$(1))
|
|
|
|
|
|
|
|
# Special classes are managed types with special behaviour
|
|
|
|
# On parse time, for each entry in variable $(1)-y
|
|
|
|
# a handler $(1)-handler is executed with the arguments:
|
|
|
|
# * $(1): directory the parser is in
|
|
|
|
# * $(2): current entry
|
|
|
|
add-special-class= \
|
|
|
|
$(eval $(1):=) \
|
|
|
|
$(eval special-classes+=$(1))
|
|
|
|
|
2016-01-23 00:50:00 +01:00
|
|
|
# Converts one or more source file paths to their corresponding build/ paths.
|
2016-01-14 01:13:33 +01:00
|
|
|
# Only .ads, adb, .c and .S get converted to .o, other files (like .ld) keep
|
|
|
|
# their name.
|
2016-01-23 00:50:00 +01:00
|
|
|
# $1 stage name
|
|
|
|
# $2 file path (list)
|
2016-01-23 01:24:33 +01:00
|
|
|
src-to-obj=\
|
|
|
|
$(patsubst $(obj)/%,$(obj)/$(1)/%,\
|
|
|
|
$(patsubst $(obj)/$(1)/%,$(obj)/%,\
|
2016-10-05 17:41:31 +02:00
|
|
|
$(patsubst 3rdparty/%,$(obj)/%,\
|
2016-01-23 01:24:33 +01:00
|
|
|
$(patsubst src/%,$(obj)/%,\
|
2016-01-14 01:13:33 +01:00
|
|
|
$(patsubst %.ads,%.o,\
|
|
|
|
$(patsubst %.adb,%.o,\
|
2016-01-23 01:24:33 +01:00
|
|
|
$(patsubst %.c,%.o,\
|
|
|
|
$(patsubst %.S,%.o,\
|
2016-10-05 17:41:31 +02:00
|
|
|
$(subst .$(1),,$(2))))))))))
|
2016-01-14 01:13:33 +01:00
|
|
|
|
|
|
|
# Converts one or more source file paths to the corresponding build/ paths
|
|
|
|
# of their Ada library information (.ali) files.
|
|
|
|
# $1 stage name
|
|
|
|
# $2 file path (list)
|
|
|
|
src-to-ali=\
|
|
|
|
$(patsubst $(obj)/%,$(obj)/$(1)/%,\
|
|
|
|
$(patsubst $(obj)/$(1)/%,$(obj)/%,\
|
2016-10-05 17:41:31 +02:00
|
|
|
$(patsubst 3rdparty/%,$(obj)/%,\
|
2016-01-14 01:13:33 +01:00
|
|
|
$(patsubst src/%,$(obj)/%,\
|
|
|
|
$(patsubst %.ads,%.ali,\
|
|
|
|
$(patsubst %.adb,%.ali,\
|
|
|
|
$(subst .$(1),,\
|
2016-10-05 17:41:31 +02:00
|
|
|
$(filter %.ads %.adb,$(2)))))))))
|
2016-01-23 00:50:00 +01:00
|
|
|
|
2010-03-06 22:18:43 +01:00
|
|
|
# Clean -y variables, include Makefile.inc
|
2010-09-30 18:55:02 +02:00
|
|
|
# Add paths to files in X-y to X-srcs
|
2010-03-06 22:18:43 +01:00
|
|
|
# Add subdirs-y to subdirs
|
|
|
|
includemakefiles= \
|
2022-09-24 15:48:15 +02:00
|
|
|
$(if $(wildcard $(1)), \
|
|
|
|
$(foreach class,classes subdirs $(classes) $(special-classes), $(eval $(class)-y:=)) \
|
|
|
|
$(eval -include $(1)) \
|
|
|
|
$(foreach class,$(classes-y), $(call add-class,$(class))) \
|
|
|
|
$(foreach special,$(special-classes), \
|
|
|
|
$(foreach item,$($(special)-y), $(call $(special)-handler,$(dir $(1)),$(item)))) \
|
|
|
|
$(foreach class,$(classes), \
|
|
|
|
$(eval $(class)-srcs+= \
|
|
|
|
$$(subst $(absobj)/,$(obj)/, \
|
|
|
|
$$(subst $(top)/,, \
|
|
|
|
$$(abspath $$(subst $(dir $(1))/,/,$$(addprefix $(dir $(1)),$$($(class)-y)))))))) \
|
|
|
|
$(eval subdirs+=$$(subst $(CURDIR)/,,$$(wildcard $$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y)))))))
|
2010-03-06 22:18:43 +01:00
|
|
|
|
2010-09-30 18:55:02 +02:00
|
|
|
# For each path in $(subdirs) call includemakefiles
|
2010-03-06 22:18:43 +01:00
|
|
|
# Repeat until subdirs is empty
|
|
|
|
evaluate_subdirs= \
|
|
|
|
$(eval cursubdirs:=$(subdirs)) \
|
|
|
|
$(eval subdirs:=) \
|
|
|
|
$(foreach dir,$(cursubdirs), \
|
2011-02-17 21:47:49 +01:00
|
|
|
$(eval $(call includemakefiles,$(dir)/Makefile.inc))) \
|
2010-03-27 18:18:39 +01:00
|
|
|
$(if $(subdirs),$(eval $(call evaluate_subdirs)))
|
2009-08-12 17:00:51 +02:00
|
|
|
|
|
|
|
# collect all object files eligible for building
|
2011-03-01 09:09:22 +01:00
|
|
|
subdirs:=$(TOPLEVEL)
|
Remove libverstage as separate library and source file class
In builds without CONFIG_VBOOT_SEPARATE_VERSTAGE, verstage files are
linked directly into the bootblock or the romstage. However, they're
still compiled with a separate "libverstage" source file class, linked
into an intermediate library and then linked into the final destination
stage.
There is no obvious benefit to doing it this way and it's unclear why it
was chosen in the first place... there are, however, obvious
disadvantages: it can result in code that is used by both libverstage
and the host stage to occur twice in the output binary. It also means
that libverstage files have their separate compiler flags that are not
necessarily aligned with the host stage, which can lead to weird effects
like <rules.h> macros not being set the way you would expect. In fact,
VBOOT_STARTS_IN_ROMSTAGE configurations are currently broken on x86
because their libverstage code that gets compiled into the romstage sets
ENV_VERSTAGE, but CAR migration code expects all ENV_VERSTAGE code to
run pre-migration.
This patch resolves these problems by removing the separate library.
There is no more difference between the 'verstage' and 'libverstage'
classes, and the source files added to them are just treated the same
way a bootblock or romstage source files in configurations where the
verstage is linked into either of these respective stages (allowing for
the normal object code deduplication and causing those files to be
compiled with the same flags as the host stage's files).
Tested this whole series by booting a Kevin, an Elm (both with and
without SEPARATE_VERSTAGE) and a Falco in normal and recovery mode.
Change-Id: I6bb84a9bf1cd54f2e02ca1f665740a9c88d88df4
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://review.coreboot.org/18302
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-03-20 23:32:15 +01:00
|
|
|
postinclude-hooks :=
|
2020-03-28 00:15:03 +01:00
|
|
|
|
|
|
|
# Don't iterate through Makefile.incs under src/ when building tests
|
|
|
|
ifneq ($(UNIT_TEST),1)
|
2010-03-27 18:18:39 +01:00
|
|
|
$(eval $(call evaluate_subdirs))
|
2020-03-28 00:15:03 +01:00
|
|
|
else
|
|
|
|
include $(TOPLEVEL)/tests/Makefile.inc
|
|
|
|
endif
|
|
|
|
|
2013-02-16 01:06:57 +01:00
|
|
|
ifeq ($(FAILBUILD),1)
|
|
|
|
$(error cannot continue build)
|
|
|
|
endif
|
2009-08-12 17:00:51 +02:00
|
|
|
|
Remove libverstage as separate library and source file class
In builds without CONFIG_VBOOT_SEPARATE_VERSTAGE, verstage files are
linked directly into the bootblock or the romstage. However, they're
still compiled with a separate "libverstage" source file class, linked
into an intermediate library and then linked into the final destination
stage.
There is no obvious benefit to doing it this way and it's unclear why it
was chosen in the first place... there are, however, obvious
disadvantages: it can result in code that is used by both libverstage
and the host stage to occur twice in the output binary. It also means
that libverstage files have their separate compiler flags that are not
necessarily aligned with the host stage, which can lead to weird effects
like <rules.h> macros not being set the way you would expect. In fact,
VBOOT_STARTS_IN_ROMSTAGE configurations are currently broken on x86
because their libverstage code that gets compiled into the romstage sets
ENV_VERSTAGE, but CAR migration code expects all ENV_VERSTAGE code to
run pre-migration.
This patch resolves these problems by removing the separate library.
There is no more difference between the 'verstage' and 'libverstage'
classes, and the source files added to them are just treated the same
way a bootblock or romstage source files in configurations where the
verstage is linked into either of these respective stages (allowing for
the normal object code deduplication and causing those files to be
compiled with the same flags as the host stage's files).
Tested this whole series by booting a Kevin, an Elm (both with and
without SEPARATE_VERSTAGE) and a Falco in normal and recovery mode.
Change-Id: I6bb84a9bf1cd54f2e02ca1f665740a9c88d88df4
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://review.coreboot.org/18302
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-03-20 23:32:15 +01:00
|
|
|
# Run hooks registered by subdirectories that need to be evaluated after all files have been parsed
|
|
|
|
$(eval $(postinclude-hooks))
|
|
|
|
|
2011-10-25 23:32:21 +02:00
|
|
|
# Eliminate duplicate mentions of source files in a class
|
|
|
|
$(foreach class,$(classes),$(eval $(class)-srcs:=$(sort $($(class)-srcs))))
|
|
|
|
|
2023-08-15 23:57:29 +02:00
|
|
|
ifeq ($(CONFIG_IWYU),y)
|
|
|
|
MAKEFLAGS += -k
|
|
|
|
SAVE_IWYU_OUTPUT := 2>&1 | grep "should\|\#include\|---\|include-list\|^[[:blank:]]\?\'" | tee -a $$(obj)/iwyu.txt
|
|
|
|
endif
|
|
|
|
|
2019-01-01 22:06:01 +01:00
|
|
|
# Build Kconfig .ads if necessary
|
2022-12-01 03:26:01 +01:00
|
|
|
ifeq ($(CONFIG_ROMSTAGE_ADA),y)
|
|
|
|
romstage-srcs += $(obj)/romstage/$(notdir $(KCONFIG_AUTOADS))
|
|
|
|
endif
|
2019-01-01 22:06:01 +01:00
|
|
|
ifeq ($(CONFIG_RAMSTAGE_ADA),y)
|
|
|
|
ramstage-srcs += $(obj)/ramstage/$(notdir $(KCONFIG_AUTOADS))
|
|
|
|
endif
|
|
|
|
|
2016-01-14 01:13:33 +01:00
|
|
|
# To track dependencies, we need all Ada specification (.ads) files in
|
|
|
|
# *-srcs. Extract / filter all specification files that have a matching
|
|
|
|
# body (.adb) file here (specifications without a body are valid sources
|
|
|
|
# in Ada).
|
|
|
|
$(foreach class,$(classes),$(eval $(class)-extra-specs := \
|
|
|
|
$(filter \
|
|
|
|
$(addprefix %/,$(patsubst %.adb,%.ads,$(notdir $(filter %.adb,$($(class)-srcs))))), \
|
|
|
|
$(filter %.ads,$($(class)-srcs)))))
|
|
|
|
$(foreach class,$(classes),$(eval $(class)-srcs := \
|
|
|
|
$(filter-out $($(class)-extra-specs),$($(class)-srcs))))
|
|
|
|
|
2015-03-27 16:56:23 +01:00
|
|
|
$(foreach class,$(classes),$(eval $(class)-objs:=$(call src-to-obj,$(class),$($(class)-srcs))))
|
2016-01-14 01:13:33 +01:00
|
|
|
$(foreach class,$(classes),$(eval $(class)-alis:=$(call src-to-ali,$(class),$($(class)-srcs))))
|
|
|
|
|
|
|
|
# For Ada includes
|
|
|
|
$(foreach class,$(classes),$(eval $(class)-ada-dirs:=$(sort $(dir $(filter %.ads %.adb,$($(class)-srcs)) $($(class)-extra-specs)))))
|
2010-09-30 18:55:02 +02:00
|
|
|
|
2013-05-15 11:47:51 +02:00
|
|
|
# Save all objs before processing them (for dependency inclusion)
|
|
|
|
originalobjs:=$(foreach var, $(addsuffix -objs,$(classes)), $($(var)))
|
|
|
|
|
2012-11-25 14:31:08 +01:00
|
|
|
# Call post-processors if they're defined
|
|
|
|
$(foreach class,$(classes),\
|
|
|
|
$(if $(value $(class)-postprocess),$(eval $(call $(class)-postprocess,$($(class)-objs)))))
|
|
|
|
|
2011-02-17 21:47:49 +01:00
|
|
|
allsrcs:=$(foreach var, $(addsuffix -srcs,$(classes)), $($(var)))
|
|
|
|
allobjs:=$(foreach var, $(addsuffix -objs,$(classes)), $($(var)))
|
2009-08-12 17:00:51 +02:00
|
|
|
alldirs:=$(sort $(abspath $(dir $(allobjs))))
|
|
|
|
|
2016-01-14 01:13:33 +01:00
|
|
|
# Reads dependencies from an Ada library information (.ali) file
|
|
|
|
# Only basenames (with suffix) are preserved so we have to look the
|
|
|
|
# paths up in $($(stage)-srcs).
|
|
|
|
# $1 stage name
|
|
|
|
# $2 ali file
|
|
|
|
create_ada_deps=$$(if $(2),\
|
|
|
|
gnat.adc \
|
|
|
|
$$(filter \
|
|
|
|
$$(addprefix %/,$$(shell sed -ne's/^D \([^\t]\+\).*$$$$/\1/p' $(2) 2>/dev/null)), \
|
|
|
|
$$($(1)-srcs) $$($(1)-extra-specs)))
|
|
|
|
|
2010-03-16 13:01:13 +01:00
|
|
|
# macro to define template macros that are used by use_template macro
|
|
|
|
define create_cc_template
|
2011-02-22 15:35:05 +01:00
|
|
|
# $1 obj class
|
2015-04-03 10:47:15 +02:00
|
|
|
# $2 source suffix (c, S, ld, ...)
|
2014-11-06 23:50:22 +01:00
|
|
|
# $3 additional compiler flags
|
|
|
|
# $4 additional dependencies
|
2011-02-17 21:48:45 +01:00
|
|
|
ifn$(EMPTY)def $(1)-objs_$(2)_template
|
2010-09-30 18:55:02 +02:00
|
|
|
de$(EMPTY)fine $(1)-objs_$(2)_template
|
2017-09-03 23:42:58 +02:00
|
|
|
ifn$(EMPTY)eq ($(filter ads adb,$(2)),)
|
2019-01-01 22:06:01 +01:00
|
|
|
$$(call src-to-obj,$1,$$(1).$2): $$(1).$2 $$(call create_ada_deps,$1,$$(call src-to-ali,$1,$$(1).$2)) $(4)
|
2017-09-03 23:42:58 +02:00
|
|
|
@printf " GCC $$$$(subst $$$$(obj)/,,$$$$(@))\n"
|
|
|
|
$(GCC_$(1)) \
|
|
|
|
$$$$(ADAFLAGS_$(1)) $$$$(addprefix -I,$$$$($(1)-ada-dirs)) \
|
|
|
|
$(3) -c -o $$$$@ $$$$<
|
|
|
|
el$(EMPTY)se
|
|
|
|
$$(call src-to-obj,$1,$$(1).$2): $$(1).$2 $(KCONFIG_AUTOHEADER) $(4)
|
2010-04-19 22:39:22 +02:00
|
|
|
@printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n"
|
2016-01-14 01:13:33 +01:00
|
|
|
$(CC_$(1)) \
|
2017-09-03 23:42:58 +02:00
|
|
|
-MMD $$$$(CPPFLAGS_$(1)) $$$$(CFLAGS_$(1)) -MT $$$$(@) \
|
2023-08-15 23:57:29 +02:00
|
|
|
$(3) -c -o $$$$@ $$$$< $(SAVE_IWYU_OUTPUT)
|
2017-09-03 23:42:58 +02:00
|
|
|
end$(EMPTY)if
|
2010-03-16 13:01:13 +01:00
|
|
|
en$(EMPTY)def
|
2011-02-17 21:48:45 +01:00
|
|
|
end$(EMPTY)if
|
2009-08-12 17:00:51 +02:00
|
|
|
endef
|
|
|
|
|
2011-02-17 21:48:45 +01:00
|
|
|
filetypes-of-class=$(subst .,,$(sort $(suffix $($(1)-srcs))))
|
|
|
|
$(foreach class,$(classes), \
|
|
|
|
$(foreach type,$(call filetypes-of-class,$(class)), \
|
2015-03-27 15:27:21 +01:00
|
|
|
$(eval $(class)-$(type)-ccopts += $(generic-$(type)-ccopts) $($(class)-generic-ccopts)) \
|
2015-04-03 10:19:38 +02:00
|
|
|
$(if $(generic-objs_$(type)_template_gen),$(eval $(call generic-objs_$(type)_template_gen,$(class))),\
|
|
|
|
$(eval $(call create_cc_template,$(class),$(type),$($(class)-$(type)-ccopts),$($(class)-$(type)-deps))))))
|
2010-09-30 18:55:02 +02:00
|
|
|
|
2015-04-03 10:32:17 +02:00
|
|
|
foreach-src=$(foreach file,$($(1)-srcs),$(eval $(call $(1)-objs_$(subst .,,$(suffix $(file)))_template,$(basename $(file)))))
|
2011-02-17 21:47:49 +01:00
|
|
|
$(eval $(foreach class,$(classes),$(call foreach-src,$(class))))
|
2010-09-30 18:55:02 +02:00
|
|
|
|
2016-01-14 01:13:33 +01:00
|
|
|
# To supported complex package initializations, we need to call the
|
|
|
|
# emitted code explicitly. gnatbind gathers all the calls for us
|
|
|
|
# and exports them as a procedure $(stage)_adainit(). Every stage that
|
|
|
|
# uses Ada code has to call it!
|
|
|
|
define gnatbind_template
|
|
|
|
# $1 class
|
|
|
|
$$(obj)/$(1)/b__$(1).adb: $$$$(filter-out $$(obj)/$(1)/b__$(1).ali,$$$$($(1)-alis))
|
|
|
|
@printf " BIND $$(subst $$(obj)/,,$$@)\n"
|
|
|
|
# We have to give gnatbind a simple filename (without leading
|
|
|
|
# path components) so just cd there.
|
|
|
|
cd $$(dir $$@) && \
|
|
|
|
$$(GNATBIND_$(1)) -a -n \
|
2015-09-29 16:41:19 +02:00
|
|
|
--RTS=$$(absobj)/libgnat-$$(ARCH-$(1)-y)/ \
|
2016-01-14 01:13:33 +01:00
|
|
|
-L$(1)_ada -o $$(notdir $$@) \
|
|
|
|
$$(subst $$(dir $$@),,$$^)
|
|
|
|
$$(obj)/$(1)/b__$(1).o: $$(obj)/$(1)/b__$(1).adb
|
2017-09-03 23:42:58 +02:00
|
|
|
@printf " GCC $$(subst $$(obj)/,,$$@)\n"
|
|
|
|
$(GCC_$(1)) $$(ADAFLAGS_$(1)) -c -o $$@ $$<
|
2016-01-14 01:13:33 +01:00
|
|
|
$(1)-objs += $$(obj)/$(1)/b__$(1).o
|
2016-09-19 11:50:04 +02:00
|
|
|
$($(1)-alis): %.ali: %.o ;
|
2016-01-14 01:13:33 +01:00
|
|
|
endef
|
|
|
|
|
2015-09-29 16:41:19 +02:00
|
|
|
$(eval $(foreach class,$(filter-out libgnat-%,$(classes)), \
|
2016-01-14 01:13:33 +01:00
|
|
|
$(if $($(class)-alis),$(call gnatbind_template,$(class)))))
|
|
|
|
|
2014-12-05 21:32:09 +01:00
|
|
|
DEPENDENCIES += $(addsuffix .d,$(basename $(allobjs)))
|
2010-03-24 16:51:48 +01:00
|
|
|
-include $(DEPENDENCIES)
|
|
|
|
|
2009-08-12 17:00:51 +02:00
|
|
|
printall:
|
2016-06-05 18:52:43 +02:00
|
|
|
@$(foreach class,$(classes), echo $(class)-objs: $($(class)-objs) | tr ' ' '\n'; echo; )
|
|
|
|
@echo alldirs: $(alldirs) | tr ' ' '\n'; echo
|
|
|
|
@echo allsrcs: $(allsrcs) | tr ' ' '\n'; echo
|
|
|
|
@echo DEPENDENCIES: $(DEPENDENCIES) | tr ' ' '\n'; echo
|
|
|
|
@$(foreach class,$(special-classes),echo $(class):'$($(class))' | tr ' ' '\n'; echo; )
|
2009-08-12 17:00:51 +02:00
|
|
|
endif
|
|
|
|
|
2011-05-22 00:18:59 +02:00
|
|
|
ifndef NOMKDIR
|
2015-06-29 23:44:37 +02:00
|
|
|
$(shell mkdir -p $(KCONFIG_SPLITCONFIG) $(objk)/lxdialog $(additional-dirs) $(alldirs))
|
2011-05-22 00:18:59 +02:00
|
|
|
endif
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2017-09-18 17:25:18 +02:00
|
|
|
$(obj)/project_filelist.txt:
|
|
|
|
if [ -z "$(wildcard $(obj)/coreboot.rom)" ]; then \
|
|
|
|
echo "*** Error: Project must be built before generating file list ***"; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
2022-12-26 00:29:49 +01:00
|
|
|
find $(obj) -path "$(obj)/util" -prune -o -path "$(obj)/external" -prune -o -name "*.d" -exec cat {} \; | \
|
2017-09-26 17:53:30 +02:00
|
|
|
sed "s|$(top)/||" | sed 's/[:\\]/ /g' | sed 's/ /\n/g' | sort | uniq | \
|
2015-07-29 23:55:18 +02:00
|
|
|
grep -v '\.o$$' > $(obj)/project_filelist.txt
|
|
|
|
|
2017-09-18 17:25:18 +02:00
|
|
|
filelist: $(obj)/project_filelist.txt
|
2017-06-06 14:44:46 +02:00
|
|
|
printf "\nFiles used in build:\n"
|
|
|
|
cat $(obj)/project_filelist.txt
|
|
|
|
|
2015-07-29 23:55:18 +02:00
|
|
|
#works with either exuberant ctags or ctags.emacs
|
|
|
|
ctags-project: clean-ctags $(obj)/project_filelist.txt
|
|
|
|
cat $(obj)/project_filelist.txt | \
|
|
|
|
xargs ctags -o tags
|
|
|
|
|
|
|
|
cscope-project: clean-cscope $(obj)/project_filelist.txt
|
|
|
|
cat $(obj)/project_filelist.txt | xargs cscope -b
|
|
|
|
|
2010-09-03 10:57:32 +02:00
|
|
|
cscope:
|
|
|
|
cscope -bR
|
|
|
|
|
2020-05-17 20:04:12 +02:00
|
|
|
sphinx:
|
|
|
|
$(MAKE) -C Documentation -f Makefile.sphinx html
|
|
|
|
|
|
|
|
sphinx-lint:
|
|
|
|
$(MAKE) SPHINXOPTS=-W -C Documentation -f Makefile.sphinx html
|
|
|
|
|
2022-07-01 11:12:25 +02:00
|
|
|
symlink:
|
|
|
|
@echo "Creating Symbolic Links.."; \
|
|
|
|
for link in $(SYMLINK_LIST); do \
|
|
|
|
SYMLINK=`cat $$link`; \
|
|
|
|
REALPATH=`realpath $$link`; \
|
|
|
|
if [ -L "$$SYMLINK" ]; then \
|
|
|
|
continue; \
|
|
|
|
elif [ ! -e "$$SYMLINK" ]; then \
|
|
|
|
echo -e "\tLINK $$SYMLINK -> $$(dirname $$REALPATH)"; \
|
|
|
|
ln -s $$(dirname $$REALPATH) $$SYMLINK; \
|
|
|
|
else \
|
|
|
|
echo -e "\tFAILED: $$SYMLINK exists"; \
|
|
|
|
fi \
|
|
|
|
done
|
|
|
|
|
|
|
|
clean-symlink:
|
|
|
|
@echo "Deleting symbolic link";\
|
|
|
|
EXISTING_SYMLINKS=`find -L ./src -xtype l | grep -v 3rdparty`; \
|
|
|
|
for link in $$EXISTING_SYMLINKS; do \
|
|
|
|
echo -e "\tUNLINK $$link"; \
|
|
|
|
rm "$$link"; \
|
|
|
|
done
|
|
|
|
|
2022-05-10 02:48:24 +02:00
|
|
|
clean-for-update:
|
2013-02-09 15:45:02 +01:00
|
|
|
rm -rf $(obj) .xcompile
|
2010-02-09 20:41:11 +01:00
|
|
|
|
2022-03-25 16:01:05 +01:00
|
|
|
clean: clean-for-update clean-utils clean-payloads
|
2011-02-22 15:35:05 +01:00
|
|
|
rm -f .ccwrap
|
2010-09-27 23:14:19 +02:00
|
|
|
|
2010-09-03 10:57:32 +02:00
|
|
|
clean-cscope:
|
|
|
|
rm -f cscope.out
|
|
|
|
|
2015-07-29 23:55:18 +02:00
|
|
|
clean-ctags:
|
|
|
|
rm -f tags
|
|
|
|
|
2017-03-27 02:49:02 +02:00
|
|
|
clean-utils:
|
2017-07-07 18:49:48 +02:00
|
|
|
$(foreach tool, $(TOOLLIST), \
|
|
|
|
$(MAKE) -C util/$(tool) clean MFLAGS= MAKEFLAGS= ;)
|
2017-03-27 02:49:02 +02:00
|
|
|
|
|
|
|
distclean-utils:
|
2017-07-07 18:49:48 +02:00
|
|
|
$(foreach tool, $(TOOLLIST), \
|
|
|
|
$(MAKE) -C util/$(tool) distclean MFLAGS= MAKEFLAGS= ; \
|
2017-03-27 02:49:02 +02:00
|
|
|
rm -f /util/$(tool)/junit.xml;)
|
|
|
|
|
|
|
|
distclean: clean clean-ctags clean-cscope distclean-payloads distclean-utils
|
2017-04-26 11:58:44 +02:00
|
|
|
rm -f .config .config.old ..config.tmp* .kconfig.d .tmpconfig* .ccwrap .xcompile
|
2017-03-27 02:49:02 +02:00
|
|
|
rm -rf coreboot-builds coreboot-builds-chromeos
|
|
|
|
rm -f abuild*.xml junit.xml* util/lint/junit.xml
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2022-05-10 02:48:24 +02:00
|
|
|
.PHONY: $(PHONY) clean clean-for-update clean-cscope cscope distclean sphinx sphinx-lint
|
2022-07-01 11:12:25 +02:00
|
|
|
.PHONY: ctags-project cscope-project clean-ctags symlink clean-symlink
|