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 | 020f51f | 2010-03-14 21:25:03 +0000 | [diff] [blame] | 33 | ifeq ($(INNER_SCANBUILD),y) |
| 34 | CC_real:=$(CC) |
| 35 | endif |
Patrick Georgi | 23d89cc | 2010-03-16 01:17:19 +0000 | [diff] [blame] | 36 | |
Marc Jones | 616da1e | 2011-10-07 17:20:30 -0600 | [diff] [blame] | 37 | $(if $(wildcard .xcompile),,$(eval $(shell bash util/xcompile/xcompile $(XGCCPATH) > .xcompile))) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 38 | include .xcompile |
Patrick Georgi | 23d89cc | 2010-03-16 01:17:19 +0000 | [diff] [blame] | 39 | |
Patrick Georgi | 020f51f | 2010-03-14 21:25:03 +0000 | [diff] [blame] | 40 | ifeq ($(INNER_SCANBUILD),y) |
| 41 | CC:=$(CC_real) |
| 42 | HOSTCC:=$(CC_real) --hostcc |
| 43 | HOSTCXX:=$(CC_real) --hostcxx |
| 44 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 45 | |
Jonathan Kollasch | 7ff5b44 | 2010-09-28 21:11:48 +0000 | [diff] [blame] | 46 | export top := $(CURDIR) |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 47 | export src := src |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 48 | export srck := $(top)/util/kconfig |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 49 | export obj ?= build |
Patrick Georgi | a2acbc7 | 2010-04-16 22:48:57 +0000 | [diff] [blame] | 50 | export objutil ?= $(obj)/util |
| 51 | export objk := $(objutil)/kconfig |
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 |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 60 | |
Patrick Georgi | e38d0a6 | 2011-03-01 08:09:22 +0000 | [diff] [blame] | 61 | # directory containing the toplevel Makefile.inc |
| 62 | TOPLEVEL := . |
| 63 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 64 | CONFIG_SHELL := sh |
| 65 | KBUILD_DEFCONFIG := configs/defconfig |
| 66 | UNAME_RELEASE := $(shell uname -r) |
Patrick Georgi | 89ec376 | 2010-12-08 19:58:30 +0000 | [diff] [blame] | 67 | DOTCONFIG ?= .config |
| 68 | KCONFIG_CONFIG = $(DOTCONFIG) |
| 69 | export KCONFIG_CONFIG |
| 70 | HAVE_DOTCONFIG := $(wildcard $(DOTCONFIG)) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 71 | MAKEFLAGS += -rR --no-print-directory |
| 72 | |
| 73 | # 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] | 74 | Q:=@ |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 75 | ifneq ($(V),1) |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 76 | ifneq ($(Q),) |
| 77 | .SILENT: |
| 78 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 79 | endif |
| 80 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 81 | HOSTCC = gcc |
| 82 | HOSTCXX = g++ |
Patrick Georgi | b3a18ac | 2012-09-13 22:13:33 +0200 | [diff] [blame] | 83 | HOSTCFLAGS := -g |
| 84 | HOSTCXXFLAGS := -g |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 85 | |
| 86 | DOXYGEN := doxygen |
| 87 | DOXYGEN_OUTPUT_DIR := doxygen |
| 88 | |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 89 | all: real-all |
| 90 | |
Patrick Georgi | e38d0a6 | 2011-03-01 08:09:22 +0000 | [diff] [blame] | 91 | # This include must come _before_ the pattern rules below! |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 92 | # Order _does_ matter for pattern rules. |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 93 | include util/kconfig/Makefile |
| 94 | |
Patrick Georgi | cf036d1 | 2010-04-21 06:36:20 +0000 | [diff] [blame] | 95 | # Three cases where we don't need fully populated $(obj) lists: |
| 96 | # 1. when no .config exists |
| 97 | # 2. when make config (in any flavour) is run |
| 98 | # 3. when make distclean is run |
| 99 | # Don't waste time on reading all Makefile.incs in these cases |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 100 | ifeq ($(strip $(HAVE_DOTCONFIG)),) |
Patrick Georgi | cf036d1 | 2010-04-21 06:36:20 +0000 | [diff] [blame] | 101 | NOCOMPILE:=1 |
| 102 | endif |
| 103 | ifneq ($(MAKECMDGOALS),) |
Patrick Georgi | c38f3ae | 2014-04-26 15:29:10 +0200 | [diff] [blame] | 104 | ifneq ($(filter %config %clean cross%,$(MAKECMDGOALS)),) |
Patrick Georgi | cf036d1 | 2010-04-21 06:36:20 +0000 | [diff] [blame] | 105 | NOCOMPILE:=1 |
| 106 | endif |
Patrick Georgi | 02ae0bf | 2013-02-09 15:45:02 +0100 | [diff] [blame] | 107 | ifeq ($(MAKECMDGOALS), %clean) |
Zheng Bao | 0fd93d6 | 2012-10-22 16:36:03 +0800 | [diff] [blame] | 108 | NOMKDIR:=1 |
| 109 | endif |
Patrick Georgi | cf036d1 | 2010-04-21 06:36:20 +0000 | [diff] [blame] | 110 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 111 | |
Patrick Georgi | cf036d1 | 2010-04-21 06:36:20 +0000 | [diff] [blame] | 112 | ifeq ($(NOCOMPILE),1) |
Patrick Georgi | e38d0a6 | 2011-03-01 08:09:22 +0000 | [diff] [blame] | 113 | include $(TOPLEVEL)/Makefile.inc |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 114 | real-all: config |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 115 | |
| 116 | else |
| 117 | |
Patrick Georgi | 977b985 | 2010-09-24 22:15:54 +0000 | [diff] [blame] | 118 | include $(HAVE_DOTCONFIG) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 119 | |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 120 | include toolchain.inc |
Ronald G. Minnich | e820e5c | 2012-11-26 14:33:09 -0800 | [diff] [blame] | 121 | |
Patrick Georgi | 23d89cc | 2010-03-16 01:17:19 +0000 | [diff] [blame] | 122 | ifneq ($(INNER_SCANBUILD),y) |
| 123 | ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) |
Edward O'Callaghan | 0e6be39 | 2014-05-10 04:42:00 +1000 | [diff] [blame] | 124 | CC:=clang -m32 -mno-mmx -mno-sse -no-integrated-as |
Patrick Georgi | 23d89cc | 2010-03-16 01:17:19 +0000 | [diff] [blame] | 125 | HOSTCC:=clang |
| 126 | endif |
| 127 | endif |
| 128 | |
Patrick Georgi | 516a2a7 | 2010-03-25 21:45:25 +0000 | [diff] [blame] | 129 | ifeq ($(CONFIG_CCACHE),y) |
Patrick Georgi | 96dafaf | 2011-05-20 22:14:07 +0000 | [diff] [blame] | 130 | CCACHE:=$(word 1,$(wildcard $(addsuffix /ccache,$(subst :, ,$(PATH))))) |
Patrick Georgi | 516a2a7 | 2010-03-25 21:45:25 +0000 | [diff] [blame] | 131 | ifeq ($(CCACHE),) |
| 132 | $(error ccache selected, but not found in PATH) |
| 133 | endif |
Patrick Georgi | 977b985 | 2010-09-24 22:15:54 +0000 | [diff] [blame] | 134 | CCACHE:=CCACHE_COMPILERCHECK=content CCACHE_BASEDIR=$(top) $(CCACHE) |
Patrick Georgi | 516a2a7 | 2010-03-25 21:45:25 +0000 | [diff] [blame] | 135 | CC := $(CCACHE) $(CC) |
| 136 | HOSTCC := $(CCACHE) $(HOSTCC) |
| 137 | HOSTCXX := $(CCACHE) $(HOSTCXX) |
| 138 | ROMCC := $(CCACHE) $(ROMCC) |
| 139 | endif |
| 140 | |
Patrick Georgi | a84e98b | 2010-03-16 19:01:32 +0000 | [diff] [blame] | 141 | strip_quotes = $(subst ",,$(subst \",,$(1))) |
| 142 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 143 | # The primary target needs to be here before we include the |
| 144 | # other files |
| 145 | |
Patrick Georgi | 020f51f | 2010-03-14 21:25:03 +0000 | [diff] [blame] | 146 | ifeq ($(INNER_SCANBUILD),y) |
| 147 | CONFIG_SCANBUILD_ENABLE:= |
| 148 | endif |
| 149 | |
| 150 | ifeq ($(CONFIG_SCANBUILD_ENABLE),y) |
| 151 | ifneq ($(CONFIG_SCANBUILD_REPORT_LOCATION),) |
| 152 | CONFIG_SCANBUILD_REPORT_LOCATION:=-o $(CONFIG_SCANBUILD_REPORT_LOCATION) |
| 153 | endif |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 154 | real-all: |
Patrick Georgi | 020f51f | 2010-03-14 21:25:03 +0000 | [diff] [blame] | 155 | echo '#!/bin/sh' > .ccwrap |
| 156 | echo 'CC="$(CC)"' >> .ccwrap |
| 157 | echo 'if [ "$$1" = "--hostcc" ]; then shift; CC="$(HOSTCC)"; fi' >> .ccwrap |
| 158 | echo 'if [ "$$1" = "--hostcxx" ]; then shift; CC="$(HOSTCXX)"; fi' >> .ccwrap |
| 159 | echo 'eval $$CC $$*' >> .ccwrap |
| 160 | chmod +x .ccwrap |
| 161 | scan-build $(CONFIG_SCANBUILD_REPORT_LOCATION) -analyze-headers --use-cc=$(top)/.ccwrap --use-c++=$(top)/.ccwrap $(MAKE) INNER_SCANBUILD=y |
| 162 | else |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 163 | real-all: real-target |
Patrick Georgi | 020f51f | 2010-03-14 21:25:03 +0000 | [diff] [blame] | 164 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 165 | |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 166 | # must come rather early |
| 167 | .SECONDEXPANSION: |
| 168 | |
Stefan Reinauer | 1425add | 2010-03-21 22:35:58 +0000 | [diff] [blame] | 169 | $(obj)/config.h: |
| 170 | $(MAKE) oldconfig |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 171 | |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 172 | # Add a new class of source/object files to the build system |
| 173 | add-class= \ |
| 174 | $(eval $(1)-srcs:=) \ |
| 175 | $(eval $(1)-objs:=) \ |
| 176 | $(eval classes+=$(1)) |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 177 | |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 178 | # Special classes are managed types with special behaviour |
| 179 | # On parse time, for each entry in variable $(1)-y |
| 180 | # a handler $(1)-handler is executed with the arguments: |
| 181 | # * $(1): directory the parser is in |
| 182 | # * $(2): current entry |
| 183 | add-special-class= \ |
| 184 | $(eval $(1):=) \ |
| 185 | $(eval special-classes+=$(1)) |
| 186 | |
Patrick Georgi | 47d68d8 | 2010-03-06 21:18:43 +0000 | [diff] [blame] | 187 | # Clean -y variables, include Makefile.inc |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 188 | # Add paths to files in X-y to X-srcs |
Patrick Georgi | 47d68d8 | 2010-03-06 21:18:43 +0000 | [diff] [blame] | 189 | # Add subdirs-y to subdirs |
| 190 | includemakefiles= \ |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 191 | $(foreach class,classes subdirs $(classes) $(special-classes), $(eval $(class)-y:=)) \ |
Patrick Georgi | 47d68d8 | 2010-03-06 21:18:43 +0000 | [diff] [blame] | 192 | $(eval -include $(1)) \ |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 193 | $(foreach class,$(classes-y), $(call add-class,$(class))) \ |
| 194 | $(foreach class,$(classes), \ |
| 195 | $(eval $(class)-srcs+= \ |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 196 | $$(subst $(top)/,, \ |
Patrick Georgi | 29ddbb8 | 2011-05-20 23:31:41 +0000 | [diff] [blame] | 197 | $$(abspath $$(subst $(dir $(1))/,/,$$(addprefix $(dir $(1)),$$($(class)-y))))))) \ |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 198 | $(foreach special,$(special-classes), \ |
| 199 | $(foreach item,$($(special)-y), $(call $(special)-handler,$(dir $(1)),$(item)))) \ |
Jonathan Kollasch | 7ff5b44 | 2010-09-28 21:11:48 +0000 | [diff] [blame] | 200 | $(eval subdirs+=$$(subst $(CURDIR)/,,$$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y))))) |
Patrick Georgi | 47d68d8 | 2010-03-06 21:18:43 +0000 | [diff] [blame] | 201 | |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 202 | # For each path in $(subdirs) call includemakefiles |
Patrick Georgi | 47d68d8 | 2010-03-06 21:18:43 +0000 | [diff] [blame] | 203 | # Repeat until subdirs is empty |
| 204 | evaluate_subdirs= \ |
| 205 | $(eval cursubdirs:=$(subdirs)) \ |
| 206 | $(eval subdirs:=) \ |
| 207 | $(foreach dir,$(cursubdirs), \ |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 208 | $(eval $(call includemakefiles,$(dir)/Makefile.inc))) \ |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 209 | $(if $(subdirs),$(eval $(call evaluate_subdirs))) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 210 | |
| 211 | # collect all object files eligible for building |
Patrick Georgi | e38d0a6 | 2011-03-01 08:09:22 +0000 | [diff] [blame] | 212 | subdirs:=$(TOPLEVEL) |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 213 | $(eval $(call evaluate_subdirs)) |
Patrick Georgi | 70c85ea | 2013-02-16 01:06:57 +0100 | [diff] [blame] | 214 | ifeq ($(FAILBUILD),1) |
| 215 | $(error cannot continue build) |
| 216 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 217 | |
Patrick Georgi | 94a4586 | 2011-10-25 14:32:21 -0700 | [diff] [blame] | 218 | # Eliminate duplicate mentions of source files in a class |
| 219 | $(foreach class,$(classes),$(eval $(class)-srcs:=$(sort $($(class)-srcs)))) |
| 220 | |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 221 | src-to-obj=$(addsuffix .$(1).o, $(basename $(patsubst src/%, $(obj)/%, $($(1)-srcs)))) |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 222 | $(foreach class,$(classes),$(eval $(class)-objs:=$(call src-to-obj,$(class)))) |
Patrick Georgi | d3428b0 | 2010-02-24 13:18:01 +0000 | [diff] [blame] | 223 | |
Nico Huber | 963bed5 | 2013-05-15 11:47:51 +0200 | [diff] [blame] | 224 | # Save all objs before processing them (for dependency inclusion) |
| 225 | originalobjs:=$(foreach var, $(addsuffix -objs,$(classes)), $($(var))) |
| 226 | |
Patrick Georgi | 79f9010 | 2012-11-25 14:31:08 +0100 | [diff] [blame] | 227 | # Call post-processors if they're defined |
| 228 | $(foreach class,$(classes),\ |
| 229 | $(if $(value $(class)-postprocess),$(eval $(call $(class)-postprocess,$($(class)-objs))))) |
| 230 | |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 231 | allsrcs:=$(foreach var, $(addsuffix -srcs,$(classes)), $($(var))) |
| 232 | allobjs:=$(foreach var, $(addsuffix -objs,$(classes)), $($(var))) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 233 | alldirs:=$(sort $(abspath $(dir $(allobjs)))) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 234 | |
Patrick Georgi patrick.georgi | c5f773d | 2010-03-16 12:01:13 +0000 | [diff] [blame] | 235 | # macro to define template macros that are used by use_template macro |
| 236 | define create_cc_template |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 237 | # $1 obj class |
Patrick Georgi patrick.georgi | c5f773d | 2010-03-16 12:01:13 +0000 | [diff] [blame] | 238 | # $2 source suffix (c, S) |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 239 | # $3 additional compiler flags |
Patrick Georgi | 57205c7 | 2011-03-08 20:49:18 +0000 | [diff] [blame] | 240 | # $4 additional dependencies |
Patrick Georgi | b8cdd9b | 2011-02-17 20:48:45 +0000 | [diff] [blame] | 241 | ifn$(EMPTY)def $(1)-objs_$(2)_template |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 242 | de$(EMPTY)fine $(1)-objs_$(2)_template |
Patrick Georgi | 57205c7 | 2011-03-08 20:49:18 +0000 | [diff] [blame] | 243 | $(obj)/$$(1).$(1).o: src/$$(1).$(2) $(obj)/config.h $(4) |
Patrick Georgi | 1cd76e7 | 2010-04-19 20:39:22 +0000 | [diff] [blame] | 244 | @printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n" |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 245 | $(CC_$(1)) $(3) -MMD $$$$(CFLAGS_$(1)) -c -o $$$$@ $$$$< |
Patrick Georgi patrick.georgi | c5f773d | 2010-03-16 12:01:13 +0000 | [diff] [blame] | 246 | en$(EMPTY)def |
Patrick Georgi | b8cdd9b | 2011-02-17 20:48:45 +0000 | [diff] [blame] | 247 | end$(EMPTY)if |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 248 | endef |
| 249 | |
Patrick Georgi | b8cdd9b | 2011-02-17 20:48:45 +0000 | [diff] [blame] | 250 | filetypes-of-class=$(subst .,,$(sort $(suffix $($(1)-srcs)))) |
| 251 | $(foreach class,$(classes), \ |
| 252 | $(foreach type,$(call filetypes-of-class,$(class)), \ |
Patrick Georgi | 57205c7 | 2011-03-08 20:49:18 +0000 | [diff] [blame] | 253 | $(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] | 254 | |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 255 | foreach-src=$(foreach file,$($(1)-srcs),$(eval $(call $(1)-objs_$(subst .,,$(suffix $(file)))_template,$(subst src/,,$(basename $(file)))))) |
Patrick Georgi | 5826265 | 2011-02-17 20:47:49 +0000 | [diff] [blame] | 256 | $(eval $(foreach class,$(classes),$(call foreach-src,$(class)))) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 257 | |
Nico Huber | 963bed5 | 2013-05-15 11:47:51 +0200 | [diff] [blame] | 258 | DEPENDENCIES = $(originalobjs:.o=.d) |
Stefan Reinauer | 6bee951 | 2010-03-24 15:51:48 +0000 | [diff] [blame] | 259 | -include $(DEPENDENCIES) |
| 260 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 261 | printall: |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 262 | @$(foreach class,$(classes),echo $(class)-objs:=$($(class)-objs); ) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 263 | @echo alldirs:=$(alldirs) |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 264 | @echo allsrcs=$(allsrcs) |
Stefan Reinauer | 6bee951 | 2010-03-24 15:51:48 +0000 | [diff] [blame] | 265 | @echo DEPENDENCIES=$(DEPENDENCIES) |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 266 | @echo LIBGCC_FILE_NAME=$(LIBGCC_FILE_NAME_$(class)) |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 267 | @$(foreach class,$(special-classes),echo $(class):='$($(class))'; ) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 268 | |
| 269 | endif |
| 270 | |
Patrick Georgi | 40ad842 | 2011-05-21 22:18:59 +0000 | [diff] [blame] | 271 | ifndef NOMKDIR |
Patrick Georgi | d520840 | 2014-04-11 20:24:06 +0200 | [diff] [blame] | 272 | $(shell mkdir -p $(KCONFIG_SPLITCONFIG) $(objutil)/kconfig/lxdialog $(additional-dirs) $(alldirs)) |
Patrick Georgi | 40ad842 | 2011-05-21 22:18:59 +0000 | [diff] [blame] | 273 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 274 | |
Warren Turkal | a9fc330 | 2010-09-03 08:57:32 +0000 | [diff] [blame] | 275 | cscope: |
| 276 | cscope -bR |
| 277 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 278 | doxy: doxygen |
| 279 | doxygen: |
Stefan Reinauer | 1bbad5c | 2010-02-10 15:36:53 +0000 | [diff] [blame] | 280 | $(DOXYGEN) documentation/Doxyfile.coreboot |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 281 | |
| 282 | doxyclean: doxygen-clean |
| 283 | doxygen-clean: |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 284 | rm -rf $(DOXYGEN_OUTPUT_DIR) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 285 | |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 286 | clean-for-update: doxygen-clean clean-for-update-target |
Patrick Georgi | 02ae0bf | 2013-02-09 15:45:02 +0100 | [diff] [blame] | 287 | rm -rf $(obj) .xcompile |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 288 | |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 289 | clean: clean-for-update clean-target |
| 290 | rm -f .ccwrap |
Warren Turkal | 0e8f204 | 2010-09-27 21:14:19 +0000 | [diff] [blame] | 291 | |
Warren Turkal | a9fc330 | 2010-09-03 08:57:32 +0000 | [diff] [blame] | 292 | clean-cscope: |
| 293 | rm -f cscope.out |
| 294 | |
Patrick Georgi | 02ae0bf | 2013-02-09 15:45:02 +0100 | [diff] [blame] | 295 | distclean: clean |
Patrick Georgi | cf036d1 | 2010-04-21 06:36:20 +0000 | [diff] [blame] | 296 | rm -f .config .config.old ..config.tmp .kconfig.d .tmpconfig* .ccwrap .xcompile |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 297 | |
Patrick Georgi | 4815913 | 2013-02-11 20:56:46 +0100 | [diff] [blame] | 298 | .PHONY: $(PHONY) clean clean-for-update clean-cscope cscope distclean doxygen doxy .xcompile |