Adding Qt5 base
[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 QMAKE_SPECFILE:=$(QT_HOST_DATA)/mkspecs/$(QMAKE_XSPEC)
69
70 PKG_INSTALL_DIR_ROOT:=$(PKG_INSTALL_DIR)
71 PKG_INSTALL_DIR:=$(PKG_INSTALL_DIR_ROOT)/$(STAGING_DIR)
72
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)" \
78 qmake \
79 -spec $(QMAKE_SPECFILE) \
80 -o $(PKG_BUILD_DIR)/$(2)/Makefile \
81 $(PKG_BUILD_DIR)/$(2)/$(if $(1),$(1),$(PKG_NAME)).pro
82 endef
83
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) \
91 $(1)
92 endef
93
94 define Build/Install/Default
95 INSTALL_ROOT="$(PKG_INSTALL_DIR_ROOT)" \
96 $(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
97 $(1) install
98 endef
99
100 define Build/Install/HostFiles
101 $(INSTALL_DIR) \
102 $(1)/host
103
104 $(CP) \
105 $(PKG_INSTALL_DIR)/host/* \
106 $(1)/host/
107 endef
108
109 define Build/Install/Headers
110 $(INSTALL_DIR) \
111 $(1)/$(QT_INSTALL_HEADERS)
112
113 $(CP) \
114 $(PKG_INSTALL_DIR)/$(QT_INSTALL_HEADERS)/* \
115 $(1)/$(QT_INSTALL_HEADERS)/
116 endef
117
118 define Build/Install/Libs
119 $(INSTALL_DIR) \
120 $(1)/$(QT_INSTALL_LIBS)
121
122 $(CP) \
123 $(PKG_INSTALL_DIR)/$(QT_INSTALL_LIBS)/$(2).so* \
124 $(1)/$(QT_INSTALL_LIBS)/
125 endef
126
127 define Build/Install/Plugins
128 $(INSTALL_DIR) \
129 $(1)/$(QT_INSTALL_PLUGINS)/$(2)
130
131 $(CP) \
132 $(PKG_INSTALL_DIR)/$(QT_INSTALL_PLUGINS)/$(2)/$(3).so* \
133 $(1)/$(QT_INSTALL_PLUGINS)/$(2)/
134 endef
135
136 define Build/Install/Examples
137 $(INSTALL_DIR) \
138 $(1)/$(QT_INSTALL_EXAMPLES)
139
140 $(CP) \
141 $(PKG_INSTALL_DIR)/$(QT_INSTALL_EXAMPLES)/* \
142 $(1)/$(QT_INSTALL_EXAMPLES)/
143
144 $(FIND) $(1)/usr/share/qt5/examples/ \
145 -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.pro' -o -name '*.pri' \) | \
146 $(XARGS) $(RM) -vf
147 endef