lenovo/x60: Remove leftover declaration
[coreboot.git] / Makefile
bloba55ad676b8383efe06a0883bf665d8446c930518
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 ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y)
79 HOSTCC := clang
80 endif
81 HOSTCXX = g++
82 HOSTCFLAGS := -g
83 HOSTCXXFLAGS := -g
85 DOXYGEN := doxygen
86 DOXYGEN_OUTPUT_DIR := doxygen
88 all: real-all
90 # This include must come _before_ the pattern rules below!
91 # Order _does_ matter for pattern rules.
92 include util/kconfig/Makefile
94 # Three cases where we don't need fully populated $(obj) lists:
95 # 1. when no .config exists
96 # 2. when make config (in any flavour) is run
97 # 3. when make distclean is run
98 # Don't waste time on reading all Makefile.incs in these cases
99 ifeq ($(strip $(HAVE_DOTCONFIG)),)
100 NOCOMPILE:=1
101 endif
102 ifneq ($(MAKECMDGOALS),)
103 ifneq ($(filter %config %clean cross%,$(MAKECMDGOALS)),)
104 NOCOMPILE:=1
105 endif
106 ifeq ($(MAKECMDGOALS), %clean)
107 NOMKDIR:=1
108 endif
109 endif
111 ifeq ($(NOCOMPILE),1)
112 include $(TOPLEVEL)/Makefile.inc
113 real-all: config
115 else
117 include $(HAVE_DOTCONFIG)
119 ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y)
120 # FIXME: armv7/aarch64 won't build right now
121 CFLAGS_x86_32 = -no-integrated-as -Qunused-arguments -target i386-elf -m32
122 CC_x86_32:=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_armv7 = -no-integrated-as -Qunused-arguments -target armv7-eabi -ccc-gcc-name $(CC_armv7)
134 CC_armv7:=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 dependencies
223 ifn$(EMPTY)def $(1)-objs_$(2)_template
224 de$(EMPTY)fine $(1)-objs_$(2)_template
225 $(obj)/$$(1).$(1).o: src/$$(1).$(2) $(obj)/config.h $(3)
226 @printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n"
227 $(CC_$(1)) -MMD $$$$(CPPFLAGS_$(1)) $$$$(CFLAGS_$(1)) -c -o $$$$@ $$$$<
228 en$(EMPTY)def
229 end$(EMPTY)if
230 endef
232 filetypes-of-class=$(subst .,,$(sort $(suffix $($(1)-srcs))))
233 $(foreach class,$(classes), \
234 $(foreach type,$(call filetypes-of-class,$(class)), \
235 $(eval $(call create_cc_template,$(class),$(type),$($(class)-$(type)-deps)))))
237 foreach-src=$(foreach file,$($(1)-srcs),$(eval $(call $(1)-objs_$(subst .,,$(suffix $(file)))_template,$(subst src/,,$(basename $(file))))))
238 $(eval $(foreach class,$(classes),$(call foreach-src,$(class))))
240 DEPENDENCIES = $(originalobjs:.o=.d)
241 -include $(DEPENDENCIES)
243 printall:
244 @$(foreach class,$(classes),echo $(class)-objs:=$($(class)-objs); )
245 @echo alldirs:=$(alldirs)
246 @echo allsrcs=$(allsrcs)
247 @echo DEPENDENCIES=$(DEPENDENCIES)
248 @echo LIBGCC_FILE_NAME=$(LIBGCC_FILE_NAME_$(class))
249 @$(foreach class,$(special-classes),echo $(class):='$($(class))'; )
251 endif
253 ifndef NOMKDIR
254 $(shell mkdir -p $(KCONFIG_SPLITCONFIG) $(objutil)/kconfig/lxdialog $(additional-dirs) $(alldirs))
255 endif
257 cscope:
258 cscope -bR
260 doxy: doxygen
261 doxygen:
262 $(DOXYGEN) documentation/Doxyfile.coreboot
264 doxyclean: doxygen-clean
265 doxygen-clean:
266 rm -rf $(DOXYGEN_OUTPUT_DIR)
268 clean-for-update: doxygen-clean clean-for-update-target
269 rm -rf $(obj) .xcompile
271 clean: clean-for-update clean-target
272 rm -f .ccwrap
274 clean-cscope:
275 rm -f cscope.out
277 distclean: clean
278 rm -f .config .config.old ..config.tmp .kconfig.d .tmpconfig* .ccwrap .xcompile
280 .PHONY: $(PHONY) clean clean-for-update clean-cscope cscope distclean doxygen doxy