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 | |
Patrick Georgi | 020f51f | 2010-03-14 21:25:03 +0000 | [diff] [blame] | 22 | ifeq ($(INNER_SCANBUILD),y) |
| 23 | CC_real:=$(CC) |
| 24 | endif |
Patrick Georgi | 23d89cc | 2010-03-16 01:17:19 +0000 | [diff] [blame] | 25 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 26 | $(if $(wildcard .xcompile),,$(eval $(shell bash util/xcompile/xcompile > .xcompile))) |
| 27 | include .xcompile |
Patrick Georgi | 23d89cc | 2010-03-16 01:17:19 +0000 | [diff] [blame] | 28 | |
Patrick Georgi | 020f51f | 2010-03-14 21:25:03 +0000 | [diff] [blame] | 29 | ifeq ($(INNER_SCANBUILD),y) |
| 30 | CC:=$(CC_real) |
| 31 | HOSTCC:=$(CC_real) --hostcc |
| 32 | HOSTCXX:=$(CC_real) --hostcxx |
| 33 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 34 | |
Patrick Georgi | 1a47b5e | 2010-02-10 18:53:40 +0000 | [diff] [blame] | 35 | export top := $(PWD) |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 36 | export src := src |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 37 | export srck := $(top)/util/kconfig |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 38 | export obj ?= build |
Patrick Georgi | a2acbc7 | 2010-04-16 22:48:57 +0000 | [diff] [blame] | 39 | export objutil ?= $(obj)/util |
| 40 | export objk := $(objutil)/kconfig |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 41 | |
| 42 | |
Stefan Reinauer | 37d8c21 | 2010-02-08 18:30:41 +0000 | [diff] [blame] | 43 | export KERNELVERSION := 4.0 |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 44 | export KCONFIG_AUTOHEADER := $(obj)/config.h |
| 45 | export KCONFIG_AUTOCONFIG := $(obj)/auto.conf |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 46 | |
| 47 | CONFIG_SHELL := sh |
| 48 | KBUILD_DEFCONFIG := configs/defconfig |
| 49 | UNAME_RELEASE := $(shell uname -r) |
| 50 | HAVE_DOTCONFIG := $(wildcard .config) |
| 51 | MAKEFLAGS += -rR --no-print-directory |
| 52 | |
| 53 | # 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] | 54 | Q:=@ |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 55 | ifneq ($(V),1) |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 56 | ifneq ($(Q),) |
| 57 | .SILENT: |
| 58 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 59 | endif |
| 60 | |
| 61 | CPP:= $(CC) -x assembler-with-cpp -DASSEMBLY -E |
Patrick Georgi | a2acbc7 | 2010-04-16 22:48:57 +0000 | [diff] [blame] | 62 | ROMCC:= $(objutil)/romcc/romcc |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 63 | HOSTCC = gcc |
| 64 | HOSTCXX = g++ |
| 65 | HOSTCFLAGS := -I$(srck) -I$(objk) -g |
| 66 | HOSTCXXFLAGS := -I$(srck) -I$(objk) |
Stefan Reinauer | 68a564f | 2010-03-16 01:02:18 +0000 | [diff] [blame] | 67 | LIBGCC_FILE_NAME := $(shell test -r `$(CC) -print-libgcc-file-name` && $(CC) -print-libgcc-file-name) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 68 | |
| 69 | DOXYGEN := doxygen |
| 70 | DOXYGEN_OUTPUT_DIR := doxygen |
| 71 | |
| 72 | ifeq ($(strip $(HAVE_DOTCONFIG)),) |
| 73 | |
| 74 | all: config |
| 75 | |
| 76 | else |
| 77 | |
| 78 | include $(top)/.config |
| 79 | |
Patrick Georgi | 23d89cc | 2010-03-16 01:17:19 +0000 | [diff] [blame] | 80 | ifneq ($(INNER_SCANBUILD),y) |
| 81 | ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) |
| 82 | CC:=clang -m32 |
| 83 | HOSTCC:=clang |
| 84 | endif |
| 85 | endif |
| 86 | |
Patrick Georgi | 516a2a7 | 2010-03-25 21:45:25 +0000 | [diff] [blame] | 87 | ifeq ($(CONFIG_CCACHE),y) |
| 88 | CCACHE:=CCACHE_COMPILERCHECK=content $(wildcard $(addsuffix /ccache,$(subst :, ,$(PATH)))) |
| 89 | ifeq ($(CCACHE),) |
| 90 | $(error ccache selected, but not found in PATH) |
| 91 | endif |
| 92 | CC := $(CCACHE) $(CC) |
| 93 | HOSTCC := $(CCACHE) $(HOSTCC) |
| 94 | HOSTCXX := $(CCACHE) $(HOSTCXX) |
| 95 | ROMCC := $(CCACHE) $(ROMCC) |
| 96 | endif |
| 97 | |
Patrick Georgi | a84e98b | 2010-03-16 19:01:32 +0000 | [diff] [blame] | 98 | strip_quotes = $(subst ",,$(subst \",,$(1))) |
| 99 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 100 | ARCHDIR-$(CONFIG_ARCH_X86) := i386 |
| 101 | ARCHDIR-$(CONFIG_ARCH_POWERPC) := ppc |
| 102 | |
Patrick Georgi | a84e98b | 2010-03-16 19:01:32 +0000 | [diff] [blame] | 103 | MAINBOARDDIR=$(call strip_quotes,$(CONFIG_MAINBOARD_DIR)) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 104 | export MAINBOARDDIR |
| 105 | |
| 106 | PLATFORM-y += src/arch/$(ARCHDIR-y) src/cpu src/mainboard/$(MAINBOARDDIR) |
| 107 | TARGETS-y := |
| 108 | |
Stefan Reinauer | 859e94a | 2010-03-16 23:07:29 +0000 | [diff] [blame] | 109 | BUILD-y := src/lib src/boot src/console src/devices src/southbridge src/northbridge src/superio src/drivers |
Patrick Georgi | 7e8c9aa | 2010-04-08 11:37:43 +0000 | [diff] [blame] | 110 | BUILD-y += util/cbfstool util/sconfig |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 111 | BUILD-$(CONFIG_ARCH_X86) += src/pc80 |
| 112 | |
Uwe Hermann | c04be93 | 2009-10-05 13:55:28 +0000 | [diff] [blame] | 113 | ifneq ($(CONFIG_LOCALVERSION),"") |
Patrick Georgi | a84e98b | 2010-03-16 19:01:32 +0000 | [diff] [blame] | 114 | COREBOOT_EXTRA_VERSION := -$(call strip_quotes,$(CONFIG_LOCALVERSION)) |
Uwe Hermann | c04be93 | 2009-10-05 13:55:28 +0000 | [diff] [blame] | 115 | endif |
| 116 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 117 | # The primary target needs to be here before we include the |
| 118 | # other files |
| 119 | |
Patrick Georgi | 020f51f | 2010-03-14 21:25:03 +0000 | [diff] [blame] | 120 | ifeq ($(INNER_SCANBUILD),y) |
| 121 | CONFIG_SCANBUILD_ENABLE:= |
| 122 | endif |
| 123 | |
| 124 | ifeq ($(CONFIG_SCANBUILD_ENABLE),y) |
| 125 | ifneq ($(CONFIG_SCANBUILD_REPORT_LOCATION),) |
| 126 | CONFIG_SCANBUILD_REPORT_LOCATION:=-o $(CONFIG_SCANBUILD_REPORT_LOCATION) |
| 127 | endif |
| 128 | all: |
| 129 | echo '#!/bin/sh' > .ccwrap |
| 130 | echo 'CC="$(CC)"' >> .ccwrap |
| 131 | echo 'if [ "$$1" = "--hostcc" ]; then shift; CC="$(HOSTCC)"; fi' >> .ccwrap |
| 132 | echo 'if [ "$$1" = "--hostcxx" ]; then shift; CC="$(HOSTCXX)"; fi' >> .ccwrap |
| 133 | echo 'eval $$CC $$*' >> .ccwrap |
| 134 | chmod +x .ccwrap |
| 135 | scan-build $(CONFIG_SCANBUILD_REPORT_LOCATION) -analyze-headers --use-cc=$(top)/.ccwrap --use-c++=$(top)/.ccwrap $(MAKE) INNER_SCANBUILD=y |
| 136 | else |
Stefan Reinauer | e9f3258 | 2010-03-29 13:04:13 +0000 | [diff] [blame] | 137 | all: $(obj)/config.h coreboot |
Patrick Georgi | 020f51f | 2010-03-14 21:25:03 +0000 | [diff] [blame] | 138 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 139 | |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 140 | # must come rather early |
| 141 | .SECONDEXPANSION: |
| 142 | |
Stefan Reinauer | 1425add | 2010-03-21 22:35:58 +0000 | [diff] [blame] | 143 | $(obj)/config.h: |
| 144 | $(MAKE) oldconfig |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 145 | |
| 146 | ####################################################################### |
| 147 | # Build the tools |
| 148 | |
Patrick Georgi | a2acbc7 | 2010-04-16 22:48:57 +0000 | [diff] [blame] | 149 | CBFSTOOL:=$(objutil)/cbfstool/cbfstool |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 150 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 151 | # needed objects that every mainboard uses |
| 152 | # Creation of these is architecture and mainboard independent |
Patrick Georgi | a2acbc7 | 2010-04-16 22:48:57 +0000 | [diff] [blame] | 153 | $(obj)/mainboard/$(MAINBOARDDIR)/static.c: $(src)/mainboard/$(MAINBOARDDIR)/devicetree.cb $(objutil)/sconfig/sconfig |
Stefan Reinauer | e705f9c | 2010-04-08 13:16:32 +0000 | [diff] [blame] | 154 | @printf " SCONFIG $(subst $(src)/,,$(<))\n" |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 155 | mkdir -p $(obj)/mainboard/$(MAINBOARDDIR) |
Patrick Georgi | a2acbc7 | 2010-04-16 22:48:57 +0000 | [diff] [blame] | 156 | $(objutil)/sconfig/sconfig $(MAINBOARDDIR) $(obj)/mainboard/$(MAINBOARDDIR) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 157 | |
Patrick Georgi | 1cd76e7 | 2010-04-19 20:39:22 +0000 | [diff] [blame^] | 158 | $(objutil)/%.o: $(objutil)/%.c $(obj)/config.h |
| 159 | @printf " HOSTCC $(subst $(objutil)/,,$(@))\n" |
| 160 | $(HOSTCC) -MMD $(HOSTCFLAGS) -c -o $@ $< |
| 161 | |
| 162 | $(obj)/%.o: $(obj)/%.c $(obj)/config.h |
| 163 | @printf " CC $(subst $(obj)/,,$(@))\n" |
| 164 | $(CC) -MMD $(CFLAGS) -c -o $@ $< |
| 165 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 166 | objs:=$(obj)/mainboard/$(MAINBOARDDIR)/static.o |
| 167 | initobjs:= |
| 168 | drivers:= |
| 169 | smmobjs:= |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 170 | types:=obj initobj driver smmobj |
Patrick Georgi | 47d68d8 | 2010-03-06 21:18:43 +0000 | [diff] [blame] | 171 | |
| 172 | # Clean -y variables, include Makefile.inc |
| 173 | # If $(3) is non-empty, add paths to files in X-y, and add them to Xs |
| 174 | # Add subdirs-y to subdirs |
| 175 | includemakefiles= \ |
| 176 | $(foreach type,$(2), $(eval $(type)-y:=)) \ |
| 177 | $(eval subdirs-y:=) \ |
| 178 | $(eval -include $(1)) \ |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 179 | $(foreach type,$(2), \ |
| 180 | $(eval $(type)s+= \ |
| 181 | $$(subst $(top)/,, \ |
| 182 | $$(abspath $$(patsubst src/%, \ |
| 183 | $(obj)/%, \ |
| 184 | $$(addprefix $(dir $(1)),$$($(type)-y))))))) \ |
Patrick Georgi | 47d68d8 | 2010-03-06 21:18:43 +0000 | [diff] [blame] | 185 | $(eval subdirs+=$$(subst $(PWD)/,,$$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y))))) |
| 186 | |
| 187 | # For each path in $(subdirs) call includemakefiles, passing $(1) as $(3) |
| 188 | # Repeat until subdirs is empty |
| 189 | evaluate_subdirs= \ |
| 190 | $(eval cursubdirs:=$(subdirs)) \ |
| 191 | $(eval subdirs:=) \ |
| 192 | $(foreach dir,$(cursubdirs), \ |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 193 | $(eval $(call includemakefiles,$(dir)/Makefile.inc,$(types)))) \ |
| 194 | $(if $(subdirs),$(eval $(call evaluate_subdirs))) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 195 | |
| 196 | # collect all object files eligible for building |
| 197 | subdirs:=$(PLATFORM-y) $(BUILD-y) |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 198 | $(eval $(call evaluate_subdirs)) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 199 | |
Patrick Georgi | d3428b0 | 2010-02-24 13:18:01 +0000 | [diff] [blame] | 200 | initobjs:=$(addsuffix .initobj.o, $(basename $(initobjs))) |
| 201 | drivers:=$(addsuffix .driver.o, $(basename $(drivers))) |
| 202 | smmobjs:=$(addsuffix .smmobj.o, $(basename $(smmobjs))) |
| 203 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 204 | allobjs:=$(foreach var, $(addsuffix s,$(types)), $($(var))) |
| 205 | alldirs:=$(sort $(abspath $(dir $(allobjs)))) |
| 206 | source_with_ext=$(patsubst $(obj)/%.o,src/%.$(1),$(allobjs)) |
| 207 | allsrc=$(wildcard $(call source_with_ext,c) $(call source_with_ext,S)) |
| 208 | |
Patrick Georgi | 9ea7bff | 2010-02-28 18:23:00 +0000 | [diff] [blame] | 209 | define objs_asl_template |
Patrick Georgi | af97d33 | 2010-02-08 15:46:37 +0000 | [diff] [blame] | 210 | $(obj)/$(1)%.o: src/$(1)%.asl |
Patrick Georgi | 1a47b5e | 2010-02-10 18:53:40 +0000 | [diff] [blame] | 211 | @printf " IASL $$(subst $(top)/,,$$(@))\n" |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 212 | $(CPP) -D__ACPI__ -P -include $(abspath $(obj)/config.h) -I$(src) -I$(src)/mainboard/$(MAINBOARDDIR) $$< -o $$(basename $$@).asl |
Patrick Georgi | af97d33 | 2010-02-08 15:46:37 +0000 | [diff] [blame] | 213 | iasl -p $$(basename $$@) -tc $$(basename $$@).asl |
| 214 | mv $$(basename $$@).hex $$(basename $$@).c |
Stefan Reinauer | ae22bcd | 2010-03-05 10:20:28 +0000 | [diff] [blame] | 215 | $(CC) $$(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] | 216 | endef |
| 217 | |
Patrick Georgi patrick.georgi | c5f773d | 2010-03-16 12:01:13 +0000 | [diff] [blame] | 218 | # macro to define template macros that are used by use_template macro |
| 219 | define create_cc_template |
| 220 | # $1 obj class (objs, initobjs, ...) |
| 221 | # $2 source suffix (c, S) |
| 222 | # $3 .o infix ("" ".initobj", ...) |
| 223 | # $4 additional compiler flags |
| 224 | de$(EMPTY)fine $(1)_$(2)_template |
Stefan Reinauer | e9f3258 | 2010-03-29 13:04:13 +0000 | [diff] [blame] | 225 | $(obj)/$$(1)%$(3).o: src/$$(1)%.$(2) $(obj)/config.h |
Patrick Georgi | 1cd76e7 | 2010-04-19 20:39:22 +0000 | [diff] [blame^] | 226 | @printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n" |
Stefan Reinauer | 6bee951 | 2010-03-24 15:51:48 +0000 | [diff] [blame] | 227 | $(CC) $(4) -MMD $$$$(CFLAGS) -c -o $$$$@ $$$$< |
Patrick Georgi patrick.georgi | c5f773d | 2010-03-16 12:01:13 +0000 | [diff] [blame] | 228 | en$(EMPTY)def |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 229 | endef |
| 230 | |
Patrick Georgi patrick.georgi | c5f773d | 2010-03-16 12:01:13 +0000 | [diff] [blame] | 231 | $(eval $(call create_cc_template,objs,c)) |
| 232 | $(eval $(call create_cc_template,objs,S,,-DASSEMBLY)) |
Stefan Reinauer | e9f3258 | 2010-03-29 13:04:13 +0000 | [diff] [blame] | 233 | $(eval $(call create_cc_template,initobjs,c,.initobj,-D__PRE_RAM__)) |
| 234 | $(eval $(call create_cc_template,initobjs,S,.initobj,-DASSEMBLY -D__PRE_RAM__)) |
Patrick Georgi patrick.georgi | c5f773d | 2010-03-16 12:01:13 +0000 | [diff] [blame] | 235 | $(eval $(call create_cc_template,drivers,c,.driver)) |
| 236 | $(eval $(call create_cc_template,drivers,S,.driver,-DASSEMBLY)) |
| 237 | $(eval $(call create_cc_template,smmobjs,c,.smmobj)) |
| 238 | $(eval $(call create_cc_template,smmobjs,S,.smmobj)) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 239 | |
| 240 | usetemplate=$(foreach d,$(sort $(dir $($(1)))),$(eval $(call $(1)_$(2)_template,$(subst $(obj)/,,$(d))))) |
| 241 | usetemplate=$(foreach d,$(sort $(dir $($(1)))),$(eval $(call $(1)_$(2)_template,$(subst $(obj)/,,$(d))))) |
Patrick Georgi | 9ea7bff | 2010-02-28 18:23:00 +0000 | [diff] [blame] | 242 | $(eval $(call usetemplate,objs,asl)) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 243 | $(eval $(call usetemplate,objs,c)) |
| 244 | $(eval $(call usetemplate,objs,S)) |
| 245 | $(eval $(call usetemplate,initobjs,c)) |
| 246 | $(eval $(call usetemplate,initobjs,S)) |
| 247 | $(eval $(call usetemplate,drivers,c)) |
| 248 | $(eval $(call usetemplate,drivers,S)) |
| 249 | $(eval $(call usetemplate,smmobjs,c)) |
| 250 | $(eval $(call usetemplate,smmobjs,S)) |
| 251 | |
Stefan Reinauer | 6bee951 | 2010-03-24 15:51:48 +0000 | [diff] [blame] | 252 | DEPENDENCIES = $(objs:.o=.d) $(initobjs:.o=.d) $(drivers:.o=.d) $(smmobjs:.o=.d) |
| 253 | -include $(DEPENDENCIES) |
| 254 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 255 | printall: |
| 256 | @echo objs:=$(objs) |
| 257 | @echo initobjs:=$(initobjs) |
| 258 | @echo drivers:=$(drivers) |
| 259 | @echo smmobjs:=$(smmobjs) |
| 260 | @echo alldirs:=$(alldirs) |
| 261 | @echo allsrc=$(allsrc) |
Stefan Reinauer | 6bee951 | 2010-03-24 15:51:48 +0000 | [diff] [blame] | 262 | @echo DEPENDENCIES=$(DEPENDENCIES) |
Stefan Reinauer | 68a564f | 2010-03-16 01:02:18 +0000 | [diff] [blame] | 263 | @echo LIBGCC_FILE_NAME=$(LIBGCC_FILE_NAME) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 264 | |
Patrick Georgi | eb49f9d | 2010-02-25 17:03:17 +0000 | [diff] [blame] | 265 | printcrt0s: |
Stefan Reinauer | acdd52f | 2010-03-30 20:32:01 +0000 | [diff] [blame] | 266 | @echo crt0s=$(crt0s) |
| 267 | @echo ldscripts=$(ldscripts) |
Patrick Georgi | eb49f9d | 2010-02-25 17:03:17 +0000 | [diff] [blame] | 268 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 269 | OBJS := $(patsubst %,$(obj)/%,$(TARGETS-y)) |
Patrick Georgi | 51e142f | 2010-03-27 17:18:39 +0000 | [diff] [blame] | 270 | INCLUDES := -Isrc -Isrc/include -I$(obj) -Isrc/arch/$(ARCHDIR-y)/include |
| 271 | INCLUDES += -Isrc/devices/oprom/include |
| 272 | # abspath is a workaround for romcc |
Stefan Reinauer | e9f3258 | 2010-03-29 13:04:13 +0000 | [diff] [blame] | 273 | INCLUDES += -include $(abspath $(obj)/config.h) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 274 | |
Patrick Georgi patrick.georgi | c5f773d | 2010-03-16 12:01:13 +0000 | [diff] [blame] | 275 | CFLAGS = $(INCLUDES) -Os -nostdinc -pipe |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 276 | CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes |
Uwe Hermann | c04be93 | 2009-10-05 13:55:28 +0000 | [diff] [blame] | 277 | CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs |
Stefan Reinauer | 68a564f | 2010-03-16 01:02:18 +0000 | [diff] [blame] | 278 | CFLAGS += -Wstrict-aliasing -Wshadow |
Myles Watson | 2e67273 | 2009-11-12 16:38:03 +0000 | [diff] [blame] | 279 | ifeq ($(CONFIG_WARNINGS_ARE_ERRORS),y) |
| 280 | CFLAGS += -Werror |
| 281 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 282 | CFLAGS += -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer |
| 283 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 284 | CBFS_COMPRESS_FLAG:=l |
Myles Watson | 422d0cb | 2009-09-23 17:48:28 +0000 | [diff] [blame] | 285 | CBFS_PAYLOAD_COMPRESS_FLAG:= |
Stefan Reinauer | 314e551 | 2010-04-09 20:36:29 +0000 | [diff] [blame] | 286 | CBFS_PAYLOAD_COMPRESS_NAME:=none |
Myles Watson | 422d0cb | 2009-09-23 17:48:28 +0000 | [diff] [blame] | 287 | ifeq ($(CONFIG_COMPRESSED_PAYLOAD_LZMA),y) |
| 288 | CBFS_PAYLOAD_COMPRESS_FLAG:=l |
Stefan Reinauer | 314e551 | 2010-04-09 20:36:29 +0000 | [diff] [blame] | 289 | CBFS_PAYLOAD_COMPRESS_NAME:=LZMA |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 290 | endif |
| 291 | |
Stefan Reinauer | c0fbbd0 | 2010-03-15 13:35:19 +0000 | [diff] [blame] | 292 | coreboot: prepare $(obj)/coreboot.rom |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 293 | |
| 294 | endif |
| 295 | |
| 296 | prepare: |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 297 | mkdir -p $(obj) |
Patrick Georgi | a2acbc7 | 2010-04-16 22:48:57 +0000 | [diff] [blame] | 298 | mkdir -p $(objutil)/kconfig/lxdialog $(objutil)/cbfstool $(objutil)/romcc $(objutil)/options |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 299 | test -n "$(alldirs)" && mkdir -p $(alldirs) || true |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 300 | |
Stefan Reinauer | e9f3258 | 2010-03-29 13:04:13 +0000 | [diff] [blame] | 301 | $(obj)/build.h: .xcompile |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 302 | @printf " GEN build.h\n" |
Patrick Georgi | cccbb89 | 2010-01-29 17:38:57 +0000 | [diff] [blame] | 303 | rm -f $(obj)/build.h |
Stefan Reinauer | b4d3af8 | 2010-02-11 03:21:29 +0000 | [diff] [blame] | 304 | printf "/* build system definitions (autogenerated) */\n" > $(obj)/build.ht |
| 305 | printf "#ifndef __BUILD_H\n" >> $(obj)/build.ht |
| 306 | printf "#define __BUILD_H\n\n" >> $(obj)/build.ht |
Patrick Georgi | 6630ce1 | 2010-04-14 20:47:45 +0000 | [diff] [blame] | 307 | 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 Georgi | cccbb89 | 2010-01-29 17:38:57 +0000 | [diff] [blame] | 308 | printf "#define COREBOOT_EXTRA_VERSION \"$(COREBOOT_EXTRA_VERSION)\"\n" >> $(obj)/build.ht |
| 309 | printf "#define COREBOOT_BUILD \"`LANG= date`\"\n" >> $(obj)/build.ht |
| 310 | printf "\n" >> $(obj)/build.ht |
| 311 | printf "#define COREBOOT_COMPILER \"$(shell LANG= $(CC) --version | head -n1)\"\n" >> $(obj)/build.ht |
| 312 | printf "#define COREBOOT_ASSEMBLER \"$(shell LANG= $(AS) --version | head -n1)\"\n" >> $(obj)/build.ht |
| 313 | printf "#define COREBOOT_LINKER \"$(shell LANG= $(LD) --version | head -n1)\"\n" >> $(obj)/build.ht |
| 314 | printf "#define COREBOOT_COMPILE_TIME \"`LANG= date +%T`\"\n" >> $(obj)/build.ht |
| 315 | printf "#define COREBOOT_COMPILE_BY \"$(subst \,@,$(shell PATH=$$PATH:/usr/ucb whoami))\"\n" >> $(obj)/build.ht |
Patrick Georgi patrick.georgi | c5f773d | 2010-03-16 12:01:13 +0000 | [diff] [blame] | 316 | printf "#define COREBOOT_COMPILE_HOST \"$(shell hostname -s 2>/dev/null)\"\n" >> $(obj)/build.ht |
| 317 | printf "#define COREBOOT_COMPILE_DOMAIN \"$(shell test `uname -s` = "Linux" && dnsdomainname || domainname 2>/dev/null)\"\n" >> $(obj)/build.ht |
Stefan Reinauer | b4d3af8 | 2010-02-11 03:21:29 +0000 | [diff] [blame] | 318 | printf "#endif\n" >> $(obj)/build.ht |
Patrick Georgi | cccbb89 | 2010-01-29 17:38:57 +0000 | [diff] [blame] | 319 | mv $(obj)/build.ht $(obj)/build.h |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 320 | |
| 321 | doxy: doxygen |
| 322 | doxygen: |
Stefan Reinauer | 1bbad5c | 2010-02-10 15:36:53 +0000 | [diff] [blame] | 323 | $(DOXYGEN) documentation/Doxyfile.coreboot |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 324 | |
| 325 | doxyclean: doxygen-clean |
| 326 | doxygen-clean: |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 327 | rm -rf $(DOXYGEN_OUTPUT_DIR) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 328 | |
Patrick Georgi | 967952a | 2010-02-09 19:41:11 +0000 | [diff] [blame] | 329 | clean-for-update: doxygen-clean |
| 330 | rm -f $(objs) $(initobjs) $(drivers) $(smmobjs) .xcompile |
Stefan Reinauer | 6bee951 | 2010-03-24 15:51:48 +0000 | [diff] [blame] | 331 | rm -f $(DEPENDENCIES) |
Patrick Georgi | 967952a | 2010-02-09 19:41:11 +0000 | [diff] [blame] | 332 | 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] | 333 | rm -rf $(obj)/bootblock* $(obj)/romstage* $(obj)/location.* |
Patrick Georgi | e64b637 | 2010-04-08 21:04:45 +0000 | [diff] [blame] | 334 | rm -f $(obj)/option_table.* $(obj)/crt0.S $(obj)/ldscript |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 335 | rm -f $(obj)/mainboard/$(MAINBOARDDIR)/static.c $(obj)/mainboard/$(MAINBOARDDIR)/config.py $(obj)/mainboard/$(MAINBOARDDIR)/static.dot |
Stefan Reinauer | f9035dd | 2010-03-17 01:18:14 +0000 | [diff] [blame] | 336 | rm -f $(obj)/mainboard/$(MAINBOARDDIR)/crt0.s $(obj)/mainboard/$(MAINBOARDDIR)/crt0.disasm |
Stefan Reinauer | 6bee951 | 2010-03-24 15:51:48 +0000 | [diff] [blame] | 337 | rm -f $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc |
Stefan Reinauer | 37e7817 | 2010-03-17 01:50:15 +0000 | [diff] [blame] | 338 | rm -f $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.* $(obj)/mainboard/$(MAINBOARDDIR)/dsdt.* |
| 339 | rm -f $(obj)/cpu/x86/smm/smm_bin.c $(obj)/cpu/x86/smm/smm.* $(obj)/cpu/x86/smm/smm |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 340 | rmdir -p $(alldirs) 2>/dev/null >/dev/null || true |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 341 | |
Patrick Georgi | 967952a | 2010-02-09 19:41:11 +0000 | [diff] [blame] | 342 | clean: clean-for-update |
Patrick Georgi | 020f51f | 2010-03-14 21:25:03 +0000 | [diff] [blame] | 343 | rm -f $(obj)/coreboot* .ccwrap |
Patrick Georgi | 967952a | 2010-02-09 19:41:11 +0000 | [diff] [blame] | 344 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 345 | distclean: clean |
Myles Watson | 1af297c | 2010-01-06 16:59:18 +0000 | [diff] [blame] | 346 | rm -rf $(obj) |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 347 | rm -f .config .config.old ..config.tmp .kconfig.d .tmpconfig* |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 348 | |
| 349 | update: |
Myles Watson | d4e5c0a | 2009-10-28 15:30:11 +0000 | [diff] [blame] | 350 | dongle.py -c /dev/term/1 $(obj)/coreboot.rom EOF |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 351 | |
| 352 | # This include must come _before_ the pattern rules below! |
| 353 | # Order _does_ matter for pattern rules. |
| 354 | include util/kconfig/Makefile |
| 355 | |
| 356 | $(obj)/ldoptions: $(obj)/config.h |
Patrick Georgi | 26774f2 | 2009-11-21 19:54:02 +0000 | [diff] [blame] | 357 | awk '/^#define ([^"])* ([^"])*$$/ {gsub("\\r","",$$3); print $$2 " = " $$3 ";";}' $< > $@ |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 358 | |
Patrick Georgi | 26774f2 | 2009-11-21 19:54:02 +0000 | [diff] [blame] | 359 | _OS=$(shell uname -s |cut -c-7) |
| 360 | STACK= |
| 361 | ifeq ($(_OS),MINGW32) |
| 362 | STACK=-Wl,--stack,16384000 |
| 363 | endif |
| 364 | ifeq ($(_OS),CYGWIN_) |
| 365 | STACK=-Wl,--stack,16384000 |
| 366 | endif |
Patrick Georgi | a2acbc7 | 2010-04-16 22:48:57 +0000 | [diff] [blame] | 367 | $(objutil)/romcc/romcc: $(top)/util/romcc/romcc.c |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 368 | @printf " HOSTCC $(subst $(obj)/,,$(@)) (this may take a while)\n" |
Uwe Hermann | 0dd63a2 | 2010-02-15 23:24:51 +0000 | [diff] [blame] | 369 | @# Note: Adding -O2 here might cause problems. For details see: |
| 370 | @# http://www.coreboot.org/pipermail/coreboot/2010-February/055825.html |
Marc Jones | 516255e | 2010-02-13 18:06:29 +0000 | [diff] [blame] | 371 | $(HOSTCC) -g $(STACK) -Wall -o $@ $< |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 372 | |
Stefan Reinauer | c0fbbd0 | 2010-03-15 13:35:19 +0000 | [diff] [blame] | 373 | .PHONY: $(PHONY) prepare clean distclean doxygen doxy coreboot .xcompile |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 374 | |