Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 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> |
Stefan Reinauer | 8ed1b6d | 2010-01-19 21:13:44 +0000 | [diff] [blame] | 6 | ## Copyright (C) 2009-2010 coresystems GmbH |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 7 | ## |
Stefan Reinauer | 16f515a | 2010-01-20 18:44:30 +0000 | [diff] [blame] | 8 | ## 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 Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 11 | ## |
Stefan Reinauer | 16f515a | 2010-01-20 18:44:30 +0000 | [diff] [blame] | 12 | ## 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 Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 20 | ## |
| 21 | |
| 22 | $(if $(wildcard .xcompile),,$(eval $(shell bash util/xcompile/xcompile > .xcompile))) |
| 23 | include .xcompile |
| 24 | |
Patrick Georgi | 1a47b5e | 2010-02-10 18:53:40 +0000 | [diff] [blame] | 25 | export top := $(PWD) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 26 | export src := $(top)/src |
| 27 | export srck := $(top)/util/kconfig |
Stefan Reinauer | e377857 | 2010-01-30 09:47:18 +0000 | [diff] [blame] | 28 | export obj ?= $(top)/build |
Myles Watson | d4e5c0a | 2009-10-28 15:30:11 +0000 | [diff] [blame] | 29 | export objk := $(obj)/util/kconfig |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 30 | export sconfig := $(top)/util/sconfig |
| 31 | export yapps2_py := $(sconfig)/yapps2.py |
| 32 | export config_g := $(sconfig)/config.g |
| 33 | |
| 34 | |
Stefan Reinauer | 37d8c21 | 2010-02-08 18:30:41 +0000 | [diff] [blame] | 35 | export KERNELVERSION := 4.0 |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 36 | export KCONFIG_AUTOHEADER := $(obj)/config.h |
| 37 | export KCONFIG_AUTOCONFIG := $(obj)/auto.conf |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 38 | |
| 39 | CONFIG_SHELL := sh |
| 40 | KBUILD_DEFCONFIG := configs/defconfig |
| 41 | UNAME_RELEASE := $(shell uname -r) |
| 42 | HAVE_DOTCONFIG := $(wildcard .config) |
| 43 | MAKEFLAGS += -rR --no-print-directory |
| 44 | |
| 45 | # Make is silent per default, but 'make V=1' will show all compiler calls. |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 46 | Q:=@ |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 47 | ifneq ($(V),1) |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 48 | ifneq ($(Q),) |
| 49 | .SILENT: |
| 50 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 51 | endif |
| 52 | |
| 53 | CPP:= $(CC) -x assembler-with-cpp -DASSEMBLY -E |
| 54 | HOSTCC = gcc |
| 55 | HOSTCXX = g++ |
| 56 | HOSTCFLAGS := -I$(srck) -I$(objk) -g |
| 57 | HOSTCXXFLAGS := -I$(srck) -I$(objk) |
Harald Gutmann | dc4bb0d | 2009-08-26 15:35:36 +0000 | [diff] [blame] | 58 | LIBGCC_FILE_NAME := $(shell $(CC) -print-libgcc-file-name) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 59 | |
| 60 | DESTDIR = /opt |
| 61 | |
| 62 | DOXYGEN := doxygen |
| 63 | DOXYGEN_OUTPUT_DIR := doxygen |
| 64 | |
| 65 | ifeq ($(strip $(HAVE_DOTCONFIG)),) |
| 66 | |
| 67 | all: config |
| 68 | |
| 69 | else |
| 70 | |
| 71 | include $(top)/.config |
| 72 | |
| 73 | ARCHDIR-$(CONFIG_ARCH_X86) := i386 |
| 74 | ARCHDIR-$(CONFIG_ARCH_POWERPC) := ppc |
| 75 | |
Patrick Georgi | 1a47b5e | 2010-02-10 18:53:40 +0000 | [diff] [blame] | 76 | MAINBOARDDIR=$(subst ",,$(CONFIG_MAINBOARD_DIR)) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 77 | export MAINBOARDDIR |
| 78 | |
| 79 | PLATFORM-y += src/arch/$(ARCHDIR-y) src/cpu src/mainboard/$(MAINBOARDDIR) |
| 80 | TARGETS-y := |
| 81 | |
| 82 | BUILD-y := src/lib src/boot src/console src/devices src/southbridge src/northbridge src/superio src/drivers util/x86emu |
| 83 | BUILD-y += util/cbfstool |
| 84 | BUILD-$(CONFIG_ARCH_X86) += src/pc80 |
| 85 | |
Uwe Hermann | c04be93 | 2009-10-05 13:55:28 +0000 | [diff] [blame] | 86 | ifneq ($(CONFIG_LOCALVERSION),"") |
Patrick Georgi | 1a47b5e | 2010-02-10 18:53:40 +0000 | [diff] [blame] | 87 | COREBOOT_EXTRA_VERSION := -$(subst ",,$(CONFIG_LOCALVERSION)) |
Uwe Hermann | c04be93 | 2009-10-05 13:55:28 +0000 | [diff] [blame] | 88 | endif |
| 89 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 90 | # The primary target needs to be here before we include the |
| 91 | # other files |
| 92 | |
| 93 | all: coreboot |
| 94 | |
| 95 | |
| 96 | ####################################################################### |
| 97 | # Build the tools |
| 98 | |
| 99 | CBFSTOOL:=$(obj)/util/cbfstool/cbfstool |
| 100 | |
| 101 | $(obj)/mainboard/$(MAINBOARDDIR)/config.py: $(yapps2_py) $(config_g) |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 102 | mkdir -p $(obj)/mainboard/$(MAINBOARDDIR) |
| 103 | python $(yapps2_py) $(config_g) $(obj)/mainboard/$(MAINBOARDDIR)/config.py |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 104 | |
| 105 | |
| 106 | # needed objects that every mainboard uses |
| 107 | # Creation of these is architecture and mainboard independent |
Myles Watson | ed03556 | 2009-09-22 21:29:32 +0000 | [diff] [blame] | 108 | $(obj)/mainboard/$(MAINBOARDDIR)/static.c: $(src)/mainboard/$(MAINBOARDDIR)/devicetree.cb $(obj)/mainboard/$(MAINBOARDDIR)/config.py |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 109 | mkdir -p $(obj)/mainboard/$(MAINBOARDDIR) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 110 | (cd $(obj)/mainboard/$(MAINBOARDDIR) ; PYTHONPATH=$(top)/util/sconfig export PYTHONPATH; python config.py $(MAINBOARDDIR) $(top) $(obj)/mainboard/$(MAINBOARDDIR)) |
| 111 | |
| 112 | $(obj)/mainboard/$(MAINBOARDDIR)/static.o: $(obj)/mainboard/$(MAINBOARDDIR)/static.c |
| 113 | # |
| 114 | |
| 115 | objs:=$(obj)/mainboard/$(MAINBOARDDIR)/static.o |
| 116 | initobjs:= |
| 117 | drivers:= |
| 118 | smmobjs:= |
| 119 | crt0s:= |
| 120 | ldscripts:= |
| 121 | types:=obj initobj driver smmobj |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 122 | includemakefiles=$(foreach type,$(2), $(eval $(type)-y:=)) $(eval subdirs-y:=) $(eval include $(1)) $(if $(strip $(3)),$(foreach type,$(2),$(eval $(type)s+=$$(patsubst src/%,$(obj)/%,$$(addprefix $(dir $(1)),$$($(type)-y)))))) $(eval subdirs+=$$(subst $(PWD)/,,$$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y))))) |
Stefan Reinauer | e377857 | 2010-01-30 09:47:18 +0000 | [diff] [blame] | 123 | evaluate_subdirs=$(eval cursubdirs:=$(subdirs)) $(eval subdirs:=) $(foreach dir,$(cursubdirs),$(eval $(call includemakefiles,$(dir)/Makefile.inc,$(types),$(1)))) $(if $(subdirs),$(eval $(call evaluate_subdirs, $(1)))) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 124 | |
| 125 | # collect all object files eligible for building |
| 126 | subdirs:=$(PLATFORM-y) $(BUILD-y) |
| 127 | $(eval $(call evaluate_subdirs, modify)) |
| 128 | |
| 129 | allobjs:=$(foreach var, $(addsuffix s,$(types)), $($(var))) |
| 130 | alldirs:=$(sort $(abspath $(dir $(allobjs)))) |
| 131 | source_with_ext=$(patsubst $(obj)/%.o,src/%.$(1),$(allobjs)) |
| 132 | allsrc=$(wildcard $(call source_with_ext,c) $(call source_with_ext,S)) |
| 133 | |
| 134 | POST_EVALUATION:=y |
| 135 | |
| 136 | # fetch rules (protected in POST_EVALUATION) that rely on the variables filled above |
| 137 | subdirs:=$(PLATFORM-y) $(BUILD-y) |
| 138 | $(eval $(call evaluate_subdirs)) |
| 139 | |
| 140 | |
Patrick Georgi | af97d33 | 2010-02-08 15:46:37 +0000 | [diff] [blame] | 141 | define objs_dsl_template |
| 142 | $(obj)/$(1)%.o: src/$(1)%.asl |
Patrick Georgi | 1a47b5e | 2010-02-10 18:53:40 +0000 | [diff] [blame] | 143 | @printf " IASL $$(subst $(top)/,,$$(@))\n" |
Patrick Georgi | af97d33 | 2010-02-08 15:46:37 +0000 | [diff] [blame] | 144 | $(CPP) -D__ACPI__ -P $(CPPFLAGS) -include $(obj)/config.h -I$(src) -I$(src)/mainboard/$(MAINBOARDDIR) $$< -o $$(basename $$@).asl |
| 145 | iasl -p $$(basename $$@) -tc $$(basename $$@).asl |
| 146 | mv $$(basename $$@).hex $$(basename $$@).c |
| 147 | $(CC) -m32 $$(CFLAGS) $$(if $$(subst dsdt,,$$(basename $$(notdir $$@))), -DAmlCode=AmlCode_$$(basename $$(notdir $$@))) -c -o $$@ $$(basename $$@).c |
Patrick Georgi | 88f55b2 | 2009-09-25 18:43:02 +0000 | [diff] [blame] | 148 | endef |
| 149 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 150 | define objs_c_template |
Stefan Reinauer | b4d3af8 | 2010-02-11 03:21:29 +0000 | [diff] [blame] | 151 | $(obj)/$(1)%.o: src/$(1)%.c $(obj)/config.h |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 152 | @printf " CC $$(subst $$(obj)/,,$$(@))\n" |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 153 | $(CC) -m32 $$(CFLAGS) -c -o $$@ $$< |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 154 | endef |
| 155 | |
| 156 | define objs_S_template |
Stefan Reinauer | b4d3af8 | 2010-02-11 03:21:29 +0000 | [diff] [blame] | 157 | $(obj)/$(1)%.o: src/$(1)%.S $(obj)/config.h |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 158 | @printf " CC $$(subst $$(obj)/,,$$(@))\n" |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 159 | $(CC) -m32 -DASSEMBLY $$(CFLAGS) -c -o $$@ $$< |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 160 | endef |
| 161 | |
| 162 | define initobjs_c_template |
Stefan Reinauer | b4d3af8 | 2010-02-11 03:21:29 +0000 | [diff] [blame] | 163 | $(obj)/$(1)%.o: src/$(1)%.c $(obj)/config.h |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 164 | @printf " CC $$(subst $$(obj)/,,$$(@))\n" |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 165 | $(CC) -m32 $$(CFLAGS) -c -o $$@ $$< |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 166 | endef |
| 167 | |
| 168 | define initobjs_S_template |
Stefan Reinauer | b4d3af8 | 2010-02-11 03:21:29 +0000 | [diff] [blame] | 169 | $(obj)/$(1)%.o: src/$(1)%.S $(obj)/config.h |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 170 | @printf " CC $$(subst $$(obj)/,,$$(@))\n" |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 171 | $(CC) -m32 -DASSEMBLY $$(CFLAGS) -c -o $$@ $$< |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 172 | endef |
| 173 | |
| 174 | define drivers_c_template |
Stefan Reinauer | b4d3af8 | 2010-02-11 03:21:29 +0000 | [diff] [blame] | 175 | $(obj)/$(1)%.o: src/$(1)%.c $(obj)/config.h |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 176 | @printf " CC $$(subst $$(obj)/,,$$(@))\n" |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 177 | $(CC) -m32 $$(CFLAGS) -c -o $$@ $$< |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 178 | endef |
| 179 | |
| 180 | define drivers_S_template |
| 181 | $(obj)/$(1)%.o: src/$(1)%.S |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 182 | @printf " CC $$(subst $$(obj)/,,$$(@))\n" |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 183 | $(CC) -m32 -DASSEMBLY $$(CFLAGS) -c -o $$@ $$< |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 184 | endef |
| 185 | |
| 186 | define smmobjs_c_template |
| 187 | $(obj)/$(1)%.o: src/$(1)%.c |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 188 | @printf " CC $$(subst $$(obj)/,,$$(@))\n" |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 189 | $(CC) -m32 $$(CFLAGS) -c -o $$@ $$< |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 190 | endef |
| 191 | |
| 192 | define smmobjs_S_template |
| 193 | $(obj)/$(1)%.o: src/$(1)%.S |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 194 | @printf " CC $$(subst $$(obj)/,,$$(@))\n" |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 195 | $(CC) -m32 $$(CFLAGS) -c -o $$@ $$< |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 196 | endef |
| 197 | |
| 198 | usetemplate=$(foreach d,$(sort $(dir $($(1)))),$(eval $(call $(1)_$(2)_template,$(subst $(obj)/,,$(d))))) |
| 199 | usetemplate=$(foreach d,$(sort $(dir $($(1)))),$(eval $(call $(1)_$(2)_template,$(subst $(obj)/,,$(d))))) |
Patrick Georgi | af97d33 | 2010-02-08 15:46:37 +0000 | [diff] [blame] | 200 | $(eval $(call usetemplate,objs,dsl)) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 201 | $(eval $(call usetemplate,objs,c)) |
| 202 | $(eval $(call usetemplate,objs,S)) |
| 203 | $(eval $(call usetemplate,initobjs,c)) |
| 204 | $(eval $(call usetemplate,initobjs,S)) |
| 205 | $(eval $(call usetemplate,drivers,c)) |
| 206 | $(eval $(call usetemplate,drivers,S)) |
| 207 | $(eval $(call usetemplate,smmobjs,c)) |
| 208 | $(eval $(call usetemplate,smmobjs,S)) |
| 209 | |
| 210 | printall: |
| 211 | @echo objs:=$(objs) |
| 212 | @echo initobjs:=$(initobjs) |
| 213 | @echo drivers:=$(drivers) |
| 214 | @echo smmobjs:=$(smmobjs) |
| 215 | @echo alldirs:=$(alldirs) |
| 216 | @echo allsrc=$(allsrc) |
| 217 | |
| 218 | OBJS := $(patsubst %,$(obj)/%,$(TARGETS-y)) |
| 219 | INCLUDES := -I$(top)/src -I$(top)/src/include -I$(obj) -I$(top)/src/arch/$(ARCHDIR-y)/include |
| 220 | INCLUDES += -I$(shell $(CC) -print-search-dirs | head -n 1 | cut -d' ' -f2)include |
Myles Watson | e680495 | 2009-08-28 14:36:12 +0000 | [diff] [blame] | 221 | INCLUDES += -I$(top)/util/x86emu/include |
Stefan Reinauer | b4d3af8 | 2010-02-11 03:21:29 +0000 | [diff] [blame] | 222 | INCLUDES += -include $(obj)/config.h |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 223 | |
Patrick Georgi | e82f475 | 2010-02-10 20:31:38 +0000 | [diff] [blame] | 224 | CFLAGS = $(INCLUDES) -Os -nostdinc |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 225 | CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes |
Uwe Hermann | c04be93 | 2009-10-05 13:55:28 +0000 | [diff] [blame] | 226 | CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs |
Patrick Georgi | 88f55b2 | 2009-09-25 18:43:02 +0000 | [diff] [blame] | 227 | CFLAGS += -Wstrict-aliasing -Wshadow |
Myles Watson | 2e67273 | 2009-11-12 16:38:03 +0000 | [diff] [blame] | 228 | ifeq ($(CONFIG_WARNINGS_ARE_ERRORS),y) |
| 229 | CFLAGS += -Werror |
| 230 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 231 | CFLAGS += -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer |
| 232 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 233 | CBFS_COMPRESS_FLAG:=l |
Myles Watson | 422d0cb | 2009-09-23 17:48:28 +0000 | [diff] [blame] | 234 | CBFS_PAYLOAD_COMPRESS_FLAG:= |
| 235 | ifeq ($(CONFIG_COMPRESSED_PAYLOAD_LZMA),y) |
| 236 | CBFS_PAYLOAD_COMPRESS_FLAG:=l |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 237 | endif |
| 238 | |
| 239 | coreboot: prepare prepare2 $(obj)/coreboot.rom |
| 240 | |
| 241 | endif |
| 242 | |
| 243 | prepare: |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 244 | mkdir -p $(obj) |
Patrick Georgi | 7faf22f | 2010-02-10 18:50:36 +0000 | [diff] [blame] | 245 | mkdir -p $(obj)/util/kconfig/lxdialog $(obj)/util/cbfstool |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 246 | test -n "$(alldirs)" && mkdir -p $(alldirs) || true |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 247 | |
Patrick Georgi | cccbb89 | 2010-01-29 17:38:57 +0000 | [diff] [blame] | 248 | prepare2: $(obj)/build.h |
| 249 | |
| 250 | $(obj)/build.h: |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 251 | @printf " GEN build.h\n" |
Patrick Georgi | cccbb89 | 2010-01-29 17:38:57 +0000 | [diff] [blame] | 252 | rm -f $(obj)/build.h |
Stefan Reinauer | b4d3af8 | 2010-02-11 03:21:29 +0000 | [diff] [blame] | 253 | printf "/* build system definitions (autogenerated) */\n" > $(obj)/build.ht |
| 254 | printf "#ifndef __BUILD_H\n" >> $(obj)/build.ht |
| 255 | printf "#define __BUILD_H\n\n" >> $(obj)/build.ht |
| 256 | printf "#define COREBOOT_VERSION \"$(KERNELVERSION)\"\n" >> $(obj)/build.ht |
Patrick Georgi | cccbb89 | 2010-01-29 17:38:57 +0000 | [diff] [blame] | 257 | printf "#define COREBOOT_EXTRA_VERSION \"$(COREBOOT_EXTRA_VERSION)\"\n" >> $(obj)/build.ht |
| 258 | printf "#define COREBOOT_BUILD \"`LANG= date`\"\n" >> $(obj)/build.ht |
| 259 | printf "\n" >> $(obj)/build.ht |
| 260 | printf "#define COREBOOT_COMPILER \"$(shell LANG= $(CC) --version | head -n1)\"\n" >> $(obj)/build.ht |
| 261 | printf "#define COREBOOT_ASSEMBLER \"$(shell LANG= $(AS) --version | head -n1)\"\n" >> $(obj)/build.ht |
| 262 | printf "#define COREBOOT_LINKER \"$(shell LANG= $(LD) --version | head -n1)\"\n" >> $(obj)/build.ht |
| 263 | printf "#define COREBOOT_COMPILE_TIME \"`LANG= date +%T`\"\n" >> $(obj)/build.ht |
| 264 | printf "#define COREBOOT_COMPILE_BY \"$(subst \,@,$(shell PATH=$$PATH:/usr/ucb whoami))\"\n" >> $(obj)/build.ht |
Stefan Reinauer | e377857 | 2010-01-30 09:47:18 +0000 | [diff] [blame] | 265 | printf "#define COREBOOT_COMPILE_HOST \"$(shell hostname -s)\"\n" >> $(obj)/build.ht |
Patrick Georgi | cccbb89 | 2010-01-29 17:38:57 +0000 | [diff] [blame] | 266 | printf "#define COREBOOT_COMPILE_DOMAIN \"$(shell test `uname -s` = "Linux" && dnsdomainname || domainname)\"\n" >> $(obj)/build.ht |
Stefan Reinauer | b4d3af8 | 2010-02-11 03:21:29 +0000 | [diff] [blame] | 267 | printf "#endif\n" >> $(obj)/build.ht |
Patrick Georgi | cccbb89 | 2010-01-29 17:38:57 +0000 | [diff] [blame] | 268 | mv $(obj)/build.ht $(obj)/build.h |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 269 | |
| 270 | doxy: doxygen |
| 271 | doxygen: |
Stefan Reinauer | 1bbad5c | 2010-02-10 15:36:53 +0000 | [diff] [blame] | 272 | $(DOXYGEN) documentation/Doxyfile.coreboot |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 273 | |
| 274 | doxyclean: doxygen-clean |
| 275 | doxygen-clean: |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 276 | rm -rf $(DOXYGEN_OUTPUT_DIR) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 277 | |
Patrick Georgi | 967952a | 2010-02-09 19:41:11 +0000 | [diff] [blame] | 278 | clean-for-update: doxygen-clean |
| 279 | rm -f $(objs) $(initobjs) $(drivers) $(smmobjs) .xcompile |
| 280 | rm -f $(obj)/coreboot_ram* $(obj)/coreboot.romstage $(obj)/coreboot.pre* $(obj)/coreboot.bootblock $(obj)/coreboot.a |
Patrick Georgi | 9341acd | 2009-12-23 12:52:56 +0000 | [diff] [blame] | 281 | rm -rf $(obj)/bootblock* $(obj)/romstage* $(obj)/location.* |
Patrick Georgi | 97fc40b | 2010-02-11 12:12:19 +0000 | [diff] [blame] | 282 | rm -f $(obj)/option_table.* $(obj)/crt0_includes.h $(obj)/ldscript |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 283 | rm -f $(obj)/mainboard/$(MAINBOARDDIR)/static.c $(obj)/mainboard/$(MAINBOARDDIR)/config.py $(obj)/mainboard/$(MAINBOARDDIR)/static.dot |
| 284 | rm -f $(obj)/mainboard/$(MAINBOARDDIR)/auto.inc $(obj)/mainboard/$(MAINBOARDDIR)/crt0.s $(obj)/mainboard/$(MAINBOARDDIR)/crt0.disasm |
| 285 | rmdir -p $(alldirs) 2>/dev/null >/dev/null || true |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 286 | $(MAKE) -C util/sconfig clean |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 287 | |
Patrick Georgi | 967952a | 2010-02-09 19:41:11 +0000 | [diff] [blame] | 288 | clean: clean-for-update |
| 289 | rm -f $(obj)/coreboot* |
| 290 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 291 | distclean: clean |
Myles Watson | 1af297c | 2010-01-06 16:59:18 +0000 | [diff] [blame] | 292 | rm -rf $(obj) |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 293 | rm -f .config .config.old ..config.tmp .kconfig.d .tmpconfig* |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 294 | |
| 295 | update: |
Myles Watson | d4e5c0a | 2009-10-28 15:30:11 +0000 | [diff] [blame] | 296 | dongle.py -c /dev/term/1 $(obj)/coreboot.rom EOF |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 297 | |
| 298 | # This include must come _before_ the pattern rules below! |
| 299 | # Order _does_ matter for pattern rules. |
| 300 | include util/kconfig/Makefile |
| 301 | |
| 302 | $(obj)/ldoptions: $(obj)/config.h |
Patrick Georgi | 26774f2 | 2009-11-21 19:54:02 +0000 | [diff] [blame] | 303 | awk '/^#define ([^"])* ([^"])*$$/ {gsub("\\r","",$$3); print $$2 " = " $$3 ";";}' $< > $@ |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 304 | |
Patrick Georgi | 26774f2 | 2009-11-21 19:54:02 +0000 | [diff] [blame] | 305 | _OS=$(shell uname -s |cut -c-7) |
| 306 | STACK= |
| 307 | ifeq ($(_OS),MINGW32) |
| 308 | STACK=-Wl,--stack,16384000 |
| 309 | endif |
| 310 | ifeq ($(_OS),CYGWIN_) |
| 311 | STACK=-Wl,--stack,16384000 |
| 312 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 313 | $(obj)/romcc: $(top)/util/romcc/romcc.c |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 314 | @printf " HOSTCC $(subst $(obj)/,,$(@)) (this may take a while)\n" |
Uwe Hermann | 0dd63a2 | 2010-02-15 23:24:51 +0000 | [diff] [blame] | 315 | @# Note: Adding -O2 here might cause problems. For details see: |
| 316 | @# http://www.coreboot.org/pipermail/coreboot/2010-February/055825.html |
Marc Jones | 516255e | 2010-02-13 18:06:29 +0000 | [diff] [blame] | 317 | $(HOSTCC) -g $(STACK) -Wall -o $@ $< |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 318 | |
| 319 | .PHONY: $(PHONY) prepare prepare2 clean distclean doxygen doxy coreboot |
| 320 | |