2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
# Global build configuration variables
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
# Read user-provided tools configuration
|
|
|
|
#
|
|
|
|
-include $(call select_from_repositories,etc/tools.conf)
|
|
|
|
-include $(BUILD_BASE_DIR)/etc/tools.conf
|
|
|
|
|
|
|
|
#
|
|
|
|
# Set undefined CUSTOM_ tools to their default values
|
|
|
|
#
|
2017-04-09 19:02:34 +00:00
|
|
|
CUSTOM_CC ?= $(CROSS_DEV_PREFIX)gcc
|
|
|
|
CUSTOM_CXX ?= $(CROSS_DEV_PREFIX)g++
|
2017-06-14 09:13:39 +00:00
|
|
|
CUSTOM_CPP ?= $(CROSS_DEV_PREFIX)cpp
|
2017-04-09 19:02:34 +00:00
|
|
|
CUSTOM_CXX_LIB ?= $(CUSTOM_CXX)
|
|
|
|
CUSTOM_LD ?= $(CROSS_DEV_PREFIX)ld
|
|
|
|
CUSTOM_AS ?= $(CROSS_DEV_PREFIX)as
|
|
|
|
CUSTOM_AR ?= $(CROSS_DEV_PREFIX)ar
|
|
|
|
CUSTOM_NM ?= $(CROSS_DEV_PREFIX)nm
|
|
|
|
CUSTOM_OBJCOPY ?= $(CROSS_DEV_PREFIX)objcopy
|
|
|
|
CUSTOM_RANLIB ?= $(CROSS_DEV_PREFIX)ranlib
|
|
|
|
CUSTOM_STRIP ?= $(CROSS_DEV_PREFIX)strip
|
2019-01-30 15:57:05 +00:00
|
|
|
CUSTOM_GNATBIND ?= $(CROSS_DEV_PREFIX)gnatbind
|
2017-04-09 19:02:34 +00:00
|
|
|
CUSTOM_HOST_CC ?= gcc
|
2018-10-08 08:30:08 +00:00
|
|
|
CUSTOM_ADA_CC ?= $(CUSTOM_CC)
|
2019-05-17 16:47:41 +00:00
|
|
|
CUSTOM_ALI2DEP ?= $(CROSS_DEV_PREFIX)ali2dep
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# GNU utilities
|
|
|
|
#
|
|
|
|
# Non-Linux operating systems may have to install 'findutils'
|
|
|
|
# to get the GNU versions of xargs and find.
|
|
|
|
#
|
|
|
|
TAC ?= tac
|
|
|
|
GNU_FIND ?= find
|
|
|
|
GNU_XARGS ?= xargs
|
|
|
|
ECHO ?= echo -e
|
|
|
|
|
|
|
|
#
|
|
|
|
# Build tools
|
|
|
|
#
|
2017-04-09 19:02:34 +00:00
|
|
|
CC = $(CUSTOM_CC)
|
|
|
|
CXX = $(CUSTOM_CXX)
|
2017-06-14 09:13:39 +00:00
|
|
|
CPP = $(CUSTOM_CPP)
|
2017-04-09 19:02:34 +00:00
|
|
|
LD = $(CUSTOM_LD)
|
|
|
|
AS = $(CUSTOM_AS)
|
|
|
|
AR = $(CUSTOM_AR)
|
|
|
|
NM = $(CUSTOM_NM)
|
|
|
|
OBJCOPY = $(CUSTOM_OBJCOPY)
|
|
|
|
RANLIB = $(CUSTOM_RANLIB)
|
|
|
|
STRIP = $(CUSTOM_STRIP)
|
2019-01-30 15:57:05 +00:00
|
|
|
GNATBIND = $(CUSTOM_GNATBIND)
|
2017-04-09 19:02:34 +00:00
|
|
|
HOST_CC = $(CUSTOM_HOST_CC)
|
2018-10-08 08:30:08 +00:00
|
|
|
ADA_CC = $(CUSTOM_ADA_CC)
|
2019-02-03 22:57:27 +00:00
|
|
|
ALI2DEP = $(CUSTOM_ALI2DEP)
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Compiler and Linker options
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
# Options for automatically generating dependency files
|
|
|
|
#
|
|
|
|
# We specify the target for the generated dependency file explicitly via
|
|
|
|
# the -MT option. Unfortunately, this option is handled differently by
|
|
|
|
# different gcc versions. Older versions used to always append the object
|
|
|
|
# file to the target. However, gcc-4.3.2 takes the -MT argument literally.
|
|
|
|
# So we have to specify both the .o file and the .d file. On older gcc
|
|
|
|
# versions, this results in the .o file to appear twice in the target
|
|
|
|
# but that is no problem.
|
|
|
|
#
|
|
|
|
CC_OPT_DEP = -MMD -MP -MT '$@ $(@:.o=.d)'
|
|
|
|
|
|
|
|
#
|
|
|
|
# Always compile with '-ffunction-sections' to enable the use of the
|
|
|
|
# linker option '-gc-sections'
|
|
|
|
#
|
|
|
|
CC_OPT += -ffunction-sections
|
|
|
|
|
|
|
|
#
|
|
|
|
# Prevent the compiler from optimizations related to strict aliasing
|
|
|
|
#
|
|
|
|
CC_OPT += -fno-strict-aliasing
|
|
|
|
|
|
|
|
#
|
|
|
|
# Do not compile/link with standard includes and standard libraries per
|
|
|
|
# default.
|
|
|
|
#
|
|
|
|
ifneq ($(STDINC),yes)
|
|
|
|
CC_OPT_NOSTDINC := -nostdinc
|
|
|
|
endif
|
|
|
|
ifneq ($(STDLIB),yes)
|
|
|
|
LD_OPT_NOSTDLIB := -nostdlib -Wl,-nostdlib
|
|
|
|
endif
|
|
|
|
|
2018-11-06 18:46:50 +00:00
|
|
|
#
|
|
|
|
# Add coverage options
|
|
|
|
#
|
|
|
|
# The directory for the coverage data (generated at runtime) is derived from
|
|
|
|
# the current build directory and is going to look like
|
|
|
|
#
|
|
|
|
# '/genodelabs/bin/test-log_gcov/2018-11-13/gcov_data/test-log_gcov'
|
|
|
|
#
|
|
|
|
# to match the path where the gcov note files (generated at build time) are
|
|
|
|
# stored in the depot package of the test program.
|
|
|
|
#
|
|
|
|
# If depot packages are not used, the path is going to look like
|
|
|
|
#
|
|
|
|
# '/gcov_data/test-log_gcov'
|
|
|
|
#
|
|
|
|
ifeq ($(COVERAGE),yes)
|
|
|
|
ifneq ($(findstring /depot/,$(CURDIR)),)
|
|
|
|
PROFILE_DIR = $(shell echo $(CURDIR) | \
|
|
|
|
sed -e 's/^.*\/depot\//\//' \
|
|
|
|
-e 's/\.build\/.*//')/gcov_data/$(TARGET)
|
|
|
|
else
|
|
|
|
PROFILE_DIR = /gcov_data/$(TARGET)
|
|
|
|
endif
|
|
|
|
CC_OPT += -fprofile-arcs -ftest-coverage -fprofile-dir=$(PROFILE_DIR)
|
|
|
|
endif
|
|
|
|
|
2018-12-05 23:52:22 +00:00
|
|
|
#
|
|
|
|
# Enable the undefined behavior sanitizer if requested
|
|
|
|
#
|
|
|
|
ifeq ($(SANITIZE_UNDEFINED),yes)
|
|
|
|
CC_OPT += -fsanitize=undefined
|
|
|
|
endif
|
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
# Default optimization and warning levels
|
|
|
|
#
|
|
|
|
CC_OLEVEL ?= -O2
|
|
|
|
CC_WARN ?= -Wall
|
|
|
|
|
2018-01-02 11:06:20 +00:00
|
|
|
#
|
|
|
|
# Additional warnings for C++
|
|
|
|
#
|
2019-02-14 14:31:30 +00:00
|
|
|
CC_CXX_WARN_STRICT ?= -Wextra -Weffc++ -Werror -Wsuggest-override
|
2018-01-02 11:06:20 +00:00
|
|
|
CC_CXX_WARN ?= $(CC_WARN) $(CC_CXX_WARN_STRICT)
|
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
# Aggregate compiler options that are common for C and C++
|
|
|
|
#
|
2012-09-20 10:36:02 +00:00
|
|
|
CC_OPT += $(CC_OPT_NOSTDINC) -g $(CC_MARCH) $(CC_OLEVEL) $(CC_OPT_DEP) $(CC_WARN)
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Incorporate source-file-specific compiler options
|
|
|
|
#
|
|
|
|
# The make variable $* refers to the currently processed compilation
|
|
|
|
# unit when 'CC_OPT' gets implicitly expanded by the rules '%.o: %.c'
|
|
|
|
# and '%.o: %.cc' of 'generic.mk'.
|
|
|
|
#
|
|
|
|
# We substitute '.' characters by '_' to allow source-file-specific
|
|
|
|
# compiler options for files with more than one dot in their name.
|
|
|
|
#
|
|
|
|
CC_OPT += $(CC_OPT_$(subst .,_,$*))
|
|
|
|
|
2016-12-29 17:27:45 +00:00
|
|
|
#
|
|
|
|
# Build program position independent as well
|
|
|
|
#
|
|
|
|
CC_OPT_PIC ?= -fPIC
|
|
|
|
CC_OPT += $(CC_OPT_PIC)
|
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
# Predefine C and C++ specific compiler options with their common values
|
|
|
|
#
|
2018-01-02 11:06:20 +00:00
|
|
|
CC_CXX_OPT += $(CC_OPT) $(CC_CXX_WARN)
|
2011-12-22 15:19:25 +00:00
|
|
|
CC_C_OPT += $(CC_OPT)
|
2019-01-30 15:57:05 +00:00
|
|
|
CC_ADA_OPT += $(filter-out -fno-builtin-cos -fno-builtin-sin -fno-builtin-cosf -fno-builtin-sinf ,$(CC_OPT)) -fexceptions
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2016-02-29 06:44:04 +00:00
|
|
|
#
|
2016-12-29 17:27:45 +00:00
|
|
|
# Rust-specific arguments
|
2016-02-29 06:44:04 +00:00
|
|
|
#
|
2016-12-29 17:27:45 +00:00
|
|
|
# Use the correct linker, include dependencies.
|
2016-02-29 06:44:04 +00:00
|
|
|
#
|
2016-12-29 17:27:45 +00:00
|
|
|
CC_RUSTC_OPT += -C linker=$(LD)
|
2016-02-29 06:44:04 +00:00
|
|
|
CC_RUSTC_OPT += $(foreach lib,$(LIBS),-L$(LIB_CACHE_DIR)/$(lib))
|
|
|
|
|
2013-09-18 14:15:24 +00:00
|
|
|
#
|
|
|
|
# Enable C++11 by default
|
|
|
|
#
|
2017-04-09 19:02:41 +00:00
|
|
|
# We substitute '.' characters by '_' to allow a source-file-specific
|
|
|
|
# C++ standard option for files with more than one dot in their name.
|
|
|
|
#
|
2019-05-06 16:03:35 +00:00
|
|
|
CC_CXX_OPT_STD ?= -std=gnu++17
|
2017-04-09 19:02:41 +00:00
|
|
|
CC_CXX_OPT += $(lastword $(CC_CXX_OPT_STD) $(CC_CXX_OPT_STD_$(subst .,_,$*)))
|
2018-01-02 11:06:20 +00:00
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
# Linker options
|
|
|
|
#
|
|
|
|
# Use '-gc-sections' by default but allow a platform to disable this feature by
|
2013-02-20 12:17:39 +00:00
|
|
|
# defining 'LD_GC_SECTIONS' empty. This is needed for older tool chains (gcc
|
|
|
|
# version 4.11 and binutils version 2.16), which happen to produce broken
|
2015-06-25 15:52:25 +00:00
|
|
|
# code when '-gc-sections' is enabled. Also, set max-page-size to 4KiB to
|
|
|
|
# prevent the linker from aligning the text segment to any built-in default
|
|
|
|
# (e.g., 4MiB on x86_64 or 64KiB on ARM). Otherwise, the padding bytes are
|
|
|
|
# wasted at the beginning of the final binary.
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
LD_OPT_GC_SECTIONS ?= -gc-sections
|
2015-06-25 15:52:25 +00:00
|
|
|
LD_OPT_ALIGN_SANE = -z max-page-size=0x1000
|
2011-12-22 15:19:25 +00:00
|
|
|
LD_OPT_PREFIX := -Wl,
|
2015-06-25 15:52:25 +00:00
|
|
|
LD_OPT += $(LD_MARCH) $(LD_OPT_GC_SECTIONS) $(LD_OPT_ALIGN_SANE)
|
2011-12-22 15:19:25 +00:00
|
|
|
CXX_LINK_OPT += $(addprefix $(LD_OPT_PREFIX),$(LD_OPT))
|
|
|
|
CXX_LINK_OPT += $(LD_OPT_NOSTDLIB)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Linker script for dynamically linked programs
|
|
|
|
#
|
2016-05-28 23:40:03 +00:00
|
|
|
LD_SCRIPT_DYN = $(BASE_DIR)/src/ld/genode_dyn.ld
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Linker script for shared libraries
|
|
|
|
#
|
2016-05-28 23:40:03 +00:00
|
|
|
LD_SCRIPT_SO ?= $(BASE_DIR)/src/ld/genode_rel.ld
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Assembler options
|
|
|
|
#
|
|
|
|
AS_OPT += $(AS_MARCH)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Control sequences for color terminals
|
|
|
|
#
|
|
|
|
# To disable colored output, define these variable empty in your
|
|
|
|
# build-local 'etc/tools.conf' file.
|
|
|
|
#
|
|
|
|
BRIGHT_COL ?= \033[01;33m
|
|
|
|
DARK_COL ?= \033[00;33m
|
|
|
|
DEFAULT_COL ?= \033[0m
|
|
|
|
|
|
|
|
ALL_INC_DIR := .
|
|
|
|
ALL_INC_DIR += $(INC_DIR)
|
|
|
|
ALL_INC_DIR += $(foreach DIR,$(REP_INC_DIR), $(foreach REP,$(REPOSITORIES),$(REP)/$(DIR)))
|
|
|
|
ALL_INC_DIR += $(foreach REP,$(REPOSITORIES),$(REP)/include)
|
|
|
|
ALL_INC_DIR += $(LIBGCC_INC_DIR)
|
2011-12-23 13:04:29 +00:00
|
|
|
ALL_INC_DIR += $(HOST_INC_DIR)
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
VERBOSE ?= @
|
|
|
|
VERBOSE_DIR ?= --no-print-directory
|
|
|
|
|
2017-08-12 20:44:58 +00:00
|
|
|
MSG_LINK ?= @$(ECHO) " LINK "
|
|
|
|
MSG_COMP ?= @$(ECHO) " COMPILE "
|
|
|
|
MSG_BUILD ?= @$(ECHO) " BUILD "
|
|
|
|
MSG_RENAME ?= @$(ECHO) " RENAME "
|
|
|
|
MSG_MERGE ?= @$(ECHO) " MERGE "
|
|
|
|
MSG_CONVERT ?= @$(ECHO) " CONVERT "
|
|
|
|
MSG_CONFIG ?= @$(ECHO) " CONFIG "
|
|
|
|
MSG_CLEAN ?= @$(ECHO) " CLEAN "
|
|
|
|
MSG_ASSEM ?= @$(ECHO) " ASSEMBLE "
|
|
|
|
MSG_INST ?= @$(ECHO) " INSTALL "
|
|
|
|
MSG_PRG ?= @$(ECHO) "$(BRIGHT_COL) Program $(DEFAULT_COL)"
|
|
|
|
MSG_LIB ?= @$(ECHO) "$(DARK_COL) Library $(DEFAULT_COL)"
|
2011-12-22 15:19:25 +00:00
|
|
|
|