2 # Copyright (C) 2015 OpenWrt.org
3 # Author: Mirko Vogt <mirko@openwrt.org>
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 # qmake - oh my.. qmake is supposed to generate Makefiles suitable for cross-compiling
9 # however fails itself hard being used in a cross compiling toolchain in any sane way.
11 # There are the QT_INSTALL_* variables - which get set via Qt's configure options,
12 # containing paths which become hardcoded into the qmake binary.
13 # Those paths are supposed to refer to the target system, however are also used for
14 # include and linker paths.
15 # Hence, setting QT_INSTALL_PREFIX=/usr would result in -I/usr/include,
16 # -L/usr/lib, etc., referencing the host headers and libraries.
17 # The QT_SYSROOT variable looks most promising for distinguishing between
18 # host and target specific paths, however it fails hard and is totally undocumented.
19 # The extprefix variable tries to cover the situation, however actually just prepends
20 # its path to the QT_INSTALL_* variables - basically cosmetics.
22 # The QT_HOST_* variables are used for host tools, libraries, mkspecs and its data.
24 # As a consequence we set QT_INSTALL_* and QT_HOST_* to absolute paths, which
25 # inevitably results in the following issues:
27 # - 'make install' results in paths like:
28 # /tmp/install_root/home/cross/openwrt/staging_dir/target-*/usr.
29 # This is workarounded by overriding the PKG_INSTALL_DIR, so the Makefiles don't
30 # have to care about that.
31 # - Once compiled, qmake's location and its requirements (mkspecs, etc.) are fixed,
32 # since its absolute paths were hardcoded. No moving around of the toolchain.
33 # - Those variables might be used for target binaries for some weird reason, so
34 # paths to the host staging_dir would make it to the target, logically leading to
36 # - Paths might make it into target binaries, thus referencing non-existing
37 # objects on the target platform. Tihs behaviour wasn't observed so far, however
38 # one might use the QT_INSTALL_* variables for some weird reason during runtime.
41 QT_EXTPREFIX
:=$(STAGING_DIR
)/$(CONFIGURE_PREFIX
)
43 QT_INSTALL_CONFIGURATION
:=/etc
/qt5
44 QT_INSTALL_PREFIX
:=$(CONFIGURE_PREFIX
)
45 QT_INSTALL_LIBS
:=$(QT_INSTALL_PREFIX
)/lib
46 QT_INSTALL_DATA
:=$(QT_INSTALL_PREFIX
)/share
/qt5
47 QT_INSTALL_HEADERS
:=$(QT_INSTALL_PREFIX
)/include
48 QT_INSTALL_BINS
:=$(QT_INSTALL_PREFIX
)/bin
49 QT_INSTALL_DOCS
:=$(QT_INSTALL_DATA
)/doc
50 QT_INSTALL_TRANSLATIONS
:=$(QT_INSTALL_DATA
)/translations
51 QT_INSTALL_ARCHDATA
:=$(QT_INSTALL_LIBS
)/qt5
52 QT_INSTALL_LIBEXECS
:=$(QT_INSTALL_ARCHDATA
)
53 QT_INSTALL_TESTS
:=$(QT_INSTALL_ARCHDATA
)/tests
54 QT_INSTALL_PLUGINS
:=$(QT_INSTALL_ARCHDATA
)/plugins
55 QT_INSTALL_IMPORTS
:=$(QT_INSTALL_ARCHDATA
)/imports
56 QT_INSTALL_QML
:=$(QT_INSTALL_ARCHDATA
)/qml
57 QT_INSTALL_EXAMPLES
:=$(QT_INSTALL_ARCHDATA
)/examples
58 QT_INSTALL_DEMOS
:=$(QT_INSTALL_EXAMPLES
)
59 QT_HOST_EXTPREFIX
:=$(STAGING_DIR
)/host
60 QT_HOST_PREFIX
:=$(QT_HOST_EXTPREFIX
)
61 QT_HOST_DATA
:=$(QT_HOST_PREFIX
)/share
62 QT_HOST_BINS
:=$(QT_HOST_PREFIX
)/bin
63 QT_HOST_LIBS
:=$(QT_HOST_PREFIX
)/lib
66 QMAKE_XSPEC
:=linux-openwrt-g
++
68 PKG_INSTALL_DIR_ROOT
:=$(PKG_INSTALL_DIR
)
69 PKG_INSTALL_DIR
:=$(PKG_INSTALL_DIR_ROOT
)/$(STAGING_DIR
)
71 define Build
/Configure
/Default
72 TARGET_CROSS
="$(TARGET_CROSS)" \
73 TARGET_CFLAGS
="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
74 TARGET_CXXFLAGS
="$(TARGET_CPPFLAGS) $(TARGET_CXXFLAGS)" \
75 TARGET_LDFLAGS
="$(TARGET_LDFLAGS)" \
77 -o
$(PKG_BUILD_DIR
)/$(MAKE_PATH
)/Makefile \
78 $(PKG_BUILD_DIR
)/$(MAKE_PATH
)/$(if
$(1),$(1).pro
,)
81 # We need to pass all qmake related variables to $(MAKE) as well, as (generated) Makefiles may invoke qmake once again for creating further Makefiles.
82 # Actually we'd also like to pass $MAKE_VARS and $MAKE_FLAGS to also make ordinary non-qmake generated Makefiles calling toolchain executables
83 # like $CC/$CXX/.. work, however this would interfere with qmake generated Makefiles, since they expect variables being set differently.
84 # For example qmake generated Makefiles expect $AR to also contain ar's arguments, while ordinary Makefiles don't.
85 # Until we find a way to disginguish both kinds of Makefiles, we will neglect ordinary Makefiles calling toolchain executables.
86 # Mixing qmake generated and ordinary Makfiles - both calling toolchain executables - is probably a very rare case anyway.
87 define Build
/Compile
/Default
88 +TARGET_CROSS
="$(TARGET_CROSS)" \
89 TARGET_CFLAGS
="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
90 TARGET_CXXFLAGS
="$(TARGET_CPPFLAGS) $(TARGET_CXXFLAGS)" \
91 TARGET_LDFLAGS
="$(TARGET_LDFLAGS)" \
92 $(MAKE
) $(PKG_JOBS
) -C
$(PKG_BUILD_DIR
)/$(MAKE_PATH
) \
96 define Build
/Install
/Default
97 INSTALL_ROOT
="$(PKG_INSTALL_DIR_ROOT)" \
98 $(MAKE
) -C
$(PKG_BUILD_DIR
)/$(MAKE_PATH
) \
102 define Build
/Install
/HostFiles
107 $(PKG_INSTALL_DIR
)/host
/* \
111 define Build
/Install
/Headers
113 $(1)/$(QT_INSTALL_HEADERS
)
116 $(PKG_INSTALL_DIR
)/$(QT_INSTALL_HEADERS
)/* \
117 $(1)/$(QT_INSTALL_HEADERS
)/
120 define Build
/Install
/Libs
122 $(1)/$(QT_INSTALL_LIBS
)
125 $(PKG_INSTALL_DIR
)/$(QT_INSTALL_LIBS
)/$(2).so
* \
126 $(1)/$(QT_INSTALL_LIBS
)/
129 define Build
/Install
/Plugins
131 $(1)/$(QT_INSTALL_PLUGINS
)/$(2)
134 $(PKG_INSTALL_DIR
)/$(QT_INSTALL_PLUGINS
)/$(2)/$(3).so
* \
135 $(1)/$(QT_INSTALL_PLUGINS
)/$(2)/
138 define Build
/Install
/Examples
140 $(1)/$(QT_INSTALL_EXAMPLES
)
143 $(PKG_INSTALL_DIR
)/$(QT_INSTALL_EXAMPLES
)/* \
144 $(1)/$(QT_INSTALL_EXAMPLES
)/
146 $(FIND
) $(1)/$(QT_INSTALL_EXAMPLES
) \
147 -type f \
( -name
'*.cpp' -o
-name
'*.h' -o
-name
'*.pro' -o
-name
'*.pri' \
) | \