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