blob: 72f3951fa9bd10b4deb073ed77f23b44c6943e66 [file] [log] [blame]
Patrick Georgi71b84802011-02-22 14:35:05 +00001##
2## This file is part of the coreboot project.
3##
4## Copyright (C) 2011 secunet Security Networks AG
5##
6## This program is free software; you can redistribute it and/or modify
7## it under the terms of the GNU General Public License as published by
8## the Free Software Foundation; version 2 of the License.
9##
10## This program is distributed in the hope that it will be useful,
11## but WITHOUT ANY WARRANTY; without even the implied warranty of
12## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13## GNU General Public License for more details.
14##
15## You should have received a copy of the GNU General Public License
16## along with this program; if not, write to the Free Software
17## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18##
19
20#######################################################################
21# misleadingly named, this is the coreboot version
Vadim Bendebury6e7abcd2012-12-10 15:47:23 -080022export KERNELVERSION := $(shell if [ -d "$(top)/.git" -a -f "`which git`" ]; \
23 then git describe --dirty --always || git describe; \
24 else echo 4.0$(KERNELREVISION); fi)
Patrick Georgi71b84802011-02-22 14:35:05 +000025
26#######################################################################
Patrick Georgi9b0de712013-12-29 18:45:23 +010027# Test for coreboot toolchain (except when explicitely not requested)
28ifneq ($(NOCOMPILE),1)
29# only run if we're doing a build (not for tests, kconfig, ...)
30ifneq ($(CONFIG_ANY_TOOLCHAIN),y)
31_toolchain=$(shell $(CC_i386) -v 2>&1 |grep -q "gcc version .*coreboot toolchain" && echo coreboot)
32ifneq ($(_toolchain),coreboot)
33$(error Please use the coreboot toolchain (or prove that your toolchain works))
34endif
35endif
36endif
37
38#######################################################################
Patrick Georgi71b84802011-02-22 14:35:05 +000039# Basic component discovery
Patrick Georgi71b84802011-02-22 14:35:05 +000040MAINBOARDDIR=$(call strip_quotes,$(CONFIG_MAINBOARD_DIR))
41export MAINBOARDDIR
42
Kyösti Mälkki0db2ae3a2012-04-19 12:00:06 +030043## Final build results, which CBFSTOOL uses to create the final
44## rom image file, are placed under $(objcbfs).
45## These typically have suffixes .debug .elf .bin and .map
Stefan Reinauera60ca362012-08-09 11:09:44 -070046export objcbfs := $(obj)/cbfs/$(call strip_quotes,$(CONFIG_CBFS_PREFIX))
Kyösti Mälkki0db2ae3a2012-04-19 12:00:06 +030047
48## Based on the active configuration, Makefile conditionally collects
49## the required assembly includes and saves them in a file.
50## Such files that do not have a clear one-to-one relation to a source
51## file under src/ are placed and built under $(objgenerated)
52export objgenerated := $(obj)/generated
53
Patrick Georgi71b84802011-02-22 14:35:05 +000054#######################################################################
55# root rule to resolve if in build mode (ie. configuration exists)
56real-target: $(obj)/config.h coreboot
Kyösti Mälkki0db2ae3a2012-04-19 12:00:06 +030057coreboot: build-dirs $(obj)/coreboot.rom
Patrick Georgi71b84802011-02-22 14:35:05 +000058
59#######################################################################
60# our phony targets
Kyösti Mälkki0db2ae3a2012-04-19 12:00:06 +030061PHONY+= clean-abuild coreboot lint lint-stable build-dirs
Patrick Georgi71b84802011-02-22 14:35:05 +000062
63#######################################################################
64# root source directories of coreboot
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -050065subdirs-y := src/lib src/console src/device src/ec src/southbridge src/soc
Kyösti Mälkki2a830d02011-12-01 17:49:43 +020066subdirs-y += src/northbridge src/superio src/drivers src/cpu src/vendorcode
Patrick Georgi499fc922012-03-09 10:53:52 +010067subdirs-y += util/cbfstool util/sconfig util/nvramtool
Patrick Georgi71b84802011-02-22 14:35:05 +000068subdirs-y += src/arch/$(ARCHDIR-y)
69subdirs-y += src/mainboard/$(MAINBOARDDIR)
70
Patrick Georgia25828d2011-09-02 09:57:01 +020071subdirs-y += site-local
72
Patrick Georgi71b84802011-02-22 14:35:05 +000073#######################################################################
74# Add source classes and their build options
Aaron Durbin9be4c472013-01-12 00:41:44 -060075classes-y := ramstage romstage bootblock smm smmstub cpu_microcode rmodules
Patrick Georgi71b84802011-02-22 14:35:05 +000076
Patrick Georgif33e3952012-11-25 17:10:47 +010077#######################################################################
78# Helper functions for ramstage postprocess
79spc :=
80spc +=
81$(spc) :=
82$(spc) +=
83
84# files-in-dir-recursive,dir,files
85files-in-dir-recursive=$(filter $(1)%,$(2))
86
87# parent-dir,dir/
88parent-dir=$(dir $(subst $( ),/,$(strip $(subst /, ,$(1)))))
89
90# filters out exactly the directory specified
91# filter-out-dir,dir_to_keep,dirs
92filter-out-dir=$(filter-out $(1),$(2))
93
94# filters out dir_to_keep and all its parents
95# filter-out-dirs,dir_to_keep,dirs
96filter-out-dirs=$(if $(filter-out ./,$(1)),$(call filter-out-dirs,$(call parent-dir,$(1)),$(call filter-out-dir,$(1),$(2))),$(call filter-out-dir,$(1),$(2)))
97
98# dir-wildcards,dirs
99dir-wildcards=$(addsuffix %,$(1))
100
101# files-in-dir,dir,files
102files-in-dir=$(filter-out $(call dir-wildcards,$(call filter-out-dirs,$(1),$(dir $(2)))),$(call files-in-dir-recursive,$(1),$(2)))
103
104#######################################################################
105# reduce command line length by linking the objects of each
106# directory into an intermediate file
107ramstage-postprocess=$(foreach d,$(sort $(dir $(1))), \
108 $(eval $(d)ramstage.o: $(call files-in-dir,$(d),$(1)); $$(LD) -o $$@ -r $$^ ) \
109 $(eval ramstage-objs:=$(d)ramstage.o $(filter-out $(call files-in-dir,$(d),$(1)),$(ramstage-objs))))
110
Patrick Georgi71b84802011-02-22 14:35:05 +0000111romstage-c-ccopts:=-D__PRE_RAM__
Stefan Reinauer61aee5f2011-04-10 04:15:23 +0000112romstage-S-ccopts:=-D__PRE_RAM__
Rudolf Marek7f0e9302011-09-02 23:23:41 +0200113ifeq ($(CONFIG_TRACE),y)
114ramstage-c-ccopts:= -finstrument-functions
115endif
Stefan Reinauerd37ab452012-12-18 16:23:28 -0800116ifeq ($(CONFIG_COVERAGE),y)
117ramstage-c-ccopts+=-fprofile-arcs -ftest-coverage
118endif
Rudolf Marek7f0e9302011-09-02 23:23:41 +0200119
Patrick Georgi7e9b9d82012-04-30 21:06:10 +0200120ifeq ($(CONFIG_USE_BLOBS),y)
121forgetthis:=$(shell git submodule update --init --checkout 3rdparty)
Patrick Georgi7e9b9d82012-04-30 21:06:10 +0200122endif
123
Hung-Te Lin5f83f6c2013-02-04 14:38:03 +0800124bootblock-c-ccopts:=-D__BOOT_BLOCK__ -D__PRE_RAM__
125bootblock-S-ccopts:=-D__BOOT_BLOCK__ -D__PRE_RAM__
Hung-Te Linfe187922013-02-01 01:09:24 +0800126
Aaron Durbin50a34642013-01-03 17:38:47 -0600127smmstub-c-ccopts:=-D__SMM__
128smmstub-S-ccopts:=-D__SMM__
Stefan Reinauer24ef1342011-04-14 22:28:00 +0000129smm-c-ccopts:=-D__SMM__
130smm-S-ccopts:=-D__SMM__
Patrick Georgi71b84802011-02-22 14:35:05 +0000131
Stefan Reinauer3aa067f2012-04-02 13:24:04 -0700132# SMM TSEG base is dynamic
Aaron Durbin50a34642013-01-03 17:38:47 -0600133ifneq ($(CONFIG_SMM_MODULES),y)
Stefan Reinauer3aa067f2012-04-02 13:24:04 -0700134ifeq ($(CONFIG_SMM_TSEG),y)
135smm-c-ccopts += -fpic
136endif
Aaron Durbin50a34642013-01-03 17:38:47 -0600137endif
Stefan Reinauer3aa067f2012-04-02 13:24:04 -0700138
Patrick Georgi57205c72011-03-08 20:49:18 +0000139ramstage-c-deps:=$$(OPTION_TABLE_H)
140romstage-c-deps:=$$(OPTION_TABLE_H)
Hung-Te Linfe187922013-02-01 01:09:24 +0800141bootblock-c-deps:=$$(OPTION_TABLE_H)
Kyösti Mälkkice22cd02013-11-30 21:06:18 +0200142smm-c-deps:=$$(OPTION_TABLE_H)
Patrick Georgi57205c72011-03-08 20:49:18 +0000143
Patrick Georgi71b84802011-02-22 14:35:05 +0000144#######################################################################
145# Add handler to compile ACPI's ASL
146define ramstage-objs_asl_template
Sven Schnelled69438e2011-03-29 09:01:10 +0000147$(obj)/$(1).ramstage.o: src/$(1).asl $(obj)/config.h
Patrick Georgi71b84802011-02-22 14:35:05 +0000148 @printf " IASL $$(subst $(top)/,,$$(@))\n"
Patrick Georgic0e16e72012-05-05 15:11:22 +0200149 $(CC) -x assembler-with-cpp -E -MMD -MT $$(@) -D__ACPI__ -P -include $(src)/include/kconfig.h -I$(obj) -I$(src) -I$(src)/include -I$(src)/arch/$(ARCHDIR-y)/include -I$(src)/mainboard/$(MAINBOARDDIR) $$< -o $$(basename $$@).asl
Marc Jones2aac3f62011-08-08 16:07:50 -0600150 cd $$(dir $$@); $(IASL) -p $$(notdir $$@) -tc $$(notdir $$(basename $$@)).asl
Patrick Georgib2a42642011-06-01 19:54:16 +0000151 mv $$(basename $$@).hex $$(basename $$@).c
Patrick Georgi71b84802011-02-22 14:35:05 +0000152 $(CC) $$(CFLAGS) $$(if $$(subst dsdt,,$$(basename $$(notdir $(1)))), -DAmlCode=AmlCode_$$(basename $$(notdir $(1)))) -c -o $$@ $$(basename $$@).c
153 # keep %.o: %.c rule from catching the temporary .c file after a make clean
154 mv $$(basename $$@).c $$(basename $$@).hex
155endef
156
157#######################################################################
Patrick Georgi3bbd2bf2012-03-09 12:30:07 +0100158# Parse plaintext cmos defaults into binary format
159# arg1: source file
160# arg2: binary file name
161cbfs-files-processor-nvramtool= \
162 $(eval $(2): $(1) $(src)/mainboard/$(MAINBOARDDIR)/cmos.layout | $(objutil)/nvramtool/nvramtool ; \
163 printf " CREATE $(2) (from $(1))\n"; $(objutil)/nvramtool/nvramtool -y $(src)/mainboard/$(MAINBOARDDIR)/cmos.layout -D $(2).tmp -p $(1) && mv $(2).tmp $(2))
164
165#######################################################################
Patrick Georgi843005c2012-04-30 23:15:17 +0200166# Link VSA binary to ELF-ish stage
167# arg1: source file
168# arg2: binary file name
169cbfs-files-processor-vsa= \
170 $(eval $(2): $(1) ; \
171 printf " CREATE $(2) (from $(1))\n"; $(OBJCOPY) --set-start 0x20 --adjust-vma 0x60000 -I binary -O elf32-i386 -B i386 $(1) $(2).tmp && $(LD) -m elf_i386 -e 0x60020 --section-start .data=0x60000 $(2).tmp -o $(2))
172
173#######################################################################
Patrick Georgi71b84802011-02-22 14:35:05 +0000174# Add handler for arbitrary files in CBFS
175$(call add-special-class,cbfs-files)
176cbfs-files-handler= \
Patrick Georgi3bbd2bf2012-03-09 12:30:07 +0100177 $(eval tmp-cbfs-method:=$(word 2, $(subst :, ,$($(2)-file)))) \
Patrick Georgi1fc2bda2012-11-15 14:51:54 +0100178 $(eval $(2)-file:=$(call strip_quotes,$(word 1, $(subst :, ,$($(2)-file))))) \
Patrick Georgi71b84802011-02-22 14:35:05 +0000179 $(if $(wildcard $(1)$($(2)-file)), \
180 $(eval tmp-cbfs-file:= $(wildcard $(1)$($(2)-file))), \
181 $(eval tmp-cbfs-file:= $($(2)-file))) \
Patrick Georgi70c85ea2013-02-16 01:06:57 +0100182 $(if $(strip $($(2)-required)), \
183 $(if $(wildcard $(tmp-cbfs-file)),, \
184 $(info This build configuration requires $($(2)-required)) \
185 $(eval FAILBUILD:=1) \
186 )) \
Patrick Georgi3bbd2bf2012-03-09 12:30:07 +0100187 $(if $(tmp-cbfs-method), \
188 $(eval tmp-old-cbfs-file:=$(tmp-cbfs-file)) \
Patrick Georgi16c7ad72012-09-21 18:11:59 +0200189 $(eval tmp-cbfs-file:=$(shell mkdir -p $(obj)/mainboard/$(MAINBOARDDIR); mktemp $(obj)/mainboard/$(MAINBOARDDIR)/cbfs-file.XXXXXX).out) \
Patrick Georgi3bbd2bf2012-03-09 12:30:07 +0100190 $(call cbfs-files-processor-$(tmp-cbfs-method),$(tmp-old-cbfs-file),$(tmp-cbfs-file))) \
Dave Frodin0013bbf2012-08-14 11:01:53 -0600191 $(eval cbfs-files += $(tmp-cbfs-file)|$(2)|$($(2)-type)|$($(2)-compression)|$($(2)-position)) \
Patrick Georgi71b84802011-02-22 14:35:05 +0000192 $(eval $(2)-name:=) \
193 $(eval $(2)-type:=) \
Dave Frodin0013bbf2012-08-14 11:01:53 -0600194 $(eval $(2)-compression:=) \
Patrick Georgi70c85ea2013-02-16 01:06:57 +0100195 $(eval $(2)-position:=) \
196 $(eval $(2)-required:=)
Patrick Georgi71b84802011-02-22 14:35:05 +0000197
198#######################################################################
199# a variety of flags for our build
Stefan Reinauer63217582012-10-29 16:52:36 -0700200CBFS_COMPRESS_FLAG:=none
Sven Schnelle8eee19d2011-05-02 19:53:04 +0000201ifeq ($(CONFIG_COMPRESS_RAMSTAGE),y)
Stefan Reinauer63217582012-10-29 16:52:36 -0700202CBFS_COMPRESS_FLAG:=LZMA
Sven Schnelle8eee19d2011-05-02 19:53:04 +0000203endif
204
Stefan Reinauer63217582012-10-29 16:52:36 -0700205CBFS_PAYLOAD_COMPRESS_FLAG:=none
Patrick Georgi71b84802011-02-22 14:35:05 +0000206ifeq ($(CONFIG_COMPRESSED_PAYLOAD_LZMA),y)
Stefan Reinauer63217582012-10-29 16:52:36 -0700207CBFS_PAYLOAD_COMPRESS_FLAG:=LZMA
Patrick Georgi71b84802011-02-22 14:35:05 +0000208endif
209
210ifneq ($(CONFIG_LOCALVERSION),"")
211COREBOOT_EXTRA_VERSION := -$(call strip_quotes,$(CONFIG_LOCALVERSION))
212endif
213
214INCLUDES := -Isrc -Isrc/include -I$(obj) -Isrc/arch/$(ARCHDIR-y)/include
Stefan Reinauer8d711552012-11-30 12:34:04 -0800215INCLUDES += -Isrc/device/oprom/include
Patrick Georgi71b84802011-02-22 14:35:05 +0000216# abspath is a workaround for romcc
Patrick Georgic0e16e72012-05-05 15:11:22 +0200217INCLUDES += -include $(src)/include/kconfig.h
Patrick Georgi71b84802011-02-22 14:35:05 +0000218
Frank Vibransec402602011-05-05 16:45:36 +0000219CFLAGS = $(INCLUDES) -Os -pipe -g -nostdinc
Patrick Georgi71b84802011-02-22 14:35:05 +0000220CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
221CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs
222CFLAGS += -Wstrict-aliasing -Wshadow
223ifeq ($(CONFIG_WARNINGS_ARE_ERRORS),y)
224CFLAGS += -Werror
225endif
Patrick Georgi71b84802011-02-22 14:35:05 +0000226CFLAGS += -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer
227
Nico Hubera15cd662013-06-19 16:16:05 +0200228additional-dirs := $(objutil)/cbfstool $(objutil)/romcc $(objutil)/ifdtool \
229 $(objutil)/ifdfake $(objutil)/options
Patrick Georgi71b84802011-02-22 14:35:05 +0000230
231#######################################################################
232# generate build support files
233$(obj)/build.h: .xcompile
234 @printf " GEN build.h\n"
235 rm -f $(obj)/build.h
236 printf "/* build system definitions (autogenerated) */\n" > $(obj)/build.ht
237 printf "#ifndef __BUILD_H\n" >> $(obj)/build.ht
238 printf "#define __BUILD_H\n\n" >> $(obj)/build.ht
Patrick Georgib8e9ba92011-03-17 07:47:49 +0000239 printf "#define COREBOOT_VERSION \"$(KERNELVERSION)\"\n" >> $(obj)/build.ht
Patrick Georgi71b84802011-02-22 14:35:05 +0000240 printf "#define COREBOOT_EXTRA_VERSION \"$(COREBOOT_EXTRA_VERSION)\"\n" >> $(obj)/build.ht
241 printf "#define COREBOOT_BUILD \"`LANG= date`\"\n" >> $(obj)/build.ht
Zheng Bao0e6d0ed2012-11-09 19:55:04 +0800242 printf "#define COREBOOT_BUILD_YEAR_BCD 0x`LANG= date +"%y"`\n" >> $(obj)/build.ht
243 printf "#define COREBOOT_BUILD_MONTH_BCD 0x`LANG= date +"%m"`\n" >> $(obj)/build.ht
244 printf "#define COREBOOT_BUILD_DAY_BCD 0x`LANG= date +"%d"`\n" >> $(obj)/build.ht
245 printf "#define COREBOOT_BUILD_WEEKDAY_BCD 0x`LANG= date +"%w"`\n" >> $(obj)/build.ht
Sven Schnelle164bcfd2011-08-14 20:56:34 +0200246 printf "#define COREBOOT_DMI_DATE \"`LANG= date +"%m/%d/%Y"`\"\n" >> $(obj)/build.ht
Patrick Georgi71b84802011-02-22 14:35:05 +0000247 printf "\n" >> $(obj)/build.ht
248 printf "#define COREBOOT_COMPILER \"$(shell LANG= $(CC) --version | head -n1)\"\n" >> $(obj)/build.ht
249 printf "#define COREBOOT_ASSEMBLER \"$(shell LANG= $(AS) --version | head -n1)\"\n" >> $(obj)/build.ht
250 printf "#define COREBOOT_LINKER \"$(shell LANG= $(LD) --version | head -n1)\"\n" >> $(obj)/build.ht
251 printf "#define COREBOOT_COMPILE_TIME \"`LANG= date +%T`\"\n" >> $(obj)/build.ht
252 printf "#define COREBOOT_COMPILE_BY \"$(subst \,@,$(shell PATH=$$PATH:/usr/ucb whoami))\"\n" >> $(obj)/build.ht
Zheng Bao86aa7c42012-09-28 16:06:44 +0800253 printf "#define COREBOOT_COMPILE_HOST \"$(shell hostname -s 2>/dev/null || hostname 2>/dev/null)\"\n" >> $(obj)/build.ht
Patrick Georgi71b84802011-02-22 14:35:05 +0000254 printf "#define COREBOOT_COMPILE_DOMAIN \"$(shell test `uname -s` = "Linux" && dnsdomainname || domainname 2>/dev/null)\"\n" >> $(obj)/build.ht
255 printf "#endif\n" >> $(obj)/build.ht
256 mv $(obj)/build.ht $(obj)/build.h
257
258$(obj)/ldoptions: $(obj)/config.h
259 awk '/^#define ([^"])* ([^"])*$$/ {gsub("\\r","",$$3); print $$2 " = " $$3 ";";}' $< > $@
260
Kyösti Mälkki0db2ae3a2012-04-19 12:00:06 +0300261build-dirs:
262 mkdir -p $(objcbfs) $(objgenerated)
263
Patrick Georgi71b84802011-02-22 14:35:05 +0000264#######################################################################
265# Build the tools
266CBFSTOOL:=$(obj)/cbfstool
Aaron Durbin3eb8eb72014-03-10 16:13:58 -0500267RMODTOOL:=$(obj)/rmodtool
Patrick Georgi71b84802011-02-22 14:35:05 +0000268
269$(CBFSTOOL): $(objutil)/cbfstool/cbfstool
270 cp $< $@
271
Aaron Durbin3eb8eb72014-03-10 16:13:58 -0500272$(RMODTOOL): $(objutil)/cbfstool/rmodtool
273 cp $< $@
274
Patrick Georgi71b84802011-02-22 14:35:05 +0000275_WINCHECK=$(shell uname -o 2> /dev/null)
276STACK=
277ifeq ($(_WINCHECK),Msys)
278 STACK=-Wl,--stack,16384000
279endif
280ifeq ($(_WINCHECK),Cygwin)
281 STACK=-Wl,--stack,16384000
282endif
283
284ROMCC:= $(objutil)/romcc/romcc
285$(ROMCC): $(top)/util/romcc/romcc.c
286 @printf " HOSTCC $(subst $(obj)/,,$(@)) (this may take a while)\n"
287 @# Note: Adding -O2 here might cause problems. For details see:
288 @# http://www.coreboot.org/pipermail/coreboot/2010-February/055825.html
289 $(HOSTCC) -g $(STACK) -Wall -o $@ $<
290
Stefan Reinauer5b635792012-08-16 14:05:42 -0700291IFDTOOL:=$(objutil)/ifdtool/ifdtool
292$(IFDTOOL): $(top)/util/ifdtool/ifdtool.c
293 @printf " HOSTCC $(subst $(obj)/,,$(@))\n"
294 $(HOSTCC) $(HOSTCFLAGS) -o $@ $<
295
Nico Hubera15cd662013-06-19 16:16:05 +0200296IFDFAKE:=$(objutil)/ifdfake/ifdfake
297$(IFDFAKE): $(top)/util/ifdfake/ifdfake.c
298 @printf " HOSTCC $(subst $(obj)/,,$(@))\n"
299 $(HOSTCC) $(HOSTCFLAGS) -o $@ $<
300
Patrick Georgi71b84802011-02-22 14:35:05 +0000301#######################################################################
302# needed objects that every mainboard uses
303# Creation of these is architecture and mainboard independent
304$(obj)/mainboard/$(MAINBOARDDIR)/static.c: $(src)/mainboard/$(MAINBOARDDIR)/devicetree.cb $(objutil)/sconfig/sconfig
305 @printf " SCONFIG $(subst $(src)/,,$(<))\n"
306 mkdir -p $(obj)/mainboard/$(MAINBOARDDIR)
307 $(objutil)/sconfig/sconfig $(MAINBOARDDIR) $(obj)/mainboard/$(MAINBOARDDIR)
308
309ramstage-y+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c
Stefan Reinauer57879c92012-07-31 16:47:25 -0700310romstage-y+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c
Patrick Georgi71b84802011-02-22 14:35:05 +0000311
312$(objutil)/%.o: $(objutil)/%.c
313 @printf " HOSTCC $(subst $(objutil)/,,$(@))\n"
314 $(HOSTCC) -MMD -I$(subst $(objutil)/,util/,$(dir $<)) -I$(dir $<) $(HOSTCFLAGS) -c -o $@ $<
315
Patrick Georgi64ccc3b82011-05-20 23:08:12 +0000316$(obj)/%.ramstage.o $(abspath $(obj))/%.ramstage.o: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H)
Patrick Georgi71b84802011-02-22 14:35:05 +0000317 @printf " CC $(subst $(obj)/,,$(@))\n"
318 $(CC) -MMD $(CFLAGS) -c -o $@ $<
319
Stefan Reinauer57879c92012-07-31 16:47:25 -0700320$(obj)/%.romstage.o $(abspath $(obj))/%.romstage.o: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H)
321 @printf " CC $(subst $(obj)/,,$(@))\n"
322 $(CC) -MMD -D__PRE_RAM__ $(CFLAGS) -c -o $@ $<
323
Hung-Te Linfe187922013-02-01 01:09:24 +0800324$(obj)/%.bootblock.o $(abspath $(obj))/%.bootblock.o: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H)
325 @printf " CC $(subst $(obj)/,,$(@))\n"
Hung-Te Lin5f83f6c2013-02-04 14:38:03 +0800326 $(CC) -MMD $(bootblock-c-ccopts) $(CFLAGS) -c -o $@ $<
Hung-Te Linfe187922013-02-01 01:09:24 +0800327
Patrick Georgi71b84802011-02-22 14:35:05 +0000328#######################################################################
329# Clean up rules
330clean-abuild:
331 rm -rf coreboot-builds
332
333clean-for-update-target:
Furquan Shaikh20f25dd2014-04-22 10:41:05 -0700334 rm -f $(obj)/ramstage* $(obj)/coreboot.romstage $(obj)/coreboot.pre* $(obj)/coreboot.bootblock $(obj)/coreboot.a
Patrick Georgi71b84802011-02-22 14:35:05 +0000335 rm -rf $(obj)/bootblock* $(obj)/romstage* $(obj)/location.*
336 rm -f $(obj)/option_table.* $(obj)/crt0.S $(obj)/ldscript
337 rm -f $(obj)/mainboard/$(MAINBOARDDIR)/static.c $(obj)/mainboard/$(MAINBOARDDIR)/config.py $(obj)/mainboard/$(MAINBOARDDIR)/static.dot
338 rm -f $(obj)/mainboard/$(MAINBOARDDIR)/crt0.s $(obj)/mainboard/$(MAINBOARDDIR)/crt0.disasm
339 rm -f $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc
340 rm -f $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.* $(obj)/mainboard/$(MAINBOARDDIR)/dsdt.*
341 rm -f $(obj)/cpu/x86/smm/smm_bin.c $(obj)/cpu/x86/smm/smm.* $(obj)/cpu/x86/smm/smm
Marc Jones1dd0dda2012-03-19 17:32:33 -0600342 $(MAKE) -C payloads/external/SeaBIOS -f Makefile.inc clean OUT=$(abspath $(obj)) HOSTCC="$(HOSTCC)" CC="$(CC)" LD="$(LD)"
Patrick Georgi71b84802011-02-22 14:35:05 +0000343
344clean-target:
345 rm -f $(obj)/coreboot*
346
347#######################################################################
348# Development utilities
349printcrt0s:
350 @echo crt0s=$(crt0s)
351 @echo ldscripts=$(ldscripts)
352
353update:
354 dongle.py -c /dev/term/1 $(obj)/coreboot.rom EOF
355
Patrick Georgicb02cb72012-02-25 19:42:59 +0100356lint lint-stable:
Zheng Bao533bca82012-09-28 19:38:37 +0800357 FAILED=0; LINTLOG=`mktemp .tmpconfig.lintXXXXX`; \
Patrick Georgicb02cb72012-02-25 19:42:59 +0100358 for script in util/lint/$@-*; do \
Patrick Georgi71b84802011-02-22 14:35:05 +0000359 echo; echo `basename $$script`; \
360 grep "^# DESCR:" $$script | sed "s,.*DESCR: *,," ; \
361 echo ========; \
362 $$script > $$LINTLOG; \
Patrick Georgic040e4762012-03-09 23:02:09 +0100363 if [ `cat $$LINTLOG | wc -l` -eq 0 ]; then \
Patrick Georgi71b84802011-02-22 14:35:05 +0000364 printf "success\n\n"; \
365 else \
366 echo test failed: ; \
367 cat $$LINTLOG; \
368 rm -f $$LINTLOG; \
369 FAILED=$$(( $$FAILED + 1 )); \
370 fi; \
371 echo ========; \
372 done; \
373 test $$FAILED -eq 0 || { echo "ERROR: $$FAILED test(s) failed." && exit 1; }; \
374 rm -f $$LINTLOG
Patrick Georgi6c445502011-05-16 15:32:28 +0000375
Patrick Georgibb605282011-06-05 15:15:49 +0200376gitconfig:
Zheng Bao50ad0952012-10-22 16:29:37 +0800377 mkdir -p .git/hooks
zbaof2c32542012-08-10 15:44:02 +0800378 for hook in commit-msg pre-commit ; do \
379 if [ util/gitconfig/$$hook -nt .git/hooks/$$hook -o \
380 ! -x .git/hooks/$$hook ]; then \
381 cp util/gitconfig/$$hook .git/hooks/$$hook; \
382 chmod +x .git/hooks/$$hook; \
383 fi; \
384 done
Ronald G. Minnich64b364d2013-01-03 08:26:09 -0800385 git config remote.origin.push HEAD:refs/for/master
Patrick Georgibb605282011-06-05 15:15:49 +0200386 (git config --global user.name >/dev/null && git config --global user.email >/dev/null) || (printf 'Please configure your name and email in git:\n\n git config --global user.name "Your Name Comes Here"\n git config --global user.email your.email@example.com\n'; exit 1)
387
Edward O'Callaghan3a722782013-11-02 03:40:39 +1100388crossgcc: crossgcc-i386 crossgcc-arm
Peter Stuge0b6b4d62011-06-09 05:06:25 +0200389
Edward O'Callaghan3a722782013-11-02 03:40:39 +1100390.PHONY: crossgcc-i386 crossgcc-arm
391crossgcc-i386: clean-for-update
392 $(MAKE) -C util/crossgcc build-i386-without-gdb
393
394crossgcc-arm: clean-for-update
395 $(MAKE) -C util/crossgcc build-armv7a-without-gdb
396
397crosstools: crosstools-i386
398
399.PHONY: crosstools-i386 crosstools-arm
400crosstools-i386: clean-for-update
401 $(MAKE) -C util/crossgcc build-i386
402
403crosstools-arm: clean-for-update
404 $(MAKE) -C util/crossgcc build-armv7a
Patrick Georgi6c445502011-05-16 15:32:28 +0000405
406crossgcc-clean: clean-for-update
407 $(MAKE) -C util/crossgcc clean
408
Aaron Durbin3eb8eb72014-03-10 16:13:58 -0500409tools: $(objutil)/kconfig/conf $(objutil)/cbfstool/cbfstool $(objutil)/cbfstool/rmodtool $(objutil)/nvramtool/nvramtool $(objutil)/romcc/romcc $(objutil)/sconfig/sconfig
Patrick Georgi43105d62011-11-05 14:44:41 +0100410