blob: 3754ab99abce6b9c675e3ce0074b551e6d981e3f [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 Georgi51e142f2010-03-27 17:18:39 +000036export src := src
Patrick Georgi0588d192009-08-12 15:00:51 +000037export srck := $(top)/util/kconfig
Patrick Georgi51e142f2010-03-27 17:18:39 +000038export obj ?= build
Patrick Georgia2acbc72010-04-16 22:48:57 +000039export objutil ?= $(obj)/util
40export objk := $(objutil)/kconfig
Patrick Georgi0588d192009-08-12 15:00:51 +000041
42
Stefan Reinauer37d8c212010-02-08 18:30:41 +000043export KERNELVERSION := 4.0
Patrick Georgi0588d192009-08-12 15:00:51 +000044export KCONFIG_AUTOHEADER := $(obj)/config.h
45export KCONFIG_AUTOCONFIG := $(obj)/auto.conf
Patrick Georgi0588d192009-08-12 15:00:51 +000046
47CONFIG_SHELL := sh
48KBUILD_DEFCONFIG := configs/defconfig
49UNAME_RELEASE := $(shell uname -r)
50HAVE_DOTCONFIG := $(wildcard .config)
51MAKEFLAGS += -rR --no-print-directory
52
53# Make is silent per default, but 'make V=1' will show all compiler calls.
Patrick Georgi2b7418e2009-08-25 19:38:46 +000054Q:=@
Patrick Georgi0588d192009-08-12 15:00:51 +000055ifneq ($(V),1)
Patrick Georgi2b7418e2009-08-25 19:38:46 +000056ifneq ($(Q),)
57.SILENT:
58endif
Patrick Georgi0588d192009-08-12 15:00:51 +000059endif
60
61CPP:= $(CC) -x assembler-with-cpp -DASSEMBLY -E
Patrick Georgia2acbc72010-04-16 22:48:57 +000062ROMCC:= $(objutil)/romcc/romcc
Patrick Georgi0588d192009-08-12 15:00:51 +000063HOSTCC = gcc
64HOSTCXX = g++
65HOSTCFLAGS := -I$(srck) -I$(objk) -g
66HOSTCXXFLAGS := -I$(srck) -I$(objk)
Stefan Reinauer68a564f2010-03-16 01:02:18 +000067LIBGCC_FILE_NAME := $(shell test -r `$(CC) -print-libgcc-file-name` && $(CC) -print-libgcc-file-name)
Patrick Georgi0588d192009-08-12 15:00:51 +000068
69DOXYGEN := doxygen
70DOXYGEN_OUTPUT_DIR := doxygen
71
Patrick Georgicf036d12010-04-21 06:36:20 +000072# Three cases where we don't need fully populated $(obj) lists:
73# 1. when no .config exists
74# 2. when make config (in any flavour) is run
75# 3. when make distclean is run
76# Don't waste time on reading all Makefile.incs in these cases
Patrick Georgi0588d192009-08-12 15:00:51 +000077ifeq ($(strip $(HAVE_DOTCONFIG)),)
Patrick Georgicf036d12010-04-21 06:36:20 +000078NOCOMPILE:=1
79endif
80ifneq ($(MAKECMDGOALS),)
81ifneq ($(filter %config distclean,$(MAKECMDGOALS)),)
82NOCOMPILE:=1
83endif
84endif
Patrick Georgi0588d192009-08-12 15:00:51 +000085
Patrick Georgicf036d12010-04-21 06:36:20 +000086ifeq ($(NOCOMPILE),1)
Patrick Georgi0588d192009-08-12 15:00:51 +000087all: config
88
89else
90
Patrick Georgi977b9852010-09-24 22:15:54 +000091include $(HAVE_DOTCONFIG)
Patrick Georgi0588d192009-08-12 15:00:51 +000092
Patrick Georgi23d89cc2010-03-16 01:17:19 +000093ifneq ($(INNER_SCANBUILD),y)
94ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y)
95CC:=clang -m32
96HOSTCC:=clang
97endif
98endif
99
Patrick Georgi516a2a72010-03-25 21:45:25 +0000100ifeq ($(CONFIG_CCACHE),y)
Patrick Georgi977b9852010-09-24 22:15:54 +0000101CCACHE:=$(wildcard $(addsuffix /ccache,$(subst :, ,$(PATH))))
Patrick Georgi516a2a72010-03-25 21:45:25 +0000102ifeq ($(CCACHE),)
103$(error ccache selected, but not found in PATH)
104endif
Patrick Georgi977b9852010-09-24 22:15:54 +0000105CCACHE:=CCACHE_COMPILERCHECK=content CCACHE_BASEDIR=$(top) $(CCACHE)
Patrick Georgi516a2a72010-03-25 21:45:25 +0000106CC := $(CCACHE) $(CC)
107HOSTCC := $(CCACHE) $(HOSTCC)
108HOSTCXX := $(CCACHE) $(HOSTCXX)
109ROMCC := $(CCACHE) $(ROMCC)
110endif
111
Patrick Georgia84e98b2010-03-16 19:01:32 +0000112strip_quotes = $(subst ",,$(subst \",,$(1)))
113
Patrick Georgi0588d192009-08-12 15:00:51 +0000114ARCHDIR-$(CONFIG_ARCH_X86) := i386
115ARCHDIR-$(CONFIG_ARCH_POWERPC) := ppc
116
Patrick Georgia84e98b2010-03-16 19:01:32 +0000117MAINBOARDDIR=$(call strip_quotes,$(CONFIG_MAINBOARD_DIR))
Patrick Georgi0588d192009-08-12 15:00:51 +0000118export MAINBOARDDIR
119
120PLATFORM-y += src/arch/$(ARCHDIR-y) src/cpu src/mainboard/$(MAINBOARDDIR)
121TARGETS-y :=
122
Stefan Reinauer859e94a2010-03-16 23:07:29 +0000123BUILD-y := src/lib src/boot src/console src/devices src/southbridge src/northbridge src/superio src/drivers
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +0000124BUILD-y += util/cbfstool util/sconfig
Patrick Georgi0588d192009-08-12 15:00:51 +0000125BUILD-$(CONFIG_ARCH_X86) += src/pc80
126
Uwe Hermannc04be932009-10-05 13:55:28 +0000127ifneq ($(CONFIG_LOCALVERSION),"")
Patrick Georgia84e98b2010-03-16 19:01:32 +0000128COREBOOT_EXTRA_VERSION := -$(call strip_quotes,$(CONFIG_LOCALVERSION))
Uwe Hermannc04be932009-10-05 13:55:28 +0000129endif
130
Patrick Georgi0588d192009-08-12 15:00:51 +0000131# The primary target needs to be here before we include the
132# other files
133
Patrick Georgi020f51f2010-03-14 21:25:03 +0000134ifeq ($(INNER_SCANBUILD),y)
135CONFIG_SCANBUILD_ENABLE:=
136endif
137
138ifeq ($(CONFIG_SCANBUILD_ENABLE),y)
139ifneq ($(CONFIG_SCANBUILD_REPORT_LOCATION),)
140CONFIG_SCANBUILD_REPORT_LOCATION:=-o $(CONFIG_SCANBUILD_REPORT_LOCATION)
141endif
142all:
143 echo '#!/bin/sh' > .ccwrap
144 echo 'CC="$(CC)"' >> .ccwrap
145 echo 'if [ "$$1" = "--hostcc" ]; then shift; CC="$(HOSTCC)"; fi' >> .ccwrap
146 echo 'if [ "$$1" = "--hostcxx" ]; then shift; CC="$(HOSTCXX)"; fi' >> .ccwrap
147 echo 'eval $$CC $$*' >> .ccwrap
148 chmod +x .ccwrap
149 scan-build $(CONFIG_SCANBUILD_REPORT_LOCATION) -analyze-headers --use-cc=$(top)/.ccwrap --use-c++=$(top)/.ccwrap $(MAKE) INNER_SCANBUILD=y
150else
Stefan Reinauere9f32582010-03-29 13:04:13 +0000151all: $(obj)/config.h coreboot
Patrick Georgi020f51f2010-03-14 21:25:03 +0000152endif
Patrick Georgi0588d192009-08-12 15:00:51 +0000153
Patrick Georgi51e142f2010-03-27 17:18:39 +0000154# must come rather early
155.SECONDEXPANSION:
156
Stefan Reinauer1425add2010-03-21 22:35:58 +0000157$(obj)/config.h:
158 $(MAKE) oldconfig
Patrick Georgi0588d192009-08-12 15:00:51 +0000159
160#######################################################################
161# Build the tools
162
Patrick Georgia2acbc72010-04-16 22:48:57 +0000163CBFSTOOL:=$(objutil)/cbfstool/cbfstool
Patrick Georgi0588d192009-08-12 15:00:51 +0000164
Stefan Reinauer14e22772010-04-27 06:56:47 +0000165# needed objects that every mainboard uses
Patrick Georgi0588d192009-08-12 15:00:51 +0000166# Creation of these is architecture and mainboard independent
Patrick Georgia2acbc72010-04-16 22:48:57 +0000167$(obj)/mainboard/$(MAINBOARDDIR)/static.c: $(src)/mainboard/$(MAINBOARDDIR)/devicetree.cb $(objutil)/sconfig/sconfig
Stefan Reinauere705f9c2010-04-08 13:16:32 +0000168 @printf " SCONFIG $(subst $(src)/,,$(<))\n"
Patrick Georgi2b7418e2009-08-25 19:38:46 +0000169 mkdir -p $(obj)/mainboard/$(MAINBOARDDIR)
Patrick Georgia2acbc72010-04-16 22:48:57 +0000170 $(objutil)/sconfig/sconfig $(MAINBOARDDIR) $(obj)/mainboard/$(MAINBOARDDIR)
Patrick Georgi0588d192009-08-12 15:00:51 +0000171
Stefan Reinauer961a7b02010-04-19 20:47:29 +0000172$(objutil)/%.o: $(objutil)/%.c
Patrick Georgi1cd76e72010-04-19 20:39:22 +0000173 @printf " HOSTCC $(subst $(objutil)/,,$(@))\n"
Patrick Georgi114e7b22010-05-05 11:19:50 +0000174 $(HOSTCC) -MMD -I$(subst $(objutil)/,util/,$(dir $<)) -I$(dir $<) $(HOSTCFLAGS) -c -o $@ $<
Patrick Georgi1cd76e72010-04-19 20:39:22 +0000175
176$(obj)/%.o: $(obj)/%.c $(obj)/config.h
177 @printf " CC $(subst $(obj)/,,$(@))\n"
178 $(CC) -MMD $(CFLAGS) -c -o $@ $<
179
Patrick Georgi0588d192009-08-12 15:00:51 +0000180objs:=$(obj)/mainboard/$(MAINBOARDDIR)/static.o
181initobjs:=
182drivers:=
183smmobjs:=
Patrick Georgi0588d192009-08-12 15:00:51 +0000184types:=obj initobj driver smmobj
Patrick Georgi47d68d82010-03-06 21:18:43 +0000185
186# Clean -y variables, include Makefile.inc
187# If $(3) is non-empty, add paths to files in X-y, and add them to Xs
188# Add subdirs-y to subdirs
189includemakefiles= \
190 $(foreach type,$(2), $(eval $(type)-y:=)) \
191 $(eval subdirs-y:=) \
192 $(eval -include $(1)) \
Patrick Georgi51e142f2010-03-27 17:18:39 +0000193 $(foreach type,$(2), \
194 $(eval $(type)s+= \
195 $$(subst $(top)/,, \
196 $$(abspath $$(patsubst src/%, \
197 $(obj)/%, \
198 $$(addprefix $(dir $(1)),$$($(type)-y))))))) \
Patrick Georgi47d68d82010-03-06 21:18:43 +0000199 $(eval subdirs+=$$(subst $(PWD)/,,$$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y)))))
200
201# For each path in $(subdirs) call includemakefiles, passing $(1) as $(3)
202# Repeat until subdirs is empty
203evaluate_subdirs= \
204 $(eval cursubdirs:=$(subdirs)) \
205 $(eval subdirs:=) \
206 $(foreach dir,$(cursubdirs), \
Patrick Georgi51e142f2010-03-27 17:18:39 +0000207 $(eval $(call includemakefiles,$(dir)/Makefile.inc,$(types)))) \
208 $(if $(subdirs),$(eval $(call evaluate_subdirs)))
Patrick Georgi0588d192009-08-12 15:00:51 +0000209
210# collect all object files eligible for building
211subdirs:=$(PLATFORM-y) $(BUILD-y)
Patrick Georgi51e142f2010-03-27 17:18:39 +0000212$(eval $(call evaluate_subdirs))
Patrick Georgi0588d192009-08-12 15:00:51 +0000213
Patrick Georgid3428b02010-02-24 13:18:01 +0000214initobjs:=$(addsuffix .initobj.o, $(basename $(initobjs)))
215drivers:=$(addsuffix .driver.o, $(basename $(drivers)))
216smmobjs:=$(addsuffix .smmobj.o, $(basename $(smmobjs)))
217
Patrick Georgi0588d192009-08-12 15:00:51 +0000218allobjs:=$(foreach var, $(addsuffix s,$(types)), $($(var)))
219alldirs:=$(sort $(abspath $(dir $(allobjs))))
220source_with_ext=$(patsubst $(obj)/%.o,src/%.$(1),$(allobjs))
221allsrc=$(wildcard $(call source_with_ext,c) $(call source_with_ext,S))
222
Patrick Georgi9ea7bff2010-02-28 18:23:00 +0000223define objs_asl_template
Patrick Georgiaf97d332010-02-08 15:46:37 +0000224$(obj)/$(1)%.o: src/$(1)%.asl
Patrick Georgi1a47b5e2010-02-10 18:53:40 +0000225 @printf " IASL $$(subst $(top)/,,$$(@))\n"
Patrick Georgi51e142f2010-03-27 17:18:39 +0000226 $(CPP) -D__ACPI__ -P -include $(abspath $(obj)/config.h) -I$(src) -I$(src)/mainboard/$(MAINBOARDDIR) $$< -o $$(basename $$@).asl
Patrick Georgiaf97d332010-02-08 15:46:37 +0000227 iasl -p $$(basename $$@) -tc $$(basename $$@).asl
228 mv $$(basename $$@).hex $$(basename $$@).c
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000229 $(CC) $$(CFLAGS) $$(if $$(subst dsdt,,$$(basename $$(notdir $$@))), -DAmlCode=AmlCode_$$(basename $$(notdir $$@))) -c -o $$@ $$(basename $$@).c
Zheng Bao12fa1592010-04-26 12:27:18 +0000230 # keep %.o: %.c rule from catching the temporary .c file after a make clean
231 mv $$(basename $$@).c $$(basename $$@).hex
Patrick Georgi88f55b22009-09-25 18:43:02 +0000232endef
233
Patrick Georgi patrick.georgic5f773d2010-03-16 12:01:13 +0000234# macro to define template macros that are used by use_template macro
235define create_cc_template
236# $1 obj class (objs, initobjs, ...)
237# $2 source suffix (c, S)
238# $3 .o infix ("" ".initobj", ...)
239# $4 additional compiler flags
240de$(EMPTY)fine $(1)_$(2)_template
Stefan Reinauere9f32582010-03-29 13:04:13 +0000241$(obj)/$$(1)%$(3).o: src/$$(1)%.$(2) $(obj)/config.h
Patrick Georgi1cd76e72010-04-19 20:39:22 +0000242 @printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n"
Stefan Reinauer6bee9512010-03-24 15:51:48 +0000243 $(CC) $(4) -MMD $$$$(CFLAGS) -c -o $$$$@ $$$$<
Patrick Georgi patrick.georgic5f773d2010-03-16 12:01:13 +0000244en$(EMPTY)def
Patrick Georgi0588d192009-08-12 15:00:51 +0000245endef
246
Patrick Georgi patrick.georgic5f773d2010-03-16 12:01:13 +0000247$(eval $(call create_cc_template,objs,c))
248$(eval $(call create_cc_template,objs,S,,-DASSEMBLY))
Stefan Reinauere9f32582010-03-29 13:04:13 +0000249$(eval $(call create_cc_template,initobjs,c,.initobj,-D__PRE_RAM__))
250$(eval $(call create_cc_template,initobjs,S,.initobj,-DASSEMBLY -D__PRE_RAM__))
Patrick Georgi patrick.georgic5f773d2010-03-16 12:01:13 +0000251$(eval $(call create_cc_template,drivers,c,.driver))
252$(eval $(call create_cc_template,drivers,S,.driver,-DASSEMBLY))
253$(eval $(call create_cc_template,smmobjs,c,.smmobj))
254$(eval $(call create_cc_template,smmobjs,S,.smmobj))
Patrick Georgi0588d192009-08-12 15:00:51 +0000255
256usetemplate=$(foreach d,$(sort $(dir $($(1)))),$(eval $(call $(1)_$(2)_template,$(subst $(obj)/,,$(d)))))
257usetemplate=$(foreach d,$(sort $(dir $($(1)))),$(eval $(call $(1)_$(2)_template,$(subst $(obj)/,,$(d)))))
Patrick Georgi9ea7bff2010-02-28 18:23:00 +0000258$(eval $(call usetemplate,objs,asl))
Patrick Georgi0588d192009-08-12 15:00:51 +0000259$(eval $(call usetemplate,objs,c))
260$(eval $(call usetemplate,objs,S))
261$(eval $(call usetemplate,initobjs,c))
262$(eval $(call usetemplate,initobjs,S))
263$(eval $(call usetemplate,drivers,c))
264$(eval $(call usetemplate,drivers,S))
265$(eval $(call usetemplate,smmobjs,c))
266$(eval $(call usetemplate,smmobjs,S))
267
Stefan Reinauer6bee9512010-03-24 15:51:48 +0000268DEPENDENCIES = $(objs:.o=.d) $(initobjs:.o=.d) $(drivers:.o=.d) $(smmobjs:.o=.d)
269-include $(DEPENDENCIES)
270
Patrick Georgi0588d192009-08-12 15:00:51 +0000271printall:
272 @echo objs:=$(objs)
273 @echo initobjs:=$(initobjs)
274 @echo drivers:=$(drivers)
275 @echo smmobjs:=$(smmobjs)
276 @echo alldirs:=$(alldirs)
277 @echo allsrc=$(allsrc)
Stefan Reinauer6bee9512010-03-24 15:51:48 +0000278 @echo DEPENDENCIES=$(DEPENDENCIES)
Stefan Reinauer68a564f2010-03-16 01:02:18 +0000279 @echo LIBGCC_FILE_NAME=$(LIBGCC_FILE_NAME)
Patrick Georgi0588d192009-08-12 15:00:51 +0000280
Patrick Georgieb49f9d2010-02-25 17:03:17 +0000281printcrt0s:
Stefan Reinaueracdd52f2010-03-30 20:32:01 +0000282 @echo crt0s=$(crt0s)
283 @echo ldscripts=$(ldscripts)
Patrick Georgieb49f9d2010-02-25 17:03:17 +0000284
Patrick Georgi0588d192009-08-12 15:00:51 +0000285OBJS := $(patsubst %,$(obj)/%,$(TARGETS-y))
Stefan Reinauer14e22772010-04-27 06:56:47 +0000286INCLUDES := -Isrc -Isrc/include -I$(obj) -Isrc/arch/$(ARCHDIR-y)/include
Patrick Georgi51e142f2010-03-27 17:18:39 +0000287INCLUDES += -Isrc/devices/oprom/include
288# abspath is a workaround for romcc
Stefan Reinauere9f32582010-03-29 13:04:13 +0000289INCLUDES += -include $(abspath $(obj)/config.h)
Patrick Georgi0588d192009-08-12 15:00:51 +0000290
Marc Jones5c312692010-09-23 15:38:55 +0000291CFLAGS = $(INCLUDES) -Os -nostdinc -pipe -g
Patrick Georgi0588d192009-08-12 15:00:51 +0000292CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
Stefan Reinauer14e22772010-04-27 06:56:47 +0000293CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs
Stefan Reinauer68a564f2010-03-16 01:02:18 +0000294CFLAGS += -Wstrict-aliasing -Wshadow
Myles Watson2e672732009-11-12 16:38:03 +0000295ifeq ($(CONFIG_WARNINGS_ARE_ERRORS),y)
296CFLAGS += -Werror
297endif
Patrick Georgi0588d192009-08-12 15:00:51 +0000298CFLAGS += -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer
299
Patrick Georgi0588d192009-08-12 15:00:51 +0000300CBFS_COMPRESS_FLAG:=l
Myles Watson422d0cb2009-09-23 17:48:28 +0000301CBFS_PAYLOAD_COMPRESS_FLAG:=
Stefan Reinauer314e5512010-04-09 20:36:29 +0000302CBFS_PAYLOAD_COMPRESS_NAME:=none
Myles Watson422d0cb2009-09-23 17:48:28 +0000303ifeq ($(CONFIG_COMPRESSED_PAYLOAD_LZMA),y)
304CBFS_PAYLOAD_COMPRESS_FLAG:=l
Stefan Reinauer314e5512010-04-09 20:36:29 +0000305CBFS_PAYLOAD_COMPRESS_NAME:=LZMA
Patrick Georgi0588d192009-08-12 15:00:51 +0000306endif
307
Patrick Georgi25fc5ff2010-04-27 09:19:47 +0000308coreboot: $(obj)/coreboot.rom
Patrick Georgi0588d192009-08-12 15:00:51 +0000309
310endif
311
Patrick Georgi25fc5ff2010-04-27 09:19:47 +0000312$(shell mkdir -p $(obj) $(objutil)/kconfig/lxdialog $(objutil)/cbfstool $(objutil)/romcc $(objutil)/options $(alldirs))
Patrick Georgi0588d192009-08-12 15:00:51 +0000313
Stefan Reinauere9f32582010-03-29 13:04:13 +0000314$(obj)/build.h: .xcompile
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000315 @printf " GEN build.h\n"
Patrick Georgicccbb892010-01-29 17:38:57 +0000316 rm -f $(obj)/build.h
Stefan Reinauerb4d3af82010-02-11 03:21:29 +0000317 printf "/* build system definitions (autogenerated) */\n" > $(obj)/build.ht
318 printf "#ifndef __BUILD_H\n" >> $(obj)/build.ht
319 printf "#define __BUILD_H\n\n" >> $(obj)/build.ht
Patrick Georgi6630ce12010-04-14 20:47:45 +0000320 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 +0000321 printf "#define COREBOOT_EXTRA_VERSION \"$(COREBOOT_EXTRA_VERSION)\"\n" >> $(obj)/build.ht
322 printf "#define COREBOOT_BUILD \"`LANG= date`\"\n" >> $(obj)/build.ht
323 printf "\n" >> $(obj)/build.ht
324 printf "#define COREBOOT_COMPILER \"$(shell LANG= $(CC) --version | head -n1)\"\n" >> $(obj)/build.ht
325 printf "#define COREBOOT_ASSEMBLER \"$(shell LANG= $(AS) --version | head -n1)\"\n" >> $(obj)/build.ht
326 printf "#define COREBOOT_LINKER \"$(shell LANG= $(LD) --version | head -n1)\"\n" >> $(obj)/build.ht
327 printf "#define COREBOOT_COMPILE_TIME \"`LANG= date +%T`\"\n" >> $(obj)/build.ht
328 printf "#define COREBOOT_COMPILE_BY \"$(subst \,@,$(shell PATH=$$PATH:/usr/ucb whoami))\"\n" >> $(obj)/build.ht
Patrick Georgi patrick.georgic5f773d2010-03-16 12:01:13 +0000329 printf "#define COREBOOT_COMPILE_HOST \"$(shell hostname -s 2>/dev/null)\"\n" >> $(obj)/build.ht
330 printf "#define COREBOOT_COMPILE_DOMAIN \"$(shell test `uname -s` = "Linux" && dnsdomainname || domainname 2>/dev/null)\"\n" >> $(obj)/build.ht
Stefan Reinauerb4d3af82010-02-11 03:21:29 +0000331 printf "#endif\n" >> $(obj)/build.ht
Patrick Georgicccbb892010-01-29 17:38:57 +0000332 mv $(obj)/build.ht $(obj)/build.h
Patrick Georgi0588d192009-08-12 15:00:51 +0000333
Warren Turkala9fc3302010-09-03 08:57:32 +0000334cscope:
335 cscope -bR
336
Patrick Georgi0588d192009-08-12 15:00:51 +0000337doxy: doxygen
338doxygen:
Stefan Reinauer1bbad5c2010-02-10 15:36:53 +0000339 $(DOXYGEN) documentation/Doxyfile.coreboot
Patrick Georgi0588d192009-08-12 15:00:51 +0000340
341doxyclean: doxygen-clean
342doxygen-clean:
Patrick Georgi2b7418e2009-08-25 19:38:46 +0000343 rm -rf $(DOXYGEN_OUTPUT_DIR)
Patrick Georgi0588d192009-08-12 15:00:51 +0000344
Patrick Georgi967952a2010-02-09 19:41:11 +0000345clean-for-update: doxygen-clean
346 rm -f $(objs) $(initobjs) $(drivers) $(smmobjs) .xcompile
Stefan Reinauer6bee9512010-03-24 15:51:48 +0000347 rm -f $(DEPENDENCIES)
Patrick Georgi967952a2010-02-09 19:41:11 +0000348 rm -f $(obj)/coreboot_ram* $(obj)/coreboot.romstage $(obj)/coreboot.pre* $(obj)/coreboot.bootblock $(obj)/coreboot.a
Patrick Georgi9341acd2009-12-23 12:52:56 +0000349 rm -rf $(obj)/bootblock* $(obj)/romstage* $(obj)/location.*
Patrick Georgie64b6372010-04-08 21:04:45 +0000350 rm -f $(obj)/option_table.* $(obj)/crt0.S $(obj)/ldscript
Patrick Georgi2b7418e2009-08-25 19:38:46 +0000351 rm -f $(obj)/mainboard/$(MAINBOARDDIR)/static.c $(obj)/mainboard/$(MAINBOARDDIR)/config.py $(obj)/mainboard/$(MAINBOARDDIR)/static.dot
Stefan Reinauerf9035dd2010-03-17 01:18:14 +0000352 rm -f $(obj)/mainboard/$(MAINBOARDDIR)/crt0.s $(obj)/mainboard/$(MAINBOARDDIR)/crt0.disasm
Stefan Reinauer6bee9512010-03-24 15:51:48 +0000353 rm -f $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc
Stefan Reinauer37e78172010-03-17 01:50:15 +0000354 rm -f $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.* $(obj)/mainboard/$(MAINBOARDDIR)/dsdt.*
355 rm -f $(obj)/cpu/x86/smm/smm_bin.c $(obj)/cpu/x86/smm/smm.* $(obj)/cpu/x86/smm/smm
Patrick Georgi2b7418e2009-08-25 19:38:46 +0000356 rmdir -p $(alldirs) 2>/dev/null >/dev/null || true
Patrick Georgi0588d192009-08-12 15:00:51 +0000357
Patrick Georgi967952a2010-02-09 19:41:11 +0000358clean: clean-for-update
Patrick Georgi020f51f2010-03-14 21:25:03 +0000359 rm -f $(obj)/coreboot* .ccwrap
Patrick Georgi967952a2010-02-09 19:41:11 +0000360
Warren Turkal0e8f2042010-09-27 21:14:19 +0000361clean-abuild:
362 rm -rf coreboot_builds
363
Warren Turkala9fc3302010-09-03 08:57:32 +0000364clean-cscope:
365 rm -f cscope.out
366
Warren Turkal0e8f2042010-09-27 21:14:19 +0000367distclean: clean-cscope clean-abuild
Myles Watson1af297c2010-01-06 16:59:18 +0000368 rm -rf $(obj)
Patrick Georgicf036d12010-04-21 06:36:20 +0000369 rm -f .config .config.old ..config.tmp .kconfig.d .tmpconfig* .ccwrap .xcompile
Patrick Georgi0588d192009-08-12 15:00:51 +0000370
371update:
Myles Watsond4e5c0a2009-10-28 15:30:11 +0000372 dongle.py -c /dev/term/1 $(obj)/coreboot.rom EOF
Patrick Georgi0588d192009-08-12 15:00:51 +0000373
374# This include must come _before_ the pattern rules below!
375# Order _does_ matter for pattern rules.
376include util/kconfig/Makefile
377
378$(obj)/ldoptions: $(obj)/config.h
Patrick Georgi26774f22009-11-21 19:54:02 +0000379 awk '/^#define ([^"])* ([^"])*$$/ {gsub("\\r","",$$3); print $$2 " = " $$3 ";";}' $< > $@
Patrick Georgi0588d192009-08-12 15:00:51 +0000380
Stefan Reinauerc53d1f32010-05-08 17:15:36 +0000381_WINCHECK=$(shell uname -o 2> /dev/null)
Patrick Georgi26774f22009-11-21 19:54:02 +0000382STACK=
Stefan Reinauerc53d1f32010-05-08 17:15:36 +0000383ifeq ($(_WINCHECK),Msys)
Patrick Georgi26774f22009-11-21 19:54:02 +0000384 STACK=-Wl,--stack,16384000
385endif
Stefan Reinauerc53d1f32010-05-08 17:15:36 +0000386ifeq ($(_WINCHECK),Cygwin)
Patrick Georgi26774f22009-11-21 19:54:02 +0000387 STACK=-Wl,--stack,16384000
388endif
Stefan Reinauerc53d1f32010-05-08 17:15:36 +0000389
Patrick Georgia2acbc72010-04-16 22:48:57 +0000390$(objutil)/romcc/romcc: $(top)/util/romcc/romcc.c
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000391 @printf " HOSTCC $(subst $(obj)/,,$(@)) (this may take a while)\n"
Uwe Hermann0dd63a22010-02-15 23:24:51 +0000392 @# Note: Adding -O2 here might cause problems. For details see:
393 @# http://www.coreboot.org/pipermail/coreboot/2010-February/055825.html
Marc Jones516255e2010-02-13 18:06:29 +0000394 $(HOSTCC) -g $(STACK) -Wall -o $@ $<
Patrick Georgi0588d192009-08-12 15:00:51 +0000395
Warren Turkal0e8f2042010-09-27 21:14:19 +0000396.PHONY: $(PHONY) clean clean-abuild clean-cscope cscope distclean doxygen doxy coreboot .xcompile
Patrick Georgi0588d192009-08-12 15:00:51 +0000397