genode/repos/libports/lib/import/import-qt5.inc
Norman Feske 4da52517c1 Simpify startup of dynamically linked binaries
This patch removes the component_entry_point library, which used to
proved a hook for the libc to intercept the call of the
'Component::construct' function. The mechansim has several shortcomings
(see the discussion in the associated issue) and was complex. So we
eventually discarded the approach in favor of the explicit handling of
the startup.

A regular Genode component provides a 'Component::construct' function,
which is determined by the dynamic linker via a symbol lookup.
For the time being, the dynamic linker falls back to looking up a 'main'
function if no 'Component::construct' function could be found.

The libc provides an implementation of 'Component::construct', which
sets up the libc's task handling and finally call the function
'Libc::Component::construct' from the context of the appllication task.
This function is expected to be provided by the libc-using application.
Consequently, Genode components that use the libc have to implement the
'Libc::Component::construct' function.

The new 'posix' library provides an implementation of
'Libc::Component::construct' that calls a main function. Hence, POSIX
programs that merely use the POSIX API merely have to add 'posix' to the
'LIBS' declaration in their 'target.mk' file. Their execution starts at
'main'.

Issue #2199
2017-01-13 13:06:52 +01:00

130 lines
3.9 KiB
PHP

# prevent import file to be included twice, for example via import-qt5_gui.mk
# and import-qt5_core.mk
ifeq ($(QT5_IMPORTED),)
QT5_IMPORTED = true
# hook for selectively skipping qt5 builds by the buildbot
ifneq ($(INHIBIT_QT5),)
REQUIRES += removal_of_INHIBIT_QT5_env_var
endif
# identify the qt5 repository by searching for a file that is unique for qt5
QT5_REP_DIR := $(call select_from_repositories,lib/import/import-qt5.inc)
QT5_REP_DIR := $(realpath $(dir $(QT5_REP_DIR))../..)
include $(QT5_REP_DIR)/lib/mk/qt5_version.inc
QT5_PORT_DIR := $(call select_from_ports,qt5)
QT5_CONTRIB_DIR := $(QT5_PORT_DIR)/src/lib/qt5/$(QT5)
QT5_INC_DIR := $(QT5_REP_DIR)/src/lib/qt5/qtbase/src/corelib/global \
$(QT5_CONTRIB_DIR)/qtbase/src/corelib/global \
$(QT5_REP_DIR)/include/qt5 \
$(QT5_REP_DIR)/include/qt5/qtbase \
$(QT5_CONTRIB_DIR)/qtbase/include \
$(QT5_CONTRIB_DIR)/qtbase/mkspecs/genode-g++ \
INC_DIR += $(QT5_INC_DIR)
# extracted from qt.prf
QT_DEFINES += -DQT_STATICPLUGIN
QT_DEFINES += -D__GENODE__
#
# Prevent inclusion of non-existent 'features.h' from 'bits/os_defines.h'
# header that comes with the Codesourcery ARM tool chain.
#
QT_DEFINES += -D_GLIBCXX_OS_DEFINES
#
# When using the Codesourcery tool chain for ARM, the compiler provides a
# built-in definition for '__linux__', which is obviously wrong when using the
# compiler for Genode. Unfortunately, Webkit tests for this definition in
# 'JavaScriptCore/wtf/Platform.h'. To prevent webkit from drawing wrong
# conclusions, we explicitly undefine '__linux__'.
#
QT_DEFINES += -U__linux__
CC_OPT += $(QT_DEFINES)
SOURCES_FILTERED = $(filter-out $(SOURCES_FILTER_OUT), $(SOURCES))
HEADERS_FILTERED = $(filter-out $(HEADERS_FILTER_OUT), $(HEADERS))
# add sources defined in qmake project files
SRC_CC += $(SOURCES_FILTERED)
# handle moc-headers, resources and ui descriptions
$(addsuffix .o,$(basename $(SRC_CC))): $(addprefix ui_,$(FORMS:.ui=.h))
SRC_CC_QT_GENERATED = $(addprefix moc_,$(HEADERS_FILTERED:.h=.cpp)) \
$(addprefix qrc_,$(RESOURCES:.qrc=.cpp))
.SECONDARY: $(SRC_CC_QT_GENERATED)
SRC_CC += $(SRC_CC_QT_GENERATED)
#
# Locations of moc, rcc, and uic binaries
#
MOC = $(BUILD_BASE_DIR)/tool/qt5/moc/moc
RCC = $(BUILD_BASE_DIR)/tool/qt5/rcc/rcc
UIC = $(BUILD_BASE_DIR)/tool/qt5/uic/uic
# moc rules
moc_%.cpp: %.h $(MOC)
$(MSG_CONVERT)$@
$(VERBOSE) $(MOC) $(QT_DEFINES) $(addprefix -I,$(QT5_INC_DIR)) $< -o $@
%.moc: %.cpp $(MOC)
$(MSG_CONVERT)$@
$(VERBOSE) $(MOC) $(QT_DEFINES) $(addprefix -I,$(QT5_INC_DIR)) $< -o $@
# rcc rule
qrc_%.cpp: %.qrc $(RCC)
$(MSG_CONVERT)$@
$(VERBOSE) $(RCC) -name $(basename $(notdir $<)) $< -o $@
# uic rule
ui_%.h: %.ui $(UIC)
$(MSG_CONVERT)$@
$(VERBOSE) $(UIC) $< -o $@
# add include dirs for QT5-specific genode addons
INC_DIR += $(QT5_REP_DIR)/include/qt5/genode
# add C++ include dirs and libs
#
# We cannot just extend the 'LIBS' variable here because 'import-*.mk' are
# included (in 'base/mk/lib.mk') by iterating through the elements of the
# 'LIBS' variable. Hence, we also need to manually import the stdlib snippet.
#
LIBS += stdcxx gallium
include $(call select_from_repositories,lib/import/import-stdcxx.mk)
include $(call select_from_repositories,lib/import/import-gallium.mk)
# custom main() thread stack size support via main() wrapper
ifeq ($(findstring -DQT_MAIN_STACK_SIZE, $(CC_CXX_OPT)), -DQT_MAIN_STACK_SIZE)
SRC_CC += qt_main.cc
vpath qt_main.cc $(QT5_REP_DIR)/src/lib/qt5
endif
# set QT_ARCH definition according to the SPECS variable
ifneq ($(filter x86_32,$(SPECS)),)
QT_DEFINES += -DQT_ARCH_I386
endif
ifneq ($(filter x86_64,$(SPECS)),)
QT_DEFINES += -DQT_ARCH_X86_64
endif
ifneq ($(filter arm,$(SPECS)),)
QT_DEFINES += -DQT_ARCH_ARMV6
endif
# remove generated files in clean rules
clean cleanall: clean_rule
clean_rule:
$(VERBOSE)$(RM) -f $(SRC_CC_QT_GENERATED)
$(VERBOSE)$(RM) -f $(SOURCES_FILTERED:.cpp=.moc)
$(VERBOSE)$(RM) -f $(addprefix ui_,$(FORMS:.ui=.h))
endif