blob: 3c97f0ed0a18cfaea5e91de2f6dd42705af59424 [file] [log] [blame]
Patrick Georgi0588d192009-08-12 15:00:51 +00001##
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>
Stefan Reinauer8ed1b6d2010-01-19 21:13:44 +00006## Copyright (C) 2009-2010 coresystems GmbH
Patrick Georgi0588d192009-08-12 15:00:51 +00007##
Stefan Reinauer16f515a2010-01-20 18:44:30 +00008## This program is free software; you can redistribute it and/or modify
9## it under the terms of the GNU General Public License as published by
10## the Free Software Foundation; version 2 of the License.
Patrick Georgi0588d192009-08-12 15:00:51 +000011##
Stefan Reinauer16f515a2010-01-20 18:44:30 +000012## This program is distributed in the hope that it will be useful,
13## but WITHOUT ANY WARRANTY; without even the implied warranty of
14## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15## GNU General Public License for more details.
16##
17## You should have received a copy of the GNU General Public License
18## along with this program; if not, write to the Free Software
19## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Patrick Georgi0588d192009-08-12 15:00:51 +000020##
21
Patrick Georgi020f51f2010-03-14 21:25:03 +000022ifeq ($(INNER_SCANBUILD),y)
23CC_real:=$(CC)
24endif
Patrick Georgi23d89cc2010-03-16 01:17:19 +000025
Patrick Georgi0588d192009-08-12 15:00:51 +000026$(if $(wildcard .xcompile),,$(eval $(shell bash util/xcompile/xcompile > .xcompile)))
27include .xcompile
Patrick Georgi23d89cc2010-03-16 01:17:19 +000028
Patrick Georgi020f51f2010-03-14 21:25:03 +000029ifeq ($(INNER_SCANBUILD),y)
30CC:=$(CC_real)
31HOSTCC:=$(CC_real) --hostcc
32HOSTCXX:=$(CC_real) --hostcxx
33endif
Patrick Georgi0588d192009-08-12 15:00:51 +000034
Patrick Georgi1a47b5e2010-02-10 18:53:40 +000035export top := $(PWD)
Patrick Georgi0588d192009-08-12 15:00:51 +000036export src := $(top)/src
37export srck := $(top)/util/kconfig
Stefan Reinauere3778572010-01-30 09:47:18 +000038export obj ?= $(top)/build
Myles Watsond4e5c0a2009-10-28 15:30:11 +000039export objk := $(obj)/util/kconfig
Patrick Georgi0588d192009-08-12 15:00:51 +000040export sconfig := $(top)/util/sconfig
41export yapps2_py := $(sconfig)/yapps2.py
42export config_g := $(sconfig)/config.g
43
44
Stefan Reinauer37d8c212010-02-08 18:30:41 +000045export KERNELVERSION := 4.0
Patrick Georgi0588d192009-08-12 15:00:51 +000046export KCONFIG_AUTOHEADER := $(obj)/config.h
47export KCONFIG_AUTOCONFIG := $(obj)/auto.conf
Patrick Georgi0588d192009-08-12 15:00:51 +000048
49CONFIG_SHELL := sh
50KBUILD_DEFCONFIG := configs/defconfig
51UNAME_RELEASE := $(shell uname -r)
52HAVE_DOTCONFIG := $(wildcard .config)
53MAKEFLAGS += -rR --no-print-directory
54
55# Make is silent per default, but 'make V=1' will show all compiler calls.
Patrick Georgi2b7418e2009-08-25 19:38:46 +000056Q:=@
Patrick Georgi0588d192009-08-12 15:00:51 +000057ifneq ($(V),1)
Patrick Georgi2b7418e2009-08-25 19:38:46 +000058ifneq ($(Q),)
59.SILENT:
60endif
Patrick Georgi0588d192009-08-12 15:00:51 +000061endif
62
63CPP:= $(CC) -x assembler-with-cpp -DASSEMBLY -E
64HOSTCC = gcc
65HOSTCXX = g++
66HOSTCFLAGS := -I$(srck) -I$(objk) -g
67HOSTCXXFLAGS := -I$(srck) -I$(objk)
Stefan Reinauer68a564f2010-03-16 01:02:18 +000068LIBGCC_FILE_NAME := $(shell test -r `$(CC) -print-libgcc-file-name` && $(CC) -print-libgcc-file-name)
Patrick Georgi0588d192009-08-12 15:00:51 +000069
70DOXYGEN := doxygen
71DOXYGEN_OUTPUT_DIR := doxygen
72
73ifeq ($(strip $(HAVE_DOTCONFIG)),)
74
75all: config
76
77else
78
79include $(top)/.config
80
Patrick Georgi23d89cc2010-03-16 01:17:19 +000081ifneq ($(INNER_SCANBUILD),y)
82ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y)
83CC:=clang -m32
84HOSTCC:=clang
85endif
86endif
87
Patrick Georgi0588d192009-08-12 15:00:51 +000088ARCHDIR-$(CONFIG_ARCH_X86) := i386
89ARCHDIR-$(CONFIG_ARCH_POWERPC) := ppc
90
Patrick Georgi1a47b5e2010-02-10 18:53:40 +000091MAINBOARDDIR=$(subst ",,$(CONFIG_MAINBOARD_DIR))
Patrick Georgi0588d192009-08-12 15:00:51 +000092export MAINBOARDDIR
93
94PLATFORM-y += src/arch/$(ARCHDIR-y) src/cpu src/mainboard/$(MAINBOARDDIR)
95TARGETS-y :=
96
97BUILD-y := src/lib src/boot src/console src/devices src/southbridge src/northbridge src/superio src/drivers util/x86emu
98BUILD-y += util/cbfstool
99BUILD-$(CONFIG_ARCH_X86) += src/pc80
100
Uwe Hermannc04be932009-10-05 13:55:28 +0000101ifneq ($(CONFIG_LOCALVERSION),"")
Patrick Georgi1a47b5e2010-02-10 18:53:40 +0000102COREBOOT_EXTRA_VERSION := -$(subst ",,$(CONFIG_LOCALVERSION))
Uwe Hermannc04be932009-10-05 13:55:28 +0000103endif
104
Patrick Georgi0588d192009-08-12 15:00:51 +0000105# The primary target needs to be here before we include the
106# other files
107
Patrick Georgi020f51f2010-03-14 21:25:03 +0000108ifeq ($(INNER_SCANBUILD),y)
109CONFIG_SCANBUILD_ENABLE:=
110endif
111
112ifeq ($(CONFIG_SCANBUILD_ENABLE),y)
113ifneq ($(CONFIG_SCANBUILD_REPORT_LOCATION),)
114CONFIG_SCANBUILD_REPORT_LOCATION:=-o $(CONFIG_SCANBUILD_REPORT_LOCATION)
115endif
116all:
117 echo '#!/bin/sh' > .ccwrap
118 echo 'CC="$(CC)"' >> .ccwrap
119 echo 'if [ "$$1" = "--hostcc" ]; then shift; CC="$(HOSTCC)"; fi' >> .ccwrap
120 echo 'if [ "$$1" = "--hostcxx" ]; then shift; CC="$(HOSTCXX)"; fi' >> .ccwrap
121 echo 'eval $$CC $$*' >> .ccwrap
122 chmod +x .ccwrap
123 scan-build $(CONFIG_SCANBUILD_REPORT_LOCATION) -analyze-headers --use-cc=$(top)/.ccwrap --use-c++=$(top)/.ccwrap $(MAKE) INNER_SCANBUILD=y
124else
Patrick Georgi0588d192009-08-12 15:00:51 +0000125all: coreboot
Patrick Georgi020f51f2010-03-14 21:25:03 +0000126endif
Patrick Georgi0588d192009-08-12 15:00:51 +0000127
128
129#######################################################################
130# Build the tools
131
132CBFSTOOL:=$(obj)/util/cbfstool/cbfstool
133
134$(obj)/mainboard/$(MAINBOARDDIR)/config.py: $(yapps2_py) $(config_g)
Patrick Georgi2b7418e2009-08-25 19:38:46 +0000135 mkdir -p $(obj)/mainboard/$(MAINBOARDDIR)
136 python $(yapps2_py) $(config_g) $(obj)/mainboard/$(MAINBOARDDIR)/config.py
Patrick Georgi0588d192009-08-12 15:00:51 +0000137
138
139# needed objects that every mainboard uses
140# Creation of these is architecture and mainboard independent
Myles Watsoned035562009-09-22 21:29:32 +0000141$(obj)/mainboard/$(MAINBOARDDIR)/static.c: $(src)/mainboard/$(MAINBOARDDIR)/devicetree.cb $(obj)/mainboard/$(MAINBOARDDIR)/config.py
Patrick Georgi2b7418e2009-08-25 19:38:46 +0000142 mkdir -p $(obj)/mainboard/$(MAINBOARDDIR)
Patrick Georgi0588d192009-08-12 15:00:51 +0000143 (cd $(obj)/mainboard/$(MAINBOARDDIR) ; PYTHONPATH=$(top)/util/sconfig export PYTHONPATH; python config.py $(MAINBOARDDIR) $(top) $(obj)/mainboard/$(MAINBOARDDIR))
144
145$(obj)/mainboard/$(MAINBOARDDIR)/static.o: $(obj)/mainboard/$(MAINBOARDDIR)/static.c
Patrick Georgi020f51f2010-03-14 21:25:03 +0000146 @printf " CC $(subst $(obj)/,,$(@))\n"
147 $(CC) $(CFLAGS) -c -o $@ $<
148
149$(obj)/arch/i386/../../option_table.o: $(obj)/arch/i386/../../option_table.c
150 @printf " CC $(subst $(obj)/,,$(@))\n"
151 $(CC) $(CFLAGS) -c -o $@ $<
Patrick Georgi0588d192009-08-12 15:00:51 +0000152
153objs:=$(obj)/mainboard/$(MAINBOARDDIR)/static.o
154initobjs:=
155drivers:=
156smmobjs:=
157crt0s:=
158ldscripts:=
159types:=obj initobj driver smmobj
Patrick Georgi47d68d82010-03-06 21:18:43 +0000160
161# Clean -y variables, include Makefile.inc
162# If $(3) is non-empty, add paths to files in X-y, and add them to Xs
163# Add subdirs-y to subdirs
164includemakefiles= \
165 $(foreach type,$(2), $(eval $(type)-y:=)) \
166 $(eval subdirs-y:=) \
167 $(eval -include $(1)) \
168 $(if $(strip $(3)), \
169 $(foreach type,$(2), \
170 $(eval $(type)s+= \
171 $$(patsubst util/%, \
172 $(obj)/util/%, \
173 $$(patsubst src/%, \
174 $(obj)/%, \
175 $$(addprefix $(dir $(1)),$$($(type)-y))))))) \
176 $(eval subdirs+=$$(subst $(PWD)/,,$$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y)))))
177
178# For each path in $(subdirs) call includemakefiles, passing $(1) as $(3)
179# Repeat until subdirs is empty
180evaluate_subdirs= \
181 $(eval cursubdirs:=$(subdirs)) \
182 $(eval subdirs:=) \
183 $(foreach dir,$(cursubdirs), \
184 $(eval $(call includemakefiles,$(dir)/Makefile.inc,$(types),$(1)))) \
185 $(if $(subdirs),$(eval $(call evaluate_subdirs, $(1))))
Patrick Georgi0588d192009-08-12 15:00:51 +0000186
187# collect all object files eligible for building
188subdirs:=$(PLATFORM-y) $(BUILD-y)
189$(eval $(call evaluate_subdirs, modify))
190
Patrick Georgid3428b02010-02-24 13:18:01 +0000191initobjs:=$(addsuffix .initobj.o, $(basename $(initobjs)))
192drivers:=$(addsuffix .driver.o, $(basename $(drivers)))
193smmobjs:=$(addsuffix .smmobj.o, $(basename $(smmobjs)))
194
Patrick Georgi0588d192009-08-12 15:00:51 +0000195allobjs:=$(foreach var, $(addsuffix s,$(types)), $($(var)))
196alldirs:=$(sort $(abspath $(dir $(allobjs))))
197source_with_ext=$(patsubst $(obj)/%.o,src/%.$(1),$(allobjs))
198allsrc=$(wildcard $(call source_with_ext,c) $(call source_with_ext,S))
199
200POST_EVALUATION:=y
201
202# fetch rules (protected in POST_EVALUATION) that rely on the variables filled above
203subdirs:=$(PLATFORM-y) $(BUILD-y)
204$(eval $(call evaluate_subdirs))
205
206
Patrick Georgi9ea7bff2010-02-28 18:23:00 +0000207define objs_asl_template
Patrick Georgiaf97d332010-02-08 15:46:37 +0000208$(obj)/$(1)%.o: src/$(1)%.asl
Patrick Georgi1a47b5e2010-02-10 18:53:40 +0000209 @printf " IASL $$(subst $(top)/,,$$(@))\n"
Patrick Georgiaf97d332010-02-08 15:46:37 +0000210 $(CPP) -D__ACPI__ -P $(CPPFLAGS) -include $(obj)/config.h -I$(src) -I$(src)/mainboard/$(MAINBOARDDIR) $$< -o $$(basename $$@).asl
211 iasl -p $$(basename $$@) -tc $$(basename $$@).asl
212 mv $$(basename $$@).hex $$(basename $$@).c
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000213 $(CC) $$(CFLAGS) $$(if $$(subst dsdt,,$$(basename $$(notdir $$@))), -DAmlCode=AmlCode_$$(basename $$(notdir $$@))) -c -o $$@ $$(basename $$@).c
Patrick Georgi88f55b22009-09-25 18:43:02 +0000214endef
215
Patrick Georgi0588d192009-08-12 15:00:51 +0000216define objs_c_template
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000217$(obj)/$(1)%.o: $(1)%.c $(obj)/config.h
218 @printf " CC $$(subst $$(obj)/,,$$(@))\n"
219 $(CC) $$(CFLAGS) -c -o $$@ $$<
220
Stefan Reinauerb4d3af82010-02-11 03:21:29 +0000221$(obj)/$(1)%.o: src/$(1)%.c $(obj)/config.h
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000222 @printf " CC $$(subst $$(obj)/,,$$(@))\n"
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000223 $(CC) $$(CFLAGS) -c -o $$@ $$<
Patrick Georgi0588d192009-08-12 15:00:51 +0000224endef
225
226define objs_S_template
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000227$(obj)/$(1)%.o: $(1)%.S $(obj)/config.h
228 @printf " CC $$(subst $$(obj)/,,$$(@))\n"
229 $(CC) -DASSEMBLY $$(CFLAGS) -c -o $$@ $$<
230
Stefan Reinauerb4d3af82010-02-11 03:21:29 +0000231$(obj)/$(1)%.o: src/$(1)%.S $(obj)/config.h
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000232 @printf " CC $$(subst $$(obj)/,,$$(@))\n"
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000233 $(CC) -DASSEMBLY $$(CFLAGS) -c -o $$@ $$<
Patrick Georgi0588d192009-08-12 15:00:51 +0000234endef
235
236define initobjs_c_template
Patrick Georgid3428b02010-02-24 13:18:01 +0000237$(obj)/$(1)%.initobj.o: src/$(1)%.c $(obj)/config.h
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000238 @printf " CC $$(subst $$(obj)/,,$$(@))\n"
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000239 $(CC) $$(CFLAGS) -c -o $$@ $$<
Patrick Georgi0588d192009-08-12 15:00:51 +0000240endef
241
242define initobjs_S_template
Patrick Georgid3428b02010-02-24 13:18:01 +0000243$(obj)/$(1)%.initobj.o: src/$(1)%.S $(obj)/config.h
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000244 @printf " CC $$(subst $$(obj)/,,$$(@))\n"
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000245 $(CC) -DASSEMBLY $$(CFLAGS) -c -o $$@ $$<
Patrick Georgi0588d192009-08-12 15:00:51 +0000246endef
247
248define drivers_c_template
Patrick Georgid3428b02010-02-24 13:18:01 +0000249$(obj)/$(1)%.driver.o: src/$(1)%.c $(obj)/config.h
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000250 @printf " CC $$(subst $$(obj)/,,$$(@))\n"
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000251 $(CC) $$(CFLAGS) -c -o $$@ $$<
Patrick Georgi0588d192009-08-12 15:00:51 +0000252endef
253
254define drivers_S_template
Patrick Georgid3428b02010-02-24 13:18:01 +0000255$(obj)/$(1)%.driver.o: src/$(1)%.S
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000256 @printf " CC $$(subst $$(obj)/,,$$(@))\n"
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000257 $(CC) -DASSEMBLY $$(CFLAGS) -c -o $$@ $$<
Patrick Georgi0588d192009-08-12 15:00:51 +0000258endef
259
260define smmobjs_c_template
Patrick Georgid3428b02010-02-24 13:18:01 +0000261$(obj)/$(1)%.smmobj.o: src/$(1)%.c
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000262 @printf " CC $$(subst $$(obj)/,,$$(@))\n"
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000263 $(CC) $$(CFLAGS) -c -o $$@ $$<
Patrick Georgi0588d192009-08-12 15:00:51 +0000264endef
265
266define smmobjs_S_template
Patrick Georgid3428b02010-02-24 13:18:01 +0000267$(obj)/$(1)%.smmobj.o: src/$(1)%.S
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000268 @printf " CC $$(subst $$(obj)/,,$$(@))\n"
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000269 $(CC) $$(CFLAGS) -c -o $$@ $$<
Patrick Georgi0588d192009-08-12 15:00:51 +0000270endef
271
272usetemplate=$(foreach d,$(sort $(dir $($(1)))),$(eval $(call $(1)_$(2)_template,$(subst $(obj)/,,$(d)))))
273usetemplate=$(foreach d,$(sort $(dir $($(1)))),$(eval $(call $(1)_$(2)_template,$(subst $(obj)/,,$(d)))))
Patrick Georgi9ea7bff2010-02-28 18:23:00 +0000274$(eval $(call usetemplate,objs,asl))
Patrick Georgi0588d192009-08-12 15:00:51 +0000275$(eval $(call usetemplate,objs,c))
276$(eval $(call usetemplate,objs,S))
277$(eval $(call usetemplate,initobjs,c))
278$(eval $(call usetemplate,initobjs,S))
279$(eval $(call usetemplate,drivers,c))
280$(eval $(call usetemplate,drivers,S))
281$(eval $(call usetemplate,smmobjs,c))
282$(eval $(call usetemplate,smmobjs,S))
283
284printall:
285 @echo objs:=$(objs)
286 @echo initobjs:=$(initobjs)
287 @echo drivers:=$(drivers)
288 @echo smmobjs:=$(smmobjs)
289 @echo alldirs:=$(alldirs)
290 @echo allsrc=$(allsrc)
Stefan Reinauer68a564f2010-03-16 01:02:18 +0000291 @echo LIBGCC_FILE_NAME=$(LIBGCC_FILE_NAME)
Patrick Georgi0588d192009-08-12 15:00:51 +0000292
Patrick Georgieb49f9d2010-02-25 17:03:17 +0000293printcrt0s:
294 @echo $(patsubst $(top)/%,%,$(crt0s))
295
Patrick Georgi0588d192009-08-12 15:00:51 +0000296OBJS := $(patsubst %,$(obj)/%,$(TARGETS-y))
297INCLUDES := -I$(top)/src -I$(top)/src/include -I$(obj) -I$(top)/src/arch/$(ARCHDIR-y)/include
Myles Watsone6804952009-08-28 14:36:12 +0000298INCLUDES += -I$(top)/util/x86emu/include
Stefan Reinauerb4d3af82010-02-11 03:21:29 +0000299INCLUDES += -include $(obj)/config.h
Patrick Georgi0588d192009-08-12 15:00:51 +0000300
Patrick Georgie82f4752010-02-10 20:31:38 +0000301CFLAGS = $(INCLUDES) -Os -nostdinc
Patrick Georgi0588d192009-08-12 15:00:51 +0000302CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
Uwe Hermannc04be932009-10-05 13:55:28 +0000303CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs
Stefan Reinauer68a564f2010-03-16 01:02:18 +0000304CFLAGS += -Wstrict-aliasing -Wshadow
Myles Watson2e672732009-11-12 16:38:03 +0000305ifeq ($(CONFIG_WARNINGS_ARE_ERRORS),y)
306CFLAGS += -Werror
307endif
Patrick Georgi0588d192009-08-12 15:00:51 +0000308CFLAGS += -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer
309
Patrick Georgi0588d192009-08-12 15:00:51 +0000310CBFS_COMPRESS_FLAG:=l
Myles Watson422d0cb2009-09-23 17:48:28 +0000311CBFS_PAYLOAD_COMPRESS_FLAG:=
312ifeq ($(CONFIG_COMPRESSED_PAYLOAD_LZMA),y)
313CBFS_PAYLOAD_COMPRESS_FLAG:=l
Patrick Georgi0588d192009-08-12 15:00:51 +0000314endif
315
Stefan Reinauerc0fbbd02010-03-15 13:35:19 +0000316coreboot: prepare $(obj)/coreboot.rom
Patrick Georgi0588d192009-08-12 15:00:51 +0000317
318endif
319
320prepare:
Patrick Georgi2b7418e2009-08-25 19:38:46 +0000321 mkdir -p $(obj)
Patrick Georgi7faf22f2010-02-10 18:50:36 +0000322 mkdir -p $(obj)/util/kconfig/lxdialog $(obj)/util/cbfstool
Patrick Georgi2b7418e2009-08-25 19:38:46 +0000323 test -n "$(alldirs)" && mkdir -p $(alldirs) || true
Patrick Georgi0588d192009-08-12 15:00:51 +0000324
Stefan Reinauerc0fbbd02010-03-15 13:35:19 +0000325$(obj)/build.h: .xcompile
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000326 @printf " GEN build.h\n"
Patrick Georgicccbb892010-01-29 17:38:57 +0000327 rm -f $(obj)/build.h
Stefan Reinauerb4d3af82010-02-11 03:21:29 +0000328 printf "/* build system definitions (autogenerated) */\n" > $(obj)/build.ht
329 printf "#ifndef __BUILD_H\n" >> $(obj)/build.ht
330 printf "#define __BUILD_H\n\n" >> $(obj)/build.ht
Zheng Baob7bc3f32010-02-23 10:33:25 +0000331 printf "#define COREBOOT_VERSION \"$(KERNELVERSION)-r$(shell if [ -d $(top)/.svn -a -f `which svnversion` ]; then svnversion $(top); else if [ -d $(top)/.git -a -f `which git` ]; then git --git-dir=/$(top)/.git log|grep git-svn-id|cut -f 2 -d@|cut -f 1 -d' '|sort -g|tail -1; fi; fi)\"\n" >> $(obj)/build.ht
Patrick Georgicccbb892010-01-29 17:38:57 +0000332 printf "#define COREBOOT_EXTRA_VERSION \"$(COREBOOT_EXTRA_VERSION)\"\n" >> $(obj)/build.ht
333 printf "#define COREBOOT_BUILD \"`LANG= date`\"\n" >> $(obj)/build.ht
334 printf "\n" >> $(obj)/build.ht
335 printf "#define COREBOOT_COMPILER \"$(shell LANG= $(CC) --version | head -n1)\"\n" >> $(obj)/build.ht
336 printf "#define COREBOOT_ASSEMBLER \"$(shell LANG= $(AS) --version | head -n1)\"\n" >> $(obj)/build.ht
337 printf "#define COREBOOT_LINKER \"$(shell LANG= $(LD) --version | head -n1)\"\n" >> $(obj)/build.ht
338 printf "#define COREBOOT_COMPILE_TIME \"`LANG= date +%T`\"\n" >> $(obj)/build.ht
339 printf "#define COREBOOT_COMPILE_BY \"$(subst \,@,$(shell PATH=$$PATH:/usr/ucb whoami))\"\n" >> $(obj)/build.ht
Stefan Reinauere3778572010-01-30 09:47:18 +0000340 printf "#define COREBOOT_COMPILE_HOST \"$(shell hostname -s)\"\n" >> $(obj)/build.ht
Patrick Georgicccbb892010-01-29 17:38:57 +0000341 printf "#define COREBOOT_COMPILE_DOMAIN \"$(shell test `uname -s` = "Linux" && dnsdomainname || domainname)\"\n" >> $(obj)/build.ht
Stefan Reinauerb4d3af82010-02-11 03:21:29 +0000342 printf "#endif\n" >> $(obj)/build.ht
Patrick Georgicccbb892010-01-29 17:38:57 +0000343 mv $(obj)/build.ht $(obj)/build.h
Patrick Georgi0588d192009-08-12 15:00:51 +0000344
345doxy: doxygen
346doxygen:
Stefan Reinauer1bbad5c2010-02-10 15:36:53 +0000347 $(DOXYGEN) documentation/Doxyfile.coreboot
Patrick Georgi0588d192009-08-12 15:00:51 +0000348
349doxyclean: doxygen-clean
350doxygen-clean:
Patrick Georgi2b7418e2009-08-25 19:38:46 +0000351 rm -rf $(DOXYGEN_OUTPUT_DIR)
Patrick Georgi0588d192009-08-12 15:00:51 +0000352
Patrick Georgi967952a2010-02-09 19:41:11 +0000353clean-for-update: doxygen-clean
354 rm -f $(objs) $(initobjs) $(drivers) $(smmobjs) .xcompile
355 rm -f $(obj)/coreboot_ram* $(obj)/coreboot.romstage $(obj)/coreboot.pre* $(obj)/coreboot.bootblock $(obj)/coreboot.a
Patrick Georgi9341acd2009-12-23 12:52:56 +0000356 rm -rf $(obj)/bootblock* $(obj)/romstage* $(obj)/location.*
Patrick Georgi97fc40b2010-02-11 12:12:19 +0000357 rm -f $(obj)/option_table.* $(obj)/crt0_includes.h $(obj)/ldscript
Patrick Georgi2b7418e2009-08-25 19:38:46 +0000358 rm -f $(obj)/mainboard/$(MAINBOARDDIR)/static.c $(obj)/mainboard/$(MAINBOARDDIR)/config.py $(obj)/mainboard/$(MAINBOARDDIR)/static.dot
359 rm -f $(obj)/mainboard/$(MAINBOARDDIR)/auto.inc $(obj)/mainboard/$(MAINBOARDDIR)/crt0.s $(obj)/mainboard/$(MAINBOARDDIR)/crt0.disasm
360 rmdir -p $(alldirs) 2>/dev/null >/dev/null || true
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000361 $(MAKE) -C util/sconfig clean
Patrick Georgi0588d192009-08-12 15:00:51 +0000362
Patrick Georgi967952a2010-02-09 19:41:11 +0000363clean: clean-for-update
Patrick Georgi020f51f2010-03-14 21:25:03 +0000364 rm -f $(obj)/coreboot* .ccwrap
Patrick Georgi967952a2010-02-09 19:41:11 +0000365
Patrick Georgi0588d192009-08-12 15:00:51 +0000366distclean: clean
Myles Watson1af297c2010-01-06 16:59:18 +0000367 rm -rf $(obj)
Patrick Georgi2b7418e2009-08-25 19:38:46 +0000368 rm -f .config .config.old ..config.tmp .kconfig.d .tmpconfig*
Patrick Georgi0588d192009-08-12 15:00:51 +0000369
370update:
Myles Watsond4e5c0a2009-10-28 15:30:11 +0000371 dongle.py -c /dev/term/1 $(obj)/coreboot.rom EOF
Patrick Georgi0588d192009-08-12 15:00:51 +0000372
373# This include must come _before_ the pattern rules below!
374# Order _does_ matter for pattern rules.
375include util/kconfig/Makefile
376
377$(obj)/ldoptions: $(obj)/config.h
Patrick Georgi26774f22009-11-21 19:54:02 +0000378 awk '/^#define ([^"])* ([^"])*$$/ {gsub("\\r","",$$3); print $$2 " = " $$3 ";";}' $< > $@
Patrick Georgi0588d192009-08-12 15:00:51 +0000379
Patrick Georgi26774f22009-11-21 19:54:02 +0000380_OS=$(shell uname -s |cut -c-7)
381STACK=
382ifeq ($(_OS),MINGW32)
383 STACK=-Wl,--stack,16384000
384endif
385ifeq ($(_OS),CYGWIN_)
386 STACK=-Wl,--stack,16384000
387endif
Patrick Georgi0588d192009-08-12 15:00:51 +0000388$(obj)/romcc: $(top)/util/romcc/romcc.c
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000389 @printf " HOSTCC $(subst $(obj)/,,$(@)) (this may take a while)\n"
Uwe Hermann0dd63a22010-02-15 23:24:51 +0000390 @# Note: Adding -O2 here might cause problems. For details see:
391 @# http://www.coreboot.org/pipermail/coreboot/2010-February/055825.html
Marc Jones516255e2010-02-13 18:06:29 +0000392 $(HOSTCC) -g $(STACK) -Wall -o $@ $<
Patrick Georgi0588d192009-08-12 15:00:51 +0000393
Stefan Reinauerc0fbbd02010-03-15 13:35:19 +0000394.PHONY: $(PHONY) prepare clean distclean doxygen doxy coreboot .xcompile
Patrick Georgi0588d192009-08-12 15:00:51 +0000395