2009-08-12 17:00:51 +02:00
|
|
|
##
|
|
|
|
## This file is part of the coreboot project.
|
|
|
|
##
|
|
|
|
## Copyright (C) 2008 Advanced Micro Devices, Inc.
|
|
|
|
## Copyright (C) 2008 Uwe Hermann <uwe@hermann-uwe.de>
|
2010-01-19 22:13:44 +01:00
|
|
|
## Copyright (C) 2009-2010 coresystems GmbH
|
2011-02-22 15:35:05 +01:00
|
|
|
## Copyright (C) 2011 secunet Security Networks AG
|
2009-08-12 17:00:51 +02:00
|
|
|
##
|
2010-01-20 19:44:30 +01:00
|
|
|
## This program is free software; you can redistribute it and/or modify
|
|
|
|
## it under the terms of the GNU General Public License as published by
|
|
|
|
## the Free Software Foundation; version 2 of the License.
|
2009-08-12 17:00:51 +02:00
|
|
|
##
|
2010-01-20 19:44:30 +01:00
|
|
|
## This program is distributed in the hope that it will be useful,
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
|
|
|
## You should have received a copy of the GNU General Public License
|
|
|
|
## along with this program; if not, write to the Free Software
|
|
|
|
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2009-08-12 17:00:51 +02:00
|
|
|
##
|
|
|
|
|
2010-03-14 22:25:03 +01:00
|
|
|
ifeq ($(INNER_SCANBUILD),y)
|
|
|
|
CC_real:=$(CC)
|
|
|
|
endif
|
2010-03-16 02:17:19 +01:00
|
|
|
|
2009-08-12 17:00:51 +02:00
|
|
|
$(if $(wildcard .xcompile),,$(eval $(shell bash util/xcompile/xcompile > .xcompile)))
|
|
|
|
include .xcompile
|
2010-03-16 02:17:19 +01:00
|
|
|
|
2010-03-14 22:25:03 +01:00
|
|
|
ifeq ($(INNER_SCANBUILD),y)
|
|
|
|
CC:=$(CC_real)
|
|
|
|
HOSTCC:=$(CC_real) --hostcc
|
|
|
|
HOSTCXX:=$(CC_real) --hostcxx
|
|
|
|
endif
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2010-09-28 23:11:48 +02:00
|
|
|
export top := $(CURDIR)
|
2010-03-27 18:18:39 +01:00
|
|
|
export src := src
|
2009-08-12 17:00:51 +02:00
|
|
|
export srck := $(top)/util/kconfig
|
2010-03-27 18:18:39 +01:00
|
|
|
export obj ?= build
|
2010-04-17 00:48:57 +02:00
|
|
|
export objutil ?= $(obj)/util
|
|
|
|
export objk := $(objutil)/kconfig
|
2009-08-12 17:00:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
export KCONFIG_AUTOHEADER := $(obj)/config.h
|
|
|
|
export KCONFIG_AUTOCONFIG := $(obj)/auto.conf
|
|
|
|
|
2011-03-01 09:09:22 +01:00
|
|
|
# directory containing the toplevel Makefile.inc
|
|
|
|
TOPLEVEL := .
|
|
|
|
|
2009-08-12 17:00:51 +02:00
|
|
|
CONFIG_SHELL := sh
|
|
|
|
KBUILD_DEFCONFIG := configs/defconfig
|
|
|
|
UNAME_RELEASE := $(shell uname -r)
|
2010-12-08 20:58:30 +01:00
|
|
|
DOTCONFIG ?= .config
|
|
|
|
KCONFIG_CONFIG = $(DOTCONFIG)
|
|
|
|
export KCONFIG_CONFIG
|
|
|
|
HAVE_DOTCONFIG := $(wildcard $(DOTCONFIG))
|
2009-08-12 17:00:51 +02:00
|
|
|
MAKEFLAGS += -rR --no-print-directory
|
|
|
|
|
|
|
|
# Make is silent per default, but 'make V=1' will show all compiler calls.
|
2009-08-25 21:38:46 +02:00
|
|
|
Q:=@
|
2009-08-12 17:00:51 +02:00
|
|
|
ifneq ($(V),1)
|
2009-08-25 21:38:46 +02:00
|
|
|
ifneq ($(Q),)
|
|
|
|
.SILENT:
|
|
|
|
endif
|
2009-08-12 17:00:51 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
HOSTCC = gcc
|
|
|
|
HOSTCXX = g++
|
|
|
|
HOSTCFLAGS := -I$(srck) -I$(objk) -g
|
|
|
|
HOSTCXXFLAGS := -I$(srck) -I$(objk)
|
2010-03-16 02:02:18 +01:00
|
|
|
LIBGCC_FILE_NAME := $(shell test -r `$(CC) -print-libgcc-file-name` && $(CC) -print-libgcc-file-name)
|
2009-08-12 17:00:51 +02:00
|
|
|
|
|
|
|
DOXYGEN := doxygen
|
|
|
|
DOXYGEN_OUTPUT_DIR := doxygen
|
|
|
|
|
2011-02-22 15:35:05 +01:00
|
|
|
all: real-all
|
|
|
|
|
2011-03-01 09:09:22 +01:00
|
|
|
# This include must come _before_ the pattern rules below!
|
2011-02-22 15:35:05 +01:00
|
|
|
# Order _does_ matter for pattern rules.
|
|
|
|
include util/kconfig/Makefile
|
|
|
|
|
2010-04-21 08:36:20 +02:00
|
|
|
# Three cases where we don't need fully populated $(obj) lists:
|
|
|
|
# 1. when no .config exists
|
|
|
|
# 2. when make config (in any flavour) is run
|
|
|
|
# 3. when make distclean is run
|
|
|
|
# Don't waste time on reading all Makefile.incs in these cases
|
2009-08-12 17:00:51 +02:00
|
|
|
ifeq ($(strip $(HAVE_DOTCONFIG)),)
|
2010-04-21 08:36:20 +02:00
|
|
|
NOCOMPILE:=1
|
|
|
|
endif
|
|
|
|
ifneq ($(MAKECMDGOALS),)
|
|
|
|
ifneq ($(filter %config distclean,$(MAKECMDGOALS)),)
|
|
|
|
NOCOMPILE:=1
|
|
|
|
endif
|
|
|
|
endif
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2010-04-21 08:36:20 +02:00
|
|
|
ifeq ($(NOCOMPILE),1)
|
2011-03-01 09:09:22 +01:00
|
|
|
include $(TOPLEVEL)/Makefile.inc
|
2011-02-22 15:35:05 +01:00
|
|
|
real-all: config
|
2009-08-12 17:00:51 +02:00
|
|
|
|
|
|
|
else
|
|
|
|
|
2010-09-25 00:15:54 +02:00
|
|
|
include $(HAVE_DOTCONFIG)
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2010-03-16 02:17:19 +01:00
|
|
|
ifneq ($(INNER_SCANBUILD),y)
|
|
|
|
ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y)
|
|
|
|
CC:=clang -m32
|
|
|
|
HOSTCC:=clang
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2010-03-25 22:45:25 +01:00
|
|
|
ifeq ($(CONFIG_CCACHE),y)
|
2011-05-21 00:14:07 +02:00
|
|
|
CCACHE:=$(word 1,$(wildcard $(addsuffix /ccache,$(subst :, ,$(PATH)))))
|
2010-03-25 22:45:25 +01:00
|
|
|
ifeq ($(CCACHE),)
|
|
|
|
$(error ccache selected, but not found in PATH)
|
|
|
|
endif
|
2010-09-25 00:15:54 +02:00
|
|
|
CCACHE:=CCACHE_COMPILERCHECK=content CCACHE_BASEDIR=$(top) $(CCACHE)
|
2010-03-25 22:45:25 +01:00
|
|
|
CC := $(CCACHE) $(CC)
|
|
|
|
HOSTCC := $(CCACHE) $(HOSTCC)
|
|
|
|
HOSTCXX := $(CCACHE) $(HOSTCXX)
|
|
|
|
ROMCC := $(CCACHE) $(ROMCC)
|
|
|
|
endif
|
|
|
|
|
2010-03-16 20:01:32 +01:00
|
|
|
strip_quotes = $(subst ",,$(subst \",,$(1)))
|
|
|
|
|
2009-08-12 17:00:51 +02:00
|
|
|
# The primary target needs to be here before we include the
|
|
|
|
# other files
|
|
|
|
|
2010-03-14 22:25:03 +01:00
|
|
|
ifeq ($(INNER_SCANBUILD),y)
|
|
|
|
CONFIG_SCANBUILD_ENABLE:=
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(CONFIG_SCANBUILD_ENABLE),y)
|
|
|
|
ifneq ($(CONFIG_SCANBUILD_REPORT_LOCATION),)
|
|
|
|
CONFIG_SCANBUILD_REPORT_LOCATION:=-o $(CONFIG_SCANBUILD_REPORT_LOCATION)
|
|
|
|
endif
|
2011-02-22 15:35:05 +01:00
|
|
|
real-all:
|
2010-03-14 22:25:03 +01:00
|
|
|
echo '#!/bin/sh' > .ccwrap
|
|
|
|
echo 'CC="$(CC)"' >> .ccwrap
|
|
|
|
echo 'if [ "$$1" = "--hostcc" ]; then shift; CC="$(HOSTCC)"; fi' >> .ccwrap
|
|
|
|
echo 'if [ "$$1" = "--hostcxx" ]; then shift; CC="$(HOSTCXX)"; fi' >> .ccwrap
|
|
|
|
echo 'eval $$CC $$*' >> .ccwrap
|
|
|
|
chmod +x .ccwrap
|
|
|
|
scan-build $(CONFIG_SCANBUILD_REPORT_LOCATION) -analyze-headers --use-cc=$(top)/.ccwrap --use-c++=$(top)/.ccwrap $(MAKE) INNER_SCANBUILD=y
|
|
|
|
else
|
2011-02-22 15:35:05 +01:00
|
|
|
real-all: real-target
|
2010-03-14 22:25:03 +01:00
|
|
|
endif
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2010-03-27 18:18:39 +01:00
|
|
|
# must come rather early
|
|
|
|
.SECONDEXPANSION:
|
|
|
|
|
2010-03-21 23:35:58 +01:00
|
|
|
$(obj)/config.h:
|
|
|
|
$(MAKE) oldconfig
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2011-02-17 21:47:49 +01:00
|
|
|
# Add a new class of source/object files to the build system
|
|
|
|
add-class= \
|
|
|
|
$(eval $(1)-srcs:=) \
|
|
|
|
$(eval $(1)-objs:=) \
|
|
|
|
$(eval classes+=$(1))
|
|
|
|
|
|
|
|
# Special classes are managed types with special behaviour
|
|
|
|
# On parse time, for each entry in variable $(1)-y
|
|
|
|
# a handler $(1)-handler is executed with the arguments:
|
|
|
|
# * $(1): directory the parser is in
|
|
|
|
# * $(2): current entry
|
|
|
|
add-special-class= \
|
|
|
|
$(eval $(1):=) \
|
|
|
|
$(eval special-classes+=$(1))
|
|
|
|
|
2010-03-06 22:18:43 +01:00
|
|
|
# Clean -y variables, include Makefile.inc
|
2010-09-30 18:55:02 +02:00
|
|
|
# Add paths to files in X-y to X-srcs
|
2010-03-06 22:18:43 +01:00
|
|
|
# Add subdirs-y to subdirs
|
|
|
|
includemakefiles= \
|
2011-02-17 21:47:49 +01:00
|
|
|
$(foreach class,classes subdirs $(classes) $(special-classes), $(eval $(class)-y:=)) \
|
2010-03-06 22:18:43 +01:00
|
|
|
$(eval -include $(1)) \
|
2011-02-17 21:47:49 +01:00
|
|
|
$(foreach class,$(classes-y), $(call add-class,$(class))) \
|
|
|
|
$(foreach class,$(classes), \
|
|
|
|
$(eval $(class)-srcs+= \
|
2010-03-27 18:18:39 +01:00
|
|
|
$$(subst $(top)/,, \
|
2011-05-21 01:31:41 +02:00
|
|
|
$$(abspath $$(subst $(dir $(1))/,/,$$(addprefix $(dir $(1)),$$($(class)-y))))))) \
|
2011-02-17 21:47:49 +01:00
|
|
|
$(foreach special,$(special-classes), \
|
|
|
|
$(foreach item,$($(special)-y), $(call $(special)-handler,$(dir $(1)),$(item)))) \
|
2010-09-28 23:11:48 +02:00
|
|
|
$(eval subdirs+=$$(subst $(CURDIR)/,,$$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y)))))
|
2010-03-06 22:18:43 +01:00
|
|
|
|
2010-09-30 18:55:02 +02:00
|
|
|
# For each path in $(subdirs) call includemakefiles
|
2010-03-06 22:18:43 +01:00
|
|
|
# Repeat until subdirs is empty
|
|
|
|
evaluate_subdirs= \
|
|
|
|
$(eval cursubdirs:=$(subdirs)) \
|
|
|
|
$(eval subdirs:=) \
|
|
|
|
$(foreach dir,$(cursubdirs), \
|
2011-02-17 21:47:49 +01:00
|
|
|
$(eval $(call includemakefiles,$(dir)/Makefile.inc))) \
|
2010-03-27 18:18:39 +01:00
|
|
|
$(if $(subdirs),$(eval $(call evaluate_subdirs)))
|
2009-08-12 17:00:51 +02:00
|
|
|
|
|
|
|
# collect all object files eligible for building
|
2011-03-01 09:09:22 +01:00
|
|
|
subdirs:=$(TOPLEVEL)
|
2010-03-27 18:18:39 +01:00
|
|
|
$(eval $(call evaluate_subdirs))
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2010-09-30 18:55:02 +02:00
|
|
|
src-to-obj=$(addsuffix .$(1).o, $(basename $(patsubst src/%, $(obj)/%, $($(1)-srcs))))
|
2011-02-17 21:47:49 +01:00
|
|
|
$(foreach class,$(classes),$(eval $(class)-objs:=$(call src-to-obj,$(class))))
|
2010-09-30 18:55:02 +02:00
|
|
|
|
2011-02-17 21:47:49 +01:00
|
|
|
allsrcs:=$(foreach var, $(addsuffix -srcs,$(classes)), $($(var)))
|
|
|
|
allobjs:=$(foreach var, $(addsuffix -objs,$(classes)), $($(var)))
|
2009-08-12 17:00:51 +02:00
|
|
|
alldirs:=$(sort $(abspath $(dir $(allobjs))))
|
|
|
|
|
2010-03-16 13:01:13 +01:00
|
|
|
# macro to define template macros that are used by use_template macro
|
|
|
|
define create_cc_template
|
2011-02-22 15:35:05 +01:00
|
|
|
# $1 obj class
|
2010-03-16 13:01:13 +01:00
|
|
|
# $2 source suffix (c, S)
|
2010-09-30 18:55:02 +02:00
|
|
|
# $3 additional compiler flags
|
2011-03-08 21:49:18 +01:00
|
|
|
# $4 additional dependencies
|
2011-02-17 21:48:45 +01:00
|
|
|
ifn$(EMPTY)def $(1)-objs_$(2)_template
|
2010-09-30 18:55:02 +02:00
|
|
|
de$(EMPTY)fine $(1)-objs_$(2)_template
|
2011-03-08 21:49:18 +01:00
|
|
|
$(obj)/$$(1).$(1).o: src/$$(1).$(2) $(obj)/config.h $(4)
|
2010-04-19 22:39:22 +02:00
|
|
|
@printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n"
|
2010-09-30 18:55:02 +02:00
|
|
|
$(CC) $(3) -MMD $$$$(CFLAGS) -c -o $$$$@ $$$$<
|
2010-03-16 13:01:13 +01:00
|
|
|
en$(EMPTY)def
|
2011-02-17 21:48:45 +01:00
|
|
|
end$(EMPTY)if
|
2009-08-12 17:00:51 +02:00
|
|
|
endef
|
|
|
|
|
2011-02-17 21:48:45 +01:00
|
|
|
filetypes-of-class=$(subst .,,$(sort $(suffix $($(1)-srcs))))
|
|
|
|
$(foreach class,$(classes), \
|
|
|
|
$(foreach type,$(call filetypes-of-class,$(class)), \
|
2011-03-08 21:49:18 +01:00
|
|
|
$(eval $(call create_cc_template,$(class),$(type),$($(class)-$(type)-ccopts),$($(class)-$(type)-deps)))))
|
2010-09-30 18:55:02 +02:00
|
|
|
|
|
|
|
foreach-src=$(foreach file,$($(1)-srcs),$(eval $(call $(1)-objs_$(subst .,,$(suffix $(file)))_template,$(subst src/,,$(basename $(file))))))
|
2011-02-17 21:47:49 +01:00
|
|
|
$(eval $(foreach class,$(classes),$(call foreach-src,$(class))))
|
2010-09-30 18:55:02 +02:00
|
|
|
|
2011-02-22 15:35:05 +01:00
|
|
|
DEPENDENCIES = $(allobjs:.o=.d)
|
2010-03-24 16:51:48 +01:00
|
|
|
-include $(DEPENDENCIES)
|
|
|
|
|
2009-08-12 17:00:51 +02:00
|
|
|
printall:
|
2011-02-22 15:35:05 +01:00
|
|
|
@$(foreach class,$(classes),echo $(class)-objs:=$($(class)-objs); )
|
2009-08-12 17:00:51 +02:00
|
|
|
@echo alldirs:=$(alldirs)
|
2010-09-30 18:55:02 +02:00
|
|
|
@echo allsrcs=$(allsrcs)
|
2010-03-24 16:51:48 +01:00
|
|
|
@echo DEPENDENCIES=$(DEPENDENCIES)
|
2010-03-16 02:02:18 +01:00
|
|
|
@echo LIBGCC_FILE_NAME=$(LIBGCC_FILE_NAME)
|
2011-02-22 15:35:05 +01:00
|
|
|
@$(foreach class,$(special-classes),echo $(class):='$($(class))'; )
|
2009-08-12 17:00:51 +02:00
|
|
|
|
|
|
|
endif
|
|
|
|
|
2011-05-22 00:18:59 +02:00
|
|
|
ifndef NOMKDIR
|
2011-02-22 15:35:05 +01:00
|
|
|
$(shell mkdir -p $(obj) $(objutil)/kconfig/lxdialog $(additional-dirs) $(alldirs))
|
2011-05-22 00:18:59 +02:00
|
|
|
endif
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2010-09-03 10:57:32 +02:00
|
|
|
cscope:
|
|
|
|
cscope -bR
|
|
|
|
|
2009-08-12 17:00:51 +02:00
|
|
|
doxy: doxygen
|
|
|
|
doxygen:
|
2010-02-10 16:36:53 +01:00
|
|
|
$(DOXYGEN) documentation/Doxyfile.coreboot
|
2009-08-12 17:00:51 +02:00
|
|
|
|
|
|
|
doxyclean: doxygen-clean
|
|
|
|
doxygen-clean:
|
2009-08-25 21:38:46 +02:00
|
|
|
rm -rf $(DOXYGEN_OUTPUT_DIR)
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2011-02-22 15:35:05 +01:00
|
|
|
clean-for-update: doxygen-clean clean-for-update-target
|
|
|
|
rm -f $(allobjs) .xcompile
|
2010-03-24 16:51:48 +01:00
|
|
|
rm -f $(DEPENDENCIES)
|
2009-08-25 21:38:46 +02:00
|
|
|
rmdir -p $(alldirs) 2>/dev/null >/dev/null || true
|
2010-02-09 20:41:11 +01:00
|
|
|
|
2011-02-22 15:35:05 +01:00
|
|
|
clean: clean-for-update clean-target
|
|
|
|
rm -f .ccwrap
|
2010-09-27 23:14:19 +02:00
|
|
|
|
2010-09-03 10:57:32 +02:00
|
|
|
clean-cscope:
|
|
|
|
rm -f cscope.out
|
|
|
|
|
2010-09-29 22:28:59 +02:00
|
|
|
distclean: clean-cscope
|
2010-01-06 17:59:18 +01:00
|
|
|
rm -rf $(obj)
|
2010-04-21 08:36:20 +02:00
|
|
|
rm -f .config .config.old ..config.tmp .kconfig.d .tmpconfig* .ccwrap .xcompile
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2011-02-22 15:35:05 +01:00
|
|
|
.PHONY: $(PHONY) clean clean-cscope cscope distclean doxygen doxy .xcompile
|