Imported Genode release 11.11
This commit is contained in:
committed by
Christian Helmuth
parent
6bcc9aef0e
commit
da4e1feaa5
14
base/mk/README
Normal file
14
base/mk/README
Normal file
@@ -0,0 +1,14 @@
|
||||
This directory contains the build system. In consists mainly of makefile
|
||||
templates for different directory roles.
|
||||
|
||||
:'global.mk': This file contains global variables, for example the
|
||||
definitions of the tools to use.
|
||||
|
||||
:'generic.mk': Generic rules for creating file types from others.
|
||||
|
||||
:'prg.mk': This file represents the target binary role of a directory.
|
||||
It must be included by all makefiles that build programs.
|
||||
|
||||
:'lib.mk': This file represents a library role. It is never used from
|
||||
within the 'src/' directory but only from the <libname>.mk files
|
||||
in 'lib/mk/'.
|
||||
14
base/mk/base-libs.mk
Normal file
14
base/mk/base-libs.mk
Normal file
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# Genode base libaries
|
||||
#
|
||||
# These linked against 'ldso' and filtered out for dynamically
|
||||
# linked binaries
|
||||
#
|
||||
BASE_LIBS = alarm allocator_avl avl_tree cxx env heap \
|
||||
ipc lock slab timed_semaphore thread signal \
|
||||
log_console slab
|
||||
|
||||
#
|
||||
# Name of Genode's dynamic linker
|
||||
#
|
||||
DYNAMIC_LINKER = ld
|
||||
146
base/mk/dep_lib.mk
Normal file
146
base/mk/dep_lib.mk
Normal file
@@ -0,0 +1,146 @@
|
||||
#
|
||||
# This file determines dependencies of a library from other libraries
|
||||
#
|
||||
# The following variables must be defined by the caller:
|
||||
#
|
||||
# VERBOSE - controls the make verboseness
|
||||
# VERBOSE_DIR - verboseness of directory change messages
|
||||
# VERBOSE_MK - verboseness of make calls
|
||||
# REPOSITORIES - source code repositories to use
|
||||
# BASE_DIR - base directory of build system repository
|
||||
# TARGET_DIR - target build directory
|
||||
# BUILD_BASE_DIR - build directory with build config
|
||||
# LIB_CACHE_DIR - destination directory for object files
|
||||
# LIB_PROGRESS_LOG - library build log file
|
||||
# BUILD_LIBS - list of libraries to build (without .lib.a or .lib.so suffix)
|
||||
# INSTALL_DIR - destination directory for installing shared libraries
|
||||
#
|
||||
|
||||
#
|
||||
# Generate dependencies only for those libs that are
|
||||
# not already contained in the library build log
|
||||
#
|
||||
include $(LIB_PROGRESS_LOG)
|
||||
ifneq ($(filter $(LIB),$(LIBS_READY)),)
|
||||
already_visited:
|
||||
@true
|
||||
else
|
||||
all: append_lib_to_progress_log
|
||||
endif
|
||||
|
||||
append_lib_to_progress_log:
|
||||
@echo "LIBS_READY += $(LIB)" >> $(LIB_PROGRESS_LOG)
|
||||
|
||||
LIB_MK_DIRS = $(foreach REP,$(REPOSITORIES),$(addprefix $(REP)/lib/mk/,$(SPECS)) $(REP)/lib/mk)
|
||||
|
||||
#
|
||||
# Of all possible file locations, use the (first) one that actually exist.
|
||||
#
|
||||
LIB_MK = $(firstword $(wildcard $(addsuffix /$(LIB).mk,$(LIB_MK_DIRS))))
|
||||
|
||||
#
|
||||
# Sanity check to detect missing library description file
|
||||
#
|
||||
ifeq ($(LIB_MK),)
|
||||
all: warn_missing_lib_mk
|
||||
else
|
||||
all: check_unsatisfied_requirements
|
||||
endif
|
||||
|
||||
warn_missing_lib_mk: generate_lib_rule_for_defect_library
|
||||
@$(ECHO) "Library-description file $(DARK_COL)$(LIB).mk$(DEFAULT_COL) is missing"
|
||||
|
||||
#
|
||||
# Determine the repository base directory from the absolute pathname
|
||||
# of the choosen libname.mk file. We need to specify the override
|
||||
# command because REP_DIR was first set by prg.mk when building a
|
||||
# program target. The repository of a library could be a different
|
||||
# one.
|
||||
#
|
||||
# Finally, we strip the trailing slash from the path. The slash was
|
||||
# used to match the whole directory in 'findstring'.
|
||||
#
|
||||
override REP_DIR := $(firstword $(foreach REP,$(REPOSITORIES),$(findstring $(REP)/,$(LIB_MK))))
|
||||
override REP_DIR := $(REP_DIR:/=)
|
||||
|
||||
include $(LIB_MK)
|
||||
include $(BASE_DIR)/mk/base-libs.mk
|
||||
#
|
||||
# Libraries from the library depends on
|
||||
#
|
||||
# For shared libraries, we have to make sure to build ldso support before
|
||||
# building a shared library.
|
||||
#
|
||||
ifdef SHARED_LIB
|
||||
LIBS += ldso-startup
|
||||
|
||||
ifeq ($(LIB),$(DYNAMIC_LINKER))
|
||||
LIBS += $(BASE_LIBS)
|
||||
else
|
||||
LIBS := $(filter-out $(BASE_LIBS),$(LIBS))
|
||||
LIBS += $(DYNAMIC_LINKER)
|
||||
endif
|
||||
|
||||
|
||||
DEP_VAR_NAME := DEP_$(LIB).lib.so
|
||||
else
|
||||
DEP_VAR_NAME := DEP_$(LIB).lib
|
||||
endif
|
||||
|
||||
#
|
||||
# Add platform preparation dependency
|
||||
#
|
||||
# We make each leaf library depend on a library called 'platform'. This way,
|
||||
# the 'platform' library becomes a prerequisite of all other libraries. The
|
||||
# 'platform' library is supposed to take precautions for setting up
|
||||
# platform-specific build environments, e.g., preparing kernel API headers.
|
||||
#
|
||||
ifeq ($(LIBS),)
|
||||
ifneq ($(LIB),platform)
|
||||
LIBS += platform
|
||||
endif
|
||||
endif
|
||||
|
||||
#
|
||||
# Check if the requirements of the target are satisfied
|
||||
#
|
||||
UNSATISFIED_REQUIREMENTS = $(filter-out $(SPECS),$(REQUIRES))
|
||||
ifneq ($(UNSATISFIED_REQUIREMENTS),)
|
||||
check_unsatisfied_requirements: warn_unsatisfied_requirements
|
||||
else
|
||||
check_unsatisfied_requirements: generate_lib_rule
|
||||
endif
|
||||
|
||||
warn_unsatisfied_requirements: generate_lib_rule_for_defect_library
|
||||
@$(ECHO) "Skip library $(LIB) because it requires $(DARK_COL)$(UNSATISFIED_REQUIREMENTS)$(DEFAULT_COL)"
|
||||
|
||||
generate_lib_rule_for_defect_library:
|
||||
@echo "INVALID_DEPS += $(LIB)" >> $(LIB_DEP_FILE)
|
||||
@echo "" >> $(LIB_DEP_FILE)
|
||||
|
||||
LIBS_TO_VISIT = $(filter-out $(LIBS_READY),$(LIBS))
|
||||
|
||||
generate_lib_rule:
|
||||
ifneq ($(LIBS),)
|
||||
@(echo "$(DEP_VAR_NAME) = $(foreach l,$(LIBS),$l.lib \$$(DEP_$l.lib))"; \
|
||||
echo "") >> $(LIB_DEP_FILE)
|
||||
endif
|
||||
@(echo "$(LIB).lib: $(addsuffix .lib,$(LIBS))"; \
|
||||
echo " @\$$(MKDIR) -p \$$(LIB_CACHE_DIR)/$(LIB)"; \
|
||||
echo " \$$(VERBOSE_MK)\$$(MAKE) $(VERBOSE_DIR) -C \$$(LIB_CACHE_DIR)/$(LIB) -f \$$(BASE_DIR)/mk/lib.mk \\"; \
|
||||
echo " REP_DIR=$(REP_DIR) \\"; \
|
||||
echo " LIB_MK=$(LIB_MK) \\"; \
|
||||
echo " LIB=$(LIB) \\"; \
|
||||
echo " DEPS=\"\$$($(DEP_VAR_NAME))\" \\"; \
|
||||
echo " BUILD_BASE_DIR=$(BUILD_BASE_DIR) \\"; \
|
||||
echo " SHELL=$(SHELL) \\"; \
|
||||
echo " SHARED_LIBS=\"\$$(SHARED_LIBS)\"\\"; \
|
||||
echo " INSTALL_DIR=\$$(INSTALL_DIR)"; \
|
||||
echo "") >> $(LIB_DEP_FILE)
|
||||
@for i in $(LIBS_TO_VISIT); do \
|
||||
$(MAKE) $(VERBOSE_DIR) -f $(BASE_DIR)/mk/dep_lib.mk REP_DIR=$(REP_DIR) LIB=$$i; done
|
||||
ifdef SHARED_LIB
|
||||
@(echo "SHARED_LIBS += $(LIB)"; \
|
||||
echo "") >> $(LIB_DEP_FILE)
|
||||
endif
|
||||
|
||||
71
base/mk/dep_prg.mk
Normal file
71
base/mk/dep_prg.mk
Normal file
@@ -0,0 +1,71 @@
|
||||
#
|
||||
# Prevent execution of any rule contained in $(TARGET_MK) as default rule
|
||||
#
|
||||
all:
|
||||
|
||||
#
|
||||
# Utility for selecting files from the list of repositories
|
||||
#
|
||||
select_from_repositories = $(firstword $(foreach REP,$(REPOSITORIES),$(wildcard $(REP)/$(1))))
|
||||
|
||||
#
|
||||
# Include target build instructions to aquire library dependecies
|
||||
#
|
||||
PRG_DIR := $(dir $(TARGET_MK))
|
||||
include $(TARGET_MK)
|
||||
|
||||
#
|
||||
# Include lib-import description files
|
||||
#
|
||||
include $(foreach LIB,$(LIBS),$(call select_from_repositories,lib/import/import-$(LIB).mk))
|
||||
|
||||
#
|
||||
# Add globally defined library supplements
|
||||
#
|
||||
include $(SPEC_FILES)
|
||||
LIBS += $(PRG_LIBS)
|
||||
|
||||
#
|
||||
# Determine location of $(TARGET_MK) within 'src/', remove trailing slash
|
||||
#
|
||||
PRG_REL_DIR := $(subst $(REP_DIR)/src/,,$(PRG_DIR))
|
||||
PRG_REL_DIR := $(PRG_REL_DIR:/=)
|
||||
|
||||
#
|
||||
# Prevent generation of program rule if requirements are unsatisfied
|
||||
#
|
||||
UNSATISFIED_REQUIREMENTS = $(filter-out $(SPECS),$(REQUIRES))
|
||||
ifneq ($(UNSATISFIED_REQUIREMENTS),)
|
||||
all:
|
||||
@$(ECHO) "Skip target $(PRG_REL_DIR) because it requires $(DARK_COL)$(UNSATISFIED_REQUIREMENTS)$(DEFAULT_COL)"
|
||||
else
|
||||
all: gen_prg_rule
|
||||
endif
|
||||
|
||||
include $(LIB_PROGRESS_LOG)
|
||||
LIBS_TO_VISIT = $(filter-out $(LIBS_READY),$(LIBS))
|
||||
|
||||
#
|
||||
# Generate program rule
|
||||
#
|
||||
gen_prg_rule:
|
||||
ifneq ($(LIBS),)
|
||||
@(echo "DEP_$(TARGET).prg = $(foreach l,$(LIBS),$l.lib \$$(DEP_$l.lib))"; \
|
||||
echo "") >> $(LIB_DEP_FILE)
|
||||
endif
|
||||
@(echo "$(TARGET).prg: $(addsuffix .lib,$(LIBS))"; \
|
||||
echo " @\$$(MKDIR) -p $(PRG_REL_DIR)"; \
|
||||
echo " \$$(VERBOSE_MK)\$$(MAKE) $(VERBOSE_DIR) -C $(PRG_REL_DIR) -f \$$(BASE_DIR)/mk/prg.mk \\"; \
|
||||
echo " REP_DIR=$(REP_DIR) \\"; \
|
||||
echo " PRG_REL_DIR=$(PRG_REL_DIR) \\"; \
|
||||
echo " BUILD_BASE_DIR=$(BUILD_BASE_DIR) \\"; \
|
||||
echo " DEPS=\"\$$(DEP_$(TARGET).prg)\" \\"; \
|
||||
echo " SHELL=$(SHELL) \\"; \
|
||||
echo " INSTALL_DIR=\"\$$(INSTALL_DIR)\""; \
|
||||
echo "") >> $(LIB_DEP_FILE)
|
||||
@for i in $(LIBS_TO_VISIT); do \
|
||||
$(MAKE) $(VERBOSE_DIR) -f $(BASE_DIR)/mk/dep_lib.mk REP_DIR=$(REP_DIR) LIB=$$i; done
|
||||
@(echo ""; \
|
||||
echo "ifeq (\$$(filter \$$(DEP_$(TARGET).prg:.lib=),\$$(INVALID_DEPS)),)"; \
|
||||
echo "all: $(TARGET).prg"; \
|
||||
echo "endif") >> $(LIB_DEP_FILE)
|
||||
85
base/mk/generic.mk
Normal file
85
base/mk/generic.mk
Normal file
@@ -0,0 +1,85 @@
|
||||
#
|
||||
# Generic rules to build file types from other file types and other
|
||||
# common functionaly that is needed to build library or program targets.
|
||||
#
|
||||
|
||||
#
|
||||
# Collect object files and avoid duplicates (by using 'sort')
|
||||
#
|
||||
SRC_O += $(addprefix binary_,$(addsuffix .o,$(notdir $(SRC_BIN))))
|
||||
SRC = $(sort $(SRC_C) $(SRC_CC) $(SRC_ADA) $(SRC_S) $(SRC_O))
|
||||
OBJECTS = $(addsuffix .o,$(basename $(SRC)))
|
||||
|
||||
#
|
||||
# Create sub directories for objects files corresponding to the sub directories
|
||||
# of their respective source files
|
||||
#
|
||||
SUB_DIRS = $(sort $(dir $(OBJECTS)))
|
||||
ifneq ($(SUB_DIRS),./)
|
||||
$(OBJECTS): $(filter-out $(wildcard $(SUB_DIRS)), $(SUB_DIRS))
|
||||
endif
|
||||
|
||||
.PHONY: $(SUB_DIRS)
|
||||
$(SUB_DIRS):
|
||||
$(VERBOSE)mkdir -p $@
|
||||
|
||||
#
|
||||
# Make sure, that we rebuild object files after Makefile changes
|
||||
#
|
||||
$(wildcard $(OBJECTS)): $(filter-out $(LIB_PROGRESS_LOG),$(MAKEFILE_LIST))
|
||||
|
||||
INCLUDES := $(addprefix -I,$(wildcard $(ALL_INC_DIR)))
|
||||
|
||||
#
|
||||
# Include dependency files for the corresponding object files except
|
||||
# when cleaning
|
||||
#
|
||||
ifneq ($(filter-out $(MAKECMDGOALS),clean),)
|
||||
-include $(OBJECTS:.o=.d)
|
||||
endif
|
||||
|
||||
%.o: %.c
|
||||
$(MSG_COMP)$@
|
||||
$(VERBOSE)$(CC) $(CC_DEF) $(CC_C_OPT) $(INCLUDES) -c $< -o $@
|
||||
|
||||
%.o: %.cc
|
||||
$(MSG_COMP)$@
|
||||
$(VERBOSE)$(CXX) $(CXX_DEF) $(CC_CXX_OPT) $(INCLUDES) -c $< -o $@
|
||||
|
||||
%.o: %.cpp
|
||||
$(MSG_COMP)$@
|
||||
$(VERBOSE)$(CXX) $(CXX_DEF) $(CC_CXX_OPT) $(INCLUDES) -c $< -o $@
|
||||
|
||||
%.o: %.s
|
||||
$(MSG_ASSEM)$@
|
||||
$(VERBOSE)$(AS) $(AS_OPT) $(INCLUDES) $< -o $@
|
||||
|
||||
#
|
||||
# Compiling Ada source codes
|
||||
#
|
||||
%.o: %.adb
|
||||
$(MSG_COMP)$@
|
||||
$(VERBOSE)gnatmake -q -c $(CC_ADA_OPT) $(INCLUDES) $<
|
||||
|
||||
#
|
||||
# Assembler files that must be preprocessed are fed to the C compiler.
|
||||
#
|
||||
%.o: %.S
|
||||
$(MSG_COMP)$@
|
||||
$(VERBOSE)$(CC) $(CC_DEF) $(CC_OPT) -D__ASSEMBLY__ $(INCLUDES) -c $< -o $@
|
||||
|
||||
#
|
||||
# Link binary data
|
||||
#
|
||||
# We transform binary data into an object file by using the 'incbin' directive
|
||||
# of the GNU assembler. This enables us to choose a any label for the binary
|
||||
# data (in contrast to 'ld -r -oformat default -b binary', which generates the
|
||||
# label from the input path name) and to align the binary data as required on
|
||||
# some architectures (e.g., ARM).
|
||||
#
|
||||
symbol_name = _binary_$(subst -,_,$(subst .,_,$(subst binary_,,$(subst .o,,$(notdir $@)))))
|
||||
|
||||
binary_%.o: %
|
||||
$(MSG_CONVERT)$@
|
||||
$(VERBOSE)echo ".global $(symbol_name)_start, $(symbol_name)_end; .data; .align 4; $(symbol_name)_start:; .incbin \"$<\"; $(symbol_name)_end:" |\
|
||||
$(AS) $(AS_OPT) -f -o $@ -
|
||||
175
base/mk/global.mk
Normal file
175
base/mk/global.mk
Normal file
@@ -0,0 +1,175 @@
|
||||
#
|
||||
# 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
|
||||
#
|
||||
CUSTOM_CC ?= $(CROSS_DEV_PREFIX)gcc
|
||||
CUSTOM_CXX ?= $(CROSS_DEV_PREFIX)g++
|
||||
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
|
||||
|
||||
#
|
||||
# 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
|
||||
#
|
||||
CC = $(CUSTOM_CC)
|
||||
CXX = $(CUSTOM_CXX)
|
||||
LD = $(CUSTOM_LD)
|
||||
AS = $(CUSTOM_AS)
|
||||
AR = $(CUSTOM_AR)
|
||||
NM = $(CUSTOM_NM)
|
||||
OBJCOPY = $(CUSTOM_OBJCOPY)
|
||||
|
||||
#
|
||||
# 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
|
||||
|
||||
#
|
||||
# Default optimization and warning levels
|
||||
#
|
||||
CC_OLEVEL ?= -O2
|
||||
CC_WARN ?= -Wall
|
||||
|
||||
#
|
||||
# Aggregate compiler options that are common for C and C++
|
||||
#
|
||||
CC_OPT += $(CC_OPT_NOSTDINC) -g $(CC_MARCH) $(CC_OLEVEL) $(CC_OPT_DEP) $(CC_WARN) $(CC_OPT_CHECKCC)
|
||||
|
||||
#
|
||||
# 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 .,_,$*))
|
||||
|
||||
#
|
||||
# Predefine C and C++ specific compiler options with their common values
|
||||
#
|
||||
CC_CXX_OPT += $(CC_OPT)
|
||||
CC_C_OPT += $(CC_OPT)
|
||||
CC_ADA_OPT += $(CC_OLEVEL) $(CC_WARN)
|
||||
|
||||
#
|
||||
# Linker options
|
||||
#
|
||||
# Use '-gc-sections' by default but allow a platform to disable this feature by
|
||||
# defining 'LD_GC_SECTIONS' empty. This is needed for the microblaze tool chain
|
||||
# (gcc version 4.11 and binutils version 2.16), which happens to produce broken
|
||||
# code when '-gc-sections' is enabled.
|
||||
#
|
||||
LD_OPT_GC_SECTIONS ?= -gc-sections
|
||||
LD_OPT_PREFIX := -Wl,
|
||||
LD_OPT += $(LD_MARCH) $(LD_OPT_GC_SECTIONS)
|
||||
CXX_LINK_OPT += $(addprefix $(LD_OPT_PREFIX),$(LD_OPT))
|
||||
CXX_LINK_OPT += $(LD_OPT_NOSTDLIB)
|
||||
|
||||
#
|
||||
# Linker script for dynamically linked programs
|
||||
#
|
||||
LD_SCRIPT_DYN = $(call select_from_repositories,src/platform/genode_dyn.ld)
|
||||
|
||||
#
|
||||
# Linker script for shared libraries
|
||||
#
|
||||
LD_SCRIPT_SO = $(call select_from_repositories,src/platform/genode_rel.ld)
|
||||
|
||||
#
|
||||
# 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)
|
||||
|
||||
INSTALL_DIR ?=
|
||||
|
||||
VERBOSE ?= @
|
||||
VERBOSE_DIR ?= --no-print-directory
|
||||
|
||||
MSG_LINK = @$(ECHO) " LINK "
|
||||
MSG_COMP = @$(ECHO) " COMPILE "
|
||||
MSG_BUILD = @$(ECHO) " BUILD "
|
||||
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)"
|
||||
|
||||
178
base/mk/lib.mk
Normal file
178
base/mk/lib.mk
Normal file
@@ -0,0 +1,178 @@
|
||||
##
|
||||
## Rules for building a library target
|
||||
##
|
||||
## The following variables must be passed when calling this file:
|
||||
##
|
||||
## BASE_DIR - base directory of the build system
|
||||
## REPOSITORIES - repositories providing libs and headers
|
||||
## VERBOSE - build verboseness modifier
|
||||
## VERBOSE_DIR - verboseness modifier for changing directories
|
||||
## VERBOSE_MK - verboseness of make calls
|
||||
## BUILD_BASE_DIR - base of build directory tree
|
||||
## LIB_CACHE_DIR - library build cache location
|
||||
## INSTALL_DIR - program target build directory
|
||||
## DEPS - library dependencies
|
||||
## REP_DIR - repository where the library resides
|
||||
##
|
||||
|
||||
#
|
||||
# Prevent <libname>.mk rules to be executed as default rule
|
||||
#
|
||||
all:
|
||||
|
||||
#
|
||||
# Function that searches for files in all
|
||||
# repositories and returns the first match.
|
||||
#
|
||||
select_from_repositories = $(firstword $(foreach REP,$(REPOSITORIES),$(wildcard $(REP)/$(1))))
|
||||
|
||||
#
|
||||
# Include specifics, for example platform, kernel-api etc.
|
||||
#
|
||||
include $(SPEC_FILES)
|
||||
|
||||
#
|
||||
# Include library build instructions
|
||||
#
|
||||
# We set the 'called_from_lib_mk' variable to allow the library decription file
|
||||
# to respond to the build pass.
|
||||
#
|
||||
BACKUP_INC_DIR := $(INC_DIR)
|
||||
called_from_lib_mk = yes
|
||||
include $(LIB_MK)
|
||||
|
||||
#
|
||||
# Sanity check for INC_DIR overrides
|
||||
#
|
||||
ifneq ($(filter-out $(INC_DIR),$(BACKUP_INC_DIR)),)
|
||||
all: error_inc_dir_override
|
||||
endif
|
||||
|
||||
error_inc_dir_override:
|
||||
@$(ECHO) "Error: $(LIB_MK) overrides INC_DIR instead of appending" ; false
|
||||
|
||||
#
|
||||
# Include lib-import descriptions of all used libraries and the target library
|
||||
#
|
||||
include $(foreach LIB,$(LIBS),$(call select_from_repositories,lib/import/import-$(LIB).mk))
|
||||
|
||||
#
|
||||
# Include global definitions
|
||||
#
|
||||
include $(BASE_DIR)/mk/global.mk
|
||||
|
||||
#
|
||||
# Name of <libname>.lib.a or <libname>.lib.so file to create
|
||||
#
|
||||
ifndef SHARED_LIB
|
||||
LIB_A := $(addsuffix .lib.a,$(LIB))
|
||||
LIB_FILENAME := $(LIB_A)
|
||||
else
|
||||
LIB_SO := $(addsuffix .lib.so,$(LIB))
|
||||
INSTALL_SO := $(INSTALL_DIR)/$(LIB_SO)
|
||||
LIB_FILENAME := $(LIB_SO)
|
||||
endif
|
||||
LIB_TAG := $(addsuffix .lib.tag,$(LIB))
|
||||
|
||||
#
|
||||
# Link libgcc to shared libraries
|
||||
#
|
||||
# For static libraries, libgcc is not needed because it will be linked
|
||||
# against the final target.
|
||||
#
|
||||
ifdef SHARED_LIB
|
||||
LIBGCC = $(shell $(CC) $(CC_MARCH) -print-libgcc-file-name)
|
||||
endif
|
||||
|
||||
#
|
||||
# Build libraries position-independent
|
||||
#
|
||||
# This option is required for building shared objects but also for static
|
||||
# libraries that are (potentially) linked against shared objects. Hence,
|
||||
# we build all libraries with '-fPIC'.
|
||||
#
|
||||
CC_OPT_PIC ?= -fPIC
|
||||
CC_OPT += $(CC_OPT_PIC)
|
||||
|
||||
#
|
||||
# Print message for the currently built library
|
||||
#
|
||||
all: message
|
||||
|
||||
message:
|
||||
$(MSG_LIB)$(LIB)
|
||||
|
||||
#
|
||||
# Trigger the creation of the <libname>.lib.a or <libname>.lib.so file
|
||||
#
|
||||
all: $(LIB_TAG)
|
||||
|
||||
$(LIB_TAG): $(LIB_A) $(LIB_SO) $(INSTALL_SO)
|
||||
@touch $@
|
||||
|
||||
include $(BASE_DIR)/mk/generic.mk
|
||||
|
||||
#
|
||||
# Rule to build the <libname>.lib.a file
|
||||
#
|
||||
# Use $(OBJECTS) instead of $^ for specifying the list of objects to include
|
||||
# in the archive because $^ may also contain non-object phony targets, e.g.,
|
||||
# used by the integration of Qt4's meta-object compiler into the Genode
|
||||
# build system.
|
||||
#
|
||||
$(LIB_A): $(OBJECTS)
|
||||
$(MSG_MERGE)$(LIB_A)
|
||||
$(VERBOSE)$(AR) -rc $@ $(OBJECTS)
|
||||
|
||||
#
|
||||
# The 'sort' is needed to ensure the same link order regardless
|
||||
# of the find order, which uses to vary among different systems.
|
||||
#
|
||||
STATIC_LIBS := $(foreach l,$(DEPS:.lib=),$(LIB_CACHE_DIR)/$l/$l.lib.a)
|
||||
STATIC_LIBS := $(sort $(wildcard $(STATIC_LIBS)))
|
||||
STATIC_LIBS_BRIEF := $(subst $(LIB_CACHE_DIR),$$libs,$(STATIC_LIBS))
|
||||
|
||||
#
|
||||
# Rule to build the <libname>.lib.so file
|
||||
#
|
||||
# The 'LIBS' variable may contain static and shared sub libraries. When linking
|
||||
# the shared library, we have to link all shared sub libraries to the library
|
||||
# to store the library-dependency information in the library. Because we do not
|
||||
# know which sub libraries are static or shared prior calling 'build_libs.mk',
|
||||
# we use an explicit call to the 'lib_so_wildcard' macro to determine the subset
|
||||
# of libraries that are shared.
|
||||
#
|
||||
# The 'ldso-startup/startup.o' object file, which contains the support code for
|
||||
# constructing static objects must be specified as object file to prevent the
|
||||
# linker from garbage-collecting it.
|
||||
#
|
||||
|
||||
USED_SHARED_LIBS := $(filter $(DEPS:.lib=),$(SHARED_LIBS))
|
||||
USED_SO_FILES := $(foreach s,$(USED_SHARED_LIBS),$(LIB_CACHE_DIR)/$s/$s.lib.so)
|
||||
|
||||
#
|
||||
# Don't link ld libary against shared objects
|
||||
#
|
||||
USED_SO_FILES := $(filter-out %ld.lib.so,$(USED_SO_FILES))
|
||||
|
||||
#
|
||||
# Default entry point of shared libraries
|
||||
#
|
||||
ENTRY_POINT ?= 0x0
|
||||
|
||||
$(LIB_SO): $(STATIC_LIBS) $(OBJECTS) $(wildcard $(LD_SCRIPT_SO))
|
||||
$(MSG_MERGE)$(LIB_SO)
|
||||
$(VERBOSE)libs=$(LIB_CACHE_DIR); $(LD) -o $(LIB_SO) -shared --eh-frame-hdr \
|
||||
$(LD_OPT) \
|
||||
-T $(LD_SCRIPT_SO) \
|
||||
--entry=$(ENTRY_POINT) \
|
||||
--whole-archive \
|
||||
--start-group \
|
||||
$(USED_SO_FILES) $(STATIC_LIBS_BRIEF) $(OBJECTS) \
|
||||
--end-group \
|
||||
--no-whole-archive \
|
||||
$(LIBGCC)
|
||||
|
||||
$(INSTALL_SO):
|
||||
$(VERBOSE)ln -sf `pwd`/$(LIB_SO) $@
|
||||
|
||||
183
base/mk/prg.mk
Normal file
183
base/mk/prg.mk
Normal file
@@ -0,0 +1,183 @@
|
||||
##
|
||||
## Rules for building a program target
|
||||
##
|
||||
## The following variables must be passed when calling this file:
|
||||
##
|
||||
## BASE_DIR - base directory of the build system
|
||||
## REP_DIR - source repository of the program
|
||||
## PRG_REL_DIR - directory of the program relative to 'src/'
|
||||
## REPOSITORIES - repositories providing libs and headers
|
||||
## INSTALL_DIR - final install location
|
||||
## VERBOSE - build verboseness modifier
|
||||
## VERBOSE_DIR - verboseness modifier for changing directories
|
||||
## VERBOSE_MK - verboseness of make calls
|
||||
## LIB_CACHE_DIR - library build cache location
|
||||
##
|
||||
|
||||
#
|
||||
# Prevent target.mk rules to be executed as default rule
|
||||
#
|
||||
all:
|
||||
|
||||
#
|
||||
# Function that searches for files in all repositories and returns the first match
|
||||
#
|
||||
select_from_repositories = $(firstword $(foreach REP,$(REPOSITORIES),$(wildcard $(REP)/$(1))))
|
||||
|
||||
#
|
||||
# Include target build instructions
|
||||
#
|
||||
PRG_DIR := $(REP_DIR)/src/$(PRG_REL_DIR)
|
||||
include $(PRG_DIR)/target.mk
|
||||
|
||||
#
|
||||
# Include lib-import description files
|
||||
#
|
||||
include $(foreach LIB,$(LIBS),$(call select_from_repositories,lib/import/import-$(LIB).mk))
|
||||
|
||||
#
|
||||
# Include specifics for platforms, kernel APIs, etc.
|
||||
#
|
||||
include $(SPEC_FILES)
|
||||
|
||||
vpath % $(PRG_DIR)
|
||||
|
||||
include $(BASE_DIR)/mk/global.mk
|
||||
|
||||
#
|
||||
# Assemble linker options for static and dynamic linkage
|
||||
#
|
||||
ifneq ($(LD_TEXT_ADDR),)
|
||||
CXX_LINK_OPT += -Wl,-Ttext=$(LD_TEXT_ADDR)
|
||||
endif
|
||||
|
||||
#
|
||||
# Supply machine-dependent arguments to the linker
|
||||
#
|
||||
CXX_LINK_OPT += $(CC_MARCH)
|
||||
|
||||
#
|
||||
# Generic linker script for statically linked binaries
|
||||
#
|
||||
LD_SCRIPT_STATIC ?= $(call select_from_repositories,src/platform/genode.ld)
|
||||
|
||||
include $(BASE_DIR)/mk/generic.mk
|
||||
include $(BASE_DIR)/mk/base-libs.mk
|
||||
|
||||
ifeq ($(INSTALL_DIR),)
|
||||
all: message $(TARGET)
|
||||
else
|
||||
all: message $(INSTALL_DIR)/$(TARGET)
|
||||
endif
|
||||
@true # prevent nothing-to-be-done message
|
||||
|
||||
.PHONY: message
|
||||
message:
|
||||
$(MSG_PRG)$(PRG_REL_DIR)/$(TARGET)
|
||||
|
||||
#
|
||||
# Enforce unconditional call of gnatmake rule when compiling Ada sources
|
||||
#
|
||||
# Citation from texinfo manual for make:
|
||||
#
|
||||
# If a rule has no prerequisites or commands, and the target of the rule
|
||||
# is a nonexistent file, then `make' imagines this target to have been
|
||||
# updated whenever its rule is run. This implies that all targets
|
||||
# depending on this one will always have their commands run.
|
||||
#
|
||||
FORCE:
|
||||
$(SRC_ADA:.adb=.o): FORCE
|
||||
|
||||
#
|
||||
# The 'sort' is needed to ensure the same link order regardless
|
||||
# of the find order, which uses to vary among different systems.
|
||||
#
|
||||
SHARED_LIBS := $(foreach l,$(DEPS:.lib=),$(LIB_CACHE_DIR)/$l/$l.lib.so)
|
||||
SHARED_LIBS := $(sort $(wildcard $(SHARED_LIBS)))
|
||||
|
||||
#
|
||||
# Use CXX for linking
|
||||
#
|
||||
LD_CMD := $(CXX) $(CXX_LINK_OPT)
|
||||
|
||||
ifeq ($(SHARED_LIBS),)
|
||||
LD_SCRIPTS := $(LD_SCRIPT_STATIC)
|
||||
FILTER_DEPS := $(DEPS:.lib=)
|
||||
else
|
||||
LD_SCRIPTS := $(LD_SCRIPT_DYN)
|
||||
LD_CMD += -Wl,--dynamic-linker=$(DYNAMIC_LINKER).lib.so \
|
||||
-Wl,--eh-frame-hdr
|
||||
|
||||
#
|
||||
# Filter out the base libraries since they will be provided by the ldso.library
|
||||
#
|
||||
FILTER_DEPS := $(filter-out $(BASE_LIBS),$(DEPS:.lib=))
|
||||
SHARED_LIBS += $(LIB_CACHE_DIR)/$(DYNAMIC_LINKER)/$(DYNAMIC_LINKER).lib.so
|
||||
endif
|
||||
|
||||
#
|
||||
# LD_SCRIPT_PREFIX is needed as 'addprefix' chokes on prefixes containing
|
||||
# commas othwerwise. For compatibilty with older tool chains, we use two -Wl
|
||||
# parameters for both components of the linker command line.
|
||||
#
|
||||
LD_SCRIPT_PREFIX = -Wl,-T -Wl,
|
||||
|
||||
#
|
||||
# LD_SCRIPTS may be a list of linker scripts (e.g., in base-linux). Further,
|
||||
# we use the default linker script if none was specified - 'addprefix' expands
|
||||
# to empty string on empty input.
|
||||
#
|
||||
LD_CMD += $(addprefix $(LD_SCRIPT_PREFIX), $(LD_SCRIPTS))
|
||||
|
||||
STATIC_LIBS := $(foreach l,$(FILTER_DEPS),$(LIB_CACHE_DIR)/$l/$l.lib.a)
|
||||
STATIC_LIBS := $(sort $(wildcard $(STATIC_LIBS)))
|
||||
|
||||
#
|
||||
# We need the linker option '--whole-archive' to make sure that all library
|
||||
# constructors marked with '__attribute__((constructor))' end up int the
|
||||
# binary. When not using this option, the linker goes through all libraries
|
||||
# to resolve a symbol and, if it finds the symbol, stops searching. This way,
|
||||
# object files that are never explicitly referenced (such as library
|
||||
# constructors) would not be visited at all.
|
||||
#
|
||||
# Furthermore, the '--whole-archive' option reveals symbol ambiguities, which
|
||||
# would go undetected if the search stops after the first match.
|
||||
#
|
||||
LINK_ITEMS := $(OBJECTS) $(STATIC_LIBS) $(SHARED_LIBS)
|
||||
SHORT_LINK_ITEMS := $(subst $(LIB_CACHE_DIR),$$libs,$(LINK_ITEMS))
|
||||
|
||||
LD_CMD += -Wl,--whole-archive -Wl,--start-group
|
||||
LD_CMD += $(SHORT_LINK_ITEMS)
|
||||
LD_CMD += -Wl,--end-group -Wl,--no-whole-archive
|
||||
LD_CMD += $(EXT_OBJECTS)
|
||||
|
||||
#
|
||||
# Link libgcc to each program
|
||||
#
|
||||
LD_LIBGCC ?= $(shell $(CC) $(CC_MARCH) -print-libgcc-file-name)
|
||||
LD_CMD += $(LD_LIBGCC)
|
||||
|
||||
#
|
||||
# Skip final linking if no objects are involved, i.e. no 'SRC' files are
|
||||
# specified in the 'target.mk' file. This applies for pseudo 'target.mk'
|
||||
# files that invoke a 3rd-party build system by providing local rule for
|
||||
# $(TARGET).
|
||||
#
|
||||
ifneq ($(OBJECTS),)
|
||||
$(TARGET): $(LINK_ITEMS) $(wildcard $(LD_SCRIPTS))
|
||||
$(MSG_LINK)$(TARGET)
|
||||
$(VERBOSE)libs=$(LIB_CACHE_DIR); $(LD_CMD) -o $@
|
||||
|
||||
$(INSTALL_DIR)/$(TARGET): $(TARGET)
|
||||
$(VERBOSE)ln -sf `pwd`/$(TARGET) $@
|
||||
else
|
||||
$(TARGET):
|
||||
$(INSTALL_DIR)/$(TARGET): $(TARGET)
|
||||
endif
|
||||
|
||||
clean_prg_objects:
|
||||
$(MSG_CLEAN)$(PRG_REL_DIR)
|
||||
$(VERBOSE)$(RM) -f $(OBJECTS) $(OBJECTS:.o=.d) $(TARGET)
|
||||
$(VERBOSE)$(RM) -f *.d *.i *.ii *.s *.ali
|
||||
|
||||
clean: clean_prg_objects
|
||||
4
base/mk/spec-32bit.mk
Normal file
4
base/mk/spec-32bit.mk
Normal file
@@ -0,0 +1,4 @@
|
||||
#
|
||||
# 32-bit-specific Genode headers
|
||||
#
|
||||
REP_INC_DIR += include/32bit
|
||||
4
base/mk/spec-64bit.mk
Normal file
4
base/mk/spec-64bit.mk
Normal file
@@ -0,0 +1,4 @@
|
||||
#
|
||||
# 64-bit-specific Genode headers
|
||||
#
|
||||
REP_INC_DIR += include/64bit
|
||||
14
base/mk/spec-arm.mk
Normal file
14
base/mk/spec-arm.mk
Normal file
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# ARM-specific Genode headers
|
||||
#
|
||||
REP_INC_DIR += include/arm
|
||||
|
||||
SPECS += 32bit
|
||||
|
||||
#
|
||||
# Prevent compiler message
|
||||
# "note: the mangling of 'va_list' has changed in GCC 4.4"
|
||||
#
|
||||
CC_OPT += -Wno-psabi
|
||||
|
||||
include $(call select_from_repositories,mk/spec-32bit.mk)
|
||||
8
base/mk/spec-arm_v5.mk
Normal file
8
base/mk/spec-arm_v5.mk
Normal file
@@ -0,0 +1,8 @@
|
||||
SPECS += arm
|
||||
|
||||
#
|
||||
# Configure target CPU
|
||||
#
|
||||
CC_OPT += -march=armv5
|
||||
|
||||
include $(call select_from_repositories,mk/spec-arm.mk)
|
||||
8
base/mk/spec-arm_v7a.mk
Normal file
8
base/mk/spec-arm_v7a.mk
Normal file
@@ -0,0 +1,8 @@
|
||||
SPECS += arm
|
||||
|
||||
#
|
||||
# Configure target CPU
|
||||
#
|
||||
CC_OPT += -march=armv7-a
|
||||
|
||||
include $(call select_from_repositories,mk/spec-arm.mk)
|
||||
1
base/mk/spec-experimental.mk
Normal file
1
base/mk/spec-experimental.mk
Normal file
@@ -0,0 +1 @@
|
||||
CC_OPT += -DEXPERIMENTAL
|
||||
8
base/mk/spec-host.mk
Normal file
8
base/mk/spec-host.mk
Normal file
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# When building for the host, we use the host's standard C environment
|
||||
#
|
||||
STDINC = yes
|
||||
STDLIB = yes
|
||||
LD_SCRIPT_STATIC =
|
||||
|
||||
REP_INC_DIR = include
|
||||
16
base/mk/spec-platform_pbxa9.mk
Normal file
16
base/mk/spec-platform_pbxa9.mk
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# Enable peripherals of the platform
|
||||
#
|
||||
SPECS += pl050 pl11x ps2 pl180 lan9118 pl011
|
||||
|
||||
#
|
||||
# Pull in CPU specifics
|
||||
#
|
||||
SPECS += arm_v7a
|
||||
|
||||
#
|
||||
# Add device parameters to include search path
|
||||
#
|
||||
REP_INC_DIR += include/platform/pbxa9
|
||||
|
||||
include $(call select_from_repositories,mk/spec-arm_v7a.mk)
|
||||
16
base/mk/spec-platform_vea9x4.mk
Normal file
16
base/mk/spec-platform_vea9x4.mk
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# Enable peripherals of the platform
|
||||
#
|
||||
SPECS += pl050 pl11x ps2 pl180 lan9118 pl011
|
||||
|
||||
#
|
||||
# Pull in CPU specifics
|
||||
#
|
||||
SPECS += arm_v7a
|
||||
|
||||
#
|
||||
# Add device parameters to include search path
|
||||
#
|
||||
REP_INC_DIR += include/platform/vea9x4
|
||||
|
||||
include $(call select_from_repositories,mk/spec-arm_v7a.mk)
|
||||
18
base/mk/spec-platform_vpb926.mk
Normal file
18
base/mk/spec-platform_vpb926.mk
Normal file
@@ -0,0 +1,18 @@
|
||||
REP_INC_DIR += include/platform/vpb926
|
||||
|
||||
#
|
||||
# Enable peripherals of the platform
|
||||
#
|
||||
SPECS += pl050 pl11x pl011 ps2
|
||||
|
||||
#
|
||||
# Pull in CPU specifics
|
||||
#
|
||||
SPECS += arm_v5
|
||||
|
||||
#
|
||||
# Add device parameters to include search path
|
||||
#
|
||||
REP_INC_DIR += include/platform/vpb926
|
||||
|
||||
include $(call select_from_repositories,mk/spec-arm_v5.mk)
|
||||
1
base/mk/spec-release.mk
Normal file
1
base/mk/spec-release.mk
Normal file
@@ -0,0 +1 @@
|
||||
CC_OPT += -DGENODE_RELEASE
|
||||
19
base/mk/spec-x86_32.mk
Normal file
19
base/mk/spec-x86_32.mk
Normal file
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# Specifics for 32-bit x86
|
||||
#
|
||||
SPECS += x86 32bit
|
||||
|
||||
#
|
||||
# x86-specific Genode headers
|
||||
#
|
||||
REP_INC_DIR += include/x86
|
||||
REP_INC_DIR += include/x86_32
|
||||
|
||||
#
|
||||
# x86-specific flags
|
||||
#
|
||||
CC_MARCH ?= -march=i686 -m32
|
||||
LD_MARCH ?= -melf_i386
|
||||
AS_MARCH ?= -march=i686 --32
|
||||
|
||||
include $(call select_from_repositories,mk/spec-32bit.mk)
|
||||
12
base/mk/spec-x86_64.mk
Normal file
12
base/mk/spec-x86_64.mk
Normal file
@@ -0,0 +1,12 @@
|
||||
#
|
||||
# Specifics for 64-bit x86
|
||||
#
|
||||
SPECS += x86 64bit
|
||||
|
||||
#
|
||||
# x86-specific Genode headers
|
||||
#
|
||||
REP_INC_DIR += include/x86
|
||||
REP_INC_DIR += include/x86_64
|
||||
|
||||
include $(call select_from_repositories,mk/spec-64bit.mk)
|
||||
Reference in New Issue
Block a user