coreboot-v3/Makefile
<<
>>
Prefs
   1##
   2## This file is part of the coreboot project.
   3##
   4## coreboot build system Lbuild
   5##
   6## Copyright (C) 2007 coresystems GmbH
   7## (Written by Stefan Reinauer <stepan@coresystems.de> for coresystems GmbH)
   8##
   9## This program is free software; you can redistribute it and/or modify
  10## it under the terms of the GNU General Public License as published by
  11## the Free Software Foundation; either version 2 of the License, or
  12## (at your option) any later version.
  13##
  14## This program is distributed in the hope that it will be useful,
  15## but WITHOUT ANY WARRANTY; without even the implied warranty of
  16## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17## GNU General Public License for more details.
  18##
  19## You should have received a copy of the GNU General Public License
  20## along with this program; if not, write to the Free Software
  21## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  22##
  23
  24VERSION = 3
  25PATCHLEVEL = 0
  26# Set the sublevel version string from the highest revision number
  27# of the checked out files.
  28SUBLEVEL := "$(shell svnversion -cn . \ | sed -e "s/.*://" -e "s/\([0-9]*\).*/\1/")"
  29
  30have_dotconfig := $(wildcard .config)
  31
  32src := $(shell pwd)
  33obj := $(shell pwd)/build
  34export src obj
  35
  36# Do not print "Entering directory ...".
  37MAKEFLAGS += --no-print-directory
  38
  39CC         ?= gcc
  40CFLAGS     := -Os -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
  41              -Werror-implicit-function-declaration -Wstrict-aliasing \
  42              -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer \
  43              -mpreferred-stack-boundary=2 -mregparm=3 -pipe
  44# FIXME: Does stack boundary or regparm break the code on real hardware?
  45
  46HOSTCC     := $(CC)
  47HOSTCXX    := g++
  48HOSTCFLAGS := -Wall -Wstrict-prototypes -g -fomit-frame-pointer \
  49              -Wno-unused -Wno-sign-compare
  50
  51LEX        := flex
  52LYX        := lyx
  53DOXYGEN    := doxygen
  54DOXYGEN_OUTPUT_DIR := doxygen
  55
  56# Make is silent per default, but 'make V=1' will show all compiler calls.
  57ifneq ($(V),1)
  58Q := @
  59endif
  60
  61KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)
  62export KERNELVERSION
  63
  64ifeq ($(strip $(have_dotconfig)),)
  65
  66all:
  67        $(Q)printf "Please run make menuconfig, xconfig or config first.\n"
  68
  69else
  70
  71include $(src)/.config
  72
  73include $(shell scanbuild=$(CONFIG_SCAN_BUILD) $(src)/util/xcompile/xcompile > $(src)/.xcompile || \
  74        { echo "complete\\ toolchain" && rm -f $(src)/.xcompile && exit 1; }; echo $(src)/.xcompile)
  75
  76ifneq ($(CONFIG_LOCALVERSION),"")
  77COREBOOT_EXTRA_VERSION := -$(shell echo $(CONFIG_LOCALVERSION))
  78endif
  79
  80all: prepare prepare2 $(obj)/coreboot.rom
  81        $(Q)printf "  DONE\n"
  82
  83ARCH:=$(shell echo $(CONFIG_ARCH))
  84MAINBOARDDIR=$(shell echo $(CONFIG_MAINBOARD_DIR))
  85export MAINBOARDDIR
  86
  87COREBOOTINCLUDE    :=   -I$(src) -Iinclude \
  88                        -I$(src)/include \
  89                        -I$(src)/include/arch/$(ARCH)/ \
  90                        -I$(src)/mainboard/$(MAINBOARDDIR)/ \
  91                        -include $(obj)/config.h
  92
  93CC := $(CC_$(ARCH))
  94AS := $(AS_$(ARCH))
  95LD := $(LD_$(ARCH))
  96NM := $(NM_$(ARCH))
  97OBJCOPY := $(OBJCOPY_$(ARCH))
  98OBJDUMP := $(OBJDUMP_$(ARCH))
  99READELF := $(READELF_$(ARCH))
 100AR := $(AR_$(ARCH))
 101
 102CFLAGS += $(CFLAGS_$(ARCH))
 103
 104CPPFLAGS := $(COREBOOTINCLUDE)
 105CFLAGS += $(COREBOOTINCLUDE)
 106
 107# Note: This _must_ come after 'CC' is set for the second time in this
 108# Makefile (see above), otherwise the build would break if 'gcc' isn't
 109# the compiler actually used for the build (e.g. on cross compiler setups).
 110CFLAGS += -nostdinc -isystem `$(CC) -print-file-name=include`
 111
 112include lib/Makefile
 113include device/Makefile
 114include mainboard/$(MAINBOARDDIR)/Makefile
 115include Rules.make
 116include northbridge/*/*/Makefile
 117include southbridge/*/*/Makefile
 118include superio/*/*/Makefile
 119include arch/$(ARCH)/Makefile
 120
 121endif
 122
 123include util/Makefile
 124
 125doc:
 126        $(Q)$(LYX) -e pdf doc/design/newboot.lyx
 127
 128doxy: doxygen
 129doxygen:
 130        $(Q)$(DOXYGEN) util/doxygen/Doxyfile.coreboot
 131
 132prepare:
 133        $(Q)mkdir -p $(obj)
 134
 135# FIXME: If .config changed, a rebuild is required.
 136
 137prepare2:
 138        $(Q)printf "  CP      $(subst $(shell pwd)/,,$(obj)/config.h)\n"
 139        $(Q)cp $(src)/.tmpconfig.h $(obj)/config.h
 140        $(Q)printf "  GEN     $(subst $(shell pwd)/,,$(obj)/build.h)\n"
 141        $(Q)printf "#define COREBOOT_VERSION \"$(KERNELVERSION)\"\n" > $(obj)/build.h
 142        $(Q)printf "#define COREBOOT_EXTRA_VERSION \"$(COREBOOT_EXTRA_VERSION)\"\n" >> $(obj)/build.h
 143        $(Q)printf "#define COREBOOT_BUILD \"`LANG= date`\"\n" >> $(obj)/build.h
 144        $(Q)printf "\n" >> $(obj)/build.h
 145        $(Q)printf "#define COREBOOT_COMPILER \"$(shell LANG= $(CC) --version | head -n1)\"\n" >> $(obj)/build.h
 146        $(Q)printf "#define COREBOOT_ASSEMBLER \"$(shell LANG= $(AS) --version | head -n1)\"\n" >> $(obj)/build.h
 147        $(Q)printf "#define COREBOOT_LINKER \"$(shell LANG= $(LD) --version | head -n1)\"\n" >> $(obj)/build.h
 148        $(Q)printf "#define COREBOOT_COMPILE_TIME \"`LANG= date +%T`\"\n" >> $(obj)/build.h
 149        $(Q)printf "#define COREBOOT_COMPILE_BY \"$(shell PATH=$$PATH:/usr/ucb whoami)\"\n" >> $(obj)/build.h
 150        $(Q)printf "#define COREBOOT_COMPILE_HOST \"$(shell hostname)\"\n" >> $(obj)/build.h
 151        $(Q)printf "#define COREBOOT_COMPILE_DOMAIN \"$(shell test `uname -s` = "Linux" && dnsdomainname || domainname)\"\n" >> $(obj)/build.h
 152
 153clean:
 154        $(Q)printf "  CLEAN   $(subst $(shell pwd)/,,$(obj))\n"
 155        $(Q)rm -rf $(obj)
 156        $(Q)printf "  CLEAN   $(subst $(shell pwd)/,,$(DOXYGEN_OUTPUT_DIR))\n"
 157        $(Q)rm -rf $(DOXYGEN_OUTPUT_DIR)
 158        $(Q)printf "  CLEAN   doc/design/newboot.pdf\n"
 159        $(Q)rm -f doc/design/newboot.pdf
 160
 161distclean: clean
 162        $(Q)printf "  CLEAN   .kconfig.d .config .tmpconfig.h .config.old .xcompile\n"
 163        $(Q)rm -f .kconfig.d .config .tmpconfig.h .config.old .xcompile
 164
 165%.o: %.c
 166        $(Q)printf "  CC      $(subst $(shell pwd)/,,$(@))\n"
 167        $(Q)$(CC) $(CFLAGS) -o $@ -c $<
 168
 169.PHONY: doc doxygen depends prepare prepare2 clean distclean
 170
 171
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.