blob: cb556e7f1ddcba6afe9af83d076f94934a09a0f2 [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 Georgi0588d192009-08-12 15:00:51 +000025$(if $(wildcard .xcompile),,$(eval $(shell bash util/xcompile/xcompile > .xcompile)))
26include .xcompile
Patrick Georgi020f51f2010-03-14 21:25:03 +000027ifeq ($(INNER_SCANBUILD),y)
28CC:=$(CC_real)
29HOSTCC:=$(CC_real) --hostcc
30HOSTCXX:=$(CC_real) --hostcxx
31endif
Patrick Georgi0588d192009-08-12 15:00:51 +000032
Patrick Georgi1a47b5e2010-02-10 18:53:40 +000033export top := $(PWD)
Patrick Georgi0588d192009-08-12 15:00:51 +000034export src := $(top)/src
35export srck := $(top)/util/kconfig
Stefan Reinauere3778572010-01-30 09:47:18 +000036export obj ?= $(top)/build
Myles Watsond4e5c0a2009-10-28 15:30:11 +000037export objk := $(obj)/util/kconfig
Patrick Georgi0588d192009-08-12 15:00:51 +000038export sconfig := $(top)/util/sconfig
39export yapps2_py := $(sconfig)/yapps2.py
40export config_g := $(sconfig)/config.g
41
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
62HOSTCC = gcc
63HOSTCXX = g++
64HOSTCFLAGS := -I$(srck) -I$(objk) -g
65HOSTCXXFLAGS := -I$(srck) -I$(objk)
Harald Gutmanndc4bb0d2009-08-26 15:35:36 +000066LIBGCC_FILE_NAME := $(shell $(CC) -print-libgcc-file-name)
Patrick Georgi0588d192009-08-12 15:00:51 +000067
68DESTDIR = /opt
69
70DOXYGEN := doxygen
71DOXYGEN_OUTPUT_DIR := doxygen
72
73ifeq ($(strip $(HAVE_DOTCONFIG)),)
74
75all: config
76
77else
78
79include $(top)/.config
80
81ARCHDIR-$(CONFIG_ARCH_X86) := i386
82ARCHDIR-$(CONFIG_ARCH_POWERPC) := ppc
83
Patrick Georgi1a47b5e2010-02-10 18:53:40 +000084MAINBOARDDIR=$(subst ",,$(CONFIG_MAINBOARD_DIR))
Patrick Georgi0588d192009-08-12 15:00:51 +000085export MAINBOARDDIR
86
87PLATFORM-y += src/arch/$(ARCHDIR-y) src/cpu src/mainboard/$(MAINBOARDDIR)
88TARGETS-y :=
89
90BUILD-y := src/lib src/boot src/console src/devices src/southbridge src/northbridge src/superio src/drivers util/x86emu
91BUILD-y += util/cbfstool
92BUILD-$(CONFIG_ARCH_X86) += src/pc80
93
Uwe Hermannc04be932009-10-05 13:55:28 +000094ifneq ($(CONFIG_LOCALVERSION),"")
Patrick Georgi1a47b5e2010-02-10 18:53:40 +000095COREBOOT_EXTRA_VERSION := -$(subst ",,$(CONFIG_LOCALVERSION))
Uwe Hermannc04be932009-10-05 13:55:28 +000096endif
97
Patrick Georgi0588d192009-08-12 15:00:51 +000098# The primary target needs to be here before we include the
99# other files
100
Patrick Georgi020f51f2010-03-14 21:25:03 +0000101ifeq ($(INNER_SCANBUILD),y)
102CONFIG_SCANBUILD_ENABLE:=
103endif
104
105ifeq ($(CONFIG_SCANBUILD_ENABLE),y)
106ifneq ($(CONFIG_SCANBUILD_REPORT_LOCATION),)
107CONFIG_SCANBUILD_REPORT_LOCATION:=-o $(CONFIG_SCANBUILD_REPORT_LOCATION)
108endif
109all:
110 echo '#!/bin/sh' > .ccwrap
111 echo 'CC="$(CC)"' >> .ccwrap
112 echo 'if [ "$$1" = "--hostcc" ]; then shift; CC="$(HOSTCC)"; fi' >> .ccwrap
113 echo 'if [ "$$1" = "--hostcxx" ]; then shift; CC="$(HOSTCXX)"; fi' >> .ccwrap
114 echo 'eval $$CC $$*' >> .ccwrap
115 chmod +x .ccwrap
116 scan-build $(CONFIG_SCANBUILD_REPORT_LOCATION) -analyze-headers --use-cc=$(top)/.ccwrap --use-c++=$(top)/.ccwrap $(MAKE) INNER_SCANBUILD=y
117else
Patrick Georgi0588d192009-08-12 15:00:51 +0000118all: coreboot
Patrick Georgi020f51f2010-03-14 21:25:03 +0000119endif
Patrick Georgi0588d192009-08-12 15:00:51 +0000120
121
122#######################################################################
123# Build the tools
124
125CBFSTOOL:=$(obj)/util/cbfstool/cbfstool
126
127$(obj)/mainboard/$(MAINBOARDDIR)/config.py: $(yapps2_py) $(config_g)
Patrick Georgi2b7418e2009-08-25 19:38:46 +0000128 mkdir -p $(obj)/mainboard/$(MAINBOARDDIR)
129 python $(yapps2_py) $(config_g) $(obj)/mainboard/$(MAINBOARDDIR)/config.py
Patrick Georgi0588d192009-08-12 15:00:51 +0000130
131
132# needed objects that every mainboard uses
133# Creation of these is architecture and mainboard independent
Myles Watsoned035562009-09-22 21:29:32 +0000134$(obj)/mainboard/$(MAINBOARDDIR)/static.c: $(src)/mainboard/$(MAINBOARDDIR)/devicetree.cb $(obj)/mainboard/$(MAINBOARDDIR)/config.py
Patrick Georgi2b7418e2009-08-25 19:38:46 +0000135 mkdir -p $(obj)/mainboard/$(MAINBOARDDIR)
Patrick Georgi0588d192009-08-12 15:00:51 +0000136 (cd $(obj)/mainboard/$(MAINBOARDDIR) ; PYTHONPATH=$(top)/util/sconfig export PYTHONPATH; python config.py $(MAINBOARDDIR) $(top) $(obj)/mainboard/$(MAINBOARDDIR))
137
138$(obj)/mainboard/$(MAINBOARDDIR)/static.o: $(obj)/mainboard/$(MAINBOARDDIR)/static.c
Patrick Georgi020f51f2010-03-14 21:25:03 +0000139 @printf " CC $(subst $(obj)/,,$(@))\n"
140 $(CC) $(CFLAGS) -c -o $@ $<
141
142$(obj)/arch/i386/../../option_table.o: $(obj)/arch/i386/../../option_table.c
143 @printf " CC $(subst $(obj)/,,$(@))\n"
144 $(CC) $(CFLAGS) -c -o $@ $<
Patrick Georgi0588d192009-08-12 15:00:51 +0000145
146objs:=$(obj)/mainboard/$(MAINBOARDDIR)/static.o
147initobjs:=
148drivers:=
149smmobjs:=
150crt0s:=
151ldscripts:=
152types:=obj initobj driver smmobj
Patrick Georgi47d68d82010-03-06 21:18:43 +0000153
154# Clean -y variables, include Makefile.inc
155# If $(3) is non-empty, add paths to files in X-y, and add them to Xs
156# Add subdirs-y to subdirs
157includemakefiles= \
158 $(foreach type,$(2), $(eval $(type)-y:=)) \
159 $(eval subdirs-y:=) \
160 $(eval -include $(1)) \
161 $(if $(strip $(3)), \
162 $(foreach type,$(2), \
163 $(eval $(type)s+= \
164 $$(patsubst util/%, \
165 $(obj)/util/%, \
166 $$(patsubst src/%, \
167 $(obj)/%, \
168 $$(addprefix $(dir $(1)),$$($(type)-y))))))) \
169 $(eval subdirs+=$$(subst $(PWD)/,,$$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y)))))
170
171# For each path in $(subdirs) call includemakefiles, passing $(1) as $(3)
172# Repeat until subdirs is empty
173evaluate_subdirs= \
174 $(eval cursubdirs:=$(subdirs)) \
175 $(eval subdirs:=) \
176 $(foreach dir,$(cursubdirs), \
177 $(eval $(call includemakefiles,$(dir)/Makefile.inc,$(types),$(1)))) \
178 $(if $(subdirs),$(eval $(call evaluate_subdirs, $(1))))
Patrick Georgi0588d192009-08-12 15:00:51 +0000179
180# collect all object files eligible for building
181subdirs:=$(PLATFORM-y) $(BUILD-y)
182$(eval $(call evaluate_subdirs, modify))
183
Patrick Georgid3428b02010-02-24 13:18:01 +0000184initobjs:=$(addsuffix .initobj.o, $(basename $(initobjs)))
185drivers:=$(addsuffix .driver.o, $(basename $(drivers)))
186smmobjs:=$(addsuffix .smmobj.o, $(basename $(smmobjs)))
187
Patrick Georgi0588d192009-08-12 15:00:51 +0000188allobjs:=$(foreach var, $(addsuffix s,$(types)), $($(var)))
189alldirs:=$(sort $(abspath $(dir $(allobjs))))
190source_with_ext=$(patsubst $(obj)/%.o,src/%.$(1),$(allobjs))
191allsrc=$(wildcard $(call source_with_ext,c) $(call source_with_ext,S))
192
193POST_EVALUATION:=y
194
195# fetch rules (protected in POST_EVALUATION) that rely on the variables filled above
196subdirs:=$(PLATFORM-y) $(BUILD-y)
197$(eval $(call evaluate_subdirs))
198
199
Patrick Georgi9ea7bff2010-02-28 18:23:00 +0000200define objs_asl_template
Patrick Georgiaf97d332010-02-08 15:46:37 +0000201$(obj)/$(1)%.o: src/$(1)%.asl
Patrick Georgi1a47b5e2010-02-10 18:53:40 +0000202 @printf " IASL $$(subst $(top)/,,$$(@))\n"
Patrick Georgiaf97d332010-02-08 15:46:37 +0000203 $(CPP) -D__ACPI__ -P $(CPPFLAGS) -include $(obj)/config.h -I$(src) -I$(src)/mainboard/$(MAINBOARDDIR) $$< -o $$(basename $$@).asl
204 iasl -p $$(basename $$@) -tc $$(basename $$@).asl
205 mv $$(basename $$@).hex $$(basename $$@).c
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000206 $(CC) $$(CFLAGS) $$(if $$(subst dsdt,,$$(basename $$(notdir $$@))), -DAmlCode=AmlCode_$$(basename $$(notdir $$@))) -c -o $$@ $$(basename $$@).c
Patrick Georgi88f55b22009-09-25 18:43:02 +0000207endef
208
Patrick Georgi0588d192009-08-12 15:00:51 +0000209define objs_c_template
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000210$(obj)/$(1)%.o: $(1)%.c $(obj)/config.h
211 @printf " CC $$(subst $$(obj)/,,$$(@))\n"
212 $(CC) $$(CFLAGS) -c -o $$@ $$<
213
Stefan Reinauerb4d3af82010-02-11 03:21:29 +0000214$(obj)/$(1)%.o: src/$(1)%.c $(obj)/config.h
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000215 @printf " CC $$(subst $$(obj)/,,$$(@))\n"
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000216 $(CC) $$(CFLAGS) -c -o $$@ $$<
Patrick Georgi0588d192009-08-12 15:00:51 +0000217endef
218
219define objs_S_template
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000220$(obj)/$(1)%.o: $(1)%.S $(obj)/config.h
221 @printf " CC $$(subst $$(obj)/,,$$(@))\n"
222 $(CC) -DASSEMBLY $$(CFLAGS) -c -o $$@ $$<
223
Stefan Reinauerb4d3af82010-02-11 03:21:29 +0000224$(obj)/$(1)%.o: src/$(1)%.S $(obj)/config.h
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000225 @printf " CC $$(subst $$(obj)/,,$$(@))\n"
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000226 $(CC) -DASSEMBLY $$(CFLAGS) -c -o $$@ $$<
Patrick Georgi0588d192009-08-12 15:00:51 +0000227endef
228
229define initobjs_c_template
Patrick Georgid3428b02010-02-24 13:18:01 +0000230$(obj)/$(1)%.initobj.o: src/$(1)%.c $(obj)/config.h
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000231 @printf " CC $$(subst $$(obj)/,,$$(@))\n"
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000232 $(CC) $$(CFLAGS) -c -o $$@ $$<
Patrick Georgi0588d192009-08-12 15:00:51 +0000233endef
234
235define initobjs_S_template
Patrick Georgid3428b02010-02-24 13:18:01 +0000236$(obj)/$(1)%.initobj.o: src/$(1)%.S $(obj)/config.h
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000237 @printf " CC $$(subst $$(obj)/,,$$(@))\n"
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000238 $(CC) -DASSEMBLY $$(CFLAGS) -c -o $$@ $$<
Patrick Georgi0588d192009-08-12 15:00:51 +0000239endef
240
241define drivers_c_template
Patrick Georgid3428b02010-02-24 13:18:01 +0000242$(obj)/$(1)%.driver.o: src/$(1)%.c $(obj)/config.h
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000243 @printf " CC $$(subst $$(obj)/,,$$(@))\n"
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000244 $(CC) $$(CFLAGS) -c -o $$@ $$<
Patrick Georgi0588d192009-08-12 15:00:51 +0000245endef
246
247define drivers_S_template
Patrick Georgid3428b02010-02-24 13:18:01 +0000248$(obj)/$(1)%.driver.o: src/$(1)%.S
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000249 @printf " CC $$(subst $$(obj)/,,$$(@))\n"
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000250 $(CC) -DASSEMBLY $$(CFLAGS) -c -o $$@ $$<
Patrick Georgi0588d192009-08-12 15:00:51 +0000251endef
252
253define smmobjs_c_template
Patrick Georgid3428b02010-02-24 13:18:01 +0000254$(obj)/$(1)%.smmobj.o: src/$(1)%.c
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000255 @printf " CC $$(subst $$(obj)/,,$$(@))\n"
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000256 $(CC) $$(CFLAGS) -c -o $$@ $$<
Patrick Georgi0588d192009-08-12 15:00:51 +0000257endef
258
259define smmobjs_S_template
Patrick Georgid3428b02010-02-24 13:18:01 +0000260$(obj)/$(1)%.smmobj.o: src/$(1)%.S
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000261 @printf " CC $$(subst $$(obj)/,,$$(@))\n"
Stefan Reinauerae22bcd2010-03-05 10:20:28 +0000262 $(CC) $$(CFLAGS) -c -o $$@ $$<
Patrick Georgi0588d192009-08-12 15:00:51 +0000263endef
264
265usetemplate=$(foreach d,$(sort $(dir $($(1)))),$(eval $(call $(1)_$(2)_template,$(subst $(obj)/,,$(d)))))
266usetemplate=$(foreach d,$(sort $(dir $($(1)))),$(eval $(call $(1)_$(2)_template,$(subst $(obj)/,,$(d)))))
Patrick Georgi9ea7bff2010-02-28 18:23:00 +0000267$(eval $(call usetemplate,objs,asl))
Patrick Georgi0588d192009-08-12 15:00:51 +0000268$(eval $(call usetemplate,objs,c))
269$(eval $(call usetemplate,objs,S))
270$(eval $(call usetemplate,initobjs,c))
271$(eval $(call usetemplate,initobjs,S))
272$(eval $(call usetemplate,drivers,c))
273$(eval $(call usetemplate,drivers,S))
274$(eval $(call usetemplate,smmobjs,c))
275$(eval $(call usetemplate,smmobjs,S))
276
277printall:
278 @echo objs:=$(objs)
279 @echo initobjs:=$(initobjs)
280 @echo drivers:=$(drivers)
281 @echo smmobjs:=$(smmobjs)
282 @echo alldirs:=$(alldirs)
283 @echo allsrc=$(allsrc)
284
Patrick Georgieb49f9d2010-02-25 17:03:17 +0000285printcrt0s:
286 @echo $(patsubst $(top)/%,%,$(crt0s))
287
Patrick Georgi0588d192009-08-12 15:00:51 +0000288OBJS := $(patsubst %,$(obj)/%,$(TARGETS-y))
289INCLUDES := -I$(top)/src -I$(top)/src/include -I$(obj) -I$(top)/src/arch/$(ARCHDIR-y)/include
290INCLUDES += -I$(shell $(CC) -print-search-dirs | head -n 1 | cut -d' ' -f2)include
Myles Watsone6804952009-08-28 14:36:12 +0000291INCLUDES += -I$(top)/util/x86emu/include
Stefan Reinauerb4d3af82010-02-11 03:21:29 +0000292INCLUDES += -include $(obj)/config.h
Patrick Georgi0588d192009-08-12 15:00:51 +0000293
Patrick Georgie82f4752010-02-10 20:31:38 +0000294CFLAGS = $(INCLUDES) -Os -nostdinc
Patrick Georgi0588d192009-08-12 15:00:51 +0000295CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
Uwe Hermannc04be932009-10-05 13:55:28 +0000296CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs
Patrick Georgi88f55b22009-09-25 18:43:02 +0000297CFLAGS += -Wstrict-aliasing -Wshadow
Myles Watson2e672732009-11-12 16:38:03 +0000298ifeq ($(CONFIG_WARNINGS_ARE_ERRORS),y)
299CFLAGS += -Werror
300endif
Patrick Georgi0588d192009-08-12 15:00:51 +0000301CFLAGS += -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer
302
Patrick Georgi0588d192009-08-12 15:00:51 +0000303CBFS_COMPRESS_FLAG:=l
Myles Watson422d0cb2009-09-23 17:48:28 +0000304CBFS_PAYLOAD_COMPRESS_FLAG:=
305ifeq ($(CONFIG_COMPRESSED_PAYLOAD_LZMA),y)
306CBFS_PAYLOAD_COMPRESS_FLAG:=l
Patrick Georgi0588d192009-08-12 15:00:51 +0000307endif
308
309coreboot: prepare prepare2 $(obj)/coreboot.rom
310
311endif
312
313prepare:
Patrick Georgi2b7418e2009-08-25 19:38:46 +0000314 mkdir -p $(obj)
Patrick Georgi7faf22f2010-02-10 18:50:36 +0000315 mkdir -p $(obj)/util/kconfig/lxdialog $(obj)/util/cbfstool
Patrick Georgi2b7418e2009-08-25 19:38:46 +0000316 test -n "$(alldirs)" && mkdir -p $(alldirs) || true
Patrick Georgi0588d192009-08-12 15:00:51 +0000317
Patrick Georgicccbb892010-01-29 17:38:57 +0000318prepare2: $(obj)/build.h
319
320$(obj)/build.h:
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000321 @printf " GEN build.h\n"
Patrick Georgicccbb892010-01-29 17:38:57 +0000322 rm -f $(obj)/build.h
Stefan Reinauerb4d3af82010-02-11 03:21:29 +0000323 printf "/* build system definitions (autogenerated) */\n" > $(obj)/build.ht
324 printf "#ifndef __BUILD_H\n" >> $(obj)/build.ht
325 printf "#define __BUILD_H\n\n" >> $(obj)/build.ht
Zheng Baob7bc3f32010-02-23 10:33:25 +0000326 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 +0000327 printf "#define COREBOOT_EXTRA_VERSION \"$(COREBOOT_EXTRA_VERSION)\"\n" >> $(obj)/build.ht
328 printf "#define COREBOOT_BUILD \"`LANG= date`\"\n" >> $(obj)/build.ht
329 printf "\n" >> $(obj)/build.ht
330 printf "#define COREBOOT_COMPILER \"$(shell LANG= $(CC) --version | head -n1)\"\n" >> $(obj)/build.ht
331 printf "#define COREBOOT_ASSEMBLER \"$(shell LANG= $(AS) --version | head -n1)\"\n" >> $(obj)/build.ht
332 printf "#define COREBOOT_LINKER \"$(shell LANG= $(LD) --version | head -n1)\"\n" >> $(obj)/build.ht
333 printf "#define COREBOOT_COMPILE_TIME \"`LANG= date +%T`\"\n" >> $(obj)/build.ht
334 printf "#define COREBOOT_COMPILE_BY \"$(subst \,@,$(shell PATH=$$PATH:/usr/ucb whoami))\"\n" >> $(obj)/build.ht
Stefan Reinauere3778572010-01-30 09:47:18 +0000335 printf "#define COREBOOT_COMPILE_HOST \"$(shell hostname -s)\"\n" >> $(obj)/build.ht
Patrick Georgicccbb892010-01-29 17:38:57 +0000336 printf "#define COREBOOT_COMPILE_DOMAIN \"$(shell test `uname -s` = "Linux" && dnsdomainname || domainname)\"\n" >> $(obj)/build.ht
Stefan Reinauerb4d3af82010-02-11 03:21:29 +0000337 printf "#endif\n" >> $(obj)/build.ht
Patrick Georgicccbb892010-01-29 17:38:57 +0000338 mv $(obj)/build.ht $(obj)/build.h
Patrick Georgi0588d192009-08-12 15:00:51 +0000339
340doxy: doxygen
341doxygen:
Stefan Reinauer1bbad5c2010-02-10 15:36:53 +0000342 $(DOXYGEN) documentation/Doxyfile.coreboot
Patrick Georgi0588d192009-08-12 15:00:51 +0000343
344doxyclean: doxygen-clean
345doxygen-clean:
Patrick Georgi2b7418e2009-08-25 19:38:46 +0000346 rm -rf $(DOXYGEN_OUTPUT_DIR)
Patrick Georgi0588d192009-08-12 15:00:51 +0000347
Patrick Georgi967952a2010-02-09 19:41:11 +0000348clean-for-update: doxygen-clean
349 rm -f $(objs) $(initobjs) $(drivers) $(smmobjs) .xcompile
350 rm -f $(obj)/coreboot_ram* $(obj)/coreboot.romstage $(obj)/coreboot.pre* $(obj)/coreboot.bootblock $(obj)/coreboot.a
Patrick Georgi9341acd2009-12-23 12:52:56 +0000351 rm -rf $(obj)/bootblock* $(obj)/romstage* $(obj)/location.*
Patrick Georgi97fc40b2010-02-11 12:12:19 +0000352 rm -f $(obj)/option_table.* $(obj)/crt0_includes.h $(obj)/ldscript
Patrick Georgi2b7418e2009-08-25 19:38:46 +0000353 rm -f $(obj)/mainboard/$(MAINBOARDDIR)/static.c $(obj)/mainboard/$(MAINBOARDDIR)/config.py $(obj)/mainboard/$(MAINBOARDDIR)/static.dot
354 rm -f $(obj)/mainboard/$(MAINBOARDDIR)/auto.inc $(obj)/mainboard/$(MAINBOARDDIR)/crt0.s $(obj)/mainboard/$(MAINBOARDDIR)/crt0.disasm
355 rmdir -p $(alldirs) 2>/dev/null >/dev/null || true
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000356 $(MAKE) -C util/sconfig clean
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
Patrick Georgi0588d192009-08-12 15:00:51 +0000361distclean: clean
Myles Watson1af297c2010-01-06 16:59:18 +0000362 rm -rf $(obj)
Patrick Georgi2b7418e2009-08-25 19:38:46 +0000363 rm -f .config .config.old ..config.tmp .kconfig.d .tmpconfig*
Patrick Georgi0588d192009-08-12 15:00:51 +0000364
365update:
Myles Watsond4e5c0a2009-10-28 15:30:11 +0000366 dongle.py -c /dev/term/1 $(obj)/coreboot.rom EOF
Patrick Georgi0588d192009-08-12 15:00:51 +0000367
368# This include must come _before_ the pattern rules below!
369# Order _does_ matter for pattern rules.
370include util/kconfig/Makefile
371
372$(obj)/ldoptions: $(obj)/config.h
Patrick Georgi26774f22009-11-21 19:54:02 +0000373 awk '/^#define ([^"])* ([^"])*$$/ {gsub("\\r","",$$3); print $$2 " = " $$3 ";";}' $< > $@
Patrick Georgi0588d192009-08-12 15:00:51 +0000374
Patrick Georgi26774f22009-11-21 19:54:02 +0000375_OS=$(shell uname -s |cut -c-7)
376STACK=
377ifeq ($(_OS),MINGW32)
378 STACK=-Wl,--stack,16384000
379endif
380ifeq ($(_OS),CYGWIN_)
381 STACK=-Wl,--stack,16384000
382endif
Patrick Georgi0588d192009-08-12 15:00:51 +0000383$(obj)/romcc: $(top)/util/romcc/romcc.c
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000384 @printf " HOSTCC $(subst $(obj)/,,$(@)) (this may take a while)\n"
Uwe Hermann0dd63a22010-02-15 23:24:51 +0000385 @# Note: Adding -O2 here might cause problems. For details see:
386 @# http://www.coreboot.org/pipermail/coreboot/2010-February/055825.html
Marc Jones516255e2010-02-13 18:06:29 +0000387 $(HOSTCC) -g $(STACK) -Wall -o $@ $<
Patrick Georgi0588d192009-08-12 15:00:51 +0000388
389.PHONY: $(PHONY) prepare prepare2 clean distclean doxygen doxy coreboot
390