blob: 4a05890dfe2735ded2db42cca32dee3a62ab0a07 [file] [log] [blame]
Patrick Georgi0588d192009-08-12 15:00:51 +00001##
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 Reinauer8ed1b6d2010-01-19 21:13:44 +00006## Copyright (C) 2009-2010 coresystems GmbH
Patrick Georgi71b84802011-02-22 14:35:05 +00007## Copyright (C) 2011 secunet Security Networks AG
Patrick Georgi0588d192009-08-12 15:00:51 +00008##
Patrick Georgi3bda0442011-06-30 15:48:57 +02009## 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 Georgi0588d192009-08-12 15:00:51 +000019##
Patrick Georgi3bda0442011-06-30 15:48:57 +020020## 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 Georgi0588d192009-08-12 15:00:51 +000031##
32
Jonathan Kollasch7ff5b442010-09-28 21:11:48 +000033export top := $(CURDIR)
Patrick Georgi51e142f2010-03-27 17:18:39 +000034export src := src
Patrick Georgi0588d192009-08-12 15:00:51 +000035export srck := $(top)/util/kconfig
Vadim Bendebury5f7e4f02015-05-06 21:00:10 -070036obj ?= build
37override obj := $(subst $(top)/,,$(abspath $(obj)))
38export obj
Patrick Georgia2acbc72010-04-16 22:48:57 +000039export objutil ?= $(obj)/util
40export objk := $(objutil)/kconfig
Vadim Bendebury5f7e4f02015-05-06 21:00:10 -070041absobj := $(abspath $(obj))
Patrick Georgi0588d192009-08-12 15:00:51 +000042
43
Patrick Georgi0588d192009-08-12 15:00:51 +000044export KCONFIG_AUTOHEADER := $(obj)/config.h
45export KCONFIG_AUTOCONFIG := $(obj)/auto.conf
Patrick Georgid5208402014-04-11 20:24:06 +020046export KCONFIG_DEPENDENCIES := $(obj)/auto.conf.cmd
47export KCONFIG_SPLITCONFIG := $(obj)/config
48export KCONFIG_TRISTATE := $(obj)/tristate.conf
49export KCONFIG_NEGATIVES := 1
Stefan Reinauerd373a002015-07-17 17:29:19 -070050export KCONFIG_STRICT := 1
Patrick Georgi0588d192009-08-12 15:00:51 +000051
Patrick Georgie38d0a62011-03-01 08:09:22 +000052# directory containing the toplevel Makefile.inc
53TOPLEVEL := .
54
Patrick Georgi0588d192009-08-12 15:00:51 +000055CONFIG_SHELL := sh
56KBUILD_DEFCONFIG := configs/defconfig
57UNAME_RELEASE := $(shell uname -r)
Paul Kocialkowskifde32752016-07-24 12:25:07 +020058DOTCONFIG ?= $(top)/.config
Patrick Georgi89ec3762010-12-08 19:58:30 +000059KCONFIG_CONFIG = $(DOTCONFIG)
60export KCONFIG_CONFIG
61HAVE_DOTCONFIG := $(wildcard $(DOTCONFIG))
Patrick Georgi0588d192009-08-12 15:00:51 +000062MAKEFLAGS += -rR --no-print-directory
63
64# Make is silent per default, but 'make V=1' will show all compiler calls.
Patrick Georgi2b7418e2009-08-25 19:38:46 +000065Q:=@
Patrick Georgi0588d192009-08-12 15:00:51 +000066ifneq ($(V),1)
Patrick Georgi2b7418e2009-08-25 19:38:46 +000067ifneq ($(Q),)
68.SILENT:
69endif
Patrick Georgi0588d192009-08-12 15:00:51 +000070endif
71
Julius Werner808a4292015-03-13 11:05:07 -070072# Disable implicit/built-in rules to make Makefile errors fail fast.
73.SUFFIXES:
74
Patrick Georgif92068d2016-02-01 12:02:29 +010075HOSTCC := $(if $(shell type gcc 2>/dev/null),gcc,cc)
Patrick Georgi0588d192009-08-12 15:00:51 +000076HOSTCXX = g++
Patrick Georgib3a18ac2012-09-13 22:13:33 +020077HOSTCFLAGS := -g
78HOSTCXXFLAGS := -g
Patrick Georgi0588d192009-08-12 15:00:51 +000079
Patrick Georgi828e0e82015-04-04 15:50:20 +020080PREPROCESS_ONLY := -E -P -x assembler-with-cpp -undef -I .
81
Patrick Georgi0588d192009-08-12 15:00:51 +000082DOXYGEN := doxygen
83DOXYGEN_OUTPUT_DIR := doxygen
84
Patrick Georgi71b84802011-02-22 14:35:05 +000085all: real-all
86
Martin Roth4eea1742015-11-25 11:50:04 -070087help_coreboot help::
88 @echo '*** coreboot platform targets ***'
Martin Roth76f14b22015-11-18 13:09:23 -070089 @echo ' Use "make [target] V=1" for extra build debug information'
90 @echo ' all - Build coreboot'
91 @echo ' clean - Remove coreboot build artifacts'
92 @echo ' distclean - Remove build artifacts and config files'
93 @echo ' doxygen - Build doxygen documentation for coreboot'
94 @echo ' what-jenkins-does - Run platform build tests (Use CPUS=# for more cores)'
95 @echo ' printall - print makefile info for debugging'
96 @echo ' lint / lint-stable - run coreboot lint tools (all / minimal)'
Werner Zeh2de64102016-01-12 12:45:49 +010097 @echo ' gitconfig - set up git to submit patches to coreboot'
Martin Roth76f14b22015-11-18 13:09:23 -070098 @echo ' ctags / ctags-project - make ctags file for all of coreboot or current board'
99 @echo ' cscope / cscope-project - make cscope.out file for coreboot or current board'
100 @echo
101
Patrick Georgie38d0a62011-03-01 08:09:22 +0000102# This include must come _before_ the pattern rules below!
Patrick Georgi71b84802011-02-22 14:35:05 +0000103# Order _does_ matter for pattern rules.
Stefan Reinauerde60c882015-06-29 14:44:37 -0700104include $(srck)/Makefile
Patrick Georgi71b84802011-02-22 14:35:05 +0000105
Patrick Georgicf036d12010-04-21 06:36:20 +0000106# Three cases where we don't need fully populated $(obj) lists:
107# 1. when no .config exists
108# 2. when make config (in any flavour) is run
109# 3. when make distclean is run
110# Don't waste time on reading all Makefile.incs in these cases
Patrick Georgi0588d192009-08-12 15:00:51 +0000111ifeq ($(strip $(HAVE_DOTCONFIG)),)
Patrick Georgicf036d12010-04-21 06:36:20 +0000112NOCOMPILE:=1
113endif
114ifneq ($(MAKECMDGOALS),)
Martin Roth109a7db2016-08-11 18:16:59 -0600115ifneq ($(filter %config %clean cross% clang iasl gnumake lint% help% what-jenkins-does,$(MAKECMDGOALS)),)
Patrick Georgicf036d12010-04-21 06:36:20 +0000116NOCOMPILE:=1
117endif
Patrick Georgi02ae0bf2013-02-09 15:45:02 +0100118ifeq ($(MAKECMDGOALS), %clean)
Zheng Bao0fd93d62012-10-22 16:36:03 +0800119NOMKDIR:=1
120endif
Patrick Georgicf036d12010-04-21 06:36:20 +0000121endif
Patrick Georgi0588d192009-08-12 15:00:51 +0000122
Patrick Georgicf036d12010-04-21 06:36:20 +0000123ifeq ($(NOCOMPILE),1)
Patrick Georgie38d0a62011-03-01 08:09:22 +0000124include $(TOPLEVEL)/Makefile.inc
Martin Roth67975572016-03-07 16:38:52 -0700125include $(TOPLEVEL)/payloads/Makefile.inc
Martin Roth20aa0432017-01-26 10:51:43 -0700126real-all:
127 @echo "Error: Expected config file ($(DOTCONFIG)) not present." >&2
128 @echo "Please specify a config file or run 'make menuconfig' to" >&2
129 @echo "generate a new config file." >&2
130 @exit 1
Patrick Georgi0588d192009-08-12 15:00:51 +0000131else
132
Paul Kocialkowski585c7812016-07-13 11:00:41 +0200133include $(DOTCONFIG)
Patrick Georgi0588d192009-08-12 15:00:51 +0000134
Patrick Georgi0ffef882017-01-19 23:20:14 +0100135# in addition to the dependency below, create the file if it doesn't exist
136# to silence stupid warnings about a file that would be generated anyway.
137$(if $(wildcard .xcompile)$(NOCOMPILE),,$(eval $(shell util/xcompile/xcompile $(XGCCPATH) > .xcompile || rm -f .xcompile)))
138
139.xcompile: util/xcompile/xcompile
140 rm -f $@
141 $< $(XGCCPATH) > $@.tmp
142 \mv -f $@.tmp $@ 2> /dev/null
143 rm -f $@.tmp
144
Patrick Georgi6dda31d2015-11-19 15:15:33 +0100145-include .xcompile
146
147ifneq ($(XCOMPILE_COMPLETE),1)
148$(shell rm -f .xcompile)
149$(error .xcompile deleted because it's invalid. \
150 Restarting the build should fix that, or explain the problem)
151endif
Patrick Georgi7b9762f2015-06-04 13:18:11 +0200152
Patrick Georgicc84a002014-05-14 21:05:35 +0200153ifneq ($(CONFIG_MMX),y)
154CFLAGS_x86_32 += -mno-mmx
155endif
156
Patrick Georgicc84a002014-05-14 21:05:35 +0200157include toolchain.inc
158
Zheng Bao07648922015-11-13 10:42:27 +0800159strip_quotes = $(strip $(subst ",,$(subst \",,$(1))))
Martin Rothbbf13992016-01-25 15:59:24 -0700160# fix makefile syntax highlighting after strip macro \" "))
Patrick Georgia84e98b2010-03-16 19:01:32 +0000161
Patrick Georgi0588d192009-08-12 15:00:51 +0000162# The primary target needs to be here before we include the
163# other files
164
Patrick Georgi71b84802011-02-22 14:35:05 +0000165real-all: real-target
Patrick Georgi0588d192009-08-12 15:00:51 +0000166
Patrick Georgi51e142f2010-03-27 17:18:39 +0000167# must come rather early
168.SECONDEXPANSION:
169
Stefan Reinauer0d869ed2015-07-17 13:31:16 -0700170$(KCONFIG_AUTOHEADER): $(KCONFIG_CONFIG)
Patrick Georgi78a5f222017-01-30 15:29:34 +0100171 +$(MAKE) oldconfig
Patrick Georgi0588d192009-08-12 15:00:51 +0000172
Patrick Georgi58262652011-02-17 20:47:49 +0000173# Add a new class of source/object files to the build system
174add-class= \
175 $(eval $(1)-srcs:=) \
176 $(eval $(1)-objs:=) \
177 $(eval classes+=$(1))
Patrick Georgi8463dd92010-09-30 16:55:02 +0000178
Patrick Georgi58262652011-02-17 20:47:49 +0000179# Special classes are managed types with special behaviour
180# On parse time, for each entry in variable $(1)-y
181# a handler $(1)-handler is executed with the arguments:
182# * $(1): directory the parser is in
183# * $(2): current entry
184add-special-class= \
185 $(eval $(1):=) \
186 $(eval special-classes+=$(1))
187
Nico Huber81b09f42016-01-23 00:50:00 +0100188# Converts one or more source file paths to their corresponding build/ paths.
Nico Huber2e09d2b2016-01-14 01:13:33 +0100189# Only .ads, adb, .c and .S get converted to .o, other files (like .ld) keep
190# their name.
Nico Huber81b09f42016-01-23 00:50:00 +0100191# $1 stage name
192# $2 file path (list)
Nico Huber98fc4262016-01-23 01:24:33 +0100193src-to-obj=\
194 $(patsubst $(obj)/%,$(obj)/$(1)/%,\
195 $(patsubst $(obj)/$(1)/%,$(obj)/%,\
Nico Huberd011b6b2016-10-05 17:41:31 +0200196 $(patsubst 3rdparty/%,$(obj)/%,\
Nico Huber98fc4262016-01-23 01:24:33 +0100197 $(patsubst src/%,$(obj)/%,\
Nico Huber2e09d2b2016-01-14 01:13:33 +0100198 $(patsubst %.ads,%.o,\
199 $(patsubst %.adb,%.o,\
Nico Huber98fc4262016-01-23 01:24:33 +0100200 $(patsubst %.c,%.o,\
201 $(patsubst %.S,%.o,\
Nico Huberd011b6b2016-10-05 17:41:31 +0200202 $(subst .$(1),,$(2))))))))))
Nico Huber2e09d2b2016-01-14 01:13:33 +0100203
204# Converts one or more source file paths to the corresponding build/ paths
205# of their Ada library information (.ali) files.
206# $1 stage name
207# $2 file path (list)
208src-to-ali=\
209 $(patsubst $(obj)/%,$(obj)/$(1)/%,\
210 $(patsubst $(obj)/$(1)/%,$(obj)/%,\
Nico Huberd011b6b2016-10-05 17:41:31 +0200211 $(patsubst 3rdparty/%,$(obj)/%,\
Nico Huber2e09d2b2016-01-14 01:13:33 +0100212 $(patsubst src/%,$(obj)/%,\
213 $(patsubst %.ads,%.ali,\
214 $(patsubst %.adb,%.ali,\
215 $(subst .$(1),,\
Nico Huberd011b6b2016-10-05 17:41:31 +0200216 $(filter %.ads %.adb,$(2)))))))))
Nico Huber81b09f42016-01-23 00:50:00 +0100217
Patrick Georgi47d68d82010-03-06 21:18:43 +0000218# Clean -y variables, include Makefile.inc
Patrick Georgi8463dd92010-09-30 16:55:02 +0000219# Add paths to files in X-y to X-srcs
Patrick Georgi47d68d82010-03-06 21:18:43 +0000220# Add subdirs-y to subdirs
221includemakefiles= \
Patrick Georgi58262652011-02-17 20:47:49 +0000222 $(foreach class,classes subdirs $(classes) $(special-classes), $(eval $(class)-y:=)) \
Patrick Georgi47d68d82010-03-06 21:18:43 +0000223 $(eval -include $(1)) \
Patrick Georgi58262652011-02-17 20:47:49 +0000224 $(foreach class,$(classes-y), $(call add-class,$(class))) \
225 $(foreach class,$(classes), \
226 $(eval $(class)-srcs+= \
Vadim Bendebury5f7e4f02015-05-06 21:00:10 -0700227 $$(subst $(absobj)/,$(obj)/, \
Patrick Georgi51e142f2010-03-27 17:18:39 +0000228 $$(subst $(top)/,, \
Vadim Bendebury5f7e4f02015-05-06 21:00:10 -0700229 $$(abspath $$(subst $(dir $(1))/,/,$$(addprefix $(dir $(1)),$$($(class)-y)))))))) \
Patrick Georgi58262652011-02-17 20:47:49 +0000230 $(foreach special,$(special-classes), \
231 $(foreach item,$($(special)-y), $(call $(special)-handler,$(dir $(1)),$(item)))) \
Jonathan Kollasch7ff5b442010-09-28 21:11:48 +0000232 $(eval subdirs+=$$(subst $(CURDIR)/,,$$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y)))))
Patrick Georgi47d68d82010-03-06 21:18:43 +0000233
Patrick Georgi8463dd92010-09-30 16:55:02 +0000234# For each path in $(subdirs) call includemakefiles
Patrick Georgi47d68d82010-03-06 21:18:43 +0000235# Repeat until subdirs is empty
236evaluate_subdirs= \
237 $(eval cursubdirs:=$(subdirs)) \
238 $(eval subdirs:=) \
239 $(foreach dir,$(cursubdirs), \
Patrick Georgi58262652011-02-17 20:47:49 +0000240 $(eval $(call includemakefiles,$(dir)/Makefile.inc))) \
Patrick Georgi51e142f2010-03-27 17:18:39 +0000241 $(if $(subdirs),$(eval $(call evaluate_subdirs)))
Patrick Georgi0588d192009-08-12 15:00:51 +0000242
243# collect all object files eligible for building
Patrick Georgie38d0a62011-03-01 08:09:22 +0000244subdirs:=$(TOPLEVEL)
Patrick Georgi51e142f2010-03-27 17:18:39 +0000245$(eval $(call evaluate_subdirs))
Patrick Georgi70c85ea2013-02-16 01:06:57 +0100246ifeq ($(FAILBUILD),1)
247$(error cannot continue build)
248endif
Patrick Georgi0588d192009-08-12 15:00:51 +0000249
Patrick Georgi94a45862011-10-25 14:32:21 -0700250# Eliminate duplicate mentions of source files in a class
251$(foreach class,$(classes),$(eval $(class)-srcs:=$(sort $($(class)-srcs))))
252
Nico Huber2e09d2b2016-01-14 01:13:33 +0100253# To track dependencies, we need all Ada specification (.ads) files in
254# *-srcs. Extract / filter all specification files that have a matching
255# body (.adb) file here (specifications without a body are valid sources
256# in Ada).
257$(foreach class,$(classes),$(eval $(class)-extra-specs := \
258 $(filter \
259 $(addprefix %/,$(patsubst %.adb,%.ads,$(notdir $(filter %.adb,$($(class)-srcs))))), \
260 $(filter %.ads,$($(class)-srcs)))))
261$(foreach class,$(classes),$(eval $(class)-srcs := \
262 $(filter-out $($(class)-extra-specs),$($(class)-srcs))))
263
Patrick Georgi10f86b02015-03-27 16:56:23 +0100264$(foreach class,$(classes),$(eval $(class)-objs:=$(call src-to-obj,$(class),$($(class)-srcs))))
Nico Huber2e09d2b2016-01-14 01:13:33 +0100265$(foreach class,$(classes),$(eval $(class)-alis:=$(call src-to-ali,$(class),$($(class)-srcs))))
266
267# For Ada includes
268$(foreach class,$(classes),$(eval $(class)-ada-dirs:=$(sort $(dir $(filter %.ads %.adb,$($(class)-srcs)) $($(class)-extra-specs)))))
Patrick Georgid3428b02010-02-24 13:18:01 +0000269
Nico Huber963bed52013-05-15 11:47:51 +0200270# Save all objs before processing them (for dependency inclusion)
271originalobjs:=$(foreach var, $(addsuffix -objs,$(classes)), $($(var)))
272
Patrick Georgi79f90102012-11-25 14:31:08 +0100273# Call post-processors if they're defined
274$(foreach class,$(classes),\
275 $(if $(value $(class)-postprocess),$(eval $(call $(class)-postprocess,$($(class)-objs)))))
276
Patrick Georgi58262652011-02-17 20:47:49 +0000277allsrcs:=$(foreach var, $(addsuffix -srcs,$(classes)), $($(var)))
278allobjs:=$(foreach var, $(addsuffix -objs,$(classes)), $($(var)))
Patrick Georgi0588d192009-08-12 15:00:51 +0000279alldirs:=$(sort $(abspath $(dir $(allobjs))))
Patrick Georgi0588d192009-08-12 15:00:51 +0000280
Nico Huber2e09d2b2016-01-14 01:13:33 +0100281# Reads dependencies from an Ada library information (.ali) file
282# Only basenames (with suffix) are preserved so we have to look the
283# paths up in $($(stage)-srcs).
284# $1 stage name
285# $2 ali file
286create_ada_deps=$$(if $(2),\
287 gnat.adc \
288 $$(filter \
289 $$(addprefix %/,$$(shell sed -ne's/^D \([^\t]\+\).*$$$$/\1/p' $(2) 2>/dev/null)), \
290 $$($(1)-srcs) $$($(1)-extra-specs)))
291
Patrick Georgi patrick.georgic5f773d2010-03-16 12:01:13 +0000292# macro to define template macros that are used by use_template macro
293define create_cc_template
Patrick Georgi71b84802011-02-22 14:35:05 +0000294# $1 obj class
Patrick Georgi990e7c92015-04-03 10:47:15 +0200295# $2 source suffix (c, S, ld, ...)
Marc Jonesa38ccfd2014-11-06 15:50:22 -0700296# $3 additional compiler flags
297# $4 additional dependencies
Patrick Georgib8cdd9b2011-02-17 20:48:45 +0000298ifn$(EMPTY)def $(1)-objs_$(2)_template
Patrick Georgi8463dd92010-09-30 16:55:02 +0000299de$(EMPTY)fine $(1)-objs_$(2)_template
Nico Huber2e09d2b2016-01-14 01:13:33 +0100300$$(call src-to-obj,$1,$$(1).$2): $$(1).$2 $$(call create_ada_deps,$1,$$(call src-to-ali,$1,$$(1).$2)) $(KCONFIG_AUTOHEADER) $(4)
Patrick Georgi1cd76e72010-04-19 20:39:22 +0000301 @printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n"
Nico Huber2e09d2b2016-01-14 01:13:33 +0100302 $(CC_$(1)) \
303 $$(if $$(filter-out ads adb,$(2)), \
304 -MMD $$$$(CPPFLAGS_$(1)) $$$$(CFLAGS_$(1)) -MT $$$$(@), \
305 $$$$(ADAFLAGS_$(1)) $$$$(addprefix -I,$$$$($(1)-ada-dirs))) \
306 $(3) -c -o $$$$@ $$$$<
Patrick Georgi patrick.georgic5f773d2010-03-16 12:01:13 +0000307en$(EMPTY)def
Patrick Georgib8cdd9b2011-02-17 20:48:45 +0000308end$(EMPTY)if
Patrick Georgi0588d192009-08-12 15:00:51 +0000309endef
310
Patrick Georgib8cdd9b2011-02-17 20:48:45 +0000311filetypes-of-class=$(subst .,,$(sort $(suffix $($(1)-srcs))))
312$(foreach class,$(classes), \
313 $(foreach type,$(call filetypes-of-class,$(class)), \
Patrick Georgi2459aee2015-03-27 15:27:21 +0100314 $(eval $(class)-$(type)-ccopts += $(generic-$(type)-ccopts) $($(class)-generic-ccopts)) \
Patrick Georgi416ab382015-04-03 10:19:38 +0200315 $(if $(generic-objs_$(type)_template_gen),$(eval $(call generic-objs_$(type)_template_gen,$(class))),\
316 $(eval $(call create_cc_template,$(class),$(type),$($(class)-$(type)-ccopts),$($(class)-$(type)-deps))))))
Patrick Georgi0588d192009-08-12 15:00:51 +0000317
Patrick Georgid69839b2015-04-03 10:32:17 +0200318foreach-src=$(foreach file,$($(1)-srcs),$(eval $(call $(1)-objs_$(subst .,,$(suffix $(file)))_template,$(basename $(file)))))
Patrick Georgi58262652011-02-17 20:47:49 +0000319$(eval $(foreach class,$(classes),$(call foreach-src,$(class))))
Patrick Georgi0588d192009-08-12 15:00:51 +0000320
Nico Huber2e09d2b2016-01-14 01:13:33 +0100321# To supported complex package initializations, we need to call the
322# emitted code explicitly. gnatbind gathers all the calls for us
323# and exports them as a procedure $(stage)_adainit(). Every stage that
324# uses Ada code has to call it!
325define gnatbind_template
326# $1 class
327$$(obj)/$(1)/b__$(1).adb: $$$$(filter-out $$(obj)/$(1)/b__$(1).ali,$$$$($(1)-alis))
328 @printf " BIND $$(subst $$(obj)/,,$$@)\n"
329 # We have to give gnatbind a simple filename (without leading
330 # path components) so just cd there.
331 cd $$(dir $$@) && \
332 $$(GNATBIND_$(1)) -a -n \
Nico Huberbe5492a2015-09-29 16:41:19 +0200333 --RTS=$$(absobj)/libgnat-$$(ARCH-$(1)-y)/ \
Nico Huber2e09d2b2016-01-14 01:13:33 +0100334 -L$(1)_ada -o $$(notdir $$@) \
335 $$(subst $$(dir $$@),,$$^)
336$$(obj)/$(1)/b__$(1).o: $$(obj)/$(1)/b__$(1).adb
337 @printf " CC $$(subst $$(obj)/,,$$@)\n"
338 $(CC_$(1)) $$(ADAFLAGS_$(1)) -c -o $$@ $$<
339$(1)-objs += $$(obj)/$(1)/b__$(1).o
Nico Huberddb24652016-09-19 11:50:04 +0200340$($(1)-alis): %.ali: %.o ;
Nico Huber2e09d2b2016-01-14 01:13:33 +0100341endef
342
Nico Huberbe5492a2015-09-29 16:41:19 +0200343$(eval $(foreach class,$(filter-out libgnat-%,$(classes)), \
Nico Huber2e09d2b2016-01-14 01:13:33 +0100344 $(if $($(class)-alis),$(call gnatbind_template,$(class)))))
345
Julius Wernerf97b88b2014-12-05 12:32:09 -0800346DEPENDENCIES += $(addsuffix .d,$(basename $(allobjs)))
Stefan Reinauer6bee9512010-03-24 15:51:48 +0000347-include $(DEPENDENCIES)
348
Patrick Georgi0588d192009-08-12 15:00:51 +0000349printall:
Martin Roth09b64442016-06-05 10:52:43 -0600350 @$(foreach class,$(classes), echo $(class)-objs: $($(class)-objs) | tr ' ' '\n'; echo; )
351 @echo alldirs: $(alldirs) | tr ' ' '\n'; echo
352 @echo allsrcs: $(allsrcs) | tr ' ' '\n'; echo
353 @echo DEPENDENCIES: $(DEPENDENCIES) | tr ' ' '\n'; echo
354 @$(foreach class,$(special-classes),echo $(class):'$($(class))' | tr ' ' '\n'; echo; )
Patrick Georgi0588d192009-08-12 15:00:51 +0000355endif
356
Patrick Georgi40ad8422011-05-21 22:18:59 +0000357ifndef NOMKDIR
Stefan Reinauerde60c882015-06-29 14:44:37 -0700358$(shell mkdir -p $(KCONFIG_SPLITCONFIG) $(objk)/lxdialog $(additional-dirs) $(alldirs))
Patrick Georgi40ad8422011-05-21 22:18:59 +0000359endif
Patrick Georgi0588d192009-08-12 15:00:51 +0000360
Martin Roth9c1b33e2015-07-29 14:55:18 -0700361$(obj)/project_filelist.txt: all
362 find $(obj) -name "*.d" -exec cat {} \; | \
363 sed 's/[:\\]/ /g' | sed 's/ /\n/g' | sort | uniq | \
364 grep -v '\.o$$' > $(obj)/project_filelist.txt
365
366#works with either exuberant ctags or ctags.emacs
367ctags-project: clean-ctags $(obj)/project_filelist.txt
368 cat $(obj)/project_filelist.txt | \
369 xargs ctags -o tags
370
371cscope-project: clean-cscope $(obj)/project_filelist.txt
372 cat $(obj)/project_filelist.txt | xargs cscope -b
373
Warren Turkala9fc3302010-09-03 08:57:32 +0000374cscope:
375 cscope -bR
376
Patrick Georgi0588d192009-08-12 15:00:51 +0000377doxy: doxygen
378doxygen:
Nicky Sielickie08a2a52015-06-06 08:55:16 -0500379 $(DOXYGEN) Documentation/Doxyfile.coreboot
Patrick Georgi0588d192009-08-12 15:00:51 +0000380
Martin Rothd7689e42014-12-29 14:56:19 -0700381doxygen_simple:
Nicky Sielickie08a2a52015-06-06 08:55:16 -0500382 $(DOXYGEN) Documentation/Doxyfile.coreboot_simple
Martin Rothd7689e42014-12-29 14:56:19 -0700383
Patrick Georgi0588d192009-08-12 15:00:51 +0000384doxyclean: doxygen-clean
385doxygen-clean:
Patrick Georgi2b7418e2009-08-25 19:38:46 +0000386 rm -rf $(DOXYGEN_OUTPUT_DIR)
Patrick Georgi0588d192009-08-12 15:00:51 +0000387
Patrick Georgi71b84802011-02-22 14:35:05 +0000388clean-for-update: doxygen-clean clean-for-update-target
Patrick Georgi02ae0bf2013-02-09 15:45:02 +0100389 rm -rf $(obj) .xcompile
Patrick Georgi0588d192009-08-12 15:00:51 +0000390
Patrick Georgi71b84802011-02-22 14:35:05 +0000391clean: clean-for-update clean-target
392 rm -f .ccwrap
Warren Turkal0e8f2042010-09-27 21:14:19 +0000393
Warren Turkala9fc3302010-09-03 08:57:32 +0000394clean-cscope:
395 rm -f cscope.out
396
Martin Roth9c1b33e2015-07-29 14:55:18 -0700397clean-ctags:
398 rm -f tags
399
Martin Roth67975572016-03-07 16:38:52 -0700400distclean: clean clean-ctags clean-cscope distclean-payloads
Patrick Georgicf036d12010-04-21 06:36:20 +0000401 rm -f .config .config.old ..config.tmp .kconfig.d .tmpconfig* .ccwrap .xcompile
Patrick Georgi0588d192009-08-12 15:00:51 +0000402
Martin Rothd7689e42014-12-29 14:56:19 -0700403.PHONY: $(PHONY) clean clean-for-update clean-cscope cscope distclean doxygen doxy doxygen_simple
Martin Roth9c1b33e2015-07-29 14:55:18 -0700404.PHONY: ctags-project cscope-project clean-ctags