2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
# \brief Front end to the Genode build system
|
|
|
|
# \author Norman Feske
|
|
|
|
# \date 2011-08-04
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
# The operation of the build system can be tuned using the following variables,
|
|
|
|
# which can be specified at the command line or supplied via the
|
|
|
|
# 'etc/build.conf' file.
|
|
|
|
#
|
|
|
|
# BASE_DIR - this directory points to Genode's 'base' repository
|
|
|
|
# REPOSITORIES - list of directories incorporared into the build process
|
|
|
|
# VERBOSE - variable that controls the verboseness of the build process
|
|
|
|
#
|
|
|
|
# By default, compiler messages are not displayed. If you are
|
|
|
|
# interested in these messages set this variable to nothing.
|
|
|
|
# ('VERBOSE=')
|
|
|
|
#
|
|
|
|
# VERBOSE_MK - variable that controls the verboseness of make invocations
|
|
|
|
# VERBOSE_DIR - variable that controls the verboseness of changing directories
|
|
|
|
#
|
|
|
|
# Using this variable, you can enable the make messages printed
|
|
|
|
# when changing directories. To enable the messages, set the
|
|
|
|
# variable to nothing.
|
|
|
|
#
|
|
|
|
# LIB_CACHE_DIR - location of the library build cache
|
|
|
|
#
|
|
|
|
# This variable defines the place for the library build cache.
|
|
|
|
# Normally, the libcache is located at 'var/libcache' and
|
|
|
|
# there is no need to change it.
|
|
|
|
#
|
2014-05-08 14:42:38 +00:00
|
|
|
# CONTRIB_DIR - location of ported 3rd-party source codes
|
2021-03-05 15:06:15 +00:00
|
|
|
# CCACHE - if set to 'yes', the build system uses the compiler cache
|
2014-05-08 14:42:38 +00:00
|
|
|
#
|
2015-05-19 16:32:41 +00:00
|
|
|
# REQUIRED_GCC_VERSION - GCC version required for building Genode
|
|
|
|
#
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
## Define global configuration variables
|
|
|
|
##
|
|
|
|
|
2022-03-10 14:25:50 +00:00
|
|
|
#
|
|
|
|
# We initially enforce .SHELLFLAGS flags in case build.mk called recursively
|
|
|
|
# (from tool/run) as SHELL will be reset to /bin/sh before setting up bash.
|
|
|
|
#
|
|
|
|
.SHELLFLAGS := -c
|
|
|
|
|
2020-04-22 09:25:58 +00:00
|
|
|
#
|
|
|
|
# Whenever using the 'run/%' rule and the run tool spawns this Makefile again
|
|
|
|
# when encountering a 'build' step, the build.conf is included a second time,
|
|
|
|
# with the content taken from the environment variable. We need to reset the
|
|
|
|
# 'REPOSITORIES' variable to prevent extending this variable twice.
|
|
|
|
# (see https://github.com/genodelabs/genode/issues/3731)
|
|
|
|
#
|
|
|
|
REPOSITORIES :=
|
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
-include etc/build.conf
|
|
|
|
|
2012-10-22 18:38:49 +00:00
|
|
|
BUILD_BASE_DIR := $(CURDIR)
|
2017-04-05 14:51:47 +00:00
|
|
|
DEBUG_DIR := $(CURDIR)/debug
|
2012-10-22 18:38:49 +00:00
|
|
|
INSTALL_DIR := $(CURDIR)/bin
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
export BASE_DIR ?= ../base
|
|
|
|
export REPOSITORIES ?= $(BASE_DIR:%base=%base-linux) $(BASE_DIR)
|
|
|
|
export VERBOSE ?= @
|
|
|
|
export VERBOSE_DIR ?= --no-print-directory
|
|
|
|
export VERBOSE_MK ?= @
|
|
|
|
export LIB_CACHE_DIR ?= $(BUILD_BASE_DIR)/var/libcache
|
|
|
|
export LIB_PROGRESS_LOG ?= $(BUILD_BASE_DIR)/progress.log
|
|
|
|
export LIB_DEP_FILE ?= var/libdeps
|
|
|
|
export ECHO ?= echo -e
|
2014-05-08 14:42:38 +00:00
|
|
|
export CONTRIB_DIR
|
tool: deprecate board-specific build directories
* Introduces BOARD variable to determine actual board
* Removes formerly deprecated kernel-specific build directories
The following boards are available:
arm_v6: rpi
arm_v7a: arndale, imx53_qsb, imx53_qsb_tz, imx6q_sabrelite, imx7d_sabre,
nit6_solox, odroid_x2, odroid_xu, panda, pbxa9, usb_armory,
wand_quad, zynq_qemu
x86_64: pc, linux, muen
x86_32: pc, linux
riscv: spike
Ref #3316
2019-04-11 14:24:33 +00:00
|
|
|
export BOARD
|
2022-02-16 13:17:07 +00:00
|
|
|
export KERNEL
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Convert user-defined directories to absolute directories
|
|
|
|
#
|
|
|
|
# The 'echo' shell command expands '~' characters to the home directory,
|
|
|
|
# 'realpath' converts relative path names to absolute.
|
|
|
|
#
|
|
|
|
REPOSITORIES := $(realpath $(shell echo $(REPOSITORIES)))
|
|
|
|
BASE_DIR := $(realpath $(shell echo $(BASE_DIR)))
|
|
|
|
|
2021-12-16 10:34:06 +00:00
|
|
|
define nl
|
|
|
|
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
ifneq ($(words $(REPOSITORIES)),$(words $(sort $(REPOSITORIES))))
|
|
|
|
$(error detected duplicates in REPOSITORIES $(foreach p,$(REPOSITORIES),$(nl) $(p)))
|
|
|
|
endif
|
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
# Configure shell program before executing any shell commands. On Ubuntu the
|
|
|
|
# standard shell is dash, which breaks colored output via its built-in echo
|
|
|
|
# command.
|
|
|
|
#
|
2022-03-10 14:25:50 +00:00
|
|
|
# SHELL is exported into the environment for tools used in rules
|
|
|
|
# (like tool/run). Unfortunately, sub-make instances will reset SHELL to
|
|
|
|
# /bin/sh if it is not explicitly provided on the command like (as we do
|
|
|
|
# below). See GNU Make manual "5.3.2 Choosing the Shell" for further details.
|
|
|
|
# .SHELLFLAGS is extended by option pipefail to make pipes fail if any pipe
|
|
|
|
# element fails.
|
|
|
|
#
|
|
|
|
export SHELL := $(shell sh -c "command -v bash")
|
|
|
|
export .SHELLFLAGS := -o pipefail $(.SHELLFLAGS)
|
|
|
|
|
|
|
|
MAKE := $(MAKE) SHELL=$(SHELL)
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2021-01-29 15:11:12 +00:00
|
|
|
#
|
|
|
|
# Discharge variables evaluated by ccache mechanism that may be inherited when
|
|
|
|
# using the build system in a nested fashion.
|
|
|
|
#
|
|
|
|
undefine CUSTOM_CXX
|
|
|
|
undefine CUSTOM_CC
|
|
|
|
|
Disambiguate kernel-specific file names
This patch removes possible ambiguities with respect to the naming of
kernel-dependent binaries and libraries. It also removes the use of
kernel-specific global side effects from the build system. The reach of
kernel-specific peculiarities has thereby become limited to the actual
users of the respective 'syscall-<kernel>' libraries.
Kernel-specific build artifacts are no longer generated at magic places
within the build directory (like okl4's includes, or the L4 build
directories of L4/Fiasco and Fiasco.OC, or the build directories of
various kernels). Instead, such artifacts have been largely moved to the
libcache. E.g., the former '<build-dir>/l4/' build directory for the L4
build system resides at '<build-dir>/var/libcache/syscall-foc/build/'.
This way, the location is unique to the kernel. Note that various tools
are still generated somewhat arbitrarily under '<build-dir>/tool/' as
there is no proper formalism for building host tools yet.
As the result of this work, it has become possible to use a joint Genode
build directory that is usable with all kernels of a given hardware
platform. E.g., on x86_32, one can now seamlessly switch between linux,
nova, sel4, okl4, fiasco, foc, and pistachio without rebuilding any
components except for core, the kernel, the dynamic linker, and the timer
driver. At the current stage, such a build directory must still be
created manually. A change of the 'create_builddir' tool will follow to
make this feature easily available.
This patch also simplifies various 'run/boot_dir' plugins by removing
the option for an externally hosted kernel. This option remained unused
for many years now.
Issue #2190
2016-12-10 00:30:38 +00:00
|
|
|
#
|
|
|
|
# Fetch SPECS configuration from all source repositories and the build directory
|
|
|
|
#
|
|
|
|
SPECS :=
|
|
|
|
-include $(foreach REP,$(REPOSITORIES),$(wildcard $(REP)/etc/specs.conf))
|
2015-05-19 16:32:41 +00:00
|
|
|
-include $(BUILD_BASE_DIR)/etc/specs.conf
|
2016-05-29 01:13:43 +00:00
|
|
|
|
Disambiguate kernel-specific file names
This patch removes possible ambiguities with respect to the naming of
kernel-dependent binaries and libraries. It also removes the use of
kernel-specific global side effects from the build system. The reach of
kernel-specific peculiarities has thereby become limited to the actual
users of the respective 'syscall-<kernel>' libraries.
Kernel-specific build artifacts are no longer generated at magic places
within the build directory (like okl4's includes, or the L4 build
directories of L4/Fiasco and Fiasco.OC, or the build directories of
various kernels). Instead, such artifacts have been largely moved to the
libcache. E.g., the former '<build-dir>/l4/' build directory for the L4
build system resides at '<build-dir>/var/libcache/syscall-foc/build/'.
This way, the location is unique to the kernel. Note that various tools
are still generated somewhat arbitrarily under '<build-dir>/tool/' as
there is no proper formalism for building host tools yet.
As the result of this work, it has become possible to use a joint Genode
build directory that is usable with all kernels of a given hardware
platform. E.g., on x86_32, one can now seamlessly switch between linux,
nova, sel4, okl4, fiasco, foc, and pistachio without rebuilding any
components except for core, the kernel, the dynamic linker, and the timer
driver. At the current stage, such a build directory must still be
created manually. A change of the 'create_builddir' tool will follow to
make this feature easily available.
This patch also simplifies various 'run/boot_dir' plugins by removing
the option for an externally hosted kernel. This option remained unused
for many years now.
Issue #2190
2016-12-10 00:30:38 +00:00
|
|
|
#
|
|
|
|
# \deprecated We include the repository-specific 'specs.conf' once again as the
|
|
|
|
# build-dir-local etc/specs.conf (as created by create_builddir)
|
|
|
|
# reassigns the 'SPECS' variable instead of appending it.
|
|
|
|
# We sort the 'SPECS' to remove duplicates. We should remove this
|
|
|
|
# once the old 'create_builddir' arguments are gone.
|
|
|
|
#
|
|
|
|
-include $(foreach REP,$(REPOSITORIES),$(wildcard $(REP)/etc/specs.conf))
|
|
|
|
SPECS := $(sort $(SPECS))
|
|
|
|
|
|
|
|
select_from_repositories = $(firstword $(foreach REP,$(REPOSITORIES),$(wildcard $(REP)/$(1))))
|
|
|
|
|
2016-05-29 01:13:43 +00:00
|
|
|
#
|
|
|
|
# Determine the spec files to incorporate into the build configuration from the
|
|
|
|
# repositories. Always consider the spec files present in BASE_DIR. This is
|
|
|
|
# needed when the build system is invoked from the package-build tool where the
|
|
|
|
# repos/base is not present in the list of REPOSITORIES.
|
|
|
|
#
|
|
|
|
export SPEC_FILES := \
|
|
|
|
$(sort $(foreach SPEC,$(SPECS),$(call select_from_repositories,mk/spec/$(SPEC).mk)) \
|
|
|
|
$(wildcard $(foreach SPEC,$(SPECS),$(BASE_DIR)/mk/spec/$(SPEC).mk)))
|
2015-05-19 16:32:41 +00:00
|
|
|
include $(SPEC_FILES)
|
|
|
|
export SPECS
|
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
include $(BASE_DIR)/mk/global.mk
|
|
|
|
|
2021-01-29 15:11:12 +00:00
|
|
|
export LIBGCC_INC_DIR := $(shell dirname `$(CUSTOM_CXX_LIB) -print-libgcc-file-name`)/include
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Find out about the target directories to build
|
|
|
|
#
|
build: support library builds via lib/<libname>
This patch adds special handling for lib/<libname> arguments to the
build system, which supersedes the former LIB=<libname> mechanism.
Whereas the old mechanism was limited to a single library, the new
convention allows multiple library arguments, similar to regular
targets. The change brings the two immediate benefits.
First, the streamlining of library and target arguments allows for the
building of libraries via the 'build' command of the run tool.
Second, it alleviates the need for pseudo target.mk files for building
shared libraries that have no direct dependencies, in particular VFS
plugins.
Since this change eases the explicit creation of shared libraries
from run scripts, we may reconsider the automatic implicit building
of shared libraries driven by targets. E.g., while developing a Qt
application, a run script could import the Qt libraries from the
depot and combine those with the developed (fresh built) target without
triggering the build of the Qt libraries in the build directory.
When issueing 'make' without arguments, all targets are built. This
patch applies this behavior to libraries as well, thereby removing the
need for the base/src/lib/target.mk pseudo target as used by the CI
tools to build all libraries.
Note that target.mk files located under src/lib/ are no longer
reachable. Therefore, all run scripts that used to trigger the
build of a shared library via a pseudo target must be adapted.
E.g., 'build lib/vfs/tap' must be replaced by 'build lib/vfs_tap'.
With this patch, the LIB=<libname> option is no longer supported.
Fixes #4599
2022-08-31 14:50:07 +00:00
|
|
|
# Arguments starting with 'run/' and 'lib/' are special. The former triggers
|
|
|
|
# the execution of a run script. The latter issues the build of a library.
|
|
|
|
#
|
|
|
|
DST_DIRS := $(filter-out clean cleanall again run/% lib/%,$(MAKECMDGOALS))
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
ifeq ($(MAKECMDGOALS),)
|
2012-03-28 16:49:38 +00:00
|
|
|
DST_DIRS := *
|
2011-12-22 15:19:25 +00:00
|
|
|
endif
|
|
|
|
|
build: support library builds via lib/<libname>
This patch adds special handling for lib/<libname> arguments to the
build system, which supersedes the former LIB=<libname> mechanism.
Whereas the old mechanism was limited to a single library, the new
convention allows multiple library arguments, similar to regular
targets. The change brings the two immediate benefits.
First, the streamlining of library and target arguments allows for the
building of libraries via the 'build' command of the run tool.
Second, it alleviates the need for pseudo target.mk files for building
shared libraries that have no direct dependencies, in particular VFS
plugins.
Since this change eases the explicit creation of shared libraries
from run scripts, we may reconsider the automatic implicit building
of shared libraries driven by targets. E.g., while developing a Qt
application, a run script could import the Qt libraries from the
depot and combine those with the developed (fresh built) target without
triggering the build of the Qt libraries in the build directory.
When issueing 'make' without arguments, all targets are built. This
patch applies this behavior to libraries as well, thereby removing the
need for the base/src/lib/target.mk pseudo target as used by the CI
tools to build all libraries.
Note that target.mk files located under src/lib/ are no longer
reachable. Therefore, all run scripts that used to trigger the
build of a shared library via a pseudo target must be adapted.
E.g., 'build lib/vfs/tap' must be replaced by 'build lib/vfs_tap'.
With this patch, the LIB=<libname> option is no longer supported.
Fixes #4599
2022-08-31 14:50:07 +00:00
|
|
|
#
|
|
|
|
# Detect use of obsoleted LIB=<libname> option
|
|
|
|
#
|
|
|
|
ifneq ($(LIB),)
|
|
|
|
$(error the 'LIB=$(LIB)' option is no longer supported, use 'make lib/$(LIB)')
|
|
|
|
endif
|
|
|
|
|
|
|
|
#
|
|
|
|
# Determine library targets specified as lib/<libname> at the command line
|
|
|
|
#
|
|
|
|
LIBS := $(notdir $(filter lib/%,$(MAKECMDGOALS)))
|
|
|
|
|
|
|
|
ifeq ($(MAKECMDGOALS),)
|
|
|
|
ALL_LIB_MK_DIRS := $(wildcard \
|
|
|
|
$(foreach R,$(REPOSITORIES),\
|
|
|
|
$R/lib/mk $(foreach S,$(SPECS),$R/lib/mk/spec/$S)))
|
|
|
|
ALL_LIB_MK_FILES := $(wildcard $(addsuffix /*.mk,$(ALL_LIB_MK_DIRS)))
|
|
|
|
LIBS := $(sort $(notdir $(ALL_LIB_MK_FILES:.mk=)))
|
|
|
|
endif
|
|
|
|
|
2021-01-29 15:11:12 +00:00
|
|
|
#
|
|
|
|
# Helper function to check if a needed tool is installed
|
|
|
|
#
|
2021-11-08 20:15:54 +00:00
|
|
|
check_tool = $(if $(shell command -v $(1)),,$(error Need to have '$(1)' installed.))
|
2021-01-29 15:11:12 +00:00
|
|
|
|
2015-05-19 16:32:41 +00:00
|
|
|
#
|
|
|
|
# Tool chain version check
|
|
|
|
#
|
2015-08-31 14:33:05 +00:00
|
|
|
# Empty DST_DIRS is interpreted as a tool-chain agnostic target, e.g., clean.
|
2015-05-19 16:32:41 +00:00
|
|
|
#
|
|
|
|
ifneq ($(DST_DIRS),)
|
2023-05-09 10:08:32 +00:00
|
|
|
REQUIRED_GCC_VERSION ?= 12.3.0
|
2015-05-19 16:32:41 +00:00
|
|
|
GCC_VERSION := $(filter $(REQUIRED_GCC_VERSION) ,$(shell $(CUSTOM_CXX) --version))
|
|
|
|
ifneq ($(GCC_VERSION), $(REQUIRED_GCC_VERSION))
|
2015-08-11 08:58:02 +00:00
|
|
|
$(error "$(CUSTOM_CXX) version $(REQUIRED_GCC_VERSION) is required")
|
2015-05-19 16:32:41 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2018-10-25 16:33:16 +00:00
|
|
|
ifneq ($(STATIC_ANALYZE),)
|
|
|
|
$(call check_tool,scan-build)
|
|
|
|
|
|
|
|
MAKE := scan-build --use-c++=$(CUSTOM_CXX) --use-cc=$(CUSTOM_CC) $(MAKE)
|
|
|
|
endif
|
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
# Default rule: build all directories specified as make arguments
|
|
|
|
#
|
build: support library builds via lib/<libname>
This patch adds special handling for lib/<libname> arguments to the
build system, which supersedes the former LIB=<libname> mechanism.
Whereas the old mechanism was limited to a single library, the new
convention allows multiple library arguments, similar to regular
targets. The change brings the two immediate benefits.
First, the streamlining of library and target arguments allows for the
building of libraries via the 'build' command of the run tool.
Second, it alleviates the need for pseudo target.mk files for building
shared libraries that have no direct dependencies, in particular VFS
plugins.
Since this change eases the explicit creation of shared libraries
from run scripts, we may reconsider the automatic implicit building
of shared libraries driven by targets. E.g., while developing a Qt
application, a run script could import the Qt libraries from the
depot and combine those with the developed (fresh built) target without
triggering the build of the Qt libraries in the build directory.
When issueing 'make' without arguments, all targets are built. This
patch applies this behavior to libraries as well, thereby removing the
need for the base/src/lib/target.mk pseudo target as used by the CI
tools to build all libraries.
Note that target.mk files located under src/lib/ are no longer
reachable. Therefore, all run scripts that used to trigger the
build of a shared library via a pseudo target must be adapted.
E.g., 'build lib/vfs/tap' must be replaced by 'build lib/vfs_tap'.
With this patch, the LIB=<libname> option is no longer supported.
Fixes #4599
2022-08-31 14:50:07 +00:00
|
|
|
_all $(DST_DIRS) $(addprefix lib/,$(LIBS)) : gen_deps_and_build_targets
|
2011-12-22 15:19:25 +00:00
|
|
|
@true
|
|
|
|
|
|
|
|
##
|
|
|
|
## First stage: generate library dependencies
|
|
|
|
##
|
|
|
|
|
|
|
|
#
|
|
|
|
# Reset library-build log and library-dependency file
|
|
|
|
#
|
|
|
|
# The 'progress' file contains the names of the already processed libraries
|
|
|
|
# of the current build process. Before considering to process any library,
|
|
|
|
# the build system checks if the library is already present in the 'progress'
|
|
|
|
# file and, if yes, skips it.
|
|
|
|
#
|
|
|
|
.PHONY: init_progress_log
|
|
|
|
init_progress_log:
|
|
|
|
@echo "#" > $(LIB_PROGRESS_LOG)
|
|
|
|
@echo "# Library build progress log - generated by dep_prg.mk and dep_lib.mk" >> $(LIB_PROGRESS_LOG)
|
|
|
|
@echo "#" >> $(LIB_PROGRESS_LOG)
|
|
|
|
|
2013-03-20 08:15:47 +00:00
|
|
|
.PHONY: init_libdep_file
|
|
|
|
init_libdep_file: $(dir $(LIB_DEP_FILE))
|
2012-03-28 16:49:38 +00:00
|
|
|
@echo "checking library dependencies..."
|
|
|
|
@(echo "#"; \
|
|
|
|
echo "# Library dependencies for build '$(DST_DIRS)'"; \
|
|
|
|
echo "#"; \
|
|
|
|
echo ""; \
|
|
|
|
echo "export SPEC_FILES := \\"; \
|
|
|
|
for i in $(SPEC_FILES); do \
|
|
|
|
echo " $$i \\"; done; \
|
|
|
|
echo ""; \
|
|
|
|
echo "LIB_CACHE_DIR = $(LIB_CACHE_DIR)"; \
|
|
|
|
echo "BASE_DIR = $(realpath $(BASE_DIR))"; \
|
|
|
|
echo "VERBOSE ?= $(VERBOSE)"; \
|
|
|
|
echo "VERBOSE_MK ?= $(VERBOSE_MK)"; \
|
|
|
|
echo "VERBOSE_DIR ?= $(VERBOSE_DIR)"; \
|
|
|
|
echo "INSTALL_DIR ?= $(INSTALL_DIR)"; \
|
2017-04-05 14:51:47 +00:00
|
|
|
echo "DEBUG_DIR ?= $(DEBUG_DIR)"; \
|
2012-03-28 16:49:38 +00:00
|
|
|
echo "SHELL ?= $(SHELL)"; \
|
|
|
|
echo "MKDIR ?= mkdir"; \
|
|
|
|
echo ""; \
|
|
|
|
echo "all:"; \
|
|
|
|
echo " @true # prevent nothing-to-be-done message"; \
|
|
|
|
echo "") > $(LIB_DEP_FILE)
|
|
|
|
|
|
|
|
#
|
|
|
|
# We check if any target.mk files exist in the specified directories within
|
|
|
|
# any of the repositories listed in the 'REPOSITORIES' variable.
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
$(dir $(LIB_DEP_FILE)):
|
|
|
|
@mkdir -p $@
|
|
|
|
|
2012-03-28 16:49:38 +00:00
|
|
|
#
|
|
|
|
# Find all 'target.mk' files located within any of the specified subdirectories
|
|
|
|
# ('DST_DIRS') and any repository. The 'sort' is used to remove duplicates.
|
|
|
|
#
|
2016-05-28 20:49:41 +00:00
|
|
|
TARGETS_TO_VISIT := $(shell find $(wildcard $(REPOSITORIES:=/src)) -false \
|
2012-03-28 16:49:38 +00:00
|
|
|
$(foreach DST,$(DST_DIRS), \
|
|
|
|
-or -path "*/src/$(DST)/**target.mk" \
|
|
|
|
-printf " %P "))
|
|
|
|
TARGETS_TO_VISIT := $(sort $(TARGETS_TO_VISIT))
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2012-03-28 16:49:38 +00:00
|
|
|
#
|
|
|
|
# Perform sanity check for non-existing targets being specified at the command
|
|
|
|
# line.
|
|
|
|
#
|
|
|
|
MISSING_TARGETS := $(strip \
|
|
|
|
$(foreach DST,$(DST_DIRS),\
|
|
|
|
$(if $(filter $(DST)/%,$(TARGETS_TO_VISIT)),,$(DST))))
|
|
|
|
|
|
|
|
ifneq ($(MAKECMDGOALS),)
|
|
|
|
ifneq ($(MISSING_TARGETS),)
|
|
|
|
init_libdep_file: error_missing_targets
|
|
|
|
error_missing_targets:
|
|
|
|
@for target in $(MISSING_TARGETS); do \
|
|
|
|
echo "Error: target '$$target' does not exist"; done
|
|
|
|
@false;
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
#
|
|
|
|
# The procedure of collecting library dependencies is realized as a single
|
|
|
|
# rule to gain maximum performance. If we invoked a rule for each target,
|
|
|
|
# we would need to spawn one additional shell per target, which would take
|
|
|
|
# 10-20 percent more time.
|
|
|
|
#
|
build: support library builds via lib/<libname>
This patch adds special handling for lib/<libname> arguments to the
build system, which supersedes the former LIB=<libname> mechanism.
Whereas the old mechanism was limited to a single library, the new
convention allows multiple library arguments, similar to regular
targets. The change brings the two immediate benefits.
First, the streamlining of library and target arguments allows for the
building of libraries via the 'build' command of the run tool.
Second, it alleviates the need for pseudo target.mk files for building
shared libraries that have no direct dependencies, in particular VFS
plugins.
Since this change eases the explicit creation of shared libraries
from run scripts, we may reconsider the automatic implicit building
of shared libraries driven by targets. E.g., while developing a Qt
application, a run script could import the Qt libraries from the
depot and combine those with the developed (fresh built) target without
triggering the build of the Qt libraries in the build directory.
When issueing 'make' without arguments, all targets are built. This
patch applies this behavior to libraries as well, thereby removing the
need for the base/src/lib/target.mk pseudo target as used by the CI
tools to build all libraries.
Note that target.mk files located under src/lib/ are no longer
reachable. Therefore, all run scripts that used to trigger the
build of a shared library via a pseudo target must be adapted.
E.g., 'build lib/vfs/tap' must be replaced by 'build lib/vfs_tap'.
With this patch, the LIB=<libname> option is no longer supported.
Fixes #4599
2022-08-31 14:50:07 +00:00
|
|
|
traverse_dependencies: $(dir $(LIB_DEP_FILE)) init_libdep_file init_progress_log
|
2012-03-28 16:49:38 +00:00
|
|
|
$(VERBOSE_MK) \
|
build: support library builds via lib/<libname>
This patch adds special handling for lib/<libname> arguments to the
build system, which supersedes the former LIB=<libname> mechanism.
Whereas the old mechanism was limited to a single library, the new
convention allows multiple library arguments, similar to regular
targets. The change brings the two immediate benefits.
First, the streamlining of library and target arguments allows for the
building of libraries via the 'build' command of the run tool.
Second, it alleviates the need for pseudo target.mk files for building
shared libraries that have no direct dependencies, in particular VFS
plugins.
Since this change eases the explicit creation of shared libraries
from run scripts, we may reconsider the automatic implicit building
of shared libraries driven by targets. E.g., while developing a Qt
application, a run script could import the Qt libraries from the
depot and combine those with the developed (fresh built) target without
triggering the build of the Qt libraries in the build directory.
When issueing 'make' without arguments, all targets are built. This
patch applies this behavior to libraries as well, thereby removing the
need for the base/src/lib/target.mk pseudo target as used by the CI
tools to build all libraries.
Note that target.mk files located under src/lib/ are no longer
reachable. Therefore, all run scripts that used to trigger the
build of a shared library via a pseudo target must be adapted.
E.g., 'build lib/vfs/tap' must be replaced by 'build lib/vfs_tap'.
With this patch, the LIB=<libname> option is no longer supported.
Fixes #4599
2022-08-31 14:50:07 +00:00
|
|
|
for lib in $(LIBS); do \
|
|
|
|
$(MAKE) $(VERBOSE_DIR) -f $(BASE_DIR)/mk/dep_lib.mk \
|
|
|
|
REP_DIR=$$rep LIB=$$lib \
|
|
|
|
BUILD_BASE_DIR=$(BUILD_BASE_DIR) \
|
|
|
|
DARK_COL="$(DARK_COL)" DEFAULT_COL="$(DEFAULT_COL)"; \
|
|
|
|
echo "all: $$lib.lib" >> $(LIB_DEP_FILE); \
|
|
|
|
done; \
|
2012-03-28 16:49:38 +00:00
|
|
|
for target in $(TARGETS_TO_VISIT); do \
|
|
|
|
for rep in $(REPOSITORIES); do \
|
|
|
|
test -f $$rep/src/$$target || continue; \
|
2011-12-22 15:19:25 +00:00
|
|
|
$(MAKE) $(VERBOSE_DIR) -f $(BASE_DIR)/mk/dep_prg.mk \
|
2012-03-28 16:49:38 +00:00
|
|
|
REP_DIR=$$rep TARGET_MK=$$rep/src/$$target \
|
|
|
|
BUILD_BASE_DIR=$(BUILD_BASE_DIR) \
|
2014-05-13 21:26:47 +00:00
|
|
|
DARK_COL="$(DARK_COL)" DEFAULT_COL="$(DEFAULT_COL)" || result=false; \
|
2012-03-28 16:49:38 +00:00
|
|
|
break; \
|
|
|
|
done; \
|
2014-05-13 21:26:47 +00:00
|
|
|
done; $$result;
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
.PHONY: $(LIB_DEP_FILE)
|
2016-05-17 18:28:44 +00:00
|
|
|
|
build: support library builds via lib/<libname>
This patch adds special handling for lib/<libname> arguments to the
build system, which supersedes the former LIB=<libname> mechanism.
Whereas the old mechanism was limited to a single library, the new
convention allows multiple library arguments, similar to regular
targets. The change brings the two immediate benefits.
First, the streamlining of library and target arguments allows for the
building of libraries via the 'build' command of the run tool.
Second, it alleviates the need for pseudo target.mk files for building
shared libraries that have no direct dependencies, in particular VFS
plugins.
Since this change eases the explicit creation of shared libraries
from run scripts, we may reconsider the automatic implicit building
of shared libraries driven by targets. E.g., while developing a Qt
application, a run script could import the Qt libraries from the
depot and combine those with the developed (fresh built) target without
triggering the build of the Qt libraries in the build directory.
When issueing 'make' without arguments, all targets are built. This
patch applies this behavior to libraries as well, thereby removing the
need for the base/src/lib/target.mk pseudo target as used by the CI
tools to build all libraries.
Note that target.mk files located under src/lib/ are no longer
reachable. Therefore, all run scripts that used to trigger the
build of a shared library via a pseudo target must be adapted.
E.g., 'build lib/vfs/tap' must be replaced by 'build lib/vfs_tap'.
With this patch, the LIB=<libname> option is no longer supported.
Fixes #4599
2022-08-31 14:50:07 +00:00
|
|
|
$(LIB_DEP_FILE): traverse_dependencies
|
2016-05-17 18:28:44 +00:00
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
## Second stage: build targets based on the result of the first stage
|
|
|
|
##
|
|
|
|
|
2017-04-05 14:51:47 +00:00
|
|
|
$(INSTALL_DIR) $(DEBUG_DIR):
|
2011-12-22 15:19:25 +00:00
|
|
|
$(VERBOSE)mkdir -p $@
|
|
|
|
|
|
|
|
.PHONY: gen_deps_and_build_targets
|
2017-04-05 14:51:47 +00:00
|
|
|
gen_deps_and_build_targets: $(INSTALL_DIR) $(DEBUG_DIR) $(LIB_DEP_FILE)
|
2016-02-04 11:20:03 +00:00
|
|
|
@(echo ""; \
|
|
|
|
echo "ifneq (\$$(MISSING_PORTS),)"; \
|
|
|
|
echo "check_ports:"; \
|
|
|
|
echo " @echo \"\""; \
|
|
|
|
echo " @echo \"Error: Ports not prepared or outdated:\""; \
|
|
|
|
echo " @echo \" \$$(sort \$$(MISSING_PORTS))\""; \
|
|
|
|
echo " @echo \"\""; \
|
|
|
|
echo " @echo \"You can prepare respectively update them as follows:\""; \
|
2016-03-11 11:29:46 +00:00
|
|
|
echo " @echo \" $(GENODE_DIR)/tool/ports/prepare_port \$$(sort \$$(MISSING_PORTS))\""; \
|
2016-02-04 11:20:03 +00:00
|
|
|
echo " @echo \"\""; \
|
|
|
|
echo " @false"; \
|
|
|
|
echo "else"; \
|
|
|
|
echo "check_ports:"; \
|
|
|
|
echo "endif"; \
|
|
|
|
echo "") >> $(LIB_DEP_FILE)
|
2022-03-10 14:25:50 +00:00
|
|
|
$(VERBOSE_MK)$(MAKE) $(VERBOSE_DIR) -f $(LIB_DEP_FILE) all
|
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
.PHONY: again
|
2017-04-05 14:51:47 +00:00
|
|
|
again: $(INSTALL_DIR) $(DEBUG_DIR)
|
2022-03-10 14:25:50 +00:00
|
|
|
$(VERBOSE_MK)$(MAKE) $(VERBOSE_DIR) -f $(LIB_DEP_FILE) all
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2021-01-29 15:11:12 +00:00
|
|
|
#
|
|
|
|
# Read tools configuration to obtain the cross-compiler prefix passed
|
|
|
|
# to the run script.
|
|
|
|
#
|
|
|
|
-include $(call select_from_repositories,etc/tools.conf)
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
## Compiler-cache support
|
|
|
|
##
|
|
|
|
|
|
|
|
#
|
|
|
|
# To hook the ccache into the build process, the compiler executables are
|
|
|
|
# shadowed by symlinks named after the compiler but pointing to the ccache
|
|
|
|
# program. When invoked, the ccache program uses argv0 to query the real
|
|
|
|
# compiler executable.
|
|
|
|
#
|
|
|
|
# If the configured tool-chain path is absolute, we assume that it is not
|
|
|
|
# already part of the PATH variable. In this (default) case, we supplement the
|
|
|
|
# tool-chain path to the CCACHE_PATH as evaluated by the ccache program.
|
|
|
|
#
|
|
|
|
# Should the tool-chain path not be absolute, the tool-chain executables must
|
|
|
|
# already be reachable via the regular PATH variable. Otherwise, the build
|
|
|
|
# would not work without ccache either.
|
|
|
|
#
|
|
|
|
|
|
|
|
ifeq ($(CCACHE),yes)
|
|
|
|
|
|
|
|
$(call check_tool,ccache)
|
|
|
|
|
|
|
|
ifneq ($(dir $(CUSTOM_CXX)),$(dir $(CUSTOM_CC)))
|
|
|
|
$(error ccache enabled but the compilers $(CUSTOM_CXX) and $(CUSTOM_CC)\
|
|
|
|
reside in different directories)
|
|
|
|
endif
|
|
|
|
|
|
|
|
CCACHE_TOOL_DIR := $(addsuffix /var/tool/ccache,$(BUILD_BASE_DIR))
|
|
|
|
CCACHED_CUSTOM_CC := $(CCACHE_TOOL_DIR)/$(notdir $(CUSTOM_CC))
|
|
|
|
CCACHED_CUSTOM_CXX := $(CCACHE_TOOL_DIR)/$(notdir $(CUSTOM_CXX))
|
|
|
|
|
|
|
|
gen_deps_and_build_targets: $(CCACHED_CUSTOM_CC) $(CCACHED_CUSTOM_CXX)
|
|
|
|
|
|
|
|
# create ccache symlinks at var/tool/ccache/
|
|
|
|
$(CCACHED_CUSTOM_CC) $(CCACHED_CUSTOM_CXX):
|
|
|
|
$(VERBOSE_MK)mkdir -p $(dir $@)
|
2021-11-08 20:15:54 +00:00
|
|
|
$(VERBOSE_MK)ln -sf `command -v ccache` $@
|
2021-01-29 15:11:12 +00:00
|
|
|
|
|
|
|
# supplement tool-chain directory to the search-path variable used by ccache
|
|
|
|
ifneq ($(filter /%,$(CUSTOM_CXX)),)
|
|
|
|
export CCACHE_PATH := $(dir $(CUSTOM_CXX)):$(PATH)
|
|
|
|
endif
|
|
|
|
|
2021-08-24 11:51:47 +00:00
|
|
|
# force preprocessor mode
|
|
|
|
export CCACHE_NODIRECT=1
|
|
|
|
|
2021-01-29 15:11:12 +00:00
|
|
|
# override CUSTOM_CC and CUSTOM_CXX to point to the ccache symlinks
|
|
|
|
export CUSTOM_CC := $(CCACHED_CUSTOM_CC)
|
|
|
|
export CUSTOM_CXX := $(CCACHED_CUSTOM_CXX)
|
|
|
|
|
2021-03-05 15:06:15 +00:00
|
|
|
RUN_OPT_CCACHE := --ccache
|
|
|
|
|
2021-01-29 15:11:12 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
##
|
|
|
|
## Rules for running automated test cases
|
|
|
|
##
|
|
|
|
|
|
|
|
RUN_OPT ?=
|
|
|
|
|
|
|
|
# helper for run/% rule
|
|
|
|
RUN_SCRIPT = $(call select_from_repositories,run/$*.run)
|
|
|
|
|
|
|
|
run/%: $(call select_from_repositories,run/%.run) $(RUN_ENV)
|
|
|
|
$(VERBOSE)test -f "$(RUN_SCRIPT)" || (echo "Error: No run script for $*"; exit -1)
|
2015-01-08 21:08:48 +00:00
|
|
|
$(VERBOSE)$(GENODE_DIR)/tool/run/run --genode-dir $(GENODE_DIR) \
|
|
|
|
--name $* \
|
|
|
|
--specs "$(SPECS)" \
|
2019-05-09 12:04:03 +00:00
|
|
|
--board "$(BOARD)" \
|
2015-01-08 21:08:48 +00:00
|
|
|
--repositories "$(REPOSITORIES)" \
|
|
|
|
--cross-dev-prefix "$(CROSS_DEV_PREFIX)" \
|
|
|
|
--qemu-args "$(QEMU_OPT)" \
|
2019-04-01 15:28:12 +00:00
|
|
|
--make "$(MAKE)" \
|
2021-03-05 15:06:15 +00:00
|
|
|
$(RUN_OPT_CCACHE) \
|
2015-01-08 21:08:48 +00:00
|
|
|
$(RUN_OPT) \
|
|
|
|
--include $(RUN_SCRIPT)
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
## Clean rules
|
|
|
|
##
|
|
|
|
|
|
|
|
#
|
|
|
|
# For cleaning, visit each directory for that a corresponding target.mk
|
|
|
|
# file exists in the source tree. For each such directory, we call
|
|
|
|
# the single_target rule.
|
|
|
|
#
|
|
|
|
clean_targets:
|
|
|
|
$(VERBOSE_MK)for d in `$(GNU_FIND) -mindepth 1 -type d | $(TAC) | sed "s/^..//"`; do \
|
|
|
|
for r in $(REPOSITORIES); do \
|
|
|
|
test -f $$r/src/$$d/target.mk && \
|
|
|
|
$(MAKE) $(VERBOSE_DIR) clean \
|
|
|
|
-C $$d \
|
|
|
|
-f $(BASE_DIR)/mk/prg.mk \
|
|
|
|
BUILD_BASE_DIR=$(BUILD_BASE_DIR) \
|
|
|
|
PRG_REL_DIR=$$d \
|
|
|
|
REP_DIR=$$r || \
|
|
|
|
true; \
|
|
|
|
done; \
|
|
|
|
done
|
|
|
|
|
|
|
|
clean_libcache:
|
|
|
|
$(VERBOSE)rm -rf var/libcache
|
|
|
|
|
|
|
|
clean_run:
|
|
|
|
$(VERBOSE)rm -rf var/run
|
2013-06-17 08:06:12 +00:00
|
|
|
$(VERBOSE)rm -rf config-00-00-00-00-00-00
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
clean_gen_files:
|
|
|
|
$(VERBOSE)rm -f $(LIB_PROGRESS_LOG)
|
|
|
|
$(VERBOSE)rm -f $(LIB_DEP_FILE)
|
|
|
|
|
|
|
|
clean_install_dir:
|
|
|
|
$(VERBOSE)(test -d $(INSTALL_DIR) && find $(INSTALL_DIR) -type l -not -readable -delete) || true
|
|
|
|
|
2017-04-05 14:51:47 +00:00
|
|
|
clean_debug_dir:
|
|
|
|
$(VERBOSE)(test -d $(DEBUG_DIR) && find $(DEBUG_DIR) -type l -not -readable -delete) || true
|
|
|
|
|
|
|
|
clean_empty_dirs: clean_targets clean_libcache clean_run clean_gen_files clean_install_dir clean_debug_dir
|
2011-12-22 15:19:25 +00:00
|
|
|
$(VERBOSE)$(GNU_FIND) . -depth -type d -empty -delete
|
|
|
|
|
|
|
|
clean cleanall: clean_empty_dirs
|
|
|
|
|