coreboot/Makefile.inc
<<
>>
Prefs
   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
  22REV=-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)
  23export KERNELVERSION      := 4.0$(REV)
  24
  25#######################################################################
  26# Basic component discovery
  27ARCHDIR-$(CONFIG_ARCH_X86) := x86
  28MAINBOARDDIR=$(call strip_quotes,$(CONFIG_MAINBOARD_DIR))
  29export MAINBOARDDIR
  30
  31#######################################################################
  32# root rule to resolve if in build mode (ie. configuration exists)
  33real-target: $(obj)/config.h coreboot
  34coreboot: $(obj)/coreboot.rom
  35
  36#######################################################################
  37# our phony targets
  38PHONY+= clean-abuild coreboot
  39
  40#######################################################################
  41# root source directories of coreboot
  42subdirs-y := src/lib src/boot src/console src/devices src/ec src/southbridge src/northbridge src/superio src/drivers src/cpu
  43subdirs-y += util/cbfstool util/sconfig
  44subdirs-y += src/arch/$(ARCHDIR-y)
  45subdirs-y += src/mainboard/$(MAINBOARDDIR)
  46
  47subdirs-$(CONFIG_ARCH_X86) += src/pc80
  48
  49#######################################################################
  50# Add source classes and their build options
  51classes-y := ramstage romstage driver smm
  52
  53romstage-c-ccopts:=-D__PRE_RAM__
  54romstage-S-ccopts:=-D__PRE_RAM__
  55smm-c-ccopts:=-D__SMM__
  56smm-S-ccopts:=-D__SMM__
  57
  58ramstage-c-deps:=$$(OPTION_TABLE_H)
  59romstage-c-deps:=$$(OPTION_TABLE_H)
  60
  61#######################################################################
  62# Add handler to compile ACPI's ASL
  63define ramstage-objs_asl_template
  64$(obj)/$(1).ramstage.o: src/$(1).asl $(obj)/config.h
  65        @printf "    IASL       $$(subst $(top)/,,$$(@))\n"
  66        $(CC) -x assembler-with-cpp -E -MMD -MT $$(@) -D__ACPI__ -P -include $(abspath $(obj)/config.h) -I$(src) -I$(src)/mainboard/$(MAINBOARDDIR) $$< -o $$(basename $$@).asl
  67        cd $$(dir $$@); iasl -p $$(notdir $$@) -tc $$(notdir $$(basename $$@)).asl
  68        mv $$(basename $$@).hex $$(basename $$@).c
  69        $(CC) $$(CFLAGS) $$(if $$(subst dsdt,,$$(basename $$(notdir $(1)))), -DAmlCode=AmlCode_$$(basename $$(notdir $(1)))) -c -o $$@ $$(basename $$@).c
  70        # keep %.o: %.c rule from catching the temporary .c file after a make clean
  71        mv $$(basename $$@).c $$(basename $$@).hex
  72endef
  73
  74#######################################################################
  75# Add handler for arbitrary files in CBFS
  76$(call add-special-class,cbfs-files)
  77cbfs-files-handler= \
  78                $(if $(wildcard $(1)$($(2)-file)), \
  79                        $(eval tmp-cbfs-file:= $(wildcard $(1)$($(2)-file))), \
  80                        $(eval tmp-cbfs-file:= $($(2)-file))) \
  81                $(eval cbfs-files += $(tmp-cbfs-file)|$(2)|$($(2)-type)|$($(2)-position)) \
  82                $(eval $(2)-name:=) \
  83                $(eval $(2)-type:=) \
  84                $(eval $(2)-position:=)
  85
  86#######################################################################
  87# a variety of flags for our build
  88CBFS_COMPRESS_FLAG:=
  89ifeq ($(CONFIG_COMPRESS_RAMSTAGE),y)
  90CBFS_COMPRESS_FLAG:=l
  91endif
  92
  93CBFS_PAYLOAD_COMPRESS_FLAG:=
  94CBFS_PAYLOAD_COMPRESS_NAME:=none
  95ifeq ($(CONFIG_COMPRESSED_PAYLOAD_LZMA),y)
  96CBFS_PAYLOAD_COMPRESS_FLAG:=l
  97CBFS_PAYLOAD_COMPRESS_NAME:=LZMA
  98endif
  99
 100ifneq ($(CONFIG_LOCALVERSION),"")
 101COREBOOT_EXTRA_VERSION := -$(call strip_quotes,$(CONFIG_LOCALVERSION))
 102endif
 103
 104INCLUDES := -Isrc -Isrc/include -I$(obj) -Isrc/arch/$(ARCHDIR-y)/include
 105INCLUDES += -Isrc/devices/oprom/include
 106# abspath is a workaround for romcc
 107INCLUDES += -include $(abspath $(obj)/config.h)
 108
 109CFLAGS = $(INCLUDES) -Os -pipe -g -nostdinc
 110CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
 111CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs
 112CFLAGS += -Wstrict-aliasing -Wshadow
 113ifeq ($(CONFIG_WARNINGS_ARE_ERRORS),y)
 114CFLAGS += -Werror
 115endif
 116CFLAGS += -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer
 117
 118additional-dirs := $(objutil)/cbfstool $(objutil)/romcc $(objutil)/options
 119
 120#######################################################################
 121# generate build support files
 122$(obj)/build.h: .xcompile
 123        @printf "    GEN        build.h\n"
 124        rm -f $(obj)/build.h
 125        printf "/* build system definitions (autogenerated) */\n" > $(obj)/build.ht
 126        printf "#ifndef __BUILD_H\n" >> $(obj)/build.ht
 127        printf "#define __BUILD_H\n\n" >> $(obj)/build.ht
 128        printf "#define COREBOOT_VERSION \"$(KERNELVERSION)\"\n" >> $(obj)/build.ht
 129        printf "#define COREBOOT_EXTRA_VERSION \"$(COREBOOT_EXTRA_VERSION)\"\n" >> $(obj)/build.ht
 130        printf "#define COREBOOT_BUILD \"`LANG= date`\"\n" >> $(obj)/build.ht
 131        printf "\n" >> $(obj)/build.ht
 132        printf "#define COREBOOT_COMPILER \"$(shell LANG= $(CC) --version | head -n1)\"\n" >> $(obj)/build.ht
 133        printf "#define COREBOOT_ASSEMBLER \"$(shell LANG= $(AS) --version | head -n1)\"\n" >> $(obj)/build.ht
 134        printf "#define COREBOOT_LINKER \"$(shell LANG= $(LD) --version | head -n1)\"\n" >> $(obj)/build.ht
 135        printf "#define COREBOOT_COMPILE_TIME \"`LANG= date +%T`\"\n" >> $(obj)/build.ht
 136        printf "#define COREBOOT_COMPILE_BY \"$(subst \,@,$(shell PATH=$$PATH:/usr/ucb whoami))\"\n" >> $(obj)/build.ht
 137        printf "#define COREBOOT_COMPILE_HOST \"$(shell hostname -s 2>/dev/null)\"\n" >> $(obj)/build.ht
 138        printf "#define COREBOOT_COMPILE_DOMAIN \"$(shell test `uname -s` = "Linux" && dnsdomainname || domainname 2>/dev/null)\"\n" >> $(obj)/build.ht
 139        printf "#endif\n" >> $(obj)/build.ht
 140        mv $(obj)/build.ht $(obj)/build.h
 141
 142$(obj)/ldoptions: $(obj)/config.h
 143        awk '/^#define ([^"])* ([^"])*$$/ {gsub("\\r","",$$3); print $$2 " = " $$3 ";";}' $< > $@
 144
 145#######################################################################
 146# Build the tools
 147CBFSTOOL:=$(obj)/cbfstool
 148
 149$(CBFSTOOL): $(objutil)/cbfstool/cbfstool
 150        cp $< $@
 151
 152_WINCHECK=$(shell uname -o 2> /dev/null)
 153STACK=
 154ifeq ($(_WINCHECK),Msys)
 155        STACK=-Wl,--stack,16384000
 156endif
 157ifeq ($(_WINCHECK),Cygwin)
 158        STACK=-Wl,--stack,16384000
 159endif
 160
 161ROMCC:= $(objutil)/romcc/romcc
 162$(ROMCC): $(top)/util/romcc/romcc.c
 163        @printf "    HOSTCC     $(subst $(obj)/,,$(@)) (this may take a while)\n"
 164        @# Note: Adding -O2 here might cause problems. For details see:
 165        @# http://www.coreboot.org/pipermail/coreboot/2010-February/055825.html
 166        $(HOSTCC) -g $(STACK) -Wall -o $@ $<
 167
 168#######################################################################
 169# needed objects that every mainboard uses
 170# Creation of these is architecture and mainboard independent
 171$(obj)/mainboard/$(MAINBOARDDIR)/static.c: $(src)/mainboard/$(MAINBOARDDIR)/devicetree.cb  $(objutil)/sconfig/sconfig
 172        @printf "    SCONFIG    $(subst $(src)/,,$(<))\n"
 173        mkdir -p $(obj)/mainboard/$(MAINBOARDDIR)
 174        $(objutil)/sconfig/sconfig $(MAINBOARDDIR) $(obj)/mainboard/$(MAINBOARDDIR)
 175
 176ramstage-y+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c
 177
 178$(objutil)/%.o: $(objutil)/%.c
 179        @printf "    HOSTCC     $(subst $(objutil)/,,$(@))\n"
 180        $(HOSTCC) -MMD -I$(subst $(objutil)/,util/,$(dir $<)) -I$(dir $<) $(HOSTCFLAGS) -c -o $@ $<
 181
 182$(obj)/%.ramstage.o $(abspath $(obj))/%.ramstage.o: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H)
 183        @printf "    CC         $(subst $(obj)/,,$(@))\n"
 184        $(CC) -MMD $(CFLAGS) -c -o $@ $<
 185
 186#######################################################################
 187# Clean up rules
 188clean-abuild:
 189        rm -rf coreboot-builds
 190
 191clean-for-update-target:
 192        rm -f $(obj)/coreboot_ram* $(obj)/coreboot.romstage $(obj)/coreboot.pre* $(obj)/coreboot.bootblock $(obj)/coreboot.a
 193        rm -rf $(obj)/bootblock* $(obj)/romstage* $(obj)/location.*
 194        rm -f $(obj)/option_table.* $(obj)/crt0.S $(obj)/ldscript
 195        rm -f $(obj)/mainboard/$(MAINBOARDDIR)/static.c $(obj)/mainboard/$(MAINBOARDDIR)/config.py $(obj)/mainboard/$(MAINBOARDDIR)/static.dot
 196        rm -f $(obj)/mainboard/$(MAINBOARDDIR)/crt0.s $(obj)/mainboard/$(MAINBOARDDIR)/crt0.disasm
 197        rm -f $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc
 198        rm -f $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.* $(obj)/mainboard/$(MAINBOARDDIR)/dsdt.*
 199        rm -f $(obj)/cpu/x86/smm/smm_bin.c $(obj)/cpu/x86/smm/smm.* $(obj)/cpu/x86/smm/smm
 200        $(MAKE) -C payloads/external/SeaBIOS -f Makefile.inc clean
 201
 202clean-target:
 203        rm -f $(obj)/coreboot*
 204
 205#######################################################################
 206# Development utilities
 207printcrt0s:
 208        @echo crt0s=$(crt0s)
 209        @echo ldscripts=$(ldscripts)
 210
 211update:
 212        dongle.py -c /dev/term/1 $(obj)/coreboot.rom EOF
 213
 214lint:
 215        FAILED=0; LINTLOG=`mktemp`; \
 216        for script in util/lint/lint-*; do \
 217                echo; echo `basename $$script`; \
 218                grep "^# DESCR:" $$script | sed "s,.*DESCR: *,," ; \
 219                echo ========; \
 220                $$script > $$LINTLOG; \
 221                if [ `wc -l $$LINTLOG | cut -d' ' -f1` -eq 0 ]; then \
 222                        printf "success\n\n"; \
 223                else \
 224                        echo test failed: ; \
 225                        cat $$LINTLOG; \
 226                        rm -f $$LINTLOG; \
 227                        FAILED=$$(( $$FAILED + 1 )); \
 228                fi; \
 229                echo ========; \
 230        done; \
 231        test $$FAILED -eq 0 || { echo "ERROR: $$FAILED test(s) failed." &&  exit 1; }; \
 232        rm -f $$LINTLOG
 233
 234crossgcc: clean-for-update
 235        $(MAKE) -C util/crossgcc build
 236
 237crossgcc-clean: clean-for-update
 238        $(MAKE) -C util/crossgcc clean
 239
 240
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.