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
|
|
|
##
|
2011-06-30 15:48:57 +02:00
|
|
|
## Redistribution and use in source and binary forms, with or without
|
|
|
|
## modification, are permitted provided that the following conditions
|
|
|
|
## are met:
|
|
|
|
## 1. Redistributions of source code must retain the above copyright
|
|
|
|
## notice, this list of conditions and the following disclaimer.
|
|
|
|
## 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
## notice, this list of conditions and the following disclaimer in the
|
|
|
|
## documentation and/or other materials provided with the distribution.
|
|
|
|
## 3. The name of the author may not be used to endorse or promote products
|
|
|
|
## derived from this software without specific prior written permission.
|
2009-08-12 17:00:51 +02:00
|
|
|
##
|
2011-06-30 15:48:57 +02:00
|
|
|
## THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
## ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
## ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
## OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
## OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
## SUCH DAMAGE.
|
2009-08-12 17:00:51 +02:00
|
|
|
##
|
|
|
|
|
2014-07-19 10:55:30 +02:00
|
|
|
# in addition to the dependency below, create the file if it doesn't exist
|
|
|
|
# to silence stupid warnings about a file that would be generated anyway.
|
|
|
|
$(if $(wildcard .xcompile),,$(eval $(shell util/xcompile/xcompile $(XGCCPATH) > .xcompile)))
|
|
|
|
|
2014-07-10 21:06:04 +02:00
|
|
|
.xcompile: util/xcompile/xcompile
|
2015-04-25 20:34:35 +02:00
|
|
|
$< $(XGCCPATH) > $@.tmp
|
|
|
|
\mv -f $@.tmp $@ 2> /dev/null
|
2014-07-10 21:06:04 +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
|
2015-05-07 06:00:10 +02:00
|
|
|
obj ?= build
|
|
|
|
override obj := $(subst $(top)/,,$(abspath $(obj)))
|
|
|
|
export obj
|
2010-04-17 00:48:57 +02:00
|
|
|
export objutil ?= $(obj)/util
|
|
|
|
export objk := $(objutil)/kconfig
|
2015-05-07 06:00:10 +02:00
|
|
|
absobj := $(abspath $(obj))
|
2009-08-12 17:00:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
export KCONFIG_AUTOHEADER := $(obj)/config.h
|
|
|
|
export KCONFIG_AUTOCONFIG := $(obj)/auto.conf
|
2014-04-11 20:24:06 +02:00
|
|
|
export KCONFIG_DEPENDENCIES := $(obj)/auto.conf.cmd
|
|
|
|
export KCONFIG_SPLITCONFIG := $(obj)/config
|
|
|
|
export KCONFIG_TRISTATE := $(obj)/tristate.conf
|
|
|
|
export KCONFIG_NEGATIVES := 1
|
2009-08-12 17:00:51 +02:00
|
|
|
|
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
|
|
|
|
|
2015-03-13 19:05:07 +01:00
|
|
|
# Disable implicit/built-in rules to make Makefile errors fail fast.
|
|
|
|
.SUFFIXES:
|
|
|
|
|
2014-10-30 01:36:42 +01:00
|
|
|
HOSTCC := gcc
|
2009-08-12 17:00:51 +02:00
|
|
|
HOSTCXX = g++
|
2012-09-13 22:13:33 +02:00
|
|
|
HOSTCFLAGS := -g
|
|
|
|
HOSTCXXFLAGS := -g
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2015-04-04 15:50:20 +02:00
|
|
|
PREPROCESS_ONLY := -E -P -x assembler-with-cpp -undef -I .
|
|
|
|
|
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),)
|
2015-02-17 12:21:32 +01:00
|
|
|
ifneq ($(filter %config %clean cross% lint% what-jenkins-does,$(MAKECMDGOALS)),)
|
2010-04-21 08:36:20 +02:00
|
|
|
NOCOMPILE:=1
|
|
|
|
endif
|
2013-02-09 15:45:02 +01:00
|
|
|
ifeq ($(MAKECMDGOALS), %clean)
|
2012-10-22 10:36:03 +02:00
|
|
|
NOMKDIR:=1
|
|
|
|
endif
|
2010-04-21 08:36:20 +02:00
|
|
|
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
|
|
|
|
2015-06-04 13:18:11 +02:00
|
|
|
include .xcompile
|
|
|
|
|
2014-05-14 21:05:35 +02:00
|
|
|
ifneq ($(CONFIG_MMX),y)
|
|
|
|
CFLAGS_x86_32 += -mno-mmx
|
|
|
|
endif
|
|
|
|
|
|
|
|
include toolchain.inc
|
|
|
|
|
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
|
|
|
|
|
2011-02-22 15:35:05 +01:00
|
|
|
real-all: real-target
|
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+= \
|
2015-05-07 06:00:10 +02:00
|
|
|
$$(subst $(absobj)/,$(obj)/, \
|
2010-03-27 18:18:39 +01:00
|
|
|
$$(subst $(top)/,, \
|
2015-05-07 06:00:10 +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))
|
2013-02-16 01:06:57 +01:00
|
|
|
ifeq ($(FAILBUILD),1)
|
|
|
|
$(error cannot continue build)
|
|
|
|
endif
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2011-10-25 23:32:21 +02:00
|
|
|
# Eliminate duplicate mentions of source files in a class
|
|
|
|
$(foreach class,$(classes),$(eval $(class)-srcs:=$(sort $($(class)-srcs))))
|
|
|
|
|
2015-03-27 17:03:28 +01:00
|
|
|
# Converts one or more source file paths to their corresponding build/ paths.
|
|
|
|
# Only .c and .S get converted to .o, other files (like .ld) keep their name.
|
|
|
|
# $1 stage name
|
|
|
|
# $2 file path (list)
|
2015-03-13 07:17:16 +01:00
|
|
|
src-to-obj=$(foreach file,$(2),$(subst .$(1),,$(basename $(patsubst src/%,$(obj)/%,$(file)))).$(1)$(patsubst %.c,%.o,$(patsubst %.S,%.o,$(suffix $(file)))))
|
2015-03-27 17:03:28 +01:00
|
|
|
|
2015-03-27 16:56:23 +01:00
|
|
|
$(foreach class,$(classes),$(eval $(class)-objs:=$(call src-to-obj,$(class),$($(class)-srcs))))
|
2010-09-30 18:55:02 +02:00
|
|
|
|
2013-05-15 11:47:51 +02:00
|
|
|
# Save all objs before processing them (for dependency inclusion)
|
|
|
|
originalobjs:=$(foreach var, $(addsuffix -objs,$(classes)), $($(var)))
|
|
|
|
|
2012-11-25 14:31:08 +01:00
|
|
|
# Call post-processors if they're defined
|
|
|
|
$(foreach class,$(classes),\
|
|
|
|
$(if $(value $(class)-postprocess),$(eval $(call $(class)-postprocess,$($(class)-objs)))))
|
|
|
|
|
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
|
2015-04-03 10:47:15 +02:00
|
|
|
# $2 source suffix (c, S, ld, ...)
|
2014-11-06 23:50:22 +01:00
|
|
|
# $3 additional compiler flags
|
|
|
|
# $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
|
2015-04-03 10:32:17 +02:00
|
|
|
$$(call src-to-obj,$1,$$(1).$2): $$(1).$2 $(obj)/config.h $(4)
|
2010-04-19 22:39:22 +02:00
|
|
|
@printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n"
|
2015-04-03 10:16:12 +02:00
|
|
|
$(CC_$(1)) -MMD $$$$(CPPFLAGS_$(1)) $$$$(CFLAGS_$(1)) -MT $$$$(@) $(3) -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)), \
|
2015-03-27 15:27:21 +01:00
|
|
|
$(eval $(class)-$(type)-ccopts += $(generic-$(type)-ccopts) $($(class)-generic-ccopts)) \
|
2015-04-03 10:19:38 +02:00
|
|
|
$(if $(generic-objs_$(type)_template_gen),$(eval $(call generic-objs_$(type)_template_gen,$(class))),\
|
|
|
|
$(eval $(call create_cc_template,$(class),$(type),$($(class)-$(type)-ccopts),$($(class)-$(type)-deps))))))
|
2010-09-30 18:55:02 +02:00
|
|
|
|
2015-04-03 10:32:17 +02:00
|
|
|
foreach-src=$(foreach file,$($(1)-srcs),$(eval $(call $(1)-objs_$(subst .,,$(suffix $(file)))_template,$(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
|
|
|
|
2014-12-05 21:32:09 +01:00
|
|
|
DEPENDENCIES += $(addsuffix .d,$(basename $(allobjs)))
|
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)
|
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
|
2014-04-11 20:24:06 +02:00
|
|
|
$(shell mkdir -p $(KCONFIG_SPLITCONFIG) $(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:
|
2015-06-06 15:55:16 +02:00
|
|
|
$(DOXYGEN) Documentation/Doxyfile.coreboot
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2014-12-29 22:56:19 +01:00
|
|
|
doxygen_simple:
|
2015-06-06 15:55:16 +02:00
|
|
|
$(DOXYGEN) Documentation/Doxyfile.coreboot_simple
|
2014-12-29 22:56:19 +01:00
|
|
|
|
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
|
2013-02-09 15:45:02 +01:00
|
|
|
rm -rf $(obj) .xcompile
|
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
|
|
|
|
|
2013-02-09 15:45:02 +01:00
|
|
|
distclean: clean
|
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
|
|
|
|
2014-12-29 22:56:19 +01:00
|
|
|
.PHONY: $(PHONY) clean clean-for-update clean-cscope cscope distclean doxygen doxy doxygen_simple
|