level Qt up to version 5.7.0 + several bug fixes
[feed/video.git] / frameworks / qt5base / files / qmake.mk
1 #
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.
6 #
7
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.
10 #
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.
21 #
22 # The QT_HOST_* variables are used for host tools, libraries, mkspecs and its data.
23 #
24 # As a consequence we set QT_INSTALL_* and QT_HOST_* to absolute paths, which
25 # inevitably results in the following issues:
26 #
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
35 # errors.
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.
39
40
41 QT_EXTPREFIX:=$(STAGING_DIR)/$(CONFIGURE_PREFIX)
42 QT_SYSROOT:=
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
64
65 QMAKE_SPEC:=linux-g++
66 QMAKE_XSPEC:=linux-openwrt-g++
67
68 PKG_INSTALL_DIR_ROOT:=$(PKG_INSTALL_DIR)
69 PKG_INSTALL_DIR:=$(PKG_INSTALL_DIR_ROOT)/$(STAGING_DIR)
70
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)" \
76 qmake \
77 -o $(PKG_BUILD_DIR)/$(MAKE_PATH)/Makefile \
78 $(PKG_BUILD_DIR)/$(MAKE_PATH)/$(if $(1),$(1),$(PKG_NAME)).pro
79 endef
80
81 # we need to pass everything to $(MAKE) as well, as Makefiles may invoke qmake once again for creating further Makefiles
82 define Build/Compile/Default
83 +TARGET_CROSS="$(TARGET_CROSS)" \
84 TARGET_CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
85 TARGET_CXXFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CXXFLAGS)" \
86 TARGET_LDFLAGS="$(TARGET_LDFLAGS)" \
87 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
88 $(1)
89 endef
90
91 define Build/Install/Default
92 INSTALL_ROOT="$(PKG_INSTALL_DIR_ROOT)" \
93 $(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
94 $(1) install
95 endef
96
97 define Build/Install/HostFiles
98 $(INSTALL_DIR) \
99 $(1)/host
100
101 $(CP) \
102 $(PKG_INSTALL_DIR)/host/* \
103 $(1)/host/
104 endef
105
106 define Build/Install/Headers
107 $(INSTALL_DIR) \
108 $(1)/$(QT_INSTALL_HEADERS)
109
110 $(CP) \
111 $(PKG_INSTALL_DIR)/$(QT_INSTALL_HEADERS)/* \
112 $(1)/$(QT_INSTALL_HEADERS)/
113 endef
114
115 define Build/Install/Libs
116 $(INSTALL_DIR) \
117 $(1)/$(QT_INSTALL_LIBS)
118
119 $(CP) \
120 $(PKG_INSTALL_DIR)/$(QT_INSTALL_LIBS)/$(2).so* \
121 $(1)/$(QT_INSTALL_LIBS)/
122 endef
123
124 define Build/Install/Plugins
125 $(INSTALL_DIR) \
126 $(1)/$(QT_INSTALL_PLUGINS)/$(2)
127
128 $(CP) \
129 $(PKG_INSTALL_DIR)/$(QT_INSTALL_PLUGINS)/$(2)/$(3).so* \
130 $(1)/$(QT_INSTALL_PLUGINS)/$(2)/
131 endef
132
133 define Build/Install/Examples
134 $(INSTALL_DIR) \
135 $(1)/$(QT_INSTALL_EXAMPLES)
136
137 $(CP) \
138 $(PKG_INSTALL_DIR)/$(QT_INSTALL_EXAMPLES)/* \
139 $(1)/$(QT_INSTALL_EXAMPLES)/
140
141 $(FIND) $(1)/$(QT_INSTALL_EXAMPLES) \
142 -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.pro' -o -name '*.pri' \) | \
143 $(XARGS) $(RM) -vf
144 endef