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 | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 25 | $(if $(wildcard .xcompile),,$(eval $(shell bash util/xcompile/xcompile > .xcompile))) |
| 26 | include .xcompile |
Patrick Georgi | 020f51f | 2010-03-14 21:25:03 +0000 | [diff] [blame] | 27 | ifeq ($(INNER_SCANBUILD),y) |
| 28 | CC:=$(CC_real) |
| 29 | HOSTCC:=$(CC_real) --hostcc |
| 30 | HOSTCXX:=$(CC_real) --hostcxx |
| 31 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 32 | |
Patrick Georgi | 1a47b5e | 2010-02-10 18:53:40 +0000 | [diff] [blame] | 33 | export top := $(PWD) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 34 | export src := $(top)/src |
| 35 | export srck := $(top)/util/kconfig |
Stefan Reinauer | e377857 | 2010-01-30 09:47:18 +0000 | [diff] [blame] | 36 | export obj ?= $(top)/build |
Myles Watson | d4e5c0a | 2009-10-28 15:30:11 +0000 | [diff] [blame] | 37 | export objk := $(obj)/util/kconfig |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 38 | export sconfig := $(top)/util/sconfig |
| 39 | export yapps2_py := $(sconfig)/yapps2.py |
| 40 | export config_g := $(sconfig)/config.g |
| 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 |
| 62 | HOSTCC = gcc |
| 63 | HOSTCXX = g++ |
| 64 | HOSTCFLAGS := -I$(srck) -I$(objk) -g |
| 65 | HOSTCXXFLAGS := -I$(srck) -I$(objk) |
Harald Gutmann | dc4bb0d | 2009-08-26 15:35:36 +0000 | [diff] [blame] | 66 | LIBGCC_FILE_NAME := $(shell $(CC) -print-libgcc-file-name) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 67 | |
| 68 | DESTDIR = /opt |
| 69 | |
| 70 | DOXYGEN := doxygen |
| 71 | DOXYGEN_OUTPUT_DIR := doxygen |
| 72 | |
| 73 | ifeq ($(strip $(HAVE_DOTCONFIG)),) |
| 74 | |
| 75 | all: config |
| 76 | |
| 77 | else |
| 78 | |
| 79 | include $(top)/.config |
| 80 | |
| 81 | ARCHDIR-$(CONFIG_ARCH_X86) := i386 |
| 82 | ARCHDIR-$(CONFIG_ARCH_POWERPC) := ppc |
| 83 | |
Patrick Georgi | 1a47b5e | 2010-02-10 18:53:40 +0000 | [diff] [blame] | 84 | MAINBOARDDIR=$(subst ",,$(CONFIG_MAINBOARD_DIR)) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 85 | export MAINBOARDDIR |
| 86 | |
| 87 | PLATFORM-y += src/arch/$(ARCHDIR-y) src/cpu src/mainboard/$(MAINBOARDDIR) |
| 88 | TARGETS-y := |
| 89 | |
| 90 | BUILD-y := src/lib src/boot src/console src/devices src/southbridge src/northbridge src/superio src/drivers util/x86emu |
| 91 | BUILD-y += util/cbfstool |
| 92 | BUILD-$(CONFIG_ARCH_X86) += src/pc80 |
| 93 | |
Uwe Hermann | c04be93 | 2009-10-05 13:55:28 +0000 | [diff] [blame] | 94 | ifneq ($(CONFIG_LOCALVERSION),"") |
Patrick Georgi | 1a47b5e | 2010-02-10 18:53:40 +0000 | [diff] [blame] | 95 | COREBOOT_EXTRA_VERSION := -$(subst ",,$(CONFIG_LOCALVERSION)) |
Uwe Hermann | c04be93 | 2009-10-05 13:55:28 +0000 | [diff] [blame] | 96 | endif |
| 97 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 98 | # The primary target needs to be here before we include the |
| 99 | # other files |
| 100 | |
Patrick Georgi | 020f51f | 2010-03-14 21:25:03 +0000 | [diff] [blame] | 101 | ifeq ($(INNER_SCANBUILD),y) |
| 102 | CONFIG_SCANBUILD_ENABLE:= |
| 103 | endif |
| 104 | |
| 105 | ifeq ($(CONFIG_SCANBUILD_ENABLE),y) |
| 106 | ifneq ($(CONFIG_SCANBUILD_REPORT_LOCATION),) |
| 107 | CONFIG_SCANBUILD_REPORT_LOCATION:=-o $(CONFIG_SCANBUILD_REPORT_LOCATION) |
| 108 | endif |
| 109 | all: |
| 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 |
| 117 | else |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 118 | all: coreboot |
Patrick Georgi | 020f51f | 2010-03-14 21:25:03 +0000 | [diff] [blame] | 119 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 120 | |
| 121 | |
| 122 | ####################################################################### |
| 123 | # Build the tools |
| 124 | |
| 125 | CBFSTOOL:=$(obj)/util/cbfstool/cbfstool |
| 126 | |
| 127 | $(obj)/mainboard/$(MAINBOARDDIR)/config.py: $(yapps2_py) $(config_g) |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 128 | mkdir -p $(obj)/mainboard/$(MAINBOARDDIR) |
| 129 | python $(yapps2_py) $(config_g) $(obj)/mainboard/$(MAINBOARDDIR)/config.py |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 130 | |
| 131 | |
| 132 | # needed objects that every mainboard uses |
| 133 | # Creation of these is architecture and mainboard independent |
Myles Watson | ed03556 | 2009-09-22 21:29:32 +0000 | [diff] [blame] | 134 | $(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] | 135 | mkdir -p $(obj)/mainboard/$(MAINBOARDDIR) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 136 | (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 Georgi | 020f51f | 2010-03-14 21:25:03 +0000 | [diff] [blame] | 139 | @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 Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 145 | |
| 146 | objs:=$(obj)/mainboard/$(MAINBOARDDIR)/static.o |
| 147 | initobjs:= |
| 148 | drivers:= |
| 149 | smmobjs:= |
| 150 | crt0s:= |
| 151 | ldscripts:= |
| 152 | types:=obj initobj driver smmobj |
Patrick Georgi | 47d68d8 | 2010-03-06 21:18:43 +0000 | [diff] [blame] | 153 | |
| 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 |
| 157 | includemakefiles= \ |
| 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 |
| 173 | evaluate_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 Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 179 | |
| 180 | # collect all object files eligible for building |
| 181 | subdirs:=$(PLATFORM-y) $(BUILD-y) |
| 182 | $(eval $(call evaluate_subdirs, modify)) |
| 183 | |
Patrick Georgi | d3428b0 | 2010-02-24 13:18:01 +0000 | [diff] [blame] | 184 | initobjs:=$(addsuffix .initobj.o, $(basename $(initobjs))) |
| 185 | drivers:=$(addsuffix .driver.o, $(basename $(drivers))) |
| 186 | smmobjs:=$(addsuffix .smmobj.o, $(basename $(smmobjs))) |
| 187 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 188 | allobjs:=$(foreach var, $(addsuffix s,$(types)), $($(var))) |
| 189 | alldirs:=$(sort $(abspath $(dir $(allobjs)))) |
| 190 | source_with_ext=$(patsubst $(obj)/%.o,src/%.$(1),$(allobjs)) |
| 191 | allsrc=$(wildcard $(call source_with_ext,c) $(call source_with_ext,S)) |
| 192 | |
| 193 | POST_EVALUATION:=y |
| 194 | |
| 195 | # fetch rules (protected in POST_EVALUATION) that rely on the variables filled above |
| 196 | subdirs:=$(PLATFORM-y) $(BUILD-y) |
| 197 | $(eval $(call evaluate_subdirs)) |
| 198 | |
| 199 | |
Patrick Georgi | 9ea7bff | 2010-02-28 18:23:00 +0000 | [diff] [blame] | 200 | define objs_asl_template |
Patrick Georgi | af97d33 | 2010-02-08 15:46:37 +0000 | [diff] [blame] | 201 | $(obj)/$(1)%.o: src/$(1)%.asl |
Patrick Georgi | 1a47b5e | 2010-02-10 18:53:40 +0000 | [diff] [blame] | 202 | @printf " IASL $$(subst $(top)/,,$$(@))\n" |
Patrick Georgi | af97d33 | 2010-02-08 15:46:37 +0000 | [diff] [blame] | 203 | $(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 Reinauer | ae22bcd | 2010-03-05 10:20:28 +0000 | [diff] [blame] | 206 | $(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] | 207 | endef |
| 208 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 209 | define objs_c_template |
Stefan Reinauer | ae22bcd | 2010-03-05 10:20:28 +0000 | [diff] [blame] | 210 | $(obj)/$(1)%.o: $(1)%.c $(obj)/config.h |
| 211 | @printf " CC $$(subst $$(obj)/,,$$(@))\n" |
| 212 | $(CC) $$(CFLAGS) -c -o $$@ $$< |
| 213 | |
Stefan Reinauer | b4d3af8 | 2010-02-11 03:21:29 +0000 | [diff] [blame] | 214 | $(obj)/$(1)%.o: src/$(1)%.c $(obj)/config.h |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 215 | @printf " CC $$(subst $$(obj)/,,$$(@))\n" |
Stefan Reinauer | ae22bcd | 2010-03-05 10:20:28 +0000 | [diff] [blame] | 216 | $(CC) $$(CFLAGS) -c -o $$@ $$< |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 217 | endef |
| 218 | |
| 219 | define objs_S_template |
Stefan Reinauer | ae22bcd | 2010-03-05 10:20:28 +0000 | [diff] [blame] | 220 | $(obj)/$(1)%.o: $(1)%.S $(obj)/config.h |
| 221 | @printf " CC $$(subst $$(obj)/,,$$(@))\n" |
| 222 | $(CC) -DASSEMBLY $$(CFLAGS) -c -o $$@ $$< |
| 223 | |
Stefan Reinauer | b4d3af8 | 2010-02-11 03:21:29 +0000 | [diff] [blame] | 224 | $(obj)/$(1)%.o: src/$(1)%.S $(obj)/config.h |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 225 | @printf " CC $$(subst $$(obj)/,,$$(@))\n" |
Stefan Reinauer | ae22bcd | 2010-03-05 10:20:28 +0000 | [diff] [blame] | 226 | $(CC) -DASSEMBLY $$(CFLAGS) -c -o $$@ $$< |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 227 | endef |
| 228 | |
| 229 | define initobjs_c_template |
Patrick Georgi | d3428b0 | 2010-02-24 13:18:01 +0000 | [diff] [blame] | 230 | $(obj)/$(1)%.initobj.o: src/$(1)%.c $(obj)/config.h |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 231 | @printf " CC $$(subst $$(obj)/,,$$(@))\n" |
Stefan Reinauer | ae22bcd | 2010-03-05 10:20:28 +0000 | [diff] [blame] | 232 | $(CC) $$(CFLAGS) -c -o $$@ $$< |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 233 | endef |
| 234 | |
| 235 | define initobjs_S_template |
Patrick Georgi | d3428b0 | 2010-02-24 13:18:01 +0000 | [diff] [blame] | 236 | $(obj)/$(1)%.initobj.o: src/$(1)%.S $(obj)/config.h |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 237 | @printf " CC $$(subst $$(obj)/,,$$(@))\n" |
Stefan Reinauer | ae22bcd | 2010-03-05 10:20:28 +0000 | [diff] [blame] | 238 | $(CC) -DASSEMBLY $$(CFLAGS) -c -o $$@ $$< |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 239 | endef |
| 240 | |
| 241 | define drivers_c_template |
Patrick Georgi | d3428b0 | 2010-02-24 13:18:01 +0000 | [diff] [blame] | 242 | $(obj)/$(1)%.driver.o: src/$(1)%.c $(obj)/config.h |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 243 | @printf " CC $$(subst $$(obj)/,,$$(@))\n" |
Stefan Reinauer | ae22bcd | 2010-03-05 10:20:28 +0000 | [diff] [blame] | 244 | $(CC) $$(CFLAGS) -c -o $$@ $$< |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 245 | endef |
| 246 | |
| 247 | define drivers_S_template |
Patrick Georgi | d3428b0 | 2010-02-24 13:18:01 +0000 | [diff] [blame] | 248 | $(obj)/$(1)%.driver.o: src/$(1)%.S |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 249 | @printf " CC $$(subst $$(obj)/,,$$(@))\n" |
Stefan Reinauer | ae22bcd | 2010-03-05 10:20:28 +0000 | [diff] [blame] | 250 | $(CC) -DASSEMBLY $$(CFLAGS) -c -o $$@ $$< |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 251 | endef |
| 252 | |
| 253 | define smmobjs_c_template |
Patrick Georgi | d3428b0 | 2010-02-24 13:18:01 +0000 | [diff] [blame] | 254 | $(obj)/$(1)%.smmobj.o: src/$(1)%.c |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 255 | @printf " CC $$(subst $$(obj)/,,$$(@))\n" |
Stefan Reinauer | ae22bcd | 2010-03-05 10:20:28 +0000 | [diff] [blame] | 256 | $(CC) $$(CFLAGS) -c -o $$@ $$< |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 257 | endef |
| 258 | |
| 259 | define smmobjs_S_template |
Patrick Georgi | d3428b0 | 2010-02-24 13:18:01 +0000 | [diff] [blame] | 260 | $(obj)/$(1)%.smmobj.o: src/$(1)%.S |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 261 | @printf " CC $$(subst $$(obj)/,,$$(@))\n" |
Stefan Reinauer | ae22bcd | 2010-03-05 10:20:28 +0000 | [diff] [blame] | 262 | $(CC) $$(CFLAGS) -c -o $$@ $$< |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 263 | endef |
| 264 | |
| 265 | usetemplate=$(foreach d,$(sort $(dir $($(1)))),$(eval $(call $(1)_$(2)_template,$(subst $(obj)/,,$(d))))) |
| 266 | 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] | 267 | $(eval $(call usetemplate,objs,asl)) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 268 | $(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 | |
| 277 | printall: |
| 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 Georgi | eb49f9d | 2010-02-25 17:03:17 +0000 | [diff] [blame] | 285 | printcrt0s: |
| 286 | @echo $(patsubst $(top)/%,%,$(crt0s)) |
| 287 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 288 | OBJS := $(patsubst %,$(obj)/%,$(TARGETS-y)) |
| 289 | INCLUDES := -I$(top)/src -I$(top)/src/include -I$(obj) -I$(top)/src/arch/$(ARCHDIR-y)/include |
| 290 | 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] | 291 | INCLUDES += -I$(top)/util/x86emu/include |
Stefan Reinauer | b4d3af8 | 2010-02-11 03:21:29 +0000 | [diff] [blame] | 292 | INCLUDES += -include $(obj)/config.h |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 293 | |
Patrick Georgi | e82f475 | 2010-02-10 20:31:38 +0000 | [diff] [blame] | 294 | CFLAGS = $(INCLUDES) -Os -nostdinc |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 295 | CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes |
Uwe Hermann | c04be93 | 2009-10-05 13:55:28 +0000 | [diff] [blame] | 296 | CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs |
Patrick Georgi | 88f55b2 | 2009-09-25 18:43:02 +0000 | [diff] [blame] | 297 | CFLAGS += -Wstrict-aliasing -Wshadow |
Myles Watson | 2e67273 | 2009-11-12 16:38:03 +0000 | [diff] [blame] | 298 | ifeq ($(CONFIG_WARNINGS_ARE_ERRORS),y) |
| 299 | CFLAGS += -Werror |
| 300 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 301 | CFLAGS += -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer |
| 302 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 303 | CBFS_COMPRESS_FLAG:=l |
Myles Watson | 422d0cb | 2009-09-23 17:48:28 +0000 | [diff] [blame] | 304 | CBFS_PAYLOAD_COMPRESS_FLAG:= |
| 305 | ifeq ($(CONFIG_COMPRESSED_PAYLOAD_LZMA),y) |
| 306 | CBFS_PAYLOAD_COMPRESS_FLAG:=l |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 307 | endif |
| 308 | |
| 309 | coreboot: prepare prepare2 $(obj)/coreboot.rom |
| 310 | |
| 311 | endif |
| 312 | |
| 313 | prepare: |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 314 | mkdir -p $(obj) |
Patrick Georgi | 7faf22f | 2010-02-10 18:50:36 +0000 | [diff] [blame] | 315 | mkdir -p $(obj)/util/kconfig/lxdialog $(obj)/util/cbfstool |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 316 | test -n "$(alldirs)" && mkdir -p $(alldirs) || true |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 317 | |
Patrick Georgi | cccbb89 | 2010-01-29 17:38:57 +0000 | [diff] [blame] | 318 | prepare2: $(obj)/build.h |
| 319 | |
| 320 | $(obj)/build.h: |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 321 | @printf " GEN build.h\n" |
Patrick Georgi | cccbb89 | 2010-01-29 17:38:57 +0000 | [diff] [blame] | 322 | rm -f $(obj)/build.h |
Stefan Reinauer | b4d3af8 | 2010-02-11 03:21:29 +0000 | [diff] [blame] | 323 | 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 Bao | b7bc3f3 | 2010-02-23 10:33:25 +0000 | [diff] [blame] | 326 | 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] | 327 | 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 Reinauer | e377857 | 2010-01-30 09:47:18 +0000 | [diff] [blame] | 335 | printf "#define COREBOOT_COMPILE_HOST \"$(shell hostname -s)\"\n" >> $(obj)/build.ht |
Patrick Georgi | cccbb89 | 2010-01-29 17:38:57 +0000 | [diff] [blame] | 336 | 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] | 337 | printf "#endif\n" >> $(obj)/build.ht |
Patrick Georgi | cccbb89 | 2010-01-29 17:38:57 +0000 | [diff] [blame] | 338 | mv $(obj)/build.ht $(obj)/build.h |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 339 | |
| 340 | doxy: doxygen |
| 341 | doxygen: |
Stefan Reinauer | 1bbad5c | 2010-02-10 15:36:53 +0000 | [diff] [blame] | 342 | $(DOXYGEN) documentation/Doxyfile.coreboot |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 343 | |
| 344 | doxyclean: doxygen-clean |
| 345 | doxygen-clean: |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 346 | rm -rf $(DOXYGEN_OUTPUT_DIR) |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 347 | |
Patrick Georgi | 967952a | 2010-02-09 19:41:11 +0000 | [diff] [blame] | 348 | clean-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 Georgi | 9341acd | 2009-12-23 12:52:56 +0000 | [diff] [blame] | 351 | rm -rf $(obj)/bootblock* $(obj)/romstage* $(obj)/location.* |
Patrick Georgi | 97fc40b | 2010-02-11 12:12:19 +0000 | [diff] [blame] | 352 | rm -f $(obj)/option_table.* $(obj)/crt0_includes.h $(obj)/ldscript |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 353 | 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 Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 356 | $(MAKE) -C util/sconfig clean |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 357 | |
Patrick Georgi | 967952a | 2010-02-09 19:41:11 +0000 | [diff] [blame] | 358 | clean: clean-for-update |
Patrick Georgi | 020f51f | 2010-03-14 21:25:03 +0000 | [diff] [blame] | 359 | rm -f $(obj)/coreboot* .ccwrap |
Patrick Georgi | 967952a | 2010-02-09 19:41:11 +0000 | [diff] [blame] | 360 | |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 361 | distclean: clean |
Myles Watson | 1af297c | 2010-01-06 16:59:18 +0000 | [diff] [blame] | 362 | rm -rf $(obj) |
Patrick Georgi | 2b7418e | 2009-08-25 19:38:46 +0000 | [diff] [blame] | 363 | rm -f .config .config.old ..config.tmp .kconfig.d .tmpconfig* |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 364 | |
| 365 | update: |
Myles Watson | d4e5c0a | 2009-10-28 15:30:11 +0000 | [diff] [blame] | 366 | dongle.py -c /dev/term/1 $(obj)/coreboot.rom EOF |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 367 | |
| 368 | # This include must come _before_ the pattern rules below! |
| 369 | # Order _does_ matter for pattern rules. |
| 370 | include util/kconfig/Makefile |
| 371 | |
| 372 | $(obj)/ldoptions: $(obj)/config.h |
Patrick Georgi | 26774f2 | 2009-11-21 19:54:02 +0000 | [diff] [blame] | 373 | awk '/^#define ([^"])* ([^"])*$$/ {gsub("\\r","",$$3); print $$2 " = " $$3 ";";}' $< > $@ |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 374 | |
Patrick Georgi | 26774f2 | 2009-11-21 19:54:02 +0000 | [diff] [blame] | 375 | _OS=$(shell uname -s |cut -c-7) |
| 376 | STACK= |
| 377 | ifeq ($(_OS),MINGW32) |
| 378 | STACK=-Wl,--stack,16384000 |
| 379 | endif |
| 380 | ifeq ($(_OS),CYGWIN_) |
| 381 | STACK=-Wl,--stack,16384000 |
| 382 | endif |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 383 | $(obj)/romcc: $(top)/util/romcc/romcc.c |
Uwe Hermann | 6c73b441 | 2009-10-28 17:10:51 +0000 | [diff] [blame] | 384 | @printf " HOSTCC $(subst $(obj)/,,$(@)) (this may take a while)\n" |
Uwe Hermann | 0dd63a2 | 2010-02-15 23:24:51 +0000 | [diff] [blame] | 385 | @# Note: Adding -O2 here might cause problems. For details see: |
| 386 | @# http://www.coreboot.org/pipermail/coreboot/2010-February/055825.html |
Marc Jones | 516255e | 2010-02-13 18:06:29 +0000 | [diff] [blame] | 387 | $(HOSTCC) -g $(STACK) -Wall -o $@ $< |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 388 | |
| 389 | .PHONY: $(PHONY) prepare prepare2 clean distclean doxygen doxy coreboot |
| 390 | |