Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 1 | ## |
| 2 | ## This file is part of the coreboot project. |
| 3 | ## |
| 4 | ## Copyright (C) 2008 Advanced Micro Devices, Inc. |
| 5 | ## Copyright (C) 2008 Uwe Hermann <uwe@hermann-uwe.de> |
Stefan Reinauer | 8ed1b6d | 2010-01-19 21:13:44 +0000 | [diff] [blame] | 6 | ## Copyright (C) 2009-2010 coresystems GmbH |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 7 | ## Copyright (C) 2011 secunet Security Networks AG |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 8 | ## |
Patrick Georgi | 3bda044 | 2011-06-30 15:48:57 +0200 | [diff] [blame] | 9 | ## Redistribution and use in source and binary forms, with or without |
| 10 | ## modification, are permitted provided that the following conditions |
| 11 | ## are met: |
| 12 | ## 1. Redistributions of source code must retain the above copyright |
| 13 | ## notice, this list of conditions and the following disclaimer. |
| 14 | ## 2. Redistributions in binary form must reproduce the above copyright |
| 15 | ## notice, this list of conditions and the following disclaimer in the |
| 16 | ## documentation and/or other materials provided with the distribution. |
| 17 | ## 3. The name of the author may not be used to endorse or promote products |
| 18 | ## derived from this software without specific prior written permission. |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 19 | ## |
Patrick Georgi | 3bda044 | 2011-06-30 15:48:57 +0200 | [diff] [blame] | 20 | ## THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
| 21 | ## ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 22 | ## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 23 | ## ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
| 24 | ## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 25 | ## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 26 | ## OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 27 | ## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 28 | ## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 29 | ## OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 30 | ## SUCH DAMAGE. |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 31 | ## |
| 32 | |
Patrick Georgi | 05560bf | 2014-07-19 10:55:30 +0200 | [diff] [blame] | 33 | # in addition to the dependency below, create the file if it doesn't exist |
| 34 | # to silence stupid warnings about a file that would be generated anyway. |
Patrick Georgi | bdb4af8 | 2015-11-19 09:53:04 +0100 | [diff] [blame] | 35 | $(if $(wildcard .xcompile),,$(eval $(shell util/xcompile/xcompile $(XGCCPATH) > .xcompile || rm -f .xcompile))) |
Patrick Georgi | 05560bf | 2014-07-19 10:55:30 +0200 | [diff] [blame] | 36 | |
Patrick Georgi | 18ff4f1 | 2014-07-10 21:06:04 +0200 | [diff] [blame] | 37 | .xcompile: util/xcompile/xcompile |
Patrick Georgi | 6dda31d | 2015-11-19 15:15:33 +0100 | [diff] [blame] | 38 | rm -f $@ |
Vadim Bendebury | e469602 | 2015-04-25 11:34:35 -0700 | [diff] [blame] | 39 | $< $(XGCCPATH) > $@.tmp |
| 40 | \mv -f $@.tmp $@ 2> /dev/null |
Patrick Georgi | 75cdfd1 | 2015-11-20 10:32:14 +0100 | [diff] [blame] | 41 | rm -f $@.tmp |
Patrick Georgi | 18ff4f1 | 2014-07-10 21:06:04 +0200 | [diff] [blame] | 42 | |
Jonathan Kollasch | 7ff5b44 | 2010-09-28 21:11:48 +0000 | [diff] [blame] | 43 | export top := $(CURDIR) |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 44 | export src := src |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 45 | export srck := $(top)/util/kconfig |
Vadim Bendebury | 5f7e4f0 | 2015-05-06 21:00:10 -0700 | [diff] [blame] | 46 | obj ?= build |
| 47 | override obj := $(subst $(top)/,,$(abspath $(obj))) |
| 48 | export obj |
Patrick Georgi | a2acbc7 | 2010-04-16 22:48:57 +0000 | [diff] [blame] | 49 | export objutil ?= $(obj)/util |
| 50 | export objk := $(objutil)/kconfig |
Vadim Bendebury | 5f7e4f0 | 2015-05-06 21:00:10 -0700 | [diff] [blame] | 51 | absobj := $(abspath $(obj)) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 52 | |
| 53 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 54 | export KCONFIG_AUTOHEADER := $(obj)/config.h |
| 55 | export KCONFIG_AUTOCONFIG := $(obj)/auto.conf |
Patrick Georgi | d520840 | 2014-04-11 20:24:06 +0200 | [diff] [blame] | 56 | export KCONFIG_DEPENDENCIES := $(obj)/auto.conf.cmd |
| 57 | export KCONFIG_SPLITCONFIG := $(obj)/config |
| 58 | export KCONFIG_TRISTATE := $(obj)/tristate.conf |
| 59 | export KCONFIG_NEGATIVES := 1 |
Stefan Reinauer | d373a00 | 2015-07-17 17:29:19 -0700 | [diff] [blame] | 60 | export KCONFIG_STRICT := 1 |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 61 | |
Patrick Georgi | e38d0a6 | 2011-03-01 08:09:22 +0000 | [diff] [blame] | 62 | # directory containing the toplevel Makefile.inc |
| 63 | TOPLEVEL := . |
| 64 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 65 | CONFIG_SHELL := sh |
| 66 | KBUILD_DEFCONFIG := configs/defconfig |
| 67 | UNAME_RELEASE := $(shell uname -r) |
Paul Kocialkowski | fde3275 | 2016-07-24 12:25:07 +0200 | [diff] [blame] | 68 | DOTCONFIG ?= $(top)/.config |
Patrick Georgi | 89ec376 | 2010-12-08 19:58:30 +0000 | [diff] [blame] | 69 | KCONFIG_CONFIG = $(DOTCONFIG) |
| 70 | export KCONFIG_CONFIG |
| 71 | HAVE_DOTCONFIG := $(wildcard $(DOTCONFIG)) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 72 | MAKEFLAGS += -rR --no-print-directory |
| 73 | |
| 74 | # 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] | 75 | Q:=@ |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 76 | ifneq ($(V),1) |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 77 | ifneq ($(Q),) |
| 78 | .SILENT: |
| 79 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 80 | endif |
| 81 | |
Julius Werner | 808a429 | 2015-03-13 11:05:07 -0700 | [diff] [blame] | 82 | # Disable implicit/built-in rules to make Makefile errors fail fast. |
| 83 | .SUFFIXES: |
| 84 | |
Patrick Georgi | f92068d | 2016-02-01 12:02:29 +0100 | [diff] [blame] | 85 | HOSTCC := $(if $(shell type gcc 2>/dev/null),gcc,cc) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 86 | HOSTCXX = g++ |
Patrick Georgi | b3a18ac | 2012-09-13 22:13:33 +0200 | [diff] [blame] | 87 | HOSTCFLAGS := -g |
| 88 | HOSTCXXFLAGS := -g |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 89 | |
Patrick Georgi | 828e0e8 | 2015-04-04 15:50:20 +0200 | [diff] [blame] | 90 | PREPROCESS_ONLY := -E -P -x assembler-with-cpp -undef -I . |
| 91 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 92 | DOXYGEN := doxygen |
| 93 | DOXYGEN_OUTPUT_DIR := doxygen |
| 94 | |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 95 | all: real-all |
| 96 | |
Martin Roth | 4eea174 | 2015-11-25 11:50:04 -0700 | [diff] [blame] | 97 | help_coreboot help:: |
| 98 | @echo '*** coreboot platform targets ***' |
Martin Roth | 76f14b2 | 2015-11-18 13:09:23 -0700 | [diff] [blame] | 99 | @echo ' Use "make [target] V=1" for extra build debug information' |
| 100 | @echo ' all - Build coreboot' |
| 101 | @echo ' clean - Remove coreboot build artifacts' |
| 102 | @echo ' distclean - Remove build artifacts and config files' |
| 103 | @echo ' doxygen - Build doxygen documentation for coreboot' |
| 104 | @echo ' what-jenkins-does - Run platform build tests (Use CPUS=# for more cores)' |
| 105 | @echo ' printall - print makefile info for debugging' |
| 106 | @echo ' lint / lint-stable - run coreboot lint tools (all / minimal)' |
Werner Zeh | 2de6410 | 2016-01-12 12:45:49 +0100 | [diff] [blame] | 107 | @echo ' gitconfig - set up git to submit patches to coreboot' |
Martin Roth | 76f14b2 | 2015-11-18 13:09:23 -0700 | [diff] [blame] | 108 | @echo ' ctags / ctags-project - make ctags file for all of coreboot or current board' |
| 109 | @echo ' cscope / cscope-project - make cscope.out file for coreboot or current board' |
| 110 | @echo |
| 111 | |
Patrick Georgi | e38d0a6 | 2011-03-01 08:09:22 +0000 | [diff] [blame] | 112 | # This include must come _before_ the pattern rules below! |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 113 | # Order _does_ matter for pattern rules. |
Stefan Reinauer | de60c88 | 2015-06-29 14:44:37 -0700 | [diff] [blame] | 114 | include $(srck)/Makefile |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 115 | |
Patrick Georgi | cf036d1 | 2010-04-21 06:36:20 +0000 | [diff] [blame] | 116 | # Three cases where we don't need fully populated $(obj) lists: |
| 117 | # 1. when no .config exists |
| 118 | # 2. when make config (in any flavour) is run |
| 119 | # 3. when make distclean is run |
| 120 | # Don't waste time on reading all Makefile.incs in these cases |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 121 | ifeq ($(strip $(HAVE_DOTCONFIG)),) |
Patrick Georgi | cf036d1 | 2010-04-21 06:36:20 +0000 | [diff] [blame] | 122 | NOCOMPILE:=1 |
| 123 | endif |
| 124 | ifneq ($(MAKECMDGOALS),) |
Martin Roth | c24f3d6 | 2015-11-25 12:50:25 -0700 | [diff] [blame] | 125 | 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] | 126 | NOCOMPILE:=1 |
| 127 | endif |
Patrick Georgi | 02ae0bf | 2013-02-09 15:45:02 +0100 | [diff] [blame] | 128 | ifeq ($(MAKECMDGOALS), %clean) |
Zheng Bao | 0fd93d6 | 2012-10-22 16:36:03 +0800 | [diff] [blame] | 129 | NOMKDIR:=1 |
| 130 | endif |
Patrick Georgi | cf036d1 | 2010-04-21 06:36:20 +0000 | [diff] [blame] | 131 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 132 | |
Patrick Georgi | cf036d1 | 2010-04-21 06:36:20 +0000 | [diff] [blame] | 133 | ifeq ($(NOCOMPILE),1) |
Patrick Georgi | e38d0a6 | 2011-03-01 08:09:22 +0000 | [diff] [blame] | 134 | include $(TOPLEVEL)/Makefile.inc |
Martin Roth | 6797557 | 2016-03-07 16:38:52 -0700 | [diff] [blame] | 135 | include $(TOPLEVEL)/payloads/Makefile.inc |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 136 | real-all: config |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 137 | |
| 138 | else |
| 139 | |
Paul Kocialkowski | 585c781 | 2016-07-13 11:00:41 +0200 | [diff] [blame] | 140 | include $(DOTCONFIG) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 141 | |
Patrick Georgi | 6dda31d | 2015-11-19 15:15:33 +0100 | [diff] [blame] | 142 | -include .xcompile |
| 143 | |
| 144 | ifneq ($(XCOMPILE_COMPLETE),1) |
| 145 | $(shell rm -f .xcompile) |
| 146 | $(error .xcompile deleted because it's invalid. \ |
| 147 | Restarting the build should fix that, or explain the problem) |
| 148 | endif |
Patrick Georgi | 7b9762f | 2015-06-04 13:18:11 +0200 | [diff] [blame] | 149 | |
Patrick Georgi | cc84a00 | 2014-05-14 21:05:35 +0200 | [diff] [blame] | 150 | ifneq ($(CONFIG_MMX),y) |
| 151 | CFLAGS_x86_32 += -mno-mmx |
| 152 | endif |
| 153 | |
Patrick Georgi | cc84a00 | 2014-05-14 21:05:35 +0200 | [diff] [blame] | 154 | include toolchain.inc |
| 155 | |
Zheng Bao | 0764892 | 2015-11-13 10:42:27 +0800 | [diff] [blame] | 156 | strip_quotes = $(strip $(subst ",,$(subst \",,$(1)))) |
Martin Roth | bbf1399 | 2016-01-25 15:59:24 -0700 | [diff] [blame] | 157 | # fix makefile syntax highlighting after strip macro \" ")) |
Patrick Georgi | a84e98b | 2010-03-16 19:01:32 +0000 | [diff] [blame] | 158 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 159 | # The primary target needs to be here before we include the |
| 160 | # other files |
| 161 | |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 162 | real-all: real-target |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 163 | |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 164 | # must come rather early |
| 165 | .SECONDEXPANSION: |
| 166 | |
Stefan Reinauer | 0d869ed | 2015-07-17 13:31:16 -0700 | [diff] [blame] | 167 | $(KCONFIG_AUTOHEADER): $(KCONFIG_CONFIG) |
Stefan Reinauer | 1425add | 2010-03-21 22:35:58 +0000 | [diff] [blame] | 168 | $(MAKE) oldconfig |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 169 | |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 170 | # Add a new class of source/object files to the build system |
| 171 | add-class= \ |
| 172 | $(eval $(1)-srcs:=) \ |
| 173 | $(eval $(1)-objs:=) \ |
| 174 | $(eval classes+=$(1)) |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 175 | |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 176 | # Special classes are managed types with special behaviour |
| 177 | # On parse time, for each entry in variable $(1)-y |
| 178 | # a handler $(1)-handler is executed with the arguments: |
| 179 | # * $(1): directory the parser is in |
| 180 | # * $(2): current entry |
| 181 | add-special-class= \ |
| 182 | $(eval $(1):=) \ |
| 183 | $(eval special-classes+=$(1)) |
| 184 | |
Nico Huber | 81b09f4 | 2016-01-23 00:50:00 +0100 | [diff] [blame] | 185 | # Converts one or more source file paths to their corresponding build/ paths. |
| 186 | # Only .c and .S get converted to .o, other files (like .ld) keep their name. |
| 187 | # $1 stage name |
| 188 | # $2 file path (list) |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 189 | src-to-obj=\ |
| 190 | $(patsubst $(obj)/%,$(obj)/$(1)/%,\ |
| 191 | $(patsubst $(obj)/$(1)/%,$(obj)/%,\ |
| 192 | $(patsubst src/%,$(obj)/%,\ |
| 193 | $(patsubst %.c,%.o,\ |
| 194 | $(patsubst %.S,%.o,\ |
| 195 | $(subst .$(1),,$(2))))))) |
Nico Huber | 81b09f4 | 2016-01-23 00:50:00 +0100 | [diff] [blame] | 196 | |
Patrick Georgi | 47d68d8 | 2010-03-06 21:18:43 +0000 | [diff] [blame] | 197 | # Clean -y variables, include Makefile.inc |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 198 | # Add paths to files in X-y to X-srcs |
Patrick Georgi | 47d68d8 | 2010-03-06 21:18:43 +0000 | [diff] [blame] | 199 | # Add subdirs-y to subdirs |
| 200 | includemakefiles= \ |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 201 | $(foreach class,classes subdirs $(classes) $(special-classes), $(eval $(class)-y:=)) \ |
Patrick Georgi | 47d68d8 | 2010-03-06 21:18:43 +0000 | [diff] [blame] | 202 | $(eval -include $(1)) \ |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 203 | $(foreach class,$(classes-y), $(call add-class,$(class))) \ |
| 204 | $(foreach class,$(classes), \ |
| 205 | $(eval $(class)-srcs+= \ |
Vadim Bendebury | 5f7e4f0 | 2015-05-06 21:00:10 -0700 | [diff] [blame] | 206 | $$(subst $(absobj)/,$(obj)/, \ |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 207 | $$(subst $(top)/,, \ |
Vadim Bendebury | 5f7e4f0 | 2015-05-06 21:00:10 -0700 | [diff] [blame] | 208 | $$(abspath $$(subst $(dir $(1))/,/,$$(addprefix $(dir $(1)),$$($(class)-y)))))))) \ |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 209 | $(foreach special,$(special-classes), \ |
| 210 | $(foreach item,$($(special)-y), $(call $(special)-handler,$(dir $(1)),$(item)))) \ |
Jonathan Kollasch | 7ff5b44 | 2010-09-28 21:11:48 +0000 | [diff] [blame] | 211 | $(eval subdirs+=$$(subst $(CURDIR)/,,$$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y))))) |
Patrick Georgi | 47d68d8 | 2010-03-06 21:18:43 +0000 | [diff] [blame] | 212 | |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 213 | # For each path in $(subdirs) call includemakefiles |
Patrick Georgi | 47d68d8 | 2010-03-06 21:18:43 +0000 | [diff] [blame] | 214 | # Repeat until subdirs is empty |
| 215 | evaluate_subdirs= \ |
| 216 | $(eval cursubdirs:=$(subdirs)) \ |
| 217 | $(eval subdirs:=) \ |
| 218 | $(foreach dir,$(cursubdirs), \ |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 219 | $(eval $(call includemakefiles,$(dir)/Makefile.inc))) \ |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 220 | $(if $(subdirs),$(eval $(call evaluate_subdirs))) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 221 | |
| 222 | # collect all object files eligible for building |
Patrick Georgi | e38d0a6 | 2011-03-01 08:09:22 +0000 | [diff] [blame] | 223 | subdirs:=$(TOPLEVEL) |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 224 | $(eval $(call evaluate_subdirs)) |
Patrick Georgi | 70c85ea | 2013-02-16 01:06:57 +0100 | [diff] [blame] | 225 | ifeq ($(FAILBUILD),1) |
| 226 | $(error cannot continue build) |
| 227 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 228 | |
Patrick Georgi | 94a4586 | 2011-10-25 14:32:21 -0700 | [diff] [blame] | 229 | # Eliminate duplicate mentions of source files in a class |
| 230 | $(foreach class,$(classes),$(eval $(class)-srcs:=$(sort $($(class)-srcs)))) |
| 231 | |
Patrick Georgi | 10f86b0 | 2015-03-27 16:56:23 +0100 | [diff] [blame] | 232 | $(foreach class,$(classes),$(eval $(class)-objs:=$(call src-to-obj,$(class),$($(class)-srcs)))) |
Patrick Georgi | d3428b0 | 2010-02-24 13:18:01 +0000 | [diff] [blame] | 233 | |
Nico Huber | 963bed5 | 2013-05-15 11:47:51 +0200 | [diff] [blame] | 234 | # Save all objs before processing them (for dependency inclusion) |
| 235 | originalobjs:=$(foreach var, $(addsuffix -objs,$(classes)), $($(var))) |
| 236 | |
Patrick Georgi | 79f9010 | 2012-11-25 14:31:08 +0100 | [diff] [blame] | 237 | # Call post-processors if they're defined |
| 238 | $(foreach class,$(classes),\ |
| 239 | $(if $(value $(class)-postprocess),$(eval $(call $(class)-postprocess,$($(class)-objs))))) |
| 240 | |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 241 | allsrcs:=$(foreach var, $(addsuffix -srcs,$(classes)), $($(var))) |
| 242 | allobjs:=$(foreach var, $(addsuffix -objs,$(classes)), $($(var))) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 243 | alldirs:=$(sort $(abspath $(dir $(allobjs)))) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 244 | |
Patrick Georgi patrick.georgi | c5f773d | 2010-03-16 12:01:13 +0000 | [diff] [blame] | 245 | # macro to define template macros that are used by use_template macro |
| 246 | define create_cc_template |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 247 | # $1 obj class |
Patrick Georgi | 990e7c9 | 2015-04-03 10:47:15 +0200 | [diff] [blame] | 248 | # $2 source suffix (c, S, ld, ...) |
Marc Jones | a38ccfd | 2014-11-06 15:50:22 -0700 | [diff] [blame] | 249 | # $3 additional compiler flags |
| 250 | # $4 additional dependencies |
Patrick Georgi | b8cdd9b | 2011-02-17 20:48:45 +0000 | [diff] [blame] | 251 | ifn$(EMPTY)def $(1)-objs_$(2)_template |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 252 | de$(EMPTY)fine $(1)-objs_$(2)_template |
Stefan Reinauer | 0d869ed | 2015-07-17 13:31:16 -0700 | [diff] [blame] | 253 | $$(call src-to-obj,$1,$$(1).$2): $$(1).$2 $(KCONFIG_AUTOHEADER) $(4) |
Patrick Georgi | 1cd76e7 | 2010-04-19 20:39:22 +0000 | [diff] [blame] | 254 | @printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n" |
Patrick Georgi | 75fcaf9 | 2015-04-03 10:16:12 +0200 | [diff] [blame] | 255 | $(CC_$(1)) -MMD $$$$(CPPFLAGS_$(1)) $$$$(CFLAGS_$(1)) -MT $$$$(@) $(3) -c -o $$$$@ $$$$< |
Patrick Georgi patrick.georgi | c5f773d | 2010-03-16 12:01:13 +0000 | [diff] [blame] | 256 | en$(EMPTY)def |
Patrick Georgi | b8cdd9b | 2011-02-17 20:48:45 +0000 | [diff] [blame] | 257 | end$(EMPTY)if |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 258 | endef |
| 259 | |
Patrick Georgi | b8cdd9b | 2011-02-17 20:48:45 +0000 | [diff] [blame] | 260 | filetypes-of-class=$(subst .,,$(sort $(suffix $($(1)-srcs)))) |
| 261 | $(foreach class,$(classes), \ |
| 262 | $(foreach type,$(call filetypes-of-class,$(class)), \ |
Patrick Georgi | 2459aee | 2015-03-27 15:27:21 +0100 | [diff] [blame] | 263 | $(eval $(class)-$(type)-ccopts += $(generic-$(type)-ccopts) $($(class)-generic-ccopts)) \ |
Patrick Georgi | 416ab38 | 2015-04-03 10:19:38 +0200 | [diff] [blame] | 264 | $(if $(generic-objs_$(type)_template_gen),$(eval $(call generic-objs_$(type)_template_gen,$(class))),\ |
| 265 | $(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] | 266 | |
Patrick Georgi | d69839b | 2015-04-03 10:32:17 +0200 | [diff] [blame] | 267 | 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] | 268 | $(eval $(foreach class,$(classes),$(call foreach-src,$(class)))) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 269 | |
Julius Werner | f97b88b | 2014-12-05 12:32:09 -0800 | [diff] [blame] | 270 | DEPENDENCIES += $(addsuffix .d,$(basename $(allobjs))) |
Stefan Reinauer | 6bee951 | 2010-03-24 15:51:48 +0000 | [diff] [blame] | 271 | -include $(DEPENDENCIES) |
| 272 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 273 | printall: |
Martin Roth | 09b6444 | 2016-06-05 10:52:43 -0600 | [diff] [blame] | 274 | @$(foreach class,$(classes), echo $(class)-objs: $($(class)-objs) | tr ' ' '\n'; echo; ) |
| 275 | @echo alldirs: $(alldirs) | tr ' ' '\n'; echo |
| 276 | @echo allsrcs: $(allsrcs) | tr ' ' '\n'; echo |
| 277 | @echo DEPENDENCIES: $(DEPENDENCIES) | tr ' ' '\n'; echo |
| 278 | @$(foreach class,$(special-classes),echo $(class):'$($(class))' | tr ' ' '\n'; echo; ) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 279 | endif |
| 280 | |
Patrick Georgi | 40ad842 | 2011-05-21 22:18:59 +0000 | [diff] [blame] | 281 | ifndef NOMKDIR |
Stefan Reinauer | de60c88 | 2015-06-29 14:44:37 -0700 | [diff] [blame] | 282 | $(shell mkdir -p $(KCONFIG_SPLITCONFIG) $(objk)/lxdialog $(additional-dirs) $(alldirs)) |
Patrick Georgi | 40ad842 | 2011-05-21 22:18:59 +0000 | [diff] [blame] | 283 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 284 | |
Martin Roth | 9c1b33e | 2015-07-29 14:55:18 -0700 | [diff] [blame] | 285 | $(obj)/project_filelist.txt: all |
| 286 | find $(obj) -name "*.d" -exec cat {} \; | \ |
| 287 | sed 's/[:\\]/ /g' | sed 's/ /\n/g' | sort | uniq | \ |
| 288 | grep -v '\.o$$' > $(obj)/project_filelist.txt |
| 289 | |
| 290 | #works with either exuberant ctags or ctags.emacs |
| 291 | ctags-project: clean-ctags $(obj)/project_filelist.txt |
| 292 | cat $(obj)/project_filelist.txt | \ |
| 293 | xargs ctags -o tags |
| 294 | |
| 295 | cscope-project: clean-cscope $(obj)/project_filelist.txt |
| 296 | cat $(obj)/project_filelist.txt | xargs cscope -b |
| 297 | |
Warren Turkal | a9fc330 | 2010-09-03 08:57:32 +0000 | [diff] [blame] | 298 | cscope: |
| 299 | cscope -bR |
| 300 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 301 | doxy: doxygen |
| 302 | doxygen: |
Nicky Sielicki | e08a2a5 | 2015-06-06 08:55:16 -0500 | [diff] [blame] | 303 | $(DOXYGEN) Documentation/Doxyfile.coreboot |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 304 | |
Martin Roth | d7689e4 | 2014-12-29 14:56:19 -0700 | [diff] [blame] | 305 | doxygen_simple: |
Nicky Sielicki | e08a2a5 | 2015-06-06 08:55:16 -0500 | [diff] [blame] | 306 | $(DOXYGEN) Documentation/Doxyfile.coreboot_simple |
Martin Roth | d7689e4 | 2014-12-29 14:56:19 -0700 | [diff] [blame] | 307 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 308 | doxyclean: doxygen-clean |
| 309 | doxygen-clean: |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 310 | rm -rf $(DOXYGEN_OUTPUT_DIR) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 311 | |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 312 | clean-for-update: doxygen-clean clean-for-update-target |
Patrick Georgi | 02ae0bf | 2013-02-09 15:45:02 +0100 | [diff] [blame] | 313 | rm -rf $(obj) .xcompile |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 314 | |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 315 | clean: clean-for-update clean-target |
| 316 | rm -f .ccwrap |
Warren Turkal | 0e8f204 | 2010-09-27 21:14:19 +0000 | [diff] [blame] | 317 | |
Warren Turkal | a9fc330 | 2010-09-03 08:57:32 +0000 | [diff] [blame] | 318 | clean-cscope: |
| 319 | rm -f cscope.out |
| 320 | |
Martin Roth | 9c1b33e | 2015-07-29 14:55:18 -0700 | [diff] [blame] | 321 | clean-ctags: |
| 322 | rm -f tags |
| 323 | |
Martin Roth | 6797557 | 2016-03-07 16:38:52 -0700 | [diff] [blame] | 324 | distclean: clean clean-ctags clean-cscope distclean-payloads |
Patrick Georgi | cf036d1 | 2010-04-21 06:36:20 +0000 | [diff] [blame] | 325 | rm -f .config .config.old ..config.tmp .kconfig.d .tmpconfig* .ccwrap .xcompile |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 326 | |
Martin Roth | d7689e4 | 2014-12-29 14:56:19 -0700 | [diff] [blame] | 327 | .PHONY: $(PHONY) clean clean-for-update clean-cscope cscope distclean doxygen doxy doxygen_simple |
Martin Roth | 9c1b33e | 2015-07-29 14:55:18 -0700 | [diff] [blame] | 328 | .PHONY: ctags-project cscope-project clean-ctags |