mainboard/google/soraka: Add stop gpio control to touchscreen device
[coreboot.git] / Makefile
blob343ec650f31eea3630e1f253b396d03859490eb5
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 export top := $(CURDIR)
34 export src := src
35 export srck := $(top)/util/kconfig
36 obj ?= build
37 override obj := $(subst $(top)/,,$(abspath $(obj)))
38 export obj
39 export objutil ?= $(obj)/util
40 export objk := $(objutil)/kconfig
41 absobj := $(abspath $(obj))
44 export KCONFIG_AUTOHEADER := $(obj)/config.h
45 export KCONFIG_AUTOCONFIG := $(obj)/auto.conf
46 export KCONFIG_DEPENDENCIES := $(obj)/auto.conf.cmd
47 export KCONFIG_SPLITCONFIG := $(obj)/config
48 export KCONFIG_TRISTATE := $(obj)/tristate.conf
49 export KCONFIG_NEGATIVES := 1
50 export KCONFIG_STRICT := 1
52 # directory containing the toplevel Makefile.inc
53 TOPLEVEL := .
55 CONFIG_SHELL := sh
56 KBUILD_DEFCONFIG := configs/defconfig
57 UNAME_RELEASE := $(shell uname -r)
58 DOTCONFIG ?= $(top)/.config
59 KCONFIG_CONFIG = $(DOTCONFIG)
60 export KCONFIG_CONFIG
61 HAVE_DOTCONFIG := $(wildcard $(DOTCONFIG))
62 MAKEFLAGS += -rR --no-print-directory
64 # Make is silent per default, but 'make V=1' will show all compiler calls.
65 Q:=@
66 ifneq ($(V),1)
67 ifneq ($(Q),)
68 .SILENT:
69 endif
70 endif
72 # Disable implicit/built-in rules to make Makefile errors fail fast.
73 .SUFFIXES:
75 HOSTCC := $(if $(shell type gcc 2>/dev/null),gcc,cc)
76 HOSTCXX = g++
77 HOSTCFLAGS := -g
78 HOSTCXXFLAGS := -g
80 PREPROCESS_ONLY := -E -P -x assembler-with-cpp -undef -I .
82 DOXYGEN := doxygen
83 DOXYGEN_OUTPUT_DIR := doxygen
85 all: real-all
87 help_coreboot help::
88 @echo '*** coreboot platform targets ***'
89 @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 ' doxyplatform - Build doxygen documentation for the current platform'
95 @echo ' printall - print makefile info for debugging'
96 @echo ' gitconfig - set up git to submit patches to coreboot'
97 @echo ' ctags / ctags-project - make ctags file for all of coreboot or current board'
98 @echo ' cscope / cscope-project - make cscope.out file for coreboot or current board'
99 @echo
101 # This include must come _before_ the pattern rules below!
102 # Order _does_ matter for pattern rules.
103 include $(srck)/Makefile
105 # Three cases where we don't need fully populated $(obj) lists:
106 # 1. when no .config exists
107 # 2. when make config (in any flavour) is run
108 # 3. when make distclean is run
109 # Don't waste time on reading all Makefile.incs in these cases
110 ifeq ($(strip $(HAVE_DOTCONFIG)),)
111 NOCOMPILE:=1
112 endif
113 ifneq ($(MAKECMDGOALS),)
114 ifneq ($(filter %config %clean cross% clang iasl gnumake lint% help% what-jenkins-does,$(MAKECMDGOALS)),)
115 NOCOMPILE:=1
116 endif
117 ifeq ($(MAKECMDGOALS), %clean)
118 NOMKDIR:=1
119 endif
120 endif
122 ifeq ($(NOCOMPILE),1)
123 include $(TOPLEVEL)/Makefile.inc
124 include $(TOPLEVEL)/payloads/Makefile.inc
125 include $(TOPLEVEL)/util/testing/Makefile.inc
126 real-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
131 else
133 include $(DOTCONFIG)
135 # 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)))
139 .xcompile: util/xcompile/xcompile
140 rm -f $@
141 $< $(XGCCPATH) > $@.tmp
142 \mv -f $@.tmp $@ 2> /dev/null
143 rm -f $@.tmp
145 -include .xcompile
147 ifneq ($(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)
151 endif
153 ifneq ($(CONFIG_MMX),y)
154 CFLAGS_x86_32 += -mno-mmx
155 endif
157 include toolchain.inc
159 strip_quotes = $(strip $(subst ",,$(subst \",,$(1))))
160 # fix makefile syntax highlighting after strip macro \" "))
162 # The primary target needs to be here before we include the
163 # other files
165 real-all: real-target
167 # must come rather early
168 .SECONDEXPANSION:
170 $(KCONFIG_AUTOHEADER): $(KCONFIG_CONFIG)
171 +$(MAKE) oldconfig
173 # Add a new class of source/object files to the build system
174 add-class= \
175 $(eval $(1)-srcs:=) \
176 $(eval $(1)-objs:=) \
177 $(eval classes+=$(1))
179 # 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
184 add-special-class= \
185 $(eval $(1):=) \
186 $(eval special-classes+=$(1))
188 # Converts one or more source file paths to their corresponding build/ paths.
189 # Only .ads, adb, .c and .S get converted to .o, other files (like .ld) keep
190 # their name.
191 # $1 stage name
192 # $2 file path (list)
193 src-to-obj=\
194 $(patsubst $(obj)/%,$(obj)/$(1)/%,\
195 $(patsubst $(obj)/$(1)/%,$(obj)/%,\
196 $(patsubst 3rdparty/%,$(obj)/%,\
197 $(patsubst src/%,$(obj)/%,\
198 $(patsubst %.ads,%.o,\
199 $(patsubst %.adb,%.o,\
200 $(patsubst %.c,%.o,\
201 $(patsubst %.S,%.o,\
202 $(subst .$(1),,$(2))))))))))
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)
208 src-to-ali=\
209 $(patsubst $(obj)/%,$(obj)/$(1)/%,\
210 $(patsubst $(obj)/$(1)/%,$(obj)/%,\
211 $(patsubst 3rdparty/%,$(obj)/%,\
212 $(patsubst src/%,$(obj)/%,\
213 $(patsubst %.ads,%.ali,\
214 $(patsubst %.adb,%.ali,\
215 $(subst .$(1),,\
216 $(filter %.ads %.adb,$(2)))))))))
218 # Clean -y variables, include Makefile.inc
219 # Add paths to files in X-y to X-srcs
220 # Add subdirs-y to subdirs
221 includemakefiles= \
222 $(foreach class,classes subdirs $(classes) $(special-classes), $(eval $(class)-y:=)) \
223 $(eval -include $(1)) \
224 $(foreach class,$(classes-y), $(call add-class,$(class))) \
225 $(foreach class,$(classes), \
226 $(eval $(class)-srcs+= \
227 $$(subst $(absobj)/,$(obj)/, \
228 $$(subst $(top)/,, \
229 $$(abspath $$(subst $(dir $(1))/,/,$$(addprefix $(dir $(1)),$$($(class)-y)))))))) \
230 $(foreach special,$(special-classes), \
231 $(foreach item,$($(special)-y), $(call $(special)-handler,$(dir $(1)),$(item)))) \
232 $(eval subdirs+=$$(subst $(CURDIR)/,,$$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y)))))
234 # For each path in $(subdirs) call includemakefiles
235 # Repeat until subdirs is empty
236 evaluate_subdirs= \
237 $(eval cursubdirs:=$(subdirs)) \
238 $(eval subdirs:=) \
239 $(foreach dir,$(cursubdirs), \
240 $(eval $(call includemakefiles,$(dir)/Makefile.inc))) \
241 $(if $(subdirs),$(eval $(call evaluate_subdirs)))
243 # collect all object files eligible for building
244 subdirs:=$(TOPLEVEL)
245 postinclude-hooks :=
246 $(eval $(call evaluate_subdirs))
247 ifeq ($(FAILBUILD),1)
248 $(error cannot continue build)
249 endif
251 # Run hooks registered by subdirectories that need to be evaluated after all files have been parsed
252 $(eval $(postinclude-hooks))
254 # Eliminate duplicate mentions of source files in a class
255 $(foreach class,$(classes),$(eval $(class)-srcs:=$(sort $($(class)-srcs))))
257 # To track dependencies, we need all Ada specification (.ads) files in
258 # *-srcs. Extract / filter all specification files that have a matching
259 # body (.adb) file here (specifications without a body are valid sources
260 # in Ada).
261 $(foreach class,$(classes),$(eval $(class)-extra-specs := \
262 $(filter \
263 $(addprefix %/,$(patsubst %.adb,%.ads,$(notdir $(filter %.adb,$($(class)-srcs))))), \
264 $(filter %.ads,$($(class)-srcs)))))
265 $(foreach class,$(classes),$(eval $(class)-srcs := \
266 $(filter-out $($(class)-extra-specs),$($(class)-srcs))))
268 $(foreach class,$(classes),$(eval $(class)-objs:=$(call src-to-obj,$(class),$($(class)-srcs))))
269 $(foreach class,$(classes),$(eval $(class)-alis:=$(call src-to-ali,$(class),$($(class)-srcs))))
271 # For Ada includes
272 $(foreach class,$(classes),$(eval $(class)-ada-dirs:=$(sort $(dir $(filter %.ads %.adb,$($(class)-srcs)) $($(class)-extra-specs)))))
274 # Save all objs before processing them (for dependency inclusion)
275 originalobjs:=$(foreach var, $(addsuffix -objs,$(classes)), $($(var)))
277 # Call post-processors if they're defined
278 $(foreach class,$(classes),\
279 $(if $(value $(class)-postprocess),$(eval $(call $(class)-postprocess,$($(class)-objs)))))
281 allsrcs:=$(foreach var, $(addsuffix -srcs,$(classes)), $($(var)))
282 allobjs:=$(foreach var, $(addsuffix -objs,$(classes)), $($(var)))
283 alldirs:=$(sort $(abspath $(dir $(allobjs))))
285 # Reads dependencies from an Ada library information (.ali) file
286 # Only basenames (with suffix) are preserved so we have to look the
287 # paths up in $($(stage)-srcs).
288 # $1 stage name
289 # $2 ali file
290 create_ada_deps=$$(if $(2),\
291 gnat.adc \
292 $$(filter \
293 $$(addprefix %/,$$(shell sed -ne's/^D \([^\t]\+\).*$$$$/\1/p' $(2) 2>/dev/null)), \
294 $$($(1)-srcs) $$($(1)-extra-specs)))
296 # macro to define template macros that are used by use_template macro
297 define create_cc_template
298 # $1 obj class
299 # $2 source suffix (c, S, ld, ...)
300 # $3 additional compiler flags
301 # $4 additional dependencies
302 ifn$(EMPTY)def $(1)-objs_$(2)_template
303 de$(EMPTY)fine $(1)-objs_$(2)_template
304 $$(call src-to-obj,$1,$$(1).$2): $$(1).$2 $$(call create_ada_deps,$1,$$(call src-to-ali,$1,$$(1).$2)) $(KCONFIG_AUTOHEADER) $(4)
305 @printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n"
306 $(CC_$(1)) \
307 $$(if $$(filter-out ads adb,$(2)), \
308 -MMD $$$$(CPPFLAGS_$(1)) $$$$(CFLAGS_$(1)) -MT $$$$(@), \
309 $$$$(ADAFLAGS_$(1)) $$$$(addprefix -I,$$$$($(1)-ada-dirs))) \
310 $(3) -c -o $$$$@ $$$$<
311 en$(EMPTY)def
312 end$(EMPTY)if
313 endef
315 filetypes-of-class=$(subst .,,$(sort $(suffix $($(1)-srcs))))
316 $(foreach class,$(classes), \
317 $(foreach type,$(call filetypes-of-class,$(class)), \
318 $(eval $(class)-$(type)-ccopts += $(generic-$(type)-ccopts) $($(class)-generic-ccopts)) \
319 $(if $(generic-objs_$(type)_template_gen),$(eval $(call generic-objs_$(type)_template_gen,$(class))),\
320 $(eval $(call create_cc_template,$(class),$(type),$($(class)-$(type)-ccopts),$($(class)-$(type)-deps))))))
322 foreach-src=$(foreach file,$($(1)-srcs),$(eval $(call $(1)-objs_$(subst .,,$(suffix $(file)))_template,$(basename $(file)))))
323 $(eval $(foreach class,$(classes),$(call foreach-src,$(class))))
325 # To supported complex package initializations, we need to call the
326 # emitted code explicitly. gnatbind gathers all the calls for us
327 # and exports them as a procedure $(stage)_adainit(). Every stage that
328 # uses Ada code has to call it!
329 define gnatbind_template
330 # $1 class
331 $$(obj)/$(1)/b__$(1).adb: $$$$(filter-out $$(obj)/$(1)/b__$(1).ali,$$$$($(1)-alis))
332 @printf " BIND $$(subst $$(obj)/,,$$@)\n"
333 # We have to give gnatbind a simple filename (without leading
334 # path components) so just cd there.
335 cd $$(dir $$@) && \
336 $$(GNATBIND_$(1)) -a -n \
337 --RTS=$$(absobj)/libgnat-$$(ARCH-$(1)-y)/ \
338 -L$(1)_ada -o $$(notdir $$@) \
339 $$(subst $$(dir $$@),,$$^)
340 $$(obj)/$(1)/b__$(1).o: $$(obj)/$(1)/b__$(1).adb
341 @printf " CC $$(subst $$(obj)/,,$$@)\n"
342 $(CC_$(1)) $$(ADAFLAGS_$(1)) -c -o $$@ $$<
343 $(1)-objs += $$(obj)/$(1)/b__$(1).o
344 $($(1)-alis): %.ali: %.o ;
345 endef
347 $(eval $(foreach class,$(filter-out libgnat-%,$(classes)), \
348 $(if $($(class)-alis),$(call gnatbind_template,$(class)))))
350 DEPENDENCIES += $(addsuffix .d,$(basename $(allobjs)))
351 -include $(DEPENDENCIES)
353 printall:
354 @$(foreach class,$(classes), echo $(class)-objs: $($(class)-objs) | tr ' ' '\n'; echo; )
355 @echo alldirs: $(alldirs) | tr ' ' '\n'; echo
356 @echo allsrcs: $(allsrcs) | tr ' ' '\n'; echo
357 @echo DEPENDENCIES: $(DEPENDENCIES) | tr ' ' '\n'; echo
358 @$(foreach class,$(special-classes),echo $(class):'$($(class))' | tr ' ' '\n'; echo; )
359 endif
361 ifndef NOMKDIR
362 $(shell mkdir -p $(KCONFIG_SPLITCONFIG) $(objk)/lxdialog $(additional-dirs) $(alldirs))
363 endif
365 $(obj)/project_filelist.txt: all
366 find $(obj) -name "*.d" -exec cat {} \; | \
367 sed 's/[:\\]/ /g' | sed 's/ /\n/g' | sort | uniq | \
368 grep -v '\.o$$' > $(obj)/project_filelist.txt
370 filelist: clean
371 $(MAKE) $(obj)/project_filelist.txt
372 printf "\nFiles used in build:\n"
373 cat $(obj)/project_filelist.txt
375 #works with either exuberant ctags or ctags.emacs
376 ctags-project: clean-ctags $(obj)/project_filelist.txt
377 cat $(obj)/project_filelist.txt | \
378 xargs ctags -o tags
380 cscope-project: clean-cscope $(obj)/project_filelist.txt
381 cat $(obj)/project_filelist.txt | xargs cscope -b
383 cscope:
384 cscope -bR
386 doxy: doxygen
387 doxygen:
388 $(DOXYGEN) Documentation/Doxyfile.coreboot
390 doxygen_simple:
391 $(DOXYGEN) Documentation/Doxyfile.coreboot_simple
393 doxyplatform doxygen_platform: $(obj)/project_filelist.txt
394 echo
395 echo "Building doxygen documentation for $(CONFIG_MAINBOARD_PART_NUMBER)"
396 export DOXYGEN_OUTPUT_DIR="$(DOXYGEN_OUTPUT_DIR)/$(CONFIG_MAINBOARD_VENDOR)/$(CONFIG_MAINBOARD_PART_NUMBER)"; \
397 mkdir -p "$$DOXYGEN_OUTPUT_DIR"; \
398 export DOXYFILES="$$(cat $(obj)/project_filelist.txt | grep -v '\.ld$$' | sed 's/\.aml/\.dsl/' | tr '\n' ' ')"; \
399 export DOXYGEN_PLATFORM="$(CONFIG_MAINBOARD_DIR) ($(CONFIG_MAINBOARD_PART_NUMBER)) version $(KERNELVERSION)"; \
400 $(DOXYGEN) Documentation/doxygen/Doxyfile.coreboot_platform
402 doxyclean: doxygen-clean
403 doxygen-clean:
404 rm -rf $(DOXYGEN_OUTPUT_DIR)
406 clean-for-update: doxygen-clean clean-for-update-target
407 rm -rf $(obj) .xcompile
409 clean: clean-for-update clean-target clean-utils
410 rm -f .ccwrap
412 clean-cscope:
413 rm -f cscope.out
415 clean-ctags:
416 rm -f tags
418 clean-utils:
419 $(foreach tool, $(TOOLLIST), \
420 $(MAKE) -C util/$(tool) clean MFLAGS= MAKEFLAGS= ;)
422 distclean-utils:
423 $(foreach tool, $(TOOLLIST), \
424 $(MAKE) -C util/$(tool) distclean MFLAGS= MAKEFLAGS= ; \
425 rm -f /util/$(tool)/junit.xml;)
427 distclean: clean clean-ctags clean-cscope distclean-payloads distclean-utils
428 rm -f .config .config.old ..config.tmp* .kconfig.d .tmpconfig* .ccwrap .xcompile
429 rm -rf coreboot-builds coreboot-builds-chromeos
430 rm -f abuild*.xml junit.xml* util/lint/junit.xml
432 .PHONY: $(PHONY) clean clean-for-update clean-cscope cscope distclean doxygen doxy doxygen_simple
433 .PHONY: ctags-project cscope-project clean-ctags