a28594fccded118671e597e081adb3bd052e2de9
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 QMAKE_SPECFILE
:=$(QT_HOST_DATA
)/mkspecs
/$(QMAKE_XSPEC
)
70 PKG_INSTALL_DIR_ROOT
:=$(PKG_INSTALL_DIR
)
71 PKG_INSTALL_DIR
:=$(PKG_INSTALL_DIR_ROOT
)/$(STAGING_DIR
)
73 define Build
/Configure
/Default
74 TARGET_CROSS
="$(TARGET_CROSS)" \
75 TARGET_CFLAGS
="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
76 TARGET_CXXFLAGS
="$(TARGET_CPPFLAGS) $(TARGET_CXXFLAGS)" \
77 TARGET_LDFLAGS
="$(TARGET_LDFLAGS)" \
79 -spec
$(QMAKE_SPECFILE
) \
80 -o
$(PKG_BUILD_DIR
)/$(2)/Makefile \
81 $(PKG_BUILD_DIR
)/$(2)/$(if
$(1),$(1),$(PKG_NAME
)).pro
84 # we need to pass everything to $(MAKE) as well, as Makefiles may invoke qmake once again for creating further Makefiles
85 define Build
/Compile
/Default
86 +TARGET_CROSS
="$(TARGET_CROSS)" \
87 TARGET_CFLAGS
="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
88 TARGET_CXXFLAGS
="$(TARGET_CPPFLAGS) $(TARGET_CXXFLAGS)" \
89 TARGET_LDFLAGS
="$(TARGET_LDFLAGS)" \
90 $(MAKE
) $(PKG_JOBS
) -C
$(PKG_BUILD_DIR
)/$(MAKE_PATH
) \
94 define Build
/Install
/Default
95 INSTALL_ROOT
="$(PKG_INSTALL_DIR_ROOT)" \
96 $(MAKE
) -C
$(PKG_BUILD_DIR
)/$(MAKE_PATH
) \
100 define Build
/Install
/HostFiles
105 $(PKG_INSTALL_DIR
)/host
/* \
109 define Build
/Install
/Headers
111 $(1)/$(QT_INSTALL_HEADERS
)
114 $(PKG_INSTALL_DIR
)/$(QT_INSTALL_HEADERS
)/* \
115 $(1)/$(QT_INSTALL_HEADERS
)/
118 define Build
/Install
/Libs
120 $(1)/$(QT_INSTALL_LIBS
)
123 $(PKG_INSTALL_DIR
)/$(QT_INSTALL_LIBS
)/$(2).so
* \
124 $(1)/$(QT_INSTALL_LIBS
)/
127 define Build
/Install
/Plugins
129 $(1)/$(QT_INSTALL_PLUGINS
)/$(2)
132 $(PKG_INSTALL_DIR
)/$(QT_INSTALL_PLUGINS
)/$(2)/$(3).so
* \
133 $(1)/$(QT_INSTALL_PLUGINS
)/$(2)/
136 define Build
/Install
/Examples
138 $(1)/$(QT_INSTALL_EXAMPLES
)
141 $(PKG_INSTALL_DIR
)/$(QT_INSTALL_EXAMPLES
)/* \
142 $(1)/$(QT_INSTALL_EXAMPLES
)/
144 $(FIND
) $(1)/usr
/share
/qt5
/examples
/ \
145 -type f \
( -name
'*.cpp' -o
-name
'*.h' -o
-name
'*.pro' -o
-name
'*.pri' \
) | \