Jacob Garber | 005fe89 | 2020-05-12 22:37:39 -0600 | [diff] [blame] | 1 | ## SPDX-License-Identifier: BSD-3-Clause |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 2 | |
Himanshu Sahdev | d1e18d9 | 2019-09-16 15:55:03 +0530 | [diff] [blame] | 3 | ifneq ($(words $(CURDIR)),1) |
| 4 | $(error Error: Path to the main directory cannot contain spaces) |
| 5 | endif |
Nico Huber | 7a1fbdb | 2017-08-23 23:48:13 +0200 | [diff] [blame] | 6 | top := $(CURDIR) |
| 7 | src := src |
| 8 | srck := $(top)/util/kconfig |
Vadim Bendebury | 5f7e4f0 | 2015-05-06 21:00:10 -0700 | [diff] [blame] | 9 | obj ?= build |
| 10 | override obj := $(subst $(top)/,,$(abspath $(obj))) |
Raul E Rangel | 81ff33c | 2019-07-11 10:44:21 -0600 | [diff] [blame] | 11 | xcompile ?= $(obj)/xcompile |
Nico Huber | 7a1fbdb | 2017-08-23 23:48:13 +0200 | [diff] [blame] | 12 | objutil ?= $(obj)/util |
| 13 | objk := $(objutil)/kconfig |
Vadim Bendebury | 5f7e4f0 | 2015-05-06 21:00:10 -0700 | [diff] [blame] | 14 | absobj := $(abspath $(obj)) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 15 | |
Nico Huber | 10a879e | 2021-03-06 13:12:34 +0100 | [diff] [blame] | 16 | additional-dirs := |
| 17 | |
Yu-Ping Wu | 0beddb5 | 2020-03-09 10:58:37 +0800 | [diff] [blame] | 18 | VBOOT_HOST_BUILD ?= $(abspath $(objutil)/vboot_lib) |
| 19 | |
Nico Huber | 7a1fbdb | 2017-08-23 23:48:13 +0200 | [diff] [blame] | 20 | COREBOOT_EXPORTS := COREBOOT_EXPORTS |
| 21 | COREBOOT_EXPORTS += top src srck obj objutil objk |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 22 | |
Nico Huber | 7a1fbdb | 2017-08-23 23:48:13 +0200 | [diff] [blame] | 23 | DOTCONFIG ?= $(top)/.config |
| 24 | KCONFIG_CONFIG = $(DOTCONFIG) |
Nico Huber | 533bc0a | 2019-01-01 19:03:33 +0100 | [diff] [blame] | 25 | KCONFIG_AUTOADS := $(obj)/cb-config.ads |
Patrick Georgi | 1cd374f | 2023-11-29 15:31:50 +0100 | [diff] [blame] | 26 | KCONFIG_RUSTCCFG := $(obj)/cb-config.rustcfg |
Nico Huber | 7a1fbdb | 2017-08-23 23:48:13 +0200 | [diff] [blame] | 27 | KCONFIG_AUTOHEADER := $(obj)/config.h |
| 28 | KCONFIG_AUTOCONFIG := $(obj)/auto.conf |
| 29 | KCONFIG_DEPENDENCIES := $(obj)/auto.conf.cmd |
Patrick Georgi | 53ea1d4 | 2019-11-22 16:55:58 +0100 | [diff] [blame] | 30 | KCONFIG_SPLITCONFIG := $(obj)/config/ |
Nico Huber | 7a1fbdb | 2017-08-23 23:48:13 +0200 | [diff] [blame] | 31 | KCONFIG_TRISTATE := $(obj)/tristate.conf |
| 32 | KCONFIG_NEGATIVES := 1 |
Patrick Georgi | 1cc6c54 | 2023-11-28 12:08:45 +0100 | [diff] [blame] | 33 | KCONFIG_WERROR := 1 |
| 34 | KCONFIG_WARN_UNKNOWN_SYMBOLS := 1 |
Nico Huber | 533bc0a | 2019-01-01 19:03:33 +0100 | [diff] [blame] | 35 | KCONFIG_PACKAGE := CB.Config |
Martin Roth | 4d7285d | 2021-11-23 12:39:44 -0700 | [diff] [blame] | 36 | KCONFIG_MAKEFILE_REAL ?= $(objk)/Makefile.real |
Nico Huber | 7a1fbdb | 2017-08-23 23:48:13 +0200 | [diff] [blame] | 37 | |
| 38 | COREBOOT_EXPORTS += KCONFIG_CONFIG KCONFIG_AUTOHEADER KCONFIG_AUTOCONFIG |
| 39 | COREBOOT_EXPORTS += KCONFIG_DEPENDENCIES KCONFIG_SPLITCONFIG KCONFIG_TRISTATE |
Patrick Georgi | 1cc6c54 | 2023-11-28 12:08:45 +0100 | [diff] [blame] | 40 | COREBOOT_EXPORTS += KCONFIG_NEGATIVES |
| 41 | ifeq ($(filter %config,$(MAKECMDGOALS)),) |
| 42 | COREBOOT_EXPORTS += KCONFIG_WERROR |
| 43 | endif |
Patrick Georgi | 0eab62b | 2023-11-20 19:49:29 +0100 | [diff] [blame] | 44 | COREBOOT_EXPORTS += KCONFIG_WARN_UNKNOWN_SYMBOLS |
Nico Huber | 533bc0a | 2019-01-01 19:03:33 +0100 | [diff] [blame] | 45 | COREBOOT_EXPORTS += KCONFIG_AUTOADS KCONFIG_PACKAGE |
Patrick Georgi | 1cd374f | 2023-11-29 15:31:50 +0100 | [diff] [blame] | 46 | COREBOOT_EXPORTS += KCONFIG_RUSTCCFG |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 47 | |
Christian Walter | a8c10c8 | 2022-07-01 11:12:25 +0200 | [diff] [blame] | 48 | # Make does not offer a recursive wildcard function, so here's one: |
| 49 | rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)) |
| 50 | SYMLINK_LIST = $(call rwildcard,site-local/,symlink.txt) |
| 51 | |
| 52 | |
Martin Roth | e3df184 | 2024-01-18 10:25:18 -0700 | [diff] [blame] | 53 | # Directory containing the toplevel Makefile.mk |
Patrick Georgi | e38d0a6 | 2011-03-01 08:09:22 +0000 | [diff] [blame] | 54 | TOPLEVEL := . |
| 55 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 56 | CONFIG_SHELL := sh |
| 57 | KBUILD_DEFCONFIG := configs/defconfig |
| 58 | UNAME_RELEASE := $(shell uname -r) |
Patrick Georgi | 89ec376 | 2010-12-08 19:58:30 +0000 | [diff] [blame] | 59 | HAVE_DOTCONFIG := $(wildcard $(DOTCONFIG)) |
Martin Roth | 4d7285d | 2021-11-23 12:39:44 -0700 | [diff] [blame] | 60 | HAVE_KCONFIG_MAKEFILE_REAL := $(wildcard $(KCONFIG_MAKEFILE_REAL)) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 61 | MAKEFLAGS += -rR --no-print-directory |
| 62 | |
| 63 | # Make is silent per default, but 'make V=1' will show all compiler calls. |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 64 | Q:=@ |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 65 | ifneq ($(V),1) |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 66 | ifneq ($(Q),) |
| 67 | .SILENT: |
Nico Huber | 7325ac5 | 2020-02-16 11:47:52 +0100 | [diff] [blame] | 68 | MAKEFLAGS += -s |
Martin Roth | ea6a93f | 2021-11-21 08:42:04 -0700 | [diff] [blame] | 69 | quiet_errors := 2>/dev/null |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 70 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 71 | endif |
| 72 | |
Julius Werner | 808a429 | 2015-03-13 11:05:07 -0700 | [diff] [blame] | 73 | # Disable implicit/built-in rules to make Makefile errors fail fast. |
| 74 | .SUFFIXES: |
| 75 | |
Patrick Georgi | b3a18ac | 2012-09-13 22:13:33 +0200 | [diff] [blame] | 76 | HOSTCFLAGS := -g |
| 77 | HOSTCXXFLAGS := -g |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 78 | |
Nico Huber | 710a38a | 2022-12-11 13:13:45 +0100 | [diff] [blame] | 79 | HOSTPKG_CONFIG ?= pkg-config |
| 80 | COREBOOT_EXPORTS += HOSTPKG_CONFIG |
| 81 | |
Patrick Georgi | 828e0e8 | 2015-04-04 15:50:20 +0200 | [diff] [blame] | 82 | PREPROCESS_ONLY := -E -P -x assembler-with-cpp -undef -I . |
| 83 | |
Nico Huber | 7a1fbdb | 2017-08-23 23:48:13 +0200 | [diff] [blame] | 84 | export $(COREBOOT_EXPORTS) |
| 85 | |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 86 | all: real-all |
| 87 | |
Martin Roth | 4eea174 | 2015-11-25 11:50:04 -0700 | [diff] [blame] | 88 | help_coreboot help:: |
| 89 | @echo '*** coreboot platform targets ***' |
Martin Roth | 76f14b2 | 2015-11-18 13:09:23 -0700 | [diff] [blame] | 90 | @echo ' Use "make [target] V=1" for extra build debug information' |
| 91 | @echo ' all - Build coreboot' |
| 92 | @echo ' clean - Remove coreboot build artifacts' |
| 93 | @echo ' distclean - Remove build artifacts and config files' |
Patrick Rudolph | f664321 | 2020-05-17 20:04:12 +0200 | [diff] [blame] | 94 | @echo ' sphinx - Build sphinx documentation for coreboot' |
Nico Huber | bfdefc2 | 2023-08-23 12:42:40 +0200 | [diff] [blame] | 95 | @echo ' sphinx-lint - Build sphinx documentation for coreboot with warnings as errors' |
Martin Roth | 763e493 | 2018-01-27 16:42:43 -0700 | [diff] [blame] | 96 | @echo ' filelist - Show files used in current build' |
Martin Roth | 76f14b2 | 2015-11-18 13:09:23 -0700 | [diff] [blame] | 97 | @echo ' printall - print makefile info for debugging' |
Werner Zeh | 2de6410 | 2016-01-12 12:45:49 +0100 | [diff] [blame] | 98 | @echo ' gitconfig - set up git to submit patches to coreboot' |
Martin Roth | 76f14b2 | 2015-11-18 13:09:23 -0700 | [diff] [blame] | 99 | @echo ' ctags / ctags-project - make ctags file for all of coreboot or current board' |
| 100 | @echo ' cscope / cscope-project - make cscope.out file for coreboot or current board' |
| 101 | @echo |
| 102 | |
Patrick Georgi | e38d0a6 | 2011-03-01 08:09:22 +0000 | [diff] [blame] | 103 | # This include must come _before_ the pattern rules below! |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 104 | # Order _does_ matter for pattern rules. |
Martin Roth | e3df184 | 2024-01-18 10:25:18 -0700 | [diff] [blame] | 105 | include $(srck)/Makefile.mk |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 106 | |
Martin Roth | 4d7285d | 2021-11-23 12:39:44 -0700 | [diff] [blame] | 107 | # The cases where we don't need fully populated $(obj) lists: |
Patrick Georgi | cf036d1 | 2010-04-21 06:36:20 +0000 | [diff] [blame] | 108 | # 1. when no .config exists |
Martin Roth | 4d7285d | 2021-11-23 12:39:44 -0700 | [diff] [blame] | 109 | # 2. When no $(obj)/util/kconfig/Makefile.real exists and we're building tools |
| 110 | # 3. when make config (in any flavour) is run |
| 111 | # 4. when make distclean is run |
Patrick Georgi | cf036d1 | 2010-04-21 06:36:20 +0000 | [diff] [blame] | 112 | # Don't waste time on reading all Makefile.incs in these cases |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 113 | ifeq ($(strip $(HAVE_DOTCONFIG)),) |
Patrick Georgi | cf036d1 | 2010-04-21 06:36:20 +0000 | [diff] [blame] | 114 | NOCOMPILE:=1 |
| 115 | endif |
Martin Roth | 4d7285d | 2021-11-23 12:39:44 -0700 | [diff] [blame] | 116 | ifeq ($(strip $(HAVE_KCONFIG_MAKEFILE_REAL)),) |
| 117 | ifneq ($(MAKECMDGOALS),tools) |
| 118 | NOCOMPILE:=1 |
| 119 | endif |
| 120 | endif |
Patrick Georgi | cf036d1 | 2010-04-21 06:36:20 +0000 | [diff] [blame] | 121 | ifneq ($(MAKECMDGOALS),) |
Elyes HAOUAS | 91fb139 | 2020-01-20 15:33:11 +0100 | [diff] [blame] | 122 | ifneq ($(filter %config %clean cross% clang iasl lint% help% what-jenkins-does,$(MAKECMDGOALS)),) |
Patrick Georgi | cf036d1 | 2010-04-21 06:36:20 +0000 | [diff] [blame] | 123 | NOCOMPILE:=1 |
| 124 | endif |
Raul E Rangel | 5592cfd | 2019-07-23 11:13:40 -0600 | [diff] [blame] | 125 | ifneq ($(filter %clean lint% help% what-jenkins-does,$(MAKECMDGOALS)),) |
Zheng Bao | 0fd93d6 | 2012-10-22 16:36:03 +0800 | [diff] [blame] | 126 | NOMKDIR:=1 |
Jakub Czapiga | a4819b3 | 2021-04-13 16:07:05 +0200 | [diff] [blame] | 127 | UNIT_TEST:=1 |
Zheng Bao | 0fd93d6 | 2012-10-22 16:36:03 +0800 | [diff] [blame] | 128 | endif |
Patrick Georgi | cf036d1 | 2010-04-21 06:36:20 +0000 | [diff] [blame] | 129 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 130 | |
Jakub Czapiga | a4819b3 | 2021-04-13 16:07:05 +0200 | [diff] [blame] | 131 | ifneq ($(filter help%, $(MAKECMDGOALS)), ) |
| 132 | NOCOMPILE:=1 |
| 133 | UNIT_TEST:=1 |
| 134 | else |
Paul Fagerburg | de6cbac | 2021-05-11 09:56:48 -0600 | [diff] [blame] | 135 | ifneq ($(filter %-test %-tests %coverage-report, $(MAKECMDGOALS)),) |
| 136 | ifneq ($(filter-out %-test %-tests %coverage-report, $(MAKECMDGOALS)),) |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 137 | $(error Cannot mix unit-tests targets with other targets) |
| 138 | endif |
| 139 | UNIT_TEST:=1 |
| 140 | NOCOMPILE:= |
| 141 | endif |
Jakub Czapiga | a4819b3 | 2021-04-13 16:07:05 +0200 | [diff] [blame] | 142 | endif |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 143 | |
Martin Roth | 5ff6bf3 | 2024-02-22 16:23:20 -0700 | [diff] [blame] | 144 | # When building the "tools" target, the BUILD_ALL_TOOLS variable needs |
| 145 | # to be set before reading the tools' Makefiles |
| 146 | ifneq ($(filter tools, $(MAKECMDGOALS)), ) |
| 147 | BUILD_ALL_TOOLS:=1 |
| 148 | endif |
| 149 | |
Raul E Rangel | 81ff33c | 2019-07-11 10:44:21 -0600 | [diff] [blame] | 150 | $(xcompile): util/xcompile/xcompile |
Raul E Rangel | 6325ce2 | 2019-07-10 16:46:34 -0600 | [diff] [blame] | 151 | rm -f $@ |
| 152 | $< $(XGCCPATH) > $@.tmp |
| 153 | \mv -f $@.tmp $@ 2> /dev/null |
| 154 | rm -f $@.tmp |
| 155 | |
Patrick Georgi | cf036d1 | 2010-04-21 06:36:20 +0000 | [diff] [blame] | 156 | ifeq ($(NOCOMPILE),1) |
Patrick Georgi | b351875f | 2020-07-06 15:31:58 +0000 | [diff] [blame] | 157 | # We also don't use .xcompile in the no-compile situations, so |
| 158 | # provide some reasonable defaults. |
| 159 | HOSTCC ?= $(if $(shell type gcc 2>/dev/null),gcc,cc) |
| 160 | HOSTCXX ?= g++ |
| 161 | |
Martin Roth | e3df184 | 2024-01-18 10:25:18 -0700 | [diff] [blame] | 162 | include $(TOPLEVEL)/Makefile.mk |
| 163 | include $(TOPLEVEL)/payloads/Makefile.mk |
| 164 | include $(TOPLEVEL)/util/testing/Makefile.mk |
| 165 | -include $(TOPLEVEL)/site-local/Makefile.mk |
Werner Zeh | b7f1c2d | 2019-10-04 07:01:13 +0200 | [diff] [blame] | 166 | -include $(TOPLEVEL)/site-local/Makefile.inc |
Martin Roth | e3df184 | 2024-01-18 10:25:18 -0700 | [diff] [blame] | 167 | include $(TOPLEVEL)/tests/Makefile.mk |
Martin Roth | 9fc9640 | 2022-11-27 19:04:16 -0700 | [diff] [blame] | 168 | printall real-all: |
Martin Roth | e28c718 | 2022-06-22 17:49:31 -0600 | [diff] [blame] | 169 | @echo "Error: Trying to build, but NOCOMPILE is set." >&2 |
| 170 | @echo " Please file a bug with the following information:" |
| 171 | @echo "- MAKECMDGOALS: $(MAKECMDGOALS)" >&2 |
| 172 | @echo "- HAVE_DOTCONFIG: $(HAVE_DOTCONFIG)" >&2 |
| 173 | @echo "- HAVE_KCONFIG_MAKEFILE_REAL: $(HAVE_KCONFIG_MAKEFILE_REAL)" >&2 |
Martin Roth | 20aa043 | 2017-01-26 10:51:43 -0700 | [diff] [blame] | 174 | @exit 1 |
Martin Roth | 9fc9640 | 2022-11-27 19:04:16 -0700 | [diff] [blame] | 175 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 176 | else |
| 177 | |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 178 | ifneq ($(UNIT_TEST),1) |
Paul Kocialkowski | 585c781 | 2016-07-13 11:00:41 +0200 | [diff] [blame] | 179 | include $(DOTCONFIG) |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 180 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 181 | |
Raul E Rangel | 81ff33c | 2019-07-11 10:44:21 -0600 | [diff] [blame] | 182 | # The toolchain requires xcompile to determine the ARCH_SUPPORTED, so we can't |
| 183 | # wait for make to generate the file. |
| 184 | $(if $(wildcard $(xcompile)),, $(shell \ |
| 185 | mkdir -p $(dir $(xcompile)) && \ |
| 186 | util/xcompile/xcompile $(XGCCPATH) > $(xcompile) || rm -f $(xcompile))) |
Patrick Georgi | 0ffef88 | 2017-01-19 23:20:14 +0100 | [diff] [blame] | 187 | |
Raul E Rangel | 81ff33c | 2019-07-11 10:44:21 -0600 | [diff] [blame] | 188 | include $(xcompile) |
Patrick Georgi | 6dda31d | 2015-11-19 15:15:33 +0100 | [diff] [blame] | 189 | |
| 190 | ifneq ($(XCOMPILE_COMPLETE),1) |
Raul E Rangel | 81ff33c | 2019-07-11 10:44:21 -0600 | [diff] [blame] | 191 | $(shell rm -f $(xcompile)) |
| 192 | $(error $(xcompile) deleted because it's invalid. \ |
Patrick Georgi | 6dda31d | 2015-11-19 15:15:33 +0100 | [diff] [blame] | 193 | Restarting the build should fix that, or explain the problem) |
| 194 | endif |
Patrick Georgi | 7b9762f | 2015-06-04 13:18:11 +0200 | [diff] [blame] | 195 | |
Patrick Georgi | ca6e5ee | 2021-04-13 15:48:38 +0200 | [diff] [blame] | 196 | # reproducible builds |
| 197 | LANG:=C |
| 198 | LC_ALL:=C |
| 199 | TZ:=UTC0 |
| 200 | ifneq ($(NOCOMPILE),1) |
| 201 | SOURCE_DATE_EPOCH := $(shell $(top)/util/genbuild_h/genbuild_h.sh . | sed -n 's/^.define COREBOOT_BUILD_EPOCH\>.*"\(.*\)".*/\1/p') |
| 202 | endif |
| 203 | # don't use COREBOOT_EXPORTS to ensure build steps outside the coreboot build system |
| 204 | # are reproducible |
| 205 | export LANG LC_ALL TZ SOURCE_DATE_EPOCH |
| 206 | |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 207 | ifneq ($(UNIT_TEST),1) |
Martin Roth | e3df184 | 2024-01-18 10:25:18 -0700 | [diff] [blame] | 208 | include toolchain.mk |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 209 | endif |
Patrick Georgi | cc84a00 | 2014-05-14 21:05:35 +0200 | [diff] [blame] | 210 | |
Zheng Bao | 0764892 | 2015-11-13 10:42:27 +0800 | [diff] [blame] | 211 | strip_quotes = $(strip $(subst ",,$(subst \",,$(1)))) |
Martin Roth | bbf1399 | 2016-01-25 15:59:24 -0700 | [diff] [blame] | 212 | # fix makefile syntax highlighting after strip macro \" ")) |
Patrick Georgi | a84e98b | 2010-03-16 19:01:32 +0000 | [diff] [blame] | 213 | |
Kyösti Mälkki | cad92ec | 2022-12-14 17:26:35 +0200 | [diff] [blame] | 214 | ifneq ($(NOCOMPILE),1) |
| 215 | $(shell rm -f $(CCACHE_STATSLOG)) |
| 216 | endif |
| 217 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 218 | # The primary target needs to be here before we include the |
| 219 | # other files |
| 220 | |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 221 | real-all: real-target |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 222 | |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 223 | # must come rather early |
Raul E Rangel | dd6efce | 2022-02-25 17:03:10 -0700 | [diff] [blame] | 224 | .SECONDARY: |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 225 | .SECONDEXPANSION: |
Raul E Rangel | cc6dc90 | 2018-08-06 16:13:32 -0600 | [diff] [blame] | 226 | .DELETE_ON_ERROR: |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 227 | |
Jonathan Neuschäfer | d2c0242 | 2018-12-11 13:06:40 +0100 | [diff] [blame] | 228 | $(KCONFIG_AUTOHEADER): $(KCONFIG_CONFIG) $(objutil)/kconfig/conf |
Patrick Georgi | 53ea1d4 | 2019-11-22 16:55:58 +0100 | [diff] [blame] | 229 | $(MAKE) olddefconfig |
| 230 | $(MAKE) syncconfig |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 231 | |
Nico Huber | 533bc0a | 2019-01-01 19:03:33 +0100 | [diff] [blame] | 232 | $(KCONFIG_AUTOCONFIG): $(KCONFIG_AUTOHEADER) |
| 233 | true |
| 234 | |
Nico Huber | eafc815 | 2019-10-25 12:47:14 +0200 | [diff] [blame] | 235 | $(KCONFIG_AUTOADS): $(KCONFIG_CONFIG) $(KCONFIG_AUTOHEADER) $(objutil)/kconfig/toada |
Nico Huber | 533bc0a | 2019-01-01 19:03:33 +0100 | [diff] [blame] | 236 | $(objutil)/kconfig/toada CB.Config <$< >$@ |
| 237 | |
Nico Huber | b567977 | 2019-01-01 22:06:01 +0100 | [diff] [blame] | 238 | $(obj)/%/$(notdir $(KCONFIG_AUTOADS)): $(KCONFIG_AUTOADS) |
| 239 | cp $< $@ |
| 240 | |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 241 | # Add a new class of source/object files to the build system |
| 242 | add-class= \ |
| 243 | $(eval $(1)-srcs:=) \ |
| 244 | $(eval $(1)-objs:=) \ |
| 245 | $(eval classes+=$(1)) |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 246 | |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 247 | # Special classes are managed types with special behaviour |
| 248 | # On parse time, for each entry in variable $(1)-y |
| 249 | # a handler $(1)-handler is executed with the arguments: |
| 250 | # * $(1): directory the parser is in |
| 251 | # * $(2): current entry |
| 252 | add-special-class= \ |
| 253 | $(eval $(1):=) \ |
| 254 | $(eval special-classes+=$(1)) |
| 255 | |
Nico Huber | 81b09f4 | 2016-01-23 00:50:00 +0100 | [diff] [blame] | 256 | # Converts one or more source file paths to their corresponding build/ paths. |
Nico Huber | 2e09d2b | 2016-01-14 01:13:33 +0100 | [diff] [blame] | 257 | # Only .ads, adb, .c and .S get converted to .o, other files (like .ld) keep |
| 258 | # their name. |
Nico Huber | 81b09f4 | 2016-01-23 00:50:00 +0100 | [diff] [blame] | 259 | # $1 stage name |
| 260 | # $2 file path (list) |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 261 | src-to-obj=\ |
| 262 | $(patsubst $(obj)/%,$(obj)/$(1)/%,\ |
| 263 | $(patsubst $(obj)/$(1)/%,$(obj)/%,\ |
Nico Huber | d011b6b | 2016-10-05 17:41:31 +0200 | [diff] [blame] | 264 | $(patsubst 3rdparty/%,$(obj)/%,\ |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 265 | $(patsubst src/%,$(obj)/%,\ |
Nico Huber | 2e09d2b | 2016-01-14 01:13:33 +0100 | [diff] [blame] | 266 | $(patsubst %.ads,%.o,\ |
| 267 | $(patsubst %.adb,%.o,\ |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 268 | $(patsubst %.c,%.o,\ |
| 269 | $(patsubst %.S,%.o,\ |
Nico Huber | d011b6b | 2016-10-05 17:41:31 +0200 | [diff] [blame] | 270 | $(subst .$(1),,$(2)))))))))) |
Nico Huber | 2e09d2b | 2016-01-14 01:13:33 +0100 | [diff] [blame] | 271 | |
| 272 | # Converts one or more source file paths to the corresponding build/ paths |
| 273 | # of their Ada library information (.ali) files. |
| 274 | # $1 stage name |
| 275 | # $2 file path (list) |
| 276 | src-to-ali=\ |
| 277 | $(patsubst $(obj)/%,$(obj)/$(1)/%,\ |
| 278 | $(patsubst $(obj)/$(1)/%,$(obj)/%,\ |
Nico Huber | d011b6b | 2016-10-05 17:41:31 +0200 | [diff] [blame] | 279 | $(patsubst 3rdparty/%,$(obj)/%,\ |
Nico Huber | 2e09d2b | 2016-01-14 01:13:33 +0100 | [diff] [blame] | 280 | $(patsubst src/%,$(obj)/%,\ |
| 281 | $(patsubst %.ads,%.ali,\ |
| 282 | $(patsubst %.adb,%.ali,\ |
| 283 | $(subst .$(1),,\ |
Nico Huber | d011b6b | 2016-10-05 17:41:31 +0200 | [diff] [blame] | 284 | $(filter %.ads %.adb,$(2))))))))) |
Nico Huber | 81b09f4 | 2016-01-23 00:50:00 +0100 | [diff] [blame] | 285 | |
Martin Roth | e3df184 | 2024-01-18 10:25:18 -0700 | [diff] [blame] | 286 | # Clean -y variables, include Makefile.mk & Makefile.inc |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 287 | # Add paths to files in X-y to X-srcs |
Patrick Georgi | 47d68d8 | 2010-03-06 21:18:43 +0000 | [diff] [blame] | 288 | # Add subdirs-y to subdirs |
| 289 | includemakefiles= \ |
Nikolai Vyssotski | b9d0072 | 2022-09-24 08:48:15 -0500 | [diff] [blame] | 290 | $(if $(wildcard $(1)), \ |
| 291 | $(foreach class,classes subdirs $(classes) $(special-classes), $(eval $(class)-y:=)) \ |
| 292 | $(eval -include $(1)) \ |
| 293 | $(foreach class,$(classes-y), $(call add-class,$(class))) \ |
| 294 | $(foreach special,$(special-classes), \ |
| 295 | $(foreach item,$($(special)-y), $(call $(special)-handler,$(dir $(1)),$(item)))) \ |
| 296 | $(foreach class,$(classes), \ |
| 297 | $(eval $(class)-srcs+= \ |
| 298 | $$(subst $(absobj)/,$(obj)/, \ |
| 299 | $$(subst $(top)/,, \ |
| 300 | $$(abspath $$(subst $(dir $(1))/,/,$$(addprefix $(dir $(1)),$$($(class)-y)))))))) \ |
| 301 | $(eval subdirs+=$$(subst $(CURDIR)/,,$$(wildcard $$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y))))))) |
Patrick Georgi | 47d68d8 | 2010-03-06 21:18:43 +0000 | [diff] [blame] | 302 | |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 303 | # For each path in $(subdirs) call includemakefiles |
Patrick Georgi | 47d68d8 | 2010-03-06 21:18:43 +0000 | [diff] [blame] | 304 | # Repeat until subdirs is empty |
Martin Roth | e3df184 | 2024-01-18 10:25:18 -0700 | [diff] [blame] | 305 | # TODO: Remove Makefile.inc support |
Patrick Georgi | 47d68d8 | 2010-03-06 21:18:43 +0000 | [diff] [blame] | 306 | evaluate_subdirs= \ |
| 307 | $(eval cursubdirs:=$(subdirs)) \ |
| 308 | $(eval subdirs:=) \ |
| 309 | $(foreach dir,$(cursubdirs), \ |
Martin Roth | e3df184 | 2024-01-18 10:25:18 -0700 | [diff] [blame] | 310 | $(eval $(call includemakefiles,$(dir)/Makefile.mk))) \ |
| 311 | $(foreach dir,$(cursubdirs), \ |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 312 | $(eval $(call includemakefiles,$(dir)/Makefile.inc))) \ |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 313 | $(if $(subdirs),$(eval $(call evaluate_subdirs))) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 314 | |
| 315 | # collect all object files eligible for building |
Patrick Georgi | e38d0a6 | 2011-03-01 08:09:22 +0000 | [diff] [blame] | 316 | subdirs:=$(TOPLEVEL) |
Julius Werner | e91d170 | 2017-03-20 15:32:15 -0700 | [diff] [blame] | 317 | postinclude-hooks := |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 318 | |
Martin Roth | e3df184 | 2024-01-18 10:25:18 -0700 | [diff] [blame] | 319 | # Don't iterate through Makefiles under src/ when building tests |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 320 | ifneq ($(UNIT_TEST),1) |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 321 | $(eval $(call evaluate_subdirs)) |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 322 | else |
Martin Roth | e3df184 | 2024-01-18 10:25:18 -0700 | [diff] [blame] | 323 | include $(TOPLEVEL)/tests/Makefile.mk |
Jan Dabros | ef1c968 | 2020-03-28 00:15:03 +0100 | [diff] [blame] | 324 | endif |
| 325 | |
Patrick Georgi | 70c85ea | 2013-02-16 01:06:57 +0100 | [diff] [blame] | 326 | ifeq ($(FAILBUILD),1) |
| 327 | $(error cannot continue build) |
| 328 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 329 | |
Julius Werner | e91d170 | 2017-03-20 15:32:15 -0700 | [diff] [blame] | 330 | # Run hooks registered by subdirectories that need to be evaluated after all files have been parsed |
| 331 | $(eval $(postinclude-hooks)) |
| 332 | |
Patrick Georgi | 94a4586 | 2011-10-25 14:32:21 -0700 | [diff] [blame] | 333 | # Eliminate duplicate mentions of source files in a class |
| 334 | $(foreach class,$(classes),$(eval $(class)-srcs:=$(sort $($(class)-srcs)))) |
| 335 | |
Martin Roth | b18726d | 2023-08-15 15:57:29 -0600 | [diff] [blame] | 336 | ifeq ($(CONFIG_IWYU),y) |
| 337 | MAKEFLAGS += -k |
| 338 | SAVE_IWYU_OUTPUT := 2>&1 | grep "should\|\#include\|---\|include-list\|^[[:blank:]]\?\'" | tee -a $$(obj)/iwyu.txt |
| 339 | endif |
| 340 | |
Nico Huber | b567977 | 2019-01-01 22:06:01 +0100 | [diff] [blame] | 341 | # Build Kconfig .ads if necessary |
Jeremy Compostella | fa83887 | 2022-11-30 19:26:01 -0700 | [diff] [blame] | 342 | ifeq ($(CONFIG_ROMSTAGE_ADA),y) |
| 343 | romstage-srcs += $(obj)/romstage/$(notdir $(KCONFIG_AUTOADS)) |
| 344 | endif |
Nico Huber | b567977 | 2019-01-01 22:06:01 +0100 | [diff] [blame] | 345 | ifeq ($(CONFIG_RAMSTAGE_ADA),y) |
| 346 | ramstage-srcs += $(obj)/ramstage/$(notdir $(KCONFIG_AUTOADS)) |
| 347 | endif |
| 348 | |
Nico Huber | 2e09d2b | 2016-01-14 01:13:33 +0100 | [diff] [blame] | 349 | # To track dependencies, we need all Ada specification (.ads) files in |
| 350 | # *-srcs. Extract / filter all specification files that have a matching |
| 351 | # body (.adb) file here (specifications without a body are valid sources |
| 352 | # in Ada). |
| 353 | $(foreach class,$(classes),$(eval $(class)-extra-specs := \ |
| 354 | $(filter \ |
| 355 | $(addprefix %/,$(patsubst %.adb,%.ads,$(notdir $(filter %.adb,$($(class)-srcs))))), \ |
| 356 | $(filter %.ads,$($(class)-srcs))))) |
| 357 | $(foreach class,$(classes),$(eval $(class)-srcs := \ |
| 358 | $(filter-out $($(class)-extra-specs),$($(class)-srcs)))) |
| 359 | |
Patrick Georgi | 10f86b0 | 2015-03-27 16:56:23 +0100 | [diff] [blame] | 360 | $(foreach class,$(classes),$(eval $(class)-objs:=$(call src-to-obj,$(class),$($(class)-srcs)))) |
Nico Huber | 2e09d2b | 2016-01-14 01:13:33 +0100 | [diff] [blame] | 361 | $(foreach class,$(classes),$(eval $(class)-alis:=$(call src-to-ali,$(class),$($(class)-srcs)))) |
| 362 | |
| 363 | # For Ada includes |
| 364 | $(foreach class,$(classes),$(eval $(class)-ada-dirs:=$(sort $(dir $(filter %.ads %.adb,$($(class)-srcs)) $($(class)-extra-specs))))) |
Patrick Georgi | d3428b0 | 2010-02-24 13:18:01 +0000 | [diff] [blame] | 365 | |
Patrick Georgi | 79f9010 | 2012-11-25 14:31:08 +0100 | [diff] [blame] | 366 | # Call post-processors if they're defined |
| 367 | $(foreach class,$(classes),\ |
| 368 | $(if $(value $(class)-postprocess),$(eval $(call $(class)-postprocess,$($(class)-objs))))) |
| 369 | |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 370 | allsrcs:=$(foreach var, $(addsuffix -srcs,$(classes)), $($(var))) |
| 371 | allobjs:=$(foreach var, $(addsuffix -objs,$(classes)), $($(var))) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 372 | alldirs:=$(sort $(abspath $(dir $(allobjs)))) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 373 | |
Nico Huber | 2e09d2b | 2016-01-14 01:13:33 +0100 | [diff] [blame] | 374 | # Reads dependencies from an Ada library information (.ali) file |
| 375 | # Only basenames (with suffix) are preserved so we have to look the |
| 376 | # paths up in $($(stage)-srcs). |
| 377 | # $1 stage name |
| 378 | # $2 ali file |
| 379 | create_ada_deps=$$(if $(2),\ |
| 380 | gnat.adc \ |
| 381 | $$(filter \ |
| 382 | $$(addprefix %/,$$(shell sed -ne's/^D \([^\t]\+\).*$$$$/\1/p' $(2) 2>/dev/null)), \ |
| 383 | $$($(1)-srcs) $$($(1)-extra-specs))) |
| 384 | |
Patrick Georgi patrick.georgi | c5f773d | 2010-03-16 12:01:13 +0000 | [diff] [blame] | 385 | # macro to define template macros that are used by use_template macro |
| 386 | define create_cc_template |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 387 | # $1 obj class |
Patrick Georgi | 990e7c9 | 2015-04-03 10:47:15 +0200 | [diff] [blame] | 388 | # $2 source suffix (c, S, ld, ...) |
Marc Jones | a38ccfd | 2014-11-06 15:50:22 -0700 | [diff] [blame] | 389 | # $3 additional compiler flags |
| 390 | # $4 additional dependencies |
Patrick Georgi | b8cdd9b | 2011-02-17 20:48:45 +0000 | [diff] [blame] | 391 | ifn$(EMPTY)def $(1)-objs_$(2)_template |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 392 | de$(EMPTY)fine $(1)-objs_$(2)_template |
Nico Huber | 1850aa6 | 2017-09-03 23:42:58 +0200 | [diff] [blame] | 393 | ifn$(EMPTY)eq ($(filter ads adb,$(2)),) |
Nico Huber | b567977 | 2019-01-01 22:06:01 +0100 | [diff] [blame] | 394 | $$(call src-to-obj,$1,$$(1).$2): $$(1).$2 $$(call create_ada_deps,$1,$$(call src-to-ali,$1,$$(1).$2)) $(4) |
Nico Huber | 1850aa6 | 2017-09-03 23:42:58 +0200 | [diff] [blame] | 395 | @printf " GCC $$$$(subst $$$$(obj)/,,$$$$(@))\n" |
| 396 | $(GCC_$(1)) \ |
| 397 | $$$$(ADAFLAGS_$(1)) $$$$(addprefix -I,$$$$($(1)-ada-dirs)) \ |
| 398 | $(3) -c -o $$$$@ $$$$< |
| 399 | el$(EMPTY)se |
| 400 | $$(call src-to-obj,$1,$$(1).$2): $$(1).$2 $(KCONFIG_AUTOHEADER) $(4) |
Patrick Georgi | 1cd76e7 | 2010-04-19 20:39:22 +0000 | [diff] [blame] | 401 | @printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n" |
Nico Huber | 2e09d2b | 2016-01-14 01:13:33 +0100 | [diff] [blame] | 402 | $(CC_$(1)) \ |
Nico Huber | 1850aa6 | 2017-09-03 23:42:58 +0200 | [diff] [blame] | 403 | -MMD $$$$(CPPFLAGS_$(1)) $$$$(CFLAGS_$(1)) -MT $$$$(@) \ |
Martin Roth | b18726d | 2023-08-15 15:57:29 -0600 | [diff] [blame] | 404 | $(3) -c -o $$$$@ $$$$< $(SAVE_IWYU_OUTPUT) |
Nico Huber | 1850aa6 | 2017-09-03 23:42:58 +0200 | [diff] [blame] | 405 | end$(EMPTY)if |
Patrick Georgi patrick.georgi | c5f773d | 2010-03-16 12:01:13 +0000 | [diff] [blame] | 406 | en$(EMPTY)def |
Patrick Georgi | b8cdd9b | 2011-02-17 20:48:45 +0000 | [diff] [blame] | 407 | end$(EMPTY)if |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 408 | endef |
| 409 | |
Patrick Georgi | b8cdd9b | 2011-02-17 20:48:45 +0000 | [diff] [blame] | 410 | filetypes-of-class=$(subst .,,$(sort $(suffix $($(1)-srcs)))) |
| 411 | $(foreach class,$(classes), \ |
| 412 | $(foreach type,$(call filetypes-of-class,$(class)), \ |
Patrick Georgi | 2459aee | 2015-03-27 15:27:21 +0100 | [diff] [blame] | 413 | $(eval $(class)-$(type)-ccopts += $(generic-$(type)-ccopts) $($(class)-generic-ccopts)) \ |
Patrick Georgi | 416ab38 | 2015-04-03 10:19:38 +0200 | [diff] [blame] | 414 | $(if $(generic-objs_$(type)_template_gen),$(eval $(call generic-objs_$(type)_template_gen,$(class))),\ |
| 415 | $(eval $(call create_cc_template,$(class),$(type),$($(class)-$(type)-ccopts),$($(class)-$(type)-deps)))))) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 416 | |
Patrick Georgi | d69839b | 2015-04-03 10:32:17 +0200 | [diff] [blame] | 417 | foreach-src=$(foreach file,$($(1)-srcs),$(eval $(call $(1)-objs_$(subst .,,$(suffix $(file)))_template,$(basename $(file))))) |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 418 | $(eval $(foreach class,$(classes),$(call foreach-src,$(class)))) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 419 | |
Nico Huber | 2e09d2b | 2016-01-14 01:13:33 +0100 | [diff] [blame] | 420 | # To supported complex package initializations, we need to call the |
| 421 | # emitted code explicitly. gnatbind gathers all the calls for us |
| 422 | # and exports them as a procedure $(stage)_adainit(). Every stage that |
| 423 | # uses Ada code has to call it! |
| 424 | define gnatbind_template |
| 425 | # $1 class |
| 426 | $$(obj)/$(1)/b__$(1).adb: $$$$(filter-out $$(obj)/$(1)/b__$(1).ali,$$$$($(1)-alis)) |
| 427 | @printf " BIND $$(subst $$(obj)/,,$$@)\n" |
| 428 | # We have to give gnatbind a simple filename (without leading |
| 429 | # path components) so just cd there. |
| 430 | cd $$(dir $$@) && \ |
| 431 | $$(GNATBIND_$(1)) -a -n \ |
Nico Huber | be5492a | 2015-09-29 16:41:19 +0200 | [diff] [blame] | 432 | --RTS=$$(absobj)/libgnat-$$(ARCH-$(1)-y)/ \ |
Nico Huber | 2e09d2b | 2016-01-14 01:13:33 +0100 | [diff] [blame] | 433 | -L$(1)_ada -o $$(notdir $$@) \ |
| 434 | $$(subst $$(dir $$@),,$$^) |
| 435 | $$(obj)/$(1)/b__$(1).o: $$(obj)/$(1)/b__$(1).adb |
Nico Huber | 1850aa6 | 2017-09-03 23:42:58 +0200 | [diff] [blame] | 436 | @printf " GCC $$(subst $$(obj)/,,$$@)\n" |
| 437 | $(GCC_$(1)) $$(ADAFLAGS_$(1)) -c -o $$@ $$< |
Nico Huber | 2e09d2b | 2016-01-14 01:13:33 +0100 | [diff] [blame] | 438 | $(1)-objs += $$(obj)/$(1)/b__$(1).o |
Nico Huber | ddb2465 | 2016-09-19 11:50:04 +0200 | [diff] [blame] | 439 | $($(1)-alis): %.ali: %.o ; |
Nico Huber | 2e09d2b | 2016-01-14 01:13:33 +0100 | [diff] [blame] | 440 | endef |
| 441 | |
Nico Huber | be5492a | 2015-09-29 16:41:19 +0200 | [diff] [blame] | 442 | $(eval $(foreach class,$(filter-out libgnat-%,$(classes)), \ |
Nico Huber | 2e09d2b | 2016-01-14 01:13:33 +0100 | [diff] [blame] | 443 | $(if $($(class)-alis),$(call gnatbind_template,$(class))))) |
| 444 | |
Julius Werner | f97b88b | 2014-12-05 12:32:09 -0800 | [diff] [blame] | 445 | DEPENDENCIES += $(addsuffix .d,$(basename $(allobjs))) |
Stefan Reinauer | 6bee951 | 2010-03-24 15:51:48 +0000 | [diff] [blame] | 446 | -include $(DEPENDENCIES) |
| 447 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 448 | printall: |
Martin Roth | 09b6444 | 2016-06-05 10:52:43 -0600 | [diff] [blame] | 449 | @$(foreach class,$(classes), echo $(class)-objs: $($(class)-objs) | tr ' ' '\n'; echo; ) |
| 450 | @echo alldirs: $(alldirs) | tr ' ' '\n'; echo |
| 451 | @echo allsrcs: $(allsrcs) | tr ' ' '\n'; echo |
| 452 | @echo DEPENDENCIES: $(DEPENDENCIES) | tr ' ' '\n'; echo |
| 453 | @$(foreach class,$(special-classes),echo $(class):'$($(class))' | tr ' ' '\n'; echo; ) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 454 | endif |
| 455 | |
Patrick Georgi | 40ad842 | 2011-05-21 22:18:59 +0000 | [diff] [blame] | 456 | ifndef NOMKDIR |
Stefan Reinauer | de60c88 | 2015-06-29 14:44:37 -0700 | [diff] [blame] | 457 | $(shell mkdir -p $(KCONFIG_SPLITCONFIG) $(objk)/lxdialog $(additional-dirs) $(alldirs)) |
Patrick Georgi | 40ad842 | 2011-05-21 22:18:59 +0000 | [diff] [blame] | 458 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 459 | |
Martin Roth | 9b0204d | 2017-09-18 09:25:18 -0600 | [diff] [blame] | 460 | $(obj)/project_filelist.txt: |
| 461 | if [ -z "$(wildcard $(obj)/coreboot.rom)" ]; then \ |
| 462 | echo "*** Error: Project must be built before generating file list ***"; \ |
| 463 | exit 1; \ |
| 464 | fi |
Maximilian Brune | c36b70c | 2022-12-26 00:29:49 +0100 | [diff] [blame] | 465 | find $(obj) -path "$(obj)/util" -prune -o -path "$(obj)/external" -prune -o -name "*.d" -exec cat {} \; | \ |
Martin Roth | 8a02727 | 2017-09-26 09:53:30 -0600 | [diff] [blame] | 466 | sed "s|$(top)/||" | sed 's/[:\\]/ /g' | sed 's/ /\n/g' | sort | uniq | \ |
Martin Roth | 9c1b33e | 2015-07-29 14:55:18 -0700 | [diff] [blame] | 467 | grep -v '\.o$$' > $(obj)/project_filelist.txt |
| 468 | |
Martin Roth | 9b0204d | 2017-09-18 09:25:18 -0600 | [diff] [blame] | 469 | filelist: $(obj)/project_filelist.txt |
Martin Roth | a18353d | 2017-06-06 06:44:46 -0600 | [diff] [blame] | 470 | printf "\nFiles used in build:\n" |
| 471 | cat $(obj)/project_filelist.txt |
| 472 | |
Martin Roth | 9c1b33e | 2015-07-29 14:55:18 -0700 | [diff] [blame] | 473 | #works with either exuberant ctags or ctags.emacs |
| 474 | ctags-project: clean-ctags $(obj)/project_filelist.txt |
| 475 | cat $(obj)/project_filelist.txt | \ |
| 476 | xargs ctags -o tags |
| 477 | |
| 478 | cscope-project: clean-cscope $(obj)/project_filelist.txt |
| 479 | cat $(obj)/project_filelist.txt | xargs cscope -b |
| 480 | |
Warren Turkal | a9fc330 | 2010-09-03 08:57:32 +0000 | [diff] [blame] | 481 | cscope: |
| 482 | cscope -bR |
| 483 | |
Patrick Rudolph | f664321 | 2020-05-17 20:04:12 +0200 | [diff] [blame] | 484 | sphinx: |
Nico Huber | 4f01483 | 2023-08-23 12:41:01 +0200 | [diff] [blame] | 485 | $(MAKE) -C Documentation sphinx |
Patrick Rudolph | f664321 | 2020-05-17 20:04:12 +0200 | [diff] [blame] | 486 | |
| 487 | sphinx-lint: |
Nico Huber | 4f01483 | 2023-08-23 12:41:01 +0200 | [diff] [blame] | 488 | $(MAKE) SPHINXOPTS=-W -C Documentation sphinx |
Patrick Rudolph | f664321 | 2020-05-17 20:04:12 +0200 | [diff] [blame] | 489 | |
Martin Roth | 754fa0e | 2024-06-18 14:30:09 -0600 | [diff] [blame^] | 490 | # Look at all of the files in the SYMLINK_LIST and create the symbolic links |
| 491 | # into the coreboot tree. Each symlink.txt file in site-local should be in the |
| 492 | # directory linked from and have a single line with the path to the location to |
| 493 | # link to. The path must be relative to the top of the coreboot directory. |
Christian Walter | a8c10c8 | 2022-07-01 11:12:25 +0200 | [diff] [blame] | 494 | symlink: |
Martin Roth | 754fa0e | 2024-06-18 14:30:09 -0600 | [diff] [blame^] | 495 | if [ -z "$(SYMLINK_LIST)" ]; then \ |
| 496 | echo "No site-local symbolic links to create."; \ |
| 497 | exit 0; \ |
| 498 | fi; \ |
| 499 | echo "Creating symbolic links.."; \ |
Christian Walter | a8c10c8 | 2022-07-01 11:12:25 +0200 | [diff] [blame] | 500 | for link in $(SYMLINK_LIST); do \ |
Martin Roth | 754fa0e | 2024-06-18 14:30:09 -0600 | [diff] [blame^] | 501 | LINKTO="$(top)/$$(head -n 1 "$${link}")"; \ |
| 502 | LINKFROM=$$(dirname "$$(realpath "$${link}")"); \ |
| 503 | if [ -L "$${LINKTO}" ]; then \ |
| 504 | echo " $${LINKTO} exists - skipping"; \ |
Christian Walter | a8c10c8 | 2022-07-01 11:12:25 +0200 | [diff] [blame] | 505 | continue; \ |
Martin Roth | 754fa0e | 2024-06-18 14:30:09 -0600 | [diff] [blame^] | 506 | fi; \ |
| 507 | LINKTO="$$(realpath -m "$${LINKTO}")" 2>/dev/null; \ |
| 508 | if [ "$${LINKTO}" = "$$(echo "$${LINKTO}" | sed "s|^$(top)||" )" ]; then \ |
| 509 | echo " FAILED: $${LINKTO} is outside of current directory." >&2; \ |
| 510 | continue; \ |
| 511 | fi; \ |
| 512 | if [ ! -e "$${LINKTO}" ]; then \ |
| 513 | echo " LINK $${LINKTO} -> $${LINKFROM}"; \ |
| 514 | ln -s "$${LINKFROM}" "$${LINKTO}" || \ |
| 515 | echo "FAILED: Could not create link." >&2; \ |
Christian Walter | a8c10c8 | 2022-07-01 11:12:25 +0200 | [diff] [blame] | 516 | else \ |
Martin Roth | 754fa0e | 2024-06-18 14:30:09 -0600 | [diff] [blame^] | 517 | echo " FAILED: $${LINKTO} exists as a file or directory." >&2; \ |
| 518 | fi; \ |
Christian Walter | a8c10c8 | 2022-07-01 11:12:25 +0200 | [diff] [blame] | 519 | done |
| 520 | |
| 521 | clean-symlink: |
| 522 | @echo "Deleting symbolic link";\ |
| 523 | EXISTING_SYMLINKS=`find -L ./src -xtype l | grep -v 3rdparty`; \ |
| 524 | for link in $$EXISTING_SYMLINKS; do \ |
| 525 | echo -e "\tUNLINK $$link"; \ |
| 526 | rm "$$link"; \ |
| 527 | done |
| 528 | |
Martin Roth | 619086d | 2022-05-09 18:48:24 -0600 | [diff] [blame] | 529 | clean-for-update: |
Patrick Georgi | 02ae0bf | 2013-02-09 15:45:02 +0100 | [diff] [blame] | 530 | rm -rf $(obj) .xcompile |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 531 | |
Arthur Heymans | f91366f | 2022-03-25 16:01:05 +0100 | [diff] [blame] | 532 | clean: clean-for-update clean-utils clean-payloads |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 533 | rm -f .ccwrap |
Warren Turkal | 0e8f204 | 2010-09-27 21:14:19 +0000 | [diff] [blame] | 534 | |
Warren Turkal | a9fc330 | 2010-09-03 08:57:32 +0000 | [diff] [blame] | 535 | clean-cscope: |
| 536 | rm -f cscope.out |
| 537 | |
Martin Roth | 9c1b33e | 2015-07-29 14:55:18 -0700 | [diff] [blame] | 538 | clean-ctags: |
| 539 | rm -f tags |
| 540 | |
Martin Roth | 20cd54f | 2017-03-26 18:49:02 -0600 | [diff] [blame] | 541 | clean-utils: |
Martin Roth | 1d721ed | 2017-07-07 10:49:48 -0600 | [diff] [blame] | 542 | $(foreach tool, $(TOOLLIST), \ |
| 543 | $(MAKE) -C util/$(tool) clean MFLAGS= MAKEFLAGS= ;) |
Martin Roth | 20cd54f | 2017-03-26 18:49:02 -0600 | [diff] [blame] | 544 | |
| 545 | distclean-utils: |
Martin Roth | 1d721ed | 2017-07-07 10:49:48 -0600 | [diff] [blame] | 546 | $(foreach tool, $(TOOLLIST), \ |
| 547 | $(MAKE) -C util/$(tool) distclean MFLAGS= MAKEFLAGS= ; \ |
Martin Roth | 20cd54f | 2017-03-26 18:49:02 -0600 | [diff] [blame] | 548 | rm -f /util/$(tool)/junit.xml;) |
| 549 | |
| 550 | distclean: clean clean-ctags clean-cscope distclean-payloads distclean-utils |
Patrick Georgi | 80656af | 2017-04-26 11:58:44 +0200 | [diff] [blame] | 551 | rm -f .config .config.old ..config.tmp* .kconfig.d .tmpconfig* .ccwrap .xcompile |
Martin Roth | 20cd54f | 2017-03-26 18:49:02 -0600 | [diff] [blame] | 552 | rm -rf coreboot-builds coreboot-builds-chromeos |
| 553 | rm -f abuild*.xml junit.xml* util/lint/junit.xml |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 554 | |
Martin Roth | 619086d | 2022-05-09 18:48:24 -0600 | [diff] [blame] | 555 | .PHONY: $(PHONY) clean clean-for-update clean-cscope cscope distclean sphinx sphinx-lint |
Christian Walter | a8c10c8 | 2022-07-01 11:12:25 +0200 | [diff] [blame] | 556 | .PHONY: ctags-project cscope-project clean-ctags symlink clean-symlink |