mb/google/eve: Enable wake from MKBP events in S3
[coreboot.git] / Makefile
blobdfc70e06c67b1b986b008790d0c0162483e46b0b
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>
6 ## Copyright (C) 2009-2010 coresystems GmbH
7 ## Copyright (C) 2011 secunet Security Networks AG
8 ##
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.
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.
33 top := $(CURDIR)
34 src := src
35 srck := $(top)/util/kconfig
36 obj ?= build
37 override obj := $(subst $(top)/,,$(abspath $(obj)))
38 objutil ?= $(obj)/util
39 objk := $(objutil)/kconfig
40 absobj := $(abspath $(obj))
42 COREBOOT_EXPORTS := COREBOOT_EXPORTS
43 COREBOOT_EXPORTS += top src srck obj objutil objk
45 DOTCONFIG ?= $(top)/.config
46 KCONFIG_CONFIG = $(DOTCONFIG)
47 KCONFIG_AUTOADS := $(obj)/cb-config.ads
48 KCONFIG_AUTOHEADER := $(obj)/config.h
49 KCONFIG_AUTOCONFIG := $(obj)/auto.conf
50 KCONFIG_DEPENDENCIES := $(obj)/auto.conf.cmd
51 KCONFIG_SPLITCONFIG := $(obj)/config
52 KCONFIG_TRISTATE := $(obj)/tristate.conf
53 KCONFIG_NEGATIVES := 1
54 KCONFIG_STRICT := 1
55 KCONFIG_PACKAGE := CB.Config
57 COREBOOT_EXPORTS += KCONFIG_CONFIG KCONFIG_AUTOHEADER KCONFIG_AUTOCONFIG
58 COREBOOT_EXPORTS += KCONFIG_DEPENDENCIES KCONFIG_SPLITCONFIG KCONFIG_TRISTATE
59 COREBOOT_EXPORTS += KCONFIG_NEGATIVES KCONFIG_STRICT
60 COREBOOT_EXPORTS += KCONFIG_AUTOADS KCONFIG_PACKAGE
62 # directory containing the toplevel Makefile.inc
63 TOPLEVEL := .
65 CONFIG_SHELL := sh
66 KBUILD_DEFCONFIG := configs/defconfig
67 UNAME_RELEASE := $(shell uname -r)
68 HAVE_DOTCONFIG := $(wildcard $(DOTCONFIG))
69 MAKEFLAGS += -rR --no-print-directory
71 # Make is silent per default, but 'make V=1' will show all compiler calls.
72 Q:=@
73 ifneq ($(V),1)
74 ifneq ($(Q),)
75 .SILENT:
76 endif
77 endif
79 # Disable implicit/built-in rules to make Makefile errors fail fast.
80 .SUFFIXES:
82 HOSTCC := $(if $(shell type gcc 2>/dev/null),gcc,cc)
83 HOSTCXX = g++
84 HOSTCFLAGS := -g
85 HOSTCXXFLAGS := -g
87 PREPROCESS_ONLY := -E -P -x assembler-with-cpp -undef -I .
89 DOXYGEN := doxygen
90 DOXYGEN_OUTPUT_DIR := doxygen
92 export $(COREBOOT_EXPORTS)
94 all: real-all
96 help_coreboot help::
97 @echo '*** coreboot platform targets ***'
98 @echo ' Use "make [target] V=1" for extra build debug information'
99 @echo ' all - Build coreboot'
100 @echo ' clean - Remove coreboot build artifacts'
101 @echo ' distclean - Remove build artifacts and config files'
102 @echo ' doxygen - Build doxygen documentation for coreboot'
103 @echo ' doxyplatform - Build doxygen documentation for the current platform'
104 @echo ' filelist - Show files used in current build'
105 @echo ' printall - print makefile info for debugging'
106 @echo ' gitconfig - set up git to submit patches to coreboot'
107 @echo ' ctags / ctags-project - make ctags file for all of coreboot or current board'
108 @echo ' cscope / cscope-project - make cscope.out file for coreboot or current board'
109 @echo
111 # This include must come _before_ the pattern rules below!
112 # Order _does_ matter for pattern rules.
113 include $(srck)/Makefile
115 # Three cases where we don't need fully populated $(obj) lists:
116 # 1. when no .config exists
117 # 2. when make config (in any flavour) is run
118 # 3. when make distclean is run
119 # Don't waste time on reading all Makefile.incs in these cases
120 ifeq ($(strip $(HAVE_DOTCONFIG)),)
121 NOCOMPILE:=1
122 endif
123 ifneq ($(MAKECMDGOALS),)
124 ifneq ($(filter %config %clean cross% clang iasl gnumake lint% help% what-jenkins-does,$(MAKECMDGOALS)),)
125 NOCOMPILE:=1
126 endif
127 ifeq ($(MAKECMDGOALS), %clean)
128 NOMKDIR:=1
129 endif
130 endif
132 -include $(TOPLEVEL)/site-local/Makefile.inc
134 ifeq ($(NOCOMPILE),1)
135 include $(TOPLEVEL)/Makefile.inc
136 include $(TOPLEVEL)/payloads/Makefile.inc
137 include $(TOPLEVEL)/util/testing/Makefile.inc
138 real-all:
139 @echo "Error: Expected config file ($(DOTCONFIG)) not present." >&2
140 @echo "Please specify a config file or run 'make menuconfig' to" >&2
141 @echo "generate a new config file." >&2
142 @exit 1
143 else
145 include $(DOTCONFIG)
147 # in addition to the dependency below, create the file if it doesn't exist
148 # to silence stupid warnings about a file that would be generated anyway.
149 $(if $(wildcard .xcompile)$(NOCOMPILE),,$(eval $(shell util/xcompile/xcompile $(XGCCPATH) > .xcompile || rm -f .xcompile)))
151 .xcompile: util/xcompile/xcompile
152 rm -f $@
153 $< $(XGCCPATH) > $@.tmp
154 \mv -f $@.tmp $@ 2> /dev/null
155 rm -f $@.tmp
157 -include .xcompile
159 ifneq ($(XCOMPILE_COMPLETE),1)
160 $(shell rm -f .xcompile)
161 $(error .xcompile deleted because it's invalid. \
162 Restarting the build should fix that, or explain the problem)
163 endif
165 ifneq ($(CONFIG_MMX),y)
166 CFLAGS_x86_32 += -mno-mmx
167 endif
169 include toolchain.inc
171 strip_quotes = $(strip $(subst ",,$(subst \",,$(1))))
172 # fix makefile syntax highlighting after strip macro \" "))
174 # The primary target needs to be here before we include the
175 # other files
177 real-all: real-target
179 # must come rather early
180 .SECONDEXPANSION:
181 .DELETE_ON_ERROR:
183 $(KCONFIG_AUTOHEADER): $(KCONFIG_CONFIG) $(objutil)/kconfig/conf
184 +$(MAKE) oldconfig
186 $(KCONFIG_AUTOCONFIG): $(KCONFIG_AUTOHEADER)
187 true
189 $(KCONFIG_AUTOADS): $(KCONFIG_AUTOCONFIG) $(objutil)/kconfig/toada
190 $(objutil)/kconfig/toada CB.Config <$< >$@
192 $(obj)/%/$(notdir $(KCONFIG_AUTOADS)): $(KCONFIG_AUTOADS)
193 cp $< $@
195 # Add a new class of source/object files to the build system
196 add-class= \
197 $(eval $(1)-srcs:=) \
198 $(eval $(1)-objs:=) \
199 $(eval classes+=$(1))
201 # Special classes are managed types with special behaviour
202 # On parse time, for each entry in variable $(1)-y
203 # a handler $(1)-handler is executed with the arguments:
204 # * $(1): directory the parser is in
205 # * $(2): current entry
206 add-special-class= \
207 $(eval $(1):=) \
208 $(eval special-classes+=$(1))
210 # Converts one or more source file paths to their corresponding build/ paths.
211 # Only .ads, adb, .c and .S get converted to .o, other files (like .ld) keep
212 # their name.
213 # $1 stage name
214 # $2 file path (list)
215 src-to-obj=\
216 $(patsubst $(obj)/%,$(obj)/$(1)/%,\
217 $(patsubst $(obj)/$(1)/%,$(obj)/%,\
218 $(patsubst 3rdparty/%,$(obj)/%,\
219 $(patsubst src/%,$(obj)/%,\
220 $(patsubst %.ads,%.o,\
221 $(patsubst %.adb,%.o,\
222 $(patsubst %.c,%.o,\
223 $(patsubst %.S,%.o,\
224 $(subst .$(1),,$(2))))))))))
226 # Converts one or more source file paths to the corresponding build/ paths
227 # of their Ada library information (.ali) files.
228 # $1 stage name
229 # $2 file path (list)
230 src-to-ali=\
231 $(patsubst $(obj)/%,$(obj)/$(1)/%,\
232 $(patsubst $(obj)/$(1)/%,$(obj)/%,\
233 $(patsubst 3rdparty/%,$(obj)/%,\
234 $(patsubst src/%,$(obj)/%,\
235 $(patsubst %.ads,%.ali,\
236 $(patsubst %.adb,%.ali,\
237 $(subst .$(1),,\
238 $(filter %.ads %.adb,$(2)))))))))
240 # Clean -y variables, include Makefile.inc
241 # Add paths to files in X-y to X-srcs
242 # Add subdirs-y to subdirs
243 includemakefiles= \
244 $(foreach class,classes subdirs $(classes) $(special-classes), $(eval $(class)-y:=)) \
245 $(eval -include $(1)) \
246 $(foreach class,$(classes-y), $(call add-class,$(class))) \
247 $(foreach class,$(classes), \
248 $(eval $(class)-srcs+= \
249 $$(subst $(absobj)/,$(obj)/, \
250 $$(subst $(top)/,, \
251 $$(abspath $$(subst $(dir $(1))/,/,$$(addprefix $(dir $(1)),$$($(class)-y)))))))) \
252 $(foreach special,$(special-classes), \
253 $(foreach item,$($(special)-y), $(call $(special)-handler,$(dir $(1)),$(item)))) \
254 $(eval subdirs+=$$(subst $(CURDIR)/,,$$(wildcard $$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y))))))
256 # For each path in $(subdirs) call includemakefiles
257 # Repeat until subdirs is empty
258 evaluate_subdirs= \
259 $(eval cursubdirs:=$(subdirs)) \
260 $(eval subdirs:=) \
261 $(foreach dir,$(cursubdirs), \
262 $(eval $(call includemakefiles,$(dir)/Makefile.inc))) \
263 $(if $(subdirs),$(eval $(call evaluate_subdirs)))
265 # collect all object files eligible for building
266 subdirs:=$(TOPLEVEL)
267 postinclude-hooks :=
268 $(eval $(call evaluate_subdirs))
269 ifeq ($(FAILBUILD),1)
270 $(error cannot continue build)
271 endif
273 # Run hooks registered by subdirectories that need to be evaluated after all files have been parsed
274 $(eval $(postinclude-hooks))
276 # Eliminate duplicate mentions of source files in a class
277 $(foreach class,$(classes),$(eval $(class)-srcs:=$(sort $($(class)-srcs))))
279 # Build Kconfig .ads if necessary
280 ifeq ($(CONFIG_RAMSTAGE_ADA),y)
281 ramstage-srcs += $(obj)/ramstage/$(notdir $(KCONFIG_AUTOADS))
282 endif
284 # To track dependencies, we need all Ada specification (.ads) files in
285 # *-srcs. Extract / filter all specification files that have a matching
286 # body (.adb) file here (specifications without a body are valid sources
287 # in Ada).
288 $(foreach class,$(classes),$(eval $(class)-extra-specs := \
289 $(filter \
290 $(addprefix %/,$(patsubst %.adb,%.ads,$(notdir $(filter %.adb,$($(class)-srcs))))), \
291 $(filter %.ads,$($(class)-srcs)))))
292 $(foreach class,$(classes),$(eval $(class)-srcs := \
293 $(filter-out $($(class)-extra-specs),$($(class)-srcs))))
295 $(foreach class,$(classes),$(eval $(class)-objs:=$(call src-to-obj,$(class),$($(class)-srcs))))
296 $(foreach class,$(classes),$(eval $(class)-alis:=$(call src-to-ali,$(class),$($(class)-srcs))))
298 # For Ada includes
299 $(foreach class,$(classes),$(eval $(class)-ada-dirs:=$(sort $(dir $(filter %.ads %.adb,$($(class)-srcs)) $($(class)-extra-specs)))))
301 # Save all objs before processing them (for dependency inclusion)
302 originalobjs:=$(foreach var, $(addsuffix -objs,$(classes)), $($(var)))
304 # Call post-processors if they're defined
305 $(foreach class,$(classes),\
306 $(if $(value $(class)-postprocess),$(eval $(call $(class)-postprocess,$($(class)-objs)))))
308 allsrcs:=$(foreach var, $(addsuffix -srcs,$(classes)), $($(var)))
309 allobjs:=$(foreach var, $(addsuffix -objs,$(classes)), $($(var)))
310 alldirs:=$(sort $(abspath $(dir $(allobjs))))
312 # Reads dependencies from an Ada library information (.ali) file
313 # Only basenames (with suffix) are preserved so we have to look the
314 # paths up in $($(stage)-srcs).
315 # $1 stage name
316 # $2 ali file
317 create_ada_deps=$$(if $(2),\
318 gnat.adc \
319 $$(filter \
320 $$(addprefix %/,$$(shell sed -ne's/^D \([^\t]\+\).*$$$$/\1/p' $(2) 2>/dev/null)), \
321 $$($(1)-srcs) $$($(1)-extra-specs)))
323 # macro to define template macros that are used by use_template macro
324 define create_cc_template
325 # $1 obj class
326 # $2 source suffix (c, S, ld, ...)
327 # $3 additional compiler flags
328 # $4 additional dependencies
329 ifn$(EMPTY)def $(1)-objs_$(2)_template
330 de$(EMPTY)fine $(1)-objs_$(2)_template
331 ifn$(EMPTY)eq ($(filter ads adb,$(2)),)
332 $$(call src-to-obj,$1,$$(1).$2): $$(1).$2 $$(call create_ada_deps,$1,$$(call src-to-ali,$1,$$(1).$2)) $(4)
333 @printf " GCC $$$$(subst $$$$(obj)/,,$$$$(@))\n"
334 $(GCC_$(1)) \
335 $$$$(ADAFLAGS_$(1)) $$$$(addprefix -I,$$$$($(1)-ada-dirs)) \
336 $(3) -c -o $$$$@ $$$$<
337 el$(EMPTY)se
338 $$(call src-to-obj,$1,$$(1).$2): $$(1).$2 $(KCONFIG_AUTOHEADER) $(4)
339 @printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n"
340 $(CC_$(1)) \
341 -MMD $$$$(CPPFLAGS_$(1)) $$$$(CFLAGS_$(1)) -MT $$$$(@) \
342 $(3) -c -o $$$$@ $$$$<
343 end$(EMPTY)if
344 en$(EMPTY)def
345 end$(EMPTY)if
346 endef
348 filetypes-of-class=$(subst .,,$(sort $(suffix $($(1)-srcs))))
349 $(foreach class,$(classes), \
350 $(foreach type,$(call filetypes-of-class,$(class)), \
351 $(eval $(class)-$(type)-ccopts += $(generic-$(type)-ccopts) $($(class)-generic-ccopts)) \
352 $(if $(generic-objs_$(type)_template_gen),$(eval $(call generic-objs_$(type)_template_gen,$(class))),\
353 $(eval $(call create_cc_template,$(class),$(type),$($(class)-$(type)-ccopts),$($(class)-$(type)-deps))))))
355 foreach-src=$(foreach file,$($(1)-srcs),$(eval $(call $(1)-objs_$(subst .,,$(suffix $(file)))_template,$(basename $(file)))))
356 $(eval $(foreach class,$(classes),$(call foreach-src,$(class))))
358 # To supported complex package initializations, we need to call the
359 # emitted code explicitly. gnatbind gathers all the calls for us
360 # and exports them as a procedure $(stage)_adainit(). Every stage that
361 # uses Ada code has to call it!
362 define gnatbind_template
363 # $1 class
364 $$(obj)/$(1)/b__$(1).adb: $$$$(filter-out $$(obj)/$(1)/b__$(1).ali,$$$$($(1)-alis))
365 @printf " BIND $$(subst $$(obj)/,,$$@)\n"
366 # We have to give gnatbind a simple filename (without leading
367 # path components) so just cd there.
368 cd $$(dir $$@) && \
369 $$(GNATBIND_$(1)) -a -n \
370 --RTS=$$(absobj)/libgnat-$$(ARCH-$(1)-y)/ \
371 -L$(1)_ada -o $$(notdir $$@) \
372 $$(subst $$(dir $$@),,$$^)
373 $$(obj)/$(1)/b__$(1).o: $$(obj)/$(1)/b__$(1).adb
374 @printf " GCC $$(subst $$(obj)/,,$$@)\n"
375 $(GCC_$(1)) $$(ADAFLAGS_$(1)) -c -o $$@ $$<
376 $(1)-objs += $$(obj)/$(1)/b__$(1).o
377 $($(1)-alis): %.ali: %.o ;
378 endef
380 $(eval $(foreach class,$(filter-out libgnat-%,$(classes)), \
381 $(if $($(class)-alis),$(call gnatbind_template,$(class)))))
383 DEPENDENCIES += $(addsuffix .d,$(basename $(allobjs)))
384 -include $(DEPENDENCIES)
386 printall:
387 @$(foreach class,$(classes), echo $(class)-objs: $($(class)-objs) | tr ' ' '\n'; echo; )
388 @echo alldirs: $(alldirs) | tr ' ' '\n'; echo
389 @echo allsrcs: $(allsrcs) | tr ' ' '\n'; echo
390 @echo DEPENDENCIES: $(DEPENDENCIES) | tr ' ' '\n'; echo
391 @$(foreach class,$(special-classes),echo $(class):'$($(class))' | tr ' ' '\n'; echo; )
392 endif
394 ifndef NOMKDIR
395 $(shell mkdir -p $(KCONFIG_SPLITCONFIG) $(objk)/lxdialog $(additional-dirs) $(alldirs))
396 endif
398 $(obj)/project_filelist.txt:
399 if [ -z "$(wildcard $(obj)/coreboot.rom)" ]; then \
400 echo "*** Error: Project must be built before generating file list ***"; \
401 exit 1; \
403 find $(obj) -path "$(obj)/util" -prune -o -name "*.d" -exec cat {} \; | \
404 sed "s|$(top)/||" | sed 's/[:\\]/ /g' | sed 's/ /\n/g' | sort | uniq | \
405 grep -v '\.o$$' > $(obj)/project_filelist.txt
407 filelist: $(obj)/project_filelist.txt
408 printf "\nFiles used in build:\n"
409 cat $(obj)/project_filelist.txt
411 #works with either exuberant ctags or ctags.emacs
412 ctags-project: clean-ctags $(obj)/project_filelist.txt
413 cat $(obj)/project_filelist.txt | \
414 xargs ctags -o tags
416 cscope-project: clean-cscope $(obj)/project_filelist.txt
417 cat $(obj)/project_filelist.txt | xargs cscope -b
419 cscope:
420 cscope -bR
422 doxy: doxygen
423 doxygen:
424 $(DOXYGEN) Documentation/Doxyfile.coreboot
426 doxygen_simple:
427 $(DOXYGEN) Documentation/Doxyfile.coreboot_simple
429 doxyplatform doxygen_platform: $(obj)/project_filelist.txt
430 echo
431 echo "Building doxygen documentation for $(CONFIG_MAINBOARD_PART_NUMBER)"
432 export DOXYGEN_OUTPUT_DIR="$(DOXYGEN_OUTPUT_DIR)/$(CONFIG_MAINBOARD_VENDOR)/$(CONFIG_MAINBOARD_PART_NUMBER)"; \
433 mkdir -p "$$DOXYGEN_OUTPUT_DIR"; \
434 export DOXYFILES="$$(cat $(obj)/project_filelist.txt | grep -v '\.ld$$' | sed 's/\.aml/\.dsl/' | tr '\n' ' ')"; \
435 export DOXYGEN_PLATFORM="$(CONFIG_MAINBOARD_DIR) ($(CONFIG_MAINBOARD_PART_NUMBER)) version $(KERNELVERSION)"; \
436 $(DOXYGEN) Documentation/doxygen/Doxyfile.coreboot_platform
438 doxyclean: doxygen-clean
439 doxygen-clean:
440 rm -rf $(DOXYGEN_OUTPUT_DIR)
442 clean-for-update: doxygen-clean clean-for-update-target
443 rm -rf $(obj) .xcompile
445 clean: clean-for-update clean-target clean-utils
446 rm -f .ccwrap
448 clean-cscope:
449 rm -f cscope.out
451 clean-ctags:
452 rm -f tags
454 clean-utils:
455 $(foreach tool, $(TOOLLIST), \
456 $(MAKE) -C util/$(tool) clean MFLAGS= MAKEFLAGS= ;)
458 distclean-utils:
459 $(foreach tool, $(TOOLLIST), \
460 $(MAKE) -C util/$(tool) distclean MFLAGS= MAKEFLAGS= ; \
461 rm -f /util/$(tool)/junit.xml;)
463 distclean: clean clean-ctags clean-cscope distclean-payloads distclean-utils
464 rm -f .config .config.old ..config.tmp* .kconfig.d .tmpconfig* .ccwrap .xcompile
465 rm -rf coreboot-builds coreboot-builds-chromeos
466 rm -f abuild*.xml junit.xml* util/lint/junit.xml
468 .PHONY: $(PHONY) clean clean-for-update clean-cscope cscope distclean doxygen doxy doxygen_simple
469 .PHONY: ctags-project cscope-project clean-ctags