tegra124: fix PLLU parameters
[coreboot.git] / Makefile
blobeaac22bb901dedf6915a852ce6d128a63bc4ada5
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 # 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.
35 $(if $(wildcard .xcompile),,$(eval $(shell util/xcompile/xcompile $(XGCCPATH) > .xcompile)))
37 .xcompile: util/xcompile/xcompile
38 A=`mktemp $@.XXXXXX`; $< $(XGCCPATH) > $$A && mv $$A $@ 2> /dev/null
40 include .xcompile
42 export top := $(CURDIR)
43 export src := src
44 export srck := $(top)/util/kconfig
45 export obj ?= build
46 export objutil ?= $(obj)/util
47 export objk := $(objutil)/kconfig
50 export KCONFIG_AUTOHEADER := $(obj)/config.h
51 export KCONFIG_AUTOCONFIG := $(obj)/auto.conf
52 export KCONFIG_DEPENDENCIES := $(obj)/auto.conf.cmd
53 export KCONFIG_SPLITCONFIG := $(obj)/config
54 export KCONFIG_TRISTATE := $(obj)/tristate.conf
55 export KCONFIG_NEGATIVES := 1
57 # directory containing the toplevel Makefile.inc
58 TOPLEVEL := .
60 CONFIG_SHELL := sh
61 KBUILD_DEFCONFIG := configs/defconfig
62 UNAME_RELEASE := $(shell uname -r)
63 DOTCONFIG ?= .config
64 KCONFIG_CONFIG = $(DOTCONFIG)
65 export KCONFIG_CONFIG
66 HAVE_DOTCONFIG := $(wildcard $(DOTCONFIG))
67 MAKEFLAGS += -rR --no-print-directory
69 # Make is silent per default, but 'make V=1' will show all compiler calls.
70 Q:=@
71 ifneq ($(V),1)
72 ifneq ($(Q),)
73 .SILENT:
74 endif
75 endif
77 HOSTCC := gcc
78 HOSTCXX = g++
79 HOSTCFLAGS := -g
80 HOSTCXXFLAGS := -g
82 DOXYGEN := doxygen
83 DOXYGEN_OUTPUT_DIR := doxygen
85 all: real-all
87 # This include must come _before_ the pattern rules below!
88 # Order _does_ matter for pattern rules.
89 include util/kconfig/Makefile
91 # Three cases where we don't need fully populated $(obj) lists:
92 # 1. when no .config exists
93 # 2. when make config (in any flavour) is run
94 # 3. when make distclean is run
95 # Don't waste time on reading all Makefile.incs in these cases
96 ifeq ($(strip $(HAVE_DOTCONFIG)),)
97 NOCOMPILE:=1
98 endif
99 ifneq ($(MAKECMDGOALS),)
100 ifneq ($(filter %config %clean cross%,$(MAKECMDGOALS)),)
101 NOCOMPILE:=1
102 endif
103 ifeq ($(MAKECMDGOALS), %clean)
104 NOMKDIR:=1
105 endif
106 endif
108 ifeq ($(NOCOMPILE),1)
109 include $(TOPLEVEL)/Makefile.inc
110 real-all: config
112 else
114 include $(HAVE_DOTCONFIG)
116 ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y)
117 # FIXME: armv7/aarch64 won't build right now
118 # NOTE: clang puts compiler-rt under lib/linux/libclang_rt.builtins-i386.a
119 # this means the triple is i386-linux-elf instead of i386-none-elf
120 CFLAGS_x86_32 = -no-integrated-as -Qunused-arguments -target i386-linux-elf -m32
121 CC_x86_32:=clang
122 HOSTCC := clang
124 ifneq ($(CONFIG_MMX),y)
125 CFLAGS_x86_32 += -mno-mmx
126 endif
128 # FIXME: we end up with conflicting flags with this, not clear on this part.
129 #ifneq ($(CONFIG_SSE),y)
130 #CFLAGS_x86_32 += -mno-sse
131 #endif
133 CFLAGS_arm = -no-integrated-as -Qunused-arguments -target arm-eabi -ccc-gcc-name $(CC_arm)
134 CC_arm:=clang
136 CFLAGS_aarch64 = -no-integrated-as -Qunused-arguments -target aarch64-eabi -ccc-gcc-name $(CC_aarch64)
137 CC_aarch64:=clang
138 endif
140 include toolchain.inc
142 strip_quotes = $(subst ",,$(subst \",,$(1)))
144 # The primary target needs to be here before we include the
145 # other files
147 real-all: real-target
149 # must come rather early
150 .SECONDEXPANSION:
152 $(obj)/config.h:
153 $(MAKE) oldconfig
155 # Add a new class of source/object files to the build system
156 add-class= \
157 $(eval $(1)-srcs:=) \
158 $(eval $(1)-objs:=) \
159 $(eval classes+=$(1))
161 # Special classes are managed types with special behaviour
162 # On parse time, for each entry in variable $(1)-y
163 # a handler $(1)-handler is executed with the arguments:
164 # * $(1): directory the parser is in
165 # * $(2): current entry
166 add-special-class= \
167 $(eval $(1):=) \
168 $(eval special-classes+=$(1))
170 # Clean -y variables, include Makefile.inc
171 # Add paths to files in X-y to X-srcs
172 # Add subdirs-y to subdirs
173 includemakefiles= \
174 $(foreach class,classes subdirs $(classes) $(special-classes), $(eval $(class)-y:=)) \
175 $(eval -include $(1)) \
176 $(foreach class,$(classes-y), $(call add-class,$(class))) \
177 $(foreach class,$(classes), \
178 $(eval $(class)-srcs+= \
179 $$(subst $(top)/,, \
180 $$(abspath $$(subst $(dir $(1))/,/,$$(addprefix $(dir $(1)),$$($(class)-y))))))) \
181 $(foreach special,$(special-classes), \
182 $(foreach item,$($(special)-y), $(call $(special)-handler,$(dir $(1)),$(item)))) \
183 $(eval subdirs+=$$(subst $(CURDIR)/,,$$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y)))))
185 # For each path in $(subdirs) call includemakefiles
186 # Repeat until subdirs is empty
187 evaluate_subdirs= \
188 $(eval cursubdirs:=$(subdirs)) \
189 $(eval subdirs:=) \
190 $(foreach dir,$(cursubdirs), \
191 $(eval $(call includemakefiles,$(dir)/Makefile.inc))) \
192 $(if $(subdirs),$(eval $(call evaluate_subdirs)))
194 # collect all object files eligible for building
195 subdirs:=$(TOPLEVEL)
196 $(eval $(call evaluate_subdirs))
197 ifeq ($(FAILBUILD),1)
198 $(error cannot continue build)
199 endif
201 # Eliminate duplicate mentions of source files in a class
202 $(foreach class,$(classes),$(eval $(class)-srcs:=$(sort $($(class)-srcs))))
204 src-to-obj=$(addsuffix .$(1).o, $(basename $(patsubst src/%, $(obj)/%, $($(1)-srcs))))
205 $(foreach class,$(classes),$(eval $(class)-objs:=$(call src-to-obj,$(class))))
207 # Save all objs before processing them (for dependency inclusion)
208 originalobjs:=$(foreach var, $(addsuffix -objs,$(classes)), $($(var)))
210 # Call post-processors if they're defined
211 $(foreach class,$(classes),\
212 $(if $(value $(class)-postprocess),$(eval $(call $(class)-postprocess,$($(class)-objs)))))
214 allsrcs:=$(foreach var, $(addsuffix -srcs,$(classes)), $($(var)))
215 allobjs:=$(foreach var, $(addsuffix -objs,$(classes)), $($(var)))
216 alldirs:=$(sort $(abspath $(dir $(allobjs))))
218 # macro to define template macros that are used by use_template macro
219 define create_cc_template
220 # $1 obj class
221 # $2 source suffix (c, S)
222 # $3 additional compiler flags
223 # $4 additional dependencies
224 ifn$(EMPTY)def $(1)-objs_$(2)_template
225 de$(EMPTY)fine $(1)-objs_$(2)_template
226 $(obj)/$$(1).$(1).o: src/$$(1).$(2) $(obj)/config.h $(4)
227 @printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n"
228 $(CC_$(1)) $(3) -MMD $$$$(CPPFLAGS_$(1)) $$$$(CFLAGS_$(1)) -c -o $$$$@ $$$$<
229 en$(EMPTY)def
230 end$(EMPTY)if
231 endef
233 filetypes-of-class=$(subst .,,$(sort $(suffix $($(1)-srcs))))
234 $(foreach class,$(classes), \
235 $(foreach type,$(call filetypes-of-class,$(class)), \
236 $(eval $(call create_cc_template,$(class),$(type),$($(class)-$(type)-ccopts),$($(class)-$(type)-deps)))))
238 foreach-src=$(foreach file,$($(1)-srcs),$(eval $(call $(1)-objs_$(subst .,,$(suffix $(file)))_template,$(subst src/,,$(basename $(file))))))
239 $(eval $(foreach class,$(classes),$(call foreach-src,$(class))))
241 DEPENDENCIES = $(originalobjs:.o=.d)
242 -include $(DEPENDENCIES)
244 printall:
245 @$(foreach class,$(classes),echo $(class)-objs:=$($(class)-objs); )
246 @echo alldirs:=$(alldirs)
247 @echo allsrcs=$(allsrcs)
248 @echo DEPENDENCIES=$(DEPENDENCIES)
249 @echo LIBGCC_FILE_NAME=$(LIBGCC_FILE_NAME_$(class))
250 @$(foreach class,$(special-classes),echo $(class):='$($(class))'; )
252 endif
254 ifndef NOMKDIR
255 $(shell mkdir -p $(KCONFIG_SPLITCONFIG) $(objutil)/kconfig/lxdialog $(additional-dirs) $(alldirs))
256 endif
258 cscope:
259 cscope -bR
261 doxy: doxygen
262 doxygen:
263 $(DOXYGEN) documentation/Doxyfile.coreboot
265 doxyclean: doxygen-clean
266 doxygen-clean:
267 rm -rf $(DOXYGEN_OUTPUT_DIR)
269 clean-for-update: doxygen-clean clean-for-update-target
270 rm -rf $(obj) .xcompile
272 clean: clean-for-update clean-target
273 rm -f .ccwrap
275 clean-cscope:
276 rm -f cscope.out
278 distclean: clean
279 rm -f .config .config.old ..config.tmp .kconfig.d .tmpconfig* .ccwrap .xcompile
281 .PHONY: $(PHONY) clean clean-for-update clean-cscope cscope distclean doxygen doxy