2009-08-12 17:00:51 +02:00
|
|
|
##
|
|
|
|
## This file is part of the coreboot project.
|
|
|
|
##
|
|
|
|
## Copyright (C) 2008 Advanced Micro Devices, Inc.
|
|
|
|
## Copyright (C) 2008 Uwe Hermann <uwe@hermann-uwe.de>
|
2010-01-19 22:13:44 +01:00
|
|
|
## Copyright (C) 2009-2010 coresystems GmbH
|
2011-02-22 15:35:05 +01:00
|
|
|
## Copyright (C) 2011 secunet Security Networks AG
|
2009-08-12 17:00:51 +02:00
|
|
|
##
|
2011-06-30 15:48:57 +02:00
|
|
|
## Redistribution and use in source and binary forms, with or without
|
|
|
|
## modification, are permitted provided that the following conditions
|
|
|
|
## are met:
|
|
|
|
## 1. Redistributions of source code must retain the above copyright
|
|
|
|
## notice, this list of conditions and the following disclaimer.
|
|
|
|
## 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
## notice, this list of conditions and the following disclaimer in the
|
|
|
|
## documentation and/or other materials provided with the distribution.
|
|
|
|
## 3. The name of the author may not be used to endorse or promote products
|
|
|
|
## derived from this software without specific prior written permission.
|
2009-08-12 17:00:51 +02:00
|
|
|
##
|
2011-06-30 15:48:57 +02:00
|
|
|
## THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
## ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
## ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
## OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
## OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
## SUCH DAMAGE.
|
2009-08-12 17:00:51 +02:00
|
|
|
##
|
|
|
|
|
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)))
|
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
|
|
|
|
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
|
|
|
|
KCONFIG_SPLITCONFIG := $(obj)/config
|
|
|
|
KCONFIG_TRISTATE := $(obj)/tristate.conf
|
|
|
|
KCONFIG_NEGATIVES := 1
|
|
|
|
KCONFIG_STRICT := 1
|
2019-01-01 19:03:33 +01:00
|
|
|
KCONFIG_PACKAGE := CB.Config
|
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
|
|
|
|
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))
|
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:
|
|
|
|
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:
|
|
|
|
|
2016-02-01 12:02:29 +01:00
|
|
|
HOSTCC := $(if $(shell type gcc 2>/dev/null),gcc,cc)
|
2009-08-12 17:00:51 +02:00
|
|
|
HOSTCXX = g++
|
2012-09-13 22:13:33 +02:00
|
|
|
HOSTCFLAGS := -g
|
|
|
|
HOSTCXXFLAGS := -g
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2015-04-04 15:50:20 +02:00
|
|
|
PREPROCESS_ONLY := -E -P -x assembler-with-cpp -undef -I .
|
|
|
|
|
2009-08-12 17:00:51 +02:00
|
|
|
DOXYGEN := doxygen
|
|
|
|
DOXYGEN_OUTPUT_DIR := doxygen
|
|
|
|
|
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'
|
|
|
|
@echo ' doxygen - Build doxygen documentation for coreboot'
|
2016-07-07 23:50:28 +02:00
|
|
|
@echo ' doxyplatform - Build doxygen documentation for the current platform'
|
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.
|
2015-06-29 23:44:37 +02:00
|
|
|
include $(srck)/Makefile
|
2011-02-22 15:35:05 +01:00
|
|
|
|
2010-04-21 08:36:20 +02:00
|
|
|
# Three cases where we don't need fully populated $(obj) lists:
|
|
|
|
# 1. when no .config exists
|
|
|
|
# 2. when make config (in any flavour) is run
|
|
|
|
# 3. when make distclean is run
|
|
|
|
# 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
|
|
|
|
ifneq ($(MAKECMDGOALS),)
|
2016-08-12 02:16:59 +02:00
|
|
|
ifneq ($(filter %config %clean cross% clang iasl gnumake lint% help% what-jenkins-does,$(MAKECMDGOALS)),)
|
2010-04-21 08:36:20 +02:00
|
|
|
NOCOMPILE:=1
|
|
|
|
endif
|
2013-02-09 15:45:02 +01:00
|
|
|
ifeq ($(MAKECMDGOALS), %clean)
|
2012-10-22 10:36:03 +02:00
|
|
|
NOMKDIR:=1
|
|
|
|
endif
|
2010-04-21 08:36:20 +02:00
|
|
|
endif
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2019-07-03 17:41:20 +02:00
|
|
|
-include $(TOPLEVEL)/site-local/Makefile.inc
|
|
|
|
|
2010-04-21 08:36:20 +02:00
|
|
|
ifeq ($(NOCOMPILE),1)
|
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
|
2017-01-26 18:51:43 +01:00
|
|
|
real-all:
|
|
|
|
@echo "Error: Expected config file ($(DOTCONFIG)) not present." >&2
|
|
|
|
@echo "Please specify a config file or run 'make menuconfig' to" >&2
|
|
|
|
@echo "generate a new config file." >&2
|
|
|
|
@exit 1
|
2009-08-12 17:00:51 +02:00
|
|
|
else
|
|
|
|
|
2016-07-13 11:00:41 +02:00
|
|
|
include $(DOTCONFIG)
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2017-01-19 23:20:14 +01:00
|
|
|
# in addition to the dependency below, create the file if it doesn't exist
|
|
|
|
# to silence stupid warnings about a file that would be generated anyway.
|
|
|
|
$(if $(wildcard .xcompile)$(NOCOMPILE),,$(eval $(shell util/xcompile/xcompile $(XGCCPATH) > .xcompile || rm -f .xcompile)))
|
|
|
|
|
|
|
|
.xcompile: util/xcompile/xcompile
|
|
|
|
rm -f $@
|
|
|
|
$< $(XGCCPATH) > $@.tmp
|
|
|
|
\mv -f $@.tmp $@ 2> /dev/null
|
|
|
|
rm -f $@.tmp
|
|
|
|
|
2015-11-19 15:15:33 +01:00
|
|
|
-include .xcompile
|
|
|
|
|
|
|
|
ifneq ($(XCOMPILE_COMPLETE),1)
|
|
|
|
$(shell rm -f .xcompile)
|
|
|
|
$(error .xcompile deleted because it's invalid. \
|
|
|
|
Restarting the build should fix that, or explain the problem)
|
|
|
|
endif
|
2015-06-04 13:18:11 +02:00
|
|
|
|
2014-05-14 21:05:35 +02:00
|
|
|
ifneq ($(CONFIG_MMX),y)
|
|
|
|
CFLAGS_x86_32 += -mno-mmx
|
|
|
|
endif
|
|
|
|
|
|
|
|
include toolchain.inc
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
.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
|
2017-01-30 15:29:34 +01:00
|
|
|
+$(MAKE) oldconfig
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2019-01-01 19:03:33 +01:00
|
|
|
$(KCONFIG_AUTOCONFIG): $(KCONFIG_AUTOHEADER)
|
|
|
|
true
|
|
|
|
|
|
|
|
$(KCONFIG_AUTOADS): $(KCONFIG_AUTOCONFIG) $(objutil)/kconfig/toada
|
|
|
|
$(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= \
|
2011-02-17 21:47:49 +01:00
|
|
|
$(foreach class,classes subdirs $(classes) $(special-classes), $(eval $(class)-y:=)) \
|
2010-03-06 22:18:43 +01:00
|
|
|
$(eval -include $(1)) \
|
2011-02-17 21:47:49 +01:00
|
|
|
$(foreach class,$(classes-y), $(call add-class,$(class))) \
|
|
|
|
$(foreach class,$(classes), \
|
|
|
|
$(eval $(class)-srcs+= \
|
2015-05-07 06:00:10 +02:00
|
|
|
$$(subst $(absobj)/,$(obj)/, \
|
2010-03-27 18:18:39 +01:00
|
|
|
$$(subst $(top)/,, \
|
2015-05-07 06:00:10 +02:00
|
|
|
$$(abspath $$(subst $(dir $(1))/,/,$$(addprefix $(dir $(1)),$$($(class)-y)))))))) \
|
2011-02-17 21:47:49 +01:00
|
|
|
$(foreach special,$(special-classes), \
|
|
|
|
$(foreach item,$($(special)-y), $(call $(special)-handler,$(dir $(1)),$(item)))) \
|
2017-10-28 11:26:01 +02:00
|
|
|
$(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 :=
|
2010-03-27 18:18:39 +01:00
|
|
|
$(eval $(call evaluate_subdirs))
|
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))))
|
|
|
|
|
2019-01-01 22:06:01 +01:00
|
|
|
# Build Kconfig .ads if necessary
|
|
|
|
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 $$$$(@) \
|
2016-01-14 01:13:33 +01:00
|
|
|
$(3) -c -o $$$$@ $$$$<
|
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
|
2017-09-26 17:53:30 +02:00
|
|
|
find $(obj) -path "$(obj)/util" -prune -o -name "*.d" -exec cat {} \; | \
|
|
|
|
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
|
|
|
|
|
2009-08-12 17:00:51 +02:00
|
|
|
doxy: doxygen
|
|
|
|
doxygen:
|
2015-06-06 15:55:16 +02:00
|
|
|
$(DOXYGEN) Documentation/Doxyfile.coreboot
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2014-12-29 22:56:19 +01:00
|
|
|
doxygen_simple:
|
2015-06-06 15:55:16 +02:00
|
|
|
$(DOXYGEN) Documentation/Doxyfile.coreboot_simple
|
2014-12-29 22:56:19 +01:00
|
|
|
|
2016-07-07 23:50:28 +02:00
|
|
|
doxyplatform doxygen_platform: $(obj)/project_filelist.txt
|
|
|
|
echo
|
|
|
|
echo "Building doxygen documentation for $(CONFIG_MAINBOARD_PART_NUMBER)"
|
|
|
|
export DOXYGEN_OUTPUT_DIR="$(DOXYGEN_OUTPUT_DIR)/$(CONFIG_MAINBOARD_VENDOR)/$(CONFIG_MAINBOARD_PART_NUMBER)"; \
|
|
|
|
mkdir -p "$$DOXYGEN_OUTPUT_DIR"; \
|
|
|
|
export DOXYFILES="$$(cat $(obj)/project_filelist.txt | grep -v '\.ld$$' | sed 's/\.aml/\.dsl/' | tr '\n' ' ')"; \
|
|
|
|
export DOXYGEN_PLATFORM="$(CONFIG_MAINBOARD_DIR) ($(CONFIG_MAINBOARD_PART_NUMBER)) version $(KERNELVERSION)"; \
|
|
|
|
$(DOXYGEN) Documentation/doxygen/Doxyfile.coreboot_platform
|
|
|
|
|
2009-08-12 17:00:51 +02:00
|
|
|
doxyclean: doxygen-clean
|
|
|
|
doxygen-clean:
|
2009-08-25 21:38:46 +02:00
|
|
|
rm -rf $(DOXYGEN_OUTPUT_DIR)
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2011-02-22 15:35:05 +01:00
|
|
|
clean-for-update: doxygen-clean clean-for-update-target
|
2013-02-09 15:45:02 +01:00
|
|
|
rm -rf $(obj) .xcompile
|
2010-02-09 20:41:11 +01:00
|
|
|
|
2017-03-27 02:49:02 +02:00
|
|
|
clean: clean-for-update clean-target clean-utils
|
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
|
|
|
|
2014-12-29 22:56:19 +01:00
|
|
|
.PHONY: $(PHONY) clean clean-for-update clean-cscope cscope distclean doxygen doxy doxygen_simple
|
2015-07-29 23:55:18 +02:00
|
|
|
.PHONY: ctags-project cscope-project clean-ctags
|