Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 1 | ## |
| 2 | ## This file is part of the coreboot project. |
| 3 | ## |
| 4 | ## Copyright (C) 2011 secunet Security Networks AG |
| 5 | ## |
| 6 | ## This program is free software; you can redistribute it and/or modify |
| 7 | ## it under the terms of the GNU General Public License as published by |
| 8 | ## the Free Software Foundation; version 2 of the License. |
| 9 | ## |
| 10 | ## This program is distributed in the hope that it will be useful, |
| 11 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | ## GNU General Public License for more details. |
| 14 | ## |
| 15 | ## You should have received a copy of the GNU General Public License |
| 16 | ## along with this program; if not, write to the Free Software |
| 17 | ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | ## |
| 19 | |
| 20 | ####################################################################### |
| 21 | # misleadingly named, this is the coreboot version |
Vadim Bendebury | 6e7abcd | 2012-12-10 15:47:23 -0800 | [diff] [blame] | 22 | export KERNELVERSION := $(shell if [ -d "$(top)/.git" -a -f "`which git`" ]; \ |
| 23 | then git describe --dirty --always || git describe; \ |
| 24 | else echo 4.0$(KERNELREVISION); fi) |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 25 | |
| 26 | ####################################################################### |
| 27 | # Basic component discovery |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 28 | MAINBOARDDIR=$(call strip_quotes,$(CONFIG_MAINBOARD_DIR)) |
| 29 | export MAINBOARDDIR |
| 30 | |
Kyösti Mälkki | 0db2ae3a | 2012-04-19 12:00:06 +0300 | [diff] [blame] | 31 | ## Final build results, which CBFSTOOL uses to create the final |
| 32 | ## rom image file, are placed under $(objcbfs). |
| 33 | ## These typically have suffixes .debug .elf .bin and .map |
Stefan Reinauer | a60ca36 | 2012-08-09 11:09:44 -0700 | [diff] [blame] | 34 | export objcbfs := $(obj)/cbfs/$(call strip_quotes,$(CONFIG_CBFS_PREFIX)) |
Kyösti Mälkki | 0db2ae3a | 2012-04-19 12:00:06 +0300 | [diff] [blame] | 35 | |
| 36 | ## Based on the active configuration, Makefile conditionally collects |
| 37 | ## the required assembly includes and saves them in a file. |
| 38 | ## Such files that do not have a clear one-to-one relation to a source |
| 39 | ## file under src/ are placed and built under $(objgenerated) |
| 40 | export objgenerated := $(obj)/generated |
| 41 | |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 42 | ####################################################################### |
| 43 | # root rule to resolve if in build mode (ie. configuration exists) |
| 44 | real-target: $(obj)/config.h coreboot |
Kyösti Mälkki | 0db2ae3a | 2012-04-19 12:00:06 +0300 | [diff] [blame] | 45 | coreboot: build-dirs $(obj)/coreboot.rom |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 46 | |
| 47 | ####################################################################### |
| 48 | # our phony targets |
Kyösti Mälkki | 0db2ae3a | 2012-04-19 12:00:06 +0300 | [diff] [blame] | 49 | PHONY+= clean-abuild coreboot lint lint-stable build-dirs |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 50 | |
| 51 | ####################################################################### |
| 52 | # root source directories of coreboot |
Stefan Reinauer | 8d71155 | 2012-11-30 12:34:04 -0800 | [diff] [blame] | 53 | subdirs-y := src/lib src/console src/device src/ec src/southbridge |
Kyösti Mälkki | 2a830d0 | 2011-12-01 17:49:43 +0200 | [diff] [blame] | 54 | subdirs-y += src/northbridge src/superio src/drivers src/cpu src/vendorcode |
Patrick Georgi | 499fc92 | 2012-03-09 10:53:52 +0100 | [diff] [blame] | 55 | subdirs-y += util/cbfstool util/sconfig util/nvramtool |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 56 | subdirs-y += src/arch/$(ARCHDIR-y) |
| 57 | subdirs-y += src/mainboard/$(MAINBOARDDIR) |
| 58 | |
Patrick Georgi | a25828d | 2011-09-02 09:57:01 +0200 | [diff] [blame] | 59 | subdirs-y += site-local |
| 60 | |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 61 | ####################################################################### |
| 62 | # Add source classes and their build options |
Hung-Te Lin | fe18792 | 2013-02-01 01:09:24 +0800 | [diff] [blame] | 63 | classes-y := ramstage romstage bootblock smm cpu_microcode |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 64 | |
Patrick Georgi | f33e395 | 2012-11-25 17:10:47 +0100 | [diff] [blame] | 65 | ####################################################################### |
| 66 | # Helper functions for ramstage postprocess |
| 67 | spc := |
| 68 | spc += |
| 69 | $(spc) := |
| 70 | $(spc) += |
| 71 | |
| 72 | # files-in-dir-recursive,dir,files |
| 73 | files-in-dir-recursive=$(filter $(1)%,$(2)) |
| 74 | |
| 75 | # parent-dir,dir/ |
| 76 | parent-dir=$(dir $(subst $( ),/,$(strip $(subst /, ,$(1))))) |
| 77 | |
| 78 | # filters out exactly the directory specified |
| 79 | # filter-out-dir,dir_to_keep,dirs |
| 80 | filter-out-dir=$(filter-out $(1),$(2)) |
| 81 | |
| 82 | # filters out dir_to_keep and all its parents |
| 83 | # filter-out-dirs,dir_to_keep,dirs |
| 84 | filter-out-dirs=$(if $(filter-out ./,$(1)),$(call filter-out-dirs,$(call parent-dir,$(1)),$(call filter-out-dir,$(1),$(2))),$(call filter-out-dir,$(1),$(2))) |
| 85 | |
| 86 | # dir-wildcards,dirs |
| 87 | dir-wildcards=$(addsuffix %,$(1)) |
| 88 | |
| 89 | # files-in-dir,dir,files |
| 90 | files-in-dir=$(filter-out $(call dir-wildcards,$(call filter-out-dirs,$(1),$(dir $(2)))),$(call files-in-dir-recursive,$(1),$(2))) |
| 91 | |
| 92 | ####################################################################### |
| 93 | # reduce command line length by linking the objects of each |
| 94 | # directory into an intermediate file |
| 95 | ramstage-postprocess=$(foreach d,$(sort $(dir $(1))), \ |
| 96 | $(eval $(d)ramstage.o: $(call files-in-dir,$(d),$(1)); $$(LD) -o $$@ -r $$^ ) \ |
| 97 | $(eval ramstage-objs:=$(d)ramstage.o $(filter-out $(call files-in-dir,$(d),$(1)),$(ramstage-objs)))) |
| 98 | |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 99 | romstage-c-ccopts:=-D__PRE_RAM__ |
Stefan Reinauer | 61aee5f | 2011-04-10 04:15:23 +0000 | [diff] [blame] | 100 | romstage-S-ccopts:=-D__PRE_RAM__ |
Rudolf Marek | 7f0e930 | 2011-09-02 23:23:41 +0200 | [diff] [blame] | 101 | ifeq ($(CONFIG_TRACE),y) |
| 102 | ramstage-c-ccopts:= -finstrument-functions |
| 103 | endif |
Stefan Reinauer | d37ab45 | 2012-12-18 16:23:28 -0800 | [diff] [blame] | 104 | ifeq ($(CONFIG_COVERAGE),y) |
| 105 | ramstage-c-ccopts+=-fprofile-arcs -ftest-coverage |
| 106 | endif |
Rudolf Marek | 7f0e930 | 2011-09-02 23:23:41 +0200 | [diff] [blame] | 107 | |
Patrick Georgi | 7e9b9d8 | 2012-04-30 21:06:10 +0200 | [diff] [blame] | 108 | ifeq ($(CONFIG_USE_BLOBS),y) |
| 109 | forgetthis:=$(shell git submodule update --init --checkout 3rdparty) |
Patrick Georgi | 7e9b9d8 | 2012-04-30 21:06:10 +0200 | [diff] [blame] | 110 | endif |
| 111 | |
Hung-Te Lin | 5f83f6c | 2013-02-04 14:38:03 +0800 | [diff] [blame] | 112 | bootblock-c-ccopts:=-D__BOOT_BLOCK__ -D__PRE_RAM__ |
| 113 | bootblock-S-ccopts:=-D__BOOT_BLOCK__ -D__PRE_RAM__ |
Hung-Te Lin | fe18792 | 2013-02-01 01:09:24 +0800 | [diff] [blame] | 114 | |
Stefan Reinauer | 24ef134 | 2011-04-14 22:28:00 +0000 | [diff] [blame] | 115 | smm-c-ccopts:=-D__SMM__ |
| 116 | smm-S-ccopts:=-D__SMM__ |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 117 | |
Stefan Reinauer | 3aa067f | 2012-04-02 13:24:04 -0700 | [diff] [blame] | 118 | # SMM TSEG base is dynamic |
| 119 | ifeq ($(CONFIG_SMM_TSEG),y) |
| 120 | smm-c-ccopts += -fpic |
| 121 | endif |
| 122 | |
Patrick Georgi | 57205c7 | 2011-03-08 20:49:18 +0000 | [diff] [blame] | 123 | ramstage-c-deps:=$$(OPTION_TABLE_H) |
| 124 | romstage-c-deps:=$$(OPTION_TABLE_H) |
Hung-Te Lin | fe18792 | 2013-02-01 01:09:24 +0800 | [diff] [blame] | 125 | bootblock-c-deps:=$$(OPTION_TABLE_H) |
Patrick Georgi | 57205c7 | 2011-03-08 20:49:18 +0000 | [diff] [blame] | 126 | |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 127 | ####################################################################### |
| 128 | # Add handler to compile ACPI's ASL |
| 129 | define ramstage-objs_asl_template |
Sven Schnelle | d69438e | 2011-03-29 09:01:10 +0000 | [diff] [blame] | 130 | $(obj)/$(1).ramstage.o: src/$(1).asl $(obj)/config.h |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 131 | @printf " IASL $$(subst $(top)/,,$$(@))\n" |
Patrick Georgi | c0e16e7 | 2012-05-05 15:11:22 +0200 | [diff] [blame] | 132 | $(CC) -x assembler-with-cpp -E -MMD -MT $$(@) -D__ACPI__ -P -include $(src)/include/kconfig.h -I$(obj) -I$(src) -I$(src)/include -I$(src)/arch/$(ARCHDIR-y)/include -I$(src)/mainboard/$(MAINBOARDDIR) $$< -o $$(basename $$@).asl |
Marc Jones | 2aac3f6 | 2011-08-08 16:07:50 -0600 | [diff] [blame] | 133 | cd $$(dir $$@); $(IASL) -p $$(notdir $$@) -tc $$(notdir $$(basename $$@)).asl |
Patrick Georgi | b2a4264 | 2011-06-01 19:54:16 +0000 | [diff] [blame] | 134 | mv $$(basename $$@).hex $$(basename $$@).c |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 135 | $(CC) $$(CFLAGS) $$(if $$(subst dsdt,,$$(basename $$(notdir $(1)))), -DAmlCode=AmlCode_$$(basename $$(notdir $(1)))) -c -o $$@ $$(basename $$@).c |
| 136 | # keep %.o: %.c rule from catching the temporary .c file after a make clean |
| 137 | mv $$(basename $$@).c $$(basename $$@).hex |
| 138 | endef |
| 139 | |
| 140 | ####################################################################### |
Patrick Georgi | 3bbd2bf | 2012-03-09 12:30:07 +0100 | [diff] [blame] | 141 | # Parse plaintext cmos defaults into binary format |
| 142 | # arg1: source file |
| 143 | # arg2: binary file name |
| 144 | cbfs-files-processor-nvramtool= \ |
| 145 | $(eval $(2): $(1) $(src)/mainboard/$(MAINBOARDDIR)/cmos.layout | $(objutil)/nvramtool/nvramtool ; \ |
| 146 | printf " CREATE $(2) (from $(1))\n"; $(objutil)/nvramtool/nvramtool -y $(src)/mainboard/$(MAINBOARDDIR)/cmos.layout -D $(2).tmp -p $(1) && mv $(2).tmp $(2)) |
| 147 | |
| 148 | ####################################################################### |
Patrick Georgi | 843005c | 2012-04-30 23:15:17 +0200 | [diff] [blame] | 149 | # Link VSA binary to ELF-ish stage |
| 150 | # arg1: source file |
| 151 | # arg2: binary file name |
| 152 | cbfs-files-processor-vsa= \ |
| 153 | $(eval $(2): $(1) ; \ |
| 154 | printf " CREATE $(2) (from $(1))\n"; $(OBJCOPY) --set-start 0x20 --adjust-vma 0x60000 -I binary -O elf32-i386 -B i386 $(1) $(2).tmp && $(LD) -m elf_i386 -e 0x60020 --section-start .data=0x60000 $(2).tmp -o $(2)) |
| 155 | |
| 156 | ####################################################################### |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 157 | # Add handler for arbitrary files in CBFS |
| 158 | $(call add-special-class,cbfs-files) |
| 159 | cbfs-files-handler= \ |
Patrick Georgi | 3bbd2bf | 2012-03-09 12:30:07 +0100 | [diff] [blame] | 160 | $(eval tmp-cbfs-method:=$(word 2, $(subst :, ,$($(2)-file)))) \ |
Patrick Georgi | 1fc2bda | 2012-11-15 14:51:54 +0100 | [diff] [blame] | 161 | $(eval $(2)-file:=$(call strip_quotes,$(word 1, $(subst :, ,$($(2)-file))))) \ |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 162 | $(if $(wildcard $(1)$($(2)-file)), \ |
| 163 | $(eval tmp-cbfs-file:= $(wildcard $(1)$($(2)-file))), \ |
| 164 | $(eval tmp-cbfs-file:= $($(2)-file))) \ |
Patrick Georgi | 70c85ea | 2013-02-16 01:06:57 +0100 | [diff] [blame] | 165 | $(if $(strip $($(2)-required)), \ |
| 166 | $(if $(wildcard $(tmp-cbfs-file)),, \ |
| 167 | $(info This build configuration requires $($(2)-required)) \ |
| 168 | $(eval FAILBUILD:=1) \ |
| 169 | )) \ |
Patrick Georgi | 3bbd2bf | 2012-03-09 12:30:07 +0100 | [diff] [blame] | 170 | $(if $(tmp-cbfs-method), \ |
| 171 | $(eval tmp-old-cbfs-file:=$(tmp-cbfs-file)) \ |
Patrick Georgi | 16c7ad7 | 2012-09-21 18:11:59 +0200 | [diff] [blame] | 172 | $(eval tmp-cbfs-file:=$(shell mkdir -p $(obj)/mainboard/$(MAINBOARDDIR); mktemp $(obj)/mainboard/$(MAINBOARDDIR)/cbfs-file.XXXXXX).out) \ |
Patrick Georgi | 3bbd2bf | 2012-03-09 12:30:07 +0100 | [diff] [blame] | 173 | $(call cbfs-files-processor-$(tmp-cbfs-method),$(tmp-old-cbfs-file),$(tmp-cbfs-file))) \ |
Dave Frodin | 0013bbf | 2012-08-14 11:01:53 -0600 | [diff] [blame] | 174 | $(eval cbfs-files += $(tmp-cbfs-file)|$(2)|$($(2)-type)|$($(2)-compression)|$($(2)-position)) \ |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 175 | $(eval $(2)-name:=) \ |
| 176 | $(eval $(2)-type:=) \ |
Dave Frodin | 0013bbf | 2012-08-14 11:01:53 -0600 | [diff] [blame] | 177 | $(eval $(2)-compression:=) \ |
Patrick Georgi | 70c85ea | 2013-02-16 01:06:57 +0100 | [diff] [blame] | 178 | $(eval $(2)-position:=) \ |
| 179 | $(eval $(2)-required:=) |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 180 | |
| 181 | ####################################################################### |
| 182 | # a variety of flags for our build |
Stefan Reinauer | 6321758 | 2012-10-29 16:52:36 -0700 | [diff] [blame] | 183 | CBFS_COMPRESS_FLAG:=none |
Sven Schnelle | 8eee19d | 2011-05-02 19:53:04 +0000 | [diff] [blame] | 184 | ifeq ($(CONFIG_COMPRESS_RAMSTAGE),y) |
Stefan Reinauer | 6321758 | 2012-10-29 16:52:36 -0700 | [diff] [blame] | 185 | CBFS_COMPRESS_FLAG:=LZMA |
Sven Schnelle | 8eee19d | 2011-05-02 19:53:04 +0000 | [diff] [blame] | 186 | endif |
| 187 | |
Stefan Reinauer | 6321758 | 2012-10-29 16:52:36 -0700 | [diff] [blame] | 188 | CBFS_PAYLOAD_COMPRESS_FLAG:=none |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 189 | ifeq ($(CONFIG_COMPRESSED_PAYLOAD_LZMA),y) |
Stefan Reinauer | 6321758 | 2012-10-29 16:52:36 -0700 | [diff] [blame] | 190 | CBFS_PAYLOAD_COMPRESS_FLAG:=LZMA |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 191 | endif |
| 192 | |
| 193 | ifneq ($(CONFIG_LOCALVERSION),"") |
| 194 | COREBOOT_EXTRA_VERSION := -$(call strip_quotes,$(CONFIG_LOCALVERSION)) |
| 195 | endif |
| 196 | |
| 197 | INCLUDES := -Isrc -Isrc/include -I$(obj) -Isrc/arch/$(ARCHDIR-y)/include |
Stefan Reinauer | 8d71155 | 2012-11-30 12:34:04 -0800 | [diff] [blame] | 198 | INCLUDES += -Isrc/device/oprom/include |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 199 | # abspath is a workaround for romcc |
Patrick Georgi | c0e16e7 | 2012-05-05 15:11:22 +0200 | [diff] [blame] | 200 | INCLUDES += -include $(src)/include/kconfig.h |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 201 | |
Frank Vibrans | ec40260 | 2011-05-05 16:45:36 +0000 | [diff] [blame] | 202 | CFLAGS = $(INCLUDES) -Os -pipe -g -nostdinc |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 203 | CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes |
| 204 | CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs |
| 205 | CFLAGS += -Wstrict-aliasing -Wshadow |
| 206 | ifeq ($(CONFIG_WARNINGS_ARE_ERRORS),y) |
| 207 | CFLAGS += -Werror |
| 208 | endif |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 209 | CFLAGS += -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer |
| 210 | |
Stefan Reinauer | 5b63579 | 2012-08-16 14:05:42 -0700 | [diff] [blame] | 211 | additional-dirs := $(objutil)/cbfstool $(objutil)/romcc $(objutil)/ifdtool $(objutil)/options |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 212 | |
| 213 | ####################################################################### |
| 214 | # generate build support files |
| 215 | $(obj)/build.h: .xcompile |
| 216 | @printf " GEN build.h\n" |
| 217 | rm -f $(obj)/build.h |
| 218 | printf "/* build system definitions (autogenerated) */\n" > $(obj)/build.ht |
| 219 | printf "#ifndef __BUILD_H\n" >> $(obj)/build.ht |
| 220 | printf "#define __BUILD_H\n\n" >> $(obj)/build.ht |
Patrick Georgi | b8e9ba9 | 2011-03-17 07:47:49 +0000 | [diff] [blame] | 221 | printf "#define COREBOOT_VERSION \"$(KERNELVERSION)\"\n" >> $(obj)/build.ht |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 222 | printf "#define COREBOOT_EXTRA_VERSION \"$(COREBOOT_EXTRA_VERSION)\"\n" >> $(obj)/build.ht |
| 223 | printf "#define COREBOOT_BUILD \"`LANG= date`\"\n" >> $(obj)/build.ht |
Zheng Bao | 0e6d0ed | 2012-11-09 19:55:04 +0800 | [diff] [blame] | 224 | printf "#define COREBOOT_BUILD_YEAR_BCD 0x`LANG= date +"%y"`\n" >> $(obj)/build.ht |
| 225 | printf "#define COREBOOT_BUILD_MONTH_BCD 0x`LANG= date +"%m"`\n" >> $(obj)/build.ht |
| 226 | printf "#define COREBOOT_BUILD_DAY_BCD 0x`LANG= date +"%d"`\n" >> $(obj)/build.ht |
| 227 | printf "#define COREBOOT_BUILD_WEEKDAY_BCD 0x`LANG= date +"%w"`\n" >> $(obj)/build.ht |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 228 | printf "#define COREBOOT_DMI_DATE \"`LANG= date +"%m/%d/%Y"`\"\n" >> $(obj)/build.ht |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 229 | printf "\n" >> $(obj)/build.ht |
| 230 | printf "#define COREBOOT_COMPILER \"$(shell LANG= $(CC) --version | head -n1)\"\n" >> $(obj)/build.ht |
| 231 | printf "#define COREBOOT_ASSEMBLER \"$(shell LANG= $(AS) --version | head -n1)\"\n" >> $(obj)/build.ht |
| 232 | printf "#define COREBOOT_LINKER \"$(shell LANG= $(LD) --version | head -n1)\"\n" >> $(obj)/build.ht |
| 233 | printf "#define COREBOOT_COMPILE_TIME \"`LANG= date +%T`\"\n" >> $(obj)/build.ht |
| 234 | printf "#define COREBOOT_COMPILE_BY \"$(subst \,@,$(shell PATH=$$PATH:/usr/ucb whoami))\"\n" >> $(obj)/build.ht |
Zheng Bao | 86aa7c4 | 2012-09-28 16:06:44 +0800 | [diff] [blame] | 235 | printf "#define COREBOOT_COMPILE_HOST \"$(shell hostname -s 2>/dev/null || hostname 2>/dev/null)\"\n" >> $(obj)/build.ht |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 236 | printf "#define COREBOOT_COMPILE_DOMAIN \"$(shell test `uname -s` = "Linux" && dnsdomainname || domainname 2>/dev/null)\"\n" >> $(obj)/build.ht |
| 237 | printf "#endif\n" >> $(obj)/build.ht |
| 238 | mv $(obj)/build.ht $(obj)/build.h |
| 239 | |
| 240 | $(obj)/ldoptions: $(obj)/config.h |
| 241 | awk '/^#define ([^"])* ([^"])*$$/ {gsub("\\r","",$$3); print $$2 " = " $$3 ";";}' $< > $@ |
| 242 | |
Kyösti Mälkki | 0db2ae3a | 2012-04-19 12:00:06 +0300 | [diff] [blame] | 243 | build-dirs: |
| 244 | mkdir -p $(objcbfs) $(objgenerated) |
| 245 | |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 246 | ####################################################################### |
| 247 | # Build the tools |
| 248 | CBFSTOOL:=$(obj)/cbfstool |
| 249 | |
| 250 | $(CBFSTOOL): $(objutil)/cbfstool/cbfstool |
| 251 | cp $< $@ |
| 252 | |
| 253 | _WINCHECK=$(shell uname -o 2> /dev/null) |
| 254 | STACK= |
| 255 | ifeq ($(_WINCHECK),Msys) |
| 256 | STACK=-Wl,--stack,16384000 |
| 257 | endif |
| 258 | ifeq ($(_WINCHECK),Cygwin) |
| 259 | STACK=-Wl,--stack,16384000 |
| 260 | endif |
| 261 | |
| 262 | ROMCC:= $(objutil)/romcc/romcc |
| 263 | $(ROMCC): $(top)/util/romcc/romcc.c |
| 264 | @printf " HOSTCC $(subst $(obj)/,,$(@)) (this may take a while)\n" |
| 265 | @# Note: Adding -O2 here might cause problems. For details see: |
| 266 | @# http://www.coreboot.org/pipermail/coreboot/2010-February/055825.html |
| 267 | $(HOSTCC) -g $(STACK) -Wall -o $@ $< |
| 268 | |
Stefan Reinauer | 5b63579 | 2012-08-16 14:05:42 -0700 | [diff] [blame] | 269 | IFDTOOL:=$(objutil)/ifdtool/ifdtool |
| 270 | $(IFDTOOL): $(top)/util/ifdtool/ifdtool.c |
| 271 | @printf " HOSTCC $(subst $(obj)/,,$(@))\n" |
| 272 | $(HOSTCC) $(HOSTCFLAGS) -o $@ $< |
| 273 | |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 274 | ####################################################################### |
| 275 | # needed objects that every mainboard uses |
| 276 | # Creation of these is architecture and mainboard independent |
| 277 | $(obj)/mainboard/$(MAINBOARDDIR)/static.c: $(src)/mainboard/$(MAINBOARDDIR)/devicetree.cb $(objutil)/sconfig/sconfig |
| 278 | @printf " SCONFIG $(subst $(src)/,,$(<))\n" |
| 279 | mkdir -p $(obj)/mainboard/$(MAINBOARDDIR) |
| 280 | $(objutil)/sconfig/sconfig $(MAINBOARDDIR) $(obj)/mainboard/$(MAINBOARDDIR) |
| 281 | |
| 282 | ramstage-y+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c |
Stefan Reinauer | 57879c9 | 2012-07-31 16:47:25 -0700 | [diff] [blame] | 283 | romstage-y+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 284 | |
| 285 | $(objutil)/%.o: $(objutil)/%.c |
| 286 | @printf " HOSTCC $(subst $(objutil)/,,$(@))\n" |
| 287 | $(HOSTCC) -MMD -I$(subst $(objutil)/,util/,$(dir $<)) -I$(dir $<) $(HOSTCFLAGS) -c -o $@ $< |
| 288 | |
Patrick Georgi | 64ccc3b8 | 2011-05-20 23:08:12 +0000 | [diff] [blame] | 289 | $(obj)/%.ramstage.o $(abspath $(obj))/%.ramstage.o: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H) |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 290 | @printf " CC $(subst $(obj)/,,$(@))\n" |
| 291 | $(CC) -MMD $(CFLAGS) -c -o $@ $< |
| 292 | |
Stefan Reinauer | 57879c9 | 2012-07-31 16:47:25 -0700 | [diff] [blame] | 293 | $(obj)/%.romstage.o $(abspath $(obj))/%.romstage.o: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H) |
| 294 | @printf " CC $(subst $(obj)/,,$(@))\n" |
| 295 | $(CC) -MMD -D__PRE_RAM__ $(CFLAGS) -c -o $@ $< |
| 296 | |
Hung-Te Lin | fe18792 | 2013-02-01 01:09:24 +0800 | [diff] [blame] | 297 | $(obj)/%.bootblock.o $(abspath $(obj))/%.bootblock.o: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H) |
| 298 | @printf " CC $(subst $(obj)/,,$(@))\n" |
Hung-Te Lin | 5f83f6c | 2013-02-04 14:38:03 +0800 | [diff] [blame] | 299 | $(CC) -MMD $(bootblock-c-ccopts) $(CFLAGS) -c -o $@ $< |
Hung-Te Lin | fe18792 | 2013-02-01 01:09:24 +0800 | [diff] [blame] | 300 | |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 301 | ####################################################################### |
| 302 | # Clean up rules |
| 303 | clean-abuild: |
| 304 | rm -rf coreboot-builds |
| 305 | |
| 306 | clean-for-update-target: |
| 307 | rm -f $(obj)/coreboot_ram* $(obj)/coreboot.romstage $(obj)/coreboot.pre* $(obj)/coreboot.bootblock $(obj)/coreboot.a |
| 308 | rm -rf $(obj)/bootblock* $(obj)/romstage* $(obj)/location.* |
| 309 | rm -f $(obj)/option_table.* $(obj)/crt0.S $(obj)/ldscript |
| 310 | rm -f $(obj)/mainboard/$(MAINBOARDDIR)/static.c $(obj)/mainboard/$(MAINBOARDDIR)/config.py $(obj)/mainboard/$(MAINBOARDDIR)/static.dot |
| 311 | rm -f $(obj)/mainboard/$(MAINBOARDDIR)/crt0.s $(obj)/mainboard/$(MAINBOARDDIR)/crt0.disasm |
| 312 | rm -f $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc |
| 313 | rm -f $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.* $(obj)/mainboard/$(MAINBOARDDIR)/dsdt.* |
| 314 | rm -f $(obj)/cpu/x86/smm/smm_bin.c $(obj)/cpu/x86/smm/smm.* $(obj)/cpu/x86/smm/smm |
Marc Jones | 1dd0dda | 2012-03-19 17:32:33 -0600 | [diff] [blame] | 315 | $(MAKE) -C payloads/external/SeaBIOS -f Makefile.inc clean OUT=$(abspath $(obj)) HOSTCC="$(HOSTCC)" CC="$(CC)" LD="$(LD)" |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 316 | |
| 317 | clean-target: |
| 318 | rm -f $(obj)/coreboot* |
| 319 | |
| 320 | ####################################################################### |
| 321 | # Development utilities |
| 322 | printcrt0s: |
| 323 | @echo crt0s=$(crt0s) |
| 324 | @echo ldscripts=$(ldscripts) |
| 325 | |
| 326 | update: |
| 327 | dongle.py -c /dev/term/1 $(obj)/coreboot.rom EOF |
| 328 | |
Patrick Georgi | cb02cb7 | 2012-02-25 19:42:59 +0100 | [diff] [blame] | 329 | lint lint-stable: |
Zheng Bao | 533bca8 | 2012-09-28 19:38:37 +0800 | [diff] [blame] | 330 | FAILED=0; LINTLOG=`mktemp .tmpconfig.lintXXXXX`; \ |
Patrick Georgi | cb02cb7 | 2012-02-25 19:42:59 +0100 | [diff] [blame] | 331 | for script in util/lint/$@-*; do \ |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 332 | echo; echo `basename $$script`; \ |
| 333 | grep "^# DESCR:" $$script | sed "s,.*DESCR: *,," ; \ |
| 334 | echo ========; \ |
| 335 | $$script > $$LINTLOG; \ |
Patrick Georgi | c040e476 | 2012-03-09 23:02:09 +0100 | [diff] [blame] | 336 | if [ `cat $$LINTLOG | wc -l` -eq 0 ]; then \ |
Patrick Georgi | 71b8480 | 2011-02-22 14:35:05 +0000 | [diff] [blame] | 337 | printf "success\n\n"; \ |
| 338 | else \ |
| 339 | echo test failed: ; \ |
| 340 | cat $$LINTLOG; \ |
| 341 | rm -f $$LINTLOG; \ |
| 342 | FAILED=$$(( $$FAILED + 1 )); \ |
| 343 | fi; \ |
| 344 | echo ========; \ |
| 345 | done; \ |
| 346 | test $$FAILED -eq 0 || { echo "ERROR: $$FAILED test(s) failed." && exit 1; }; \ |
| 347 | rm -f $$LINTLOG |
Patrick Georgi | 6c44550 | 2011-05-16 15:32:28 +0000 | [diff] [blame] | 348 | |
Patrick Georgi | bb60528 | 2011-06-05 15:15:49 +0200 | [diff] [blame] | 349 | gitconfig: |
Zheng Bao | 50ad095 | 2012-10-22 16:29:37 +0800 | [diff] [blame] | 350 | mkdir -p .git/hooks |
zbao | f2c3254 | 2012-08-10 15:44:02 +0800 | [diff] [blame] | 351 | for hook in commit-msg pre-commit ; do \ |
| 352 | if [ util/gitconfig/$$hook -nt .git/hooks/$$hook -o \ |
| 353 | ! -x .git/hooks/$$hook ]; then \ |
| 354 | cp util/gitconfig/$$hook .git/hooks/$$hook; \ |
| 355 | chmod +x .git/hooks/$$hook; \ |
| 356 | fi; \ |
| 357 | done |
Ronald G. Minnich | 64b364d | 2013-01-03 08:26:09 -0800 | [diff] [blame] | 358 | git config remote.origin.push HEAD:refs/for/master |
Patrick Georgi | bb60528 | 2011-06-05 15:15:49 +0200 | [diff] [blame] | 359 | (git config --global user.name >/dev/null && git config --global user.email >/dev/null) || (printf 'Please configure your name and email in git:\n\n git config --global user.name "Your Name Comes Here"\n git config --global user.email your.email@example.com\n'; exit 1) |
| 360 | |
Patrick Georgi | 6c44550 | 2011-05-16 15:32:28 +0000 | [diff] [blame] | 361 | crossgcc: clean-for-update |
Peter Stuge | 0b6b4d6 | 2011-06-09 05:06:25 +0200 | [diff] [blame] | 362 | $(MAKE) -C util/crossgcc build-without-gdb |
| 363 | |
| 364 | crosstools: clean-for-update |
Patrick Georgi | 6c44550 | 2011-05-16 15:32:28 +0000 | [diff] [blame] | 365 | $(MAKE) -C util/crossgcc build |
| 366 | |
| 367 | crossgcc-clean: clean-for-update |
| 368 | $(MAKE) -C util/crossgcc clean |
| 369 | |
Patrick Georgi | 43105d6 | 2011-11-05 14:44:41 +0100 | [diff] [blame] | 370 | tools: $(objutil)/kconfig/conf $(objutil)/cbfstool/cbfstool $(objutil)/nvramtool/nvramtool $(objutil)/romcc/romcc $(objutil)/sconfig/sconfig |
| 371 | |