qt5base.mk 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. ################################################################################
  2. #
  3. # qt5base
  4. #
  5. ################################################################################
  6. QT5BASE_VERSION = $(QT5_VERSION)
  7. QT5BASE_SITE = $(QT5_SITE)
  8. QT5BASE_SOURCE = qtbase-$(QT5_SOURCE_TARBALL_PREFIX)-$(QT5BASE_VERSION).tar.xz
  9. QT5BASE_DEPENDENCIES = host-pkgconf pcre2 zlib
  10. QT5BASE_INSTALL_STAGING = YES
  11. # A few comments:
  12. # * -no-pch to workaround the issue described at
  13. # http://comments.gmane.org/gmane.comp.lib.qt.devel/5933.
  14. # * -system-zlib because zlib is mandatory for Qt build, and we
  15. # want to use the Buildroot packaged zlib
  16. # * -system-pcre because pcre is mandatory to build Qt, and we
  17. # want to use the one packaged in Buildroot
  18. QT5BASE_CONFIGURE_OPTS += \
  19. -optimized-qmake \
  20. -no-cups \
  21. -no-iconv \
  22. -system-zlib \
  23. -system-pcre \
  24. -no-pch \
  25. -shared
  26. # starting from version 5.9.0, -optimize-debug is enabled by default
  27. # for debug builds and it overrides -O* with -Og which is not what we
  28. # want.
  29. QT5BASE_CONFIGURE_OPTS += -no-optimize-debug
  30. QT5BASE_CFLAGS = $(TARGET_CFLAGS)
  31. QT5BASE_CXXFLAGS = $(TARGET_CXXFLAGS)
  32. ifeq ($(BR2_TOOLCHAIN_HAS_GCC_BUG_90620),y)
  33. QT5BASE_CFLAGS += -O0
  34. QT5BASE_CXXFLAGS += -O0
  35. endif
  36. ifeq ($(BR2_X86_CPU_HAS_SSE2),)
  37. QT5BASE_CONFIGURE_OPTS += -no-sse2
  38. else ifeq ($(BR2_X86_CPU_HAS_SSE3),)
  39. QT5BASE_CONFIGURE_OPTS += -no-sse3
  40. else ifeq ($(BR2_X86_CPU_HAS_SSSE3),)
  41. QT5BASE_CONFIGURE_OPTS += -no-ssse3
  42. else ifeq ($(BR2_X86_CPU_HAS_SSE4),)
  43. QT5BASE_CONFIGURE_OPTS += -no-sse4.1
  44. else ifeq ($(BR2_X86_CPU_HAS_SSE42),)
  45. QT5BASE_CONFIGURE_OPTS += -no-sse4.2
  46. else ifeq ($(BR2_X86_CPU_HAS_AVX),)
  47. QT5BASE_CONFIGURE_OPTS += -no-avx
  48. else ifeq ($(BR2_X86_CPU_HAS_AVX2),)
  49. QT5BASE_CONFIGURE_OPTS += -no-avx2
  50. else
  51. # no buildroot BR2_X86_CPU_HAS_AVX512 option yet for qt configure
  52. # option '-no-avx512'
  53. endif
  54. ifeq ($(BR2_PACKAGE_LIBDRM),y)
  55. QT5BASE_CONFIGURE_OPTS += -kms
  56. QT5BASE_DEPENDENCIES += libdrm
  57. else
  58. QT5BASE_CONFIGURE_OPTS += -no-kms
  59. endif
  60. # Uses libgbm from mesa3d
  61. ifeq ($(BR2_PACKAGE_MESA3D_OPENGL_EGL),y)
  62. QT5BASE_CONFIGURE_OPTS += -gbm
  63. QT5BASE_DEPENDENCIES += mesa3d
  64. else ifeq ($(BR2_PACKAGE_GCNANO_BINARIES),y)
  65. QT5BASE_CONFIGURE_OPTS += -gbm
  66. QT5BASE_DEPENDENCIES += gcnano-binaries
  67. else ifeq ($(BR2_PACKAGE_TI_SGX_LIBGBM),y)
  68. QT5BASE_CONFIGURE_OPTS += -gbm
  69. QT5BASE_DEPENDENCIES += ti-sgx-libgbm
  70. else
  71. QT5BASE_CONFIGURE_OPTS += -no-gbm
  72. endif
  73. ifeq ($(BR2_ENABLE_DEBUG),y)
  74. QT5BASE_CONFIGURE_OPTS += -debug
  75. else
  76. QT5BASE_CONFIGURE_OPTS += -release
  77. endif
  78. QT5BASE_CONFIGURE_OPTS += -opensource -confirm-license
  79. QT5BASE_LICENSE = GPL-2.0+ or LGPL-3.0, GPL-3.0 with exception(tools), GFDL-1.3 (docs)
  80. QT5BASE_LICENSE_FILES = LICENSE.GPL2 LICENSE.GPL3 LICENSE.GPL3-EXCEPT LICENSE.LGPLv3 LICENSE.FDL
  81. ifeq ($(BR2_PACKAGE_QT5BASE_EXAMPLES),y)
  82. QT5BASE_LICENSE += , BSD-3-Clause (examples)
  83. QT5BASE_LICENSE_FILES += header.BSD
  84. endif
  85. QT5BASE_CONFIG_FILE = $(call qstrip,$(BR2_PACKAGE_QT5BASE_CONFIG_FILE))
  86. ifneq ($(QT5BASE_CONFIG_FILE),)
  87. QT5BASE_CONFIGURE_OPTS += -qconfig buildroot
  88. endif
  89. ifeq ($(BR2_PACKAGE_HAS_UDEV),y)
  90. QT5BASE_DEPENDENCIES += udev
  91. endif
  92. # Qt5 SQL Plugins
  93. ifeq ($(BR2_PACKAGE_QT5BASE_SQL),y)
  94. ifeq ($(BR2_PACKAGE_QT5BASE_MYSQL),y)
  95. QT5BASE_CONFIGURE_OPTS += -plugin-sql-mysql -mysql_config $(STAGING_DIR)/usr/bin/mysql_config
  96. QT5BASE_DEPENDENCIES += mysql
  97. else
  98. QT5BASE_CONFIGURE_OPTS += -no-sql-mysql
  99. endif
  100. ifeq ($(BR2_PACKAGE_QT5BASE_PSQL),y)
  101. QT5BASE_CONFIGURE_OPTS += -plugin-sql-psql -psql_config $(STAGING_DIR)/usr/bin/pg_config
  102. QT5BASE_DEPENDENCIES += postgresql
  103. else
  104. QT5BASE_CONFIGURE_OPTS += -no-sql-psql
  105. endif
  106. QT5BASE_CONFIGURE_OPTS += $(if $(BR2_PACKAGE_QT5BASE_SQLITE_QT),-plugin-sql-sqlite)
  107. QT5BASE_CONFIGURE_OPTS += $(if $(BR2_PACKAGE_QT5BASE_SQLITE_SYSTEM),-system-sqlite)
  108. QT5BASE_DEPENDENCIES += $(if $(BR2_PACKAGE_QT5BASE_SQLITE_SYSTEM),sqlite)
  109. QT5BASE_CONFIGURE_OPTS += $(if $(BR2_PACKAGE_QT5BASE_SQLITE_NONE),-no-sql-sqlite)
  110. endif
  111. ifeq ($(BR2_PACKAGE_QT5BASE_GUI),y)
  112. QT5BASE_CONFIGURE_OPTS += -gui -system-freetype
  113. QT5BASE_DEPENDENCIES += freetype
  114. else
  115. QT5BASE_CONFIGURE_OPTS += -no-gui -no-freetype
  116. endif
  117. ifeq ($(BR2_PACKAGE_QT5BASE_HARFBUZZ),y)
  118. ifeq ($(BR2_TOOLCHAIN_HAS_SYNC_4),y)
  119. # system harfbuzz in case __sync for 4 bytes is supported
  120. QT5BASE_CONFIGURE_OPTS += -system-harfbuzz
  121. QT5BASE_DEPENDENCIES += harfbuzz
  122. else
  123. # qt harfbuzz otherwise (using QAtomic instead)
  124. QT5BASE_CONFIGURE_OPTS += -qt-harfbuzz
  125. QT5BASE_LICENSE += , MIT (harfbuzz)
  126. QT5BASE_LICENSE_FILES += src/3rdparty/harfbuzz-ng/COPYING
  127. endif
  128. else
  129. QT5BASE_CONFIGURE_OPTS += -no-harfbuzz
  130. endif
  131. QT5BASE_CONFIGURE_OPTS += $(if $(BR2_PACKAGE_QT5BASE_WIDGETS),-widgets,-no-widgets)
  132. # We have to use --enable-linuxfb, otherwise Qt thinks that -linuxfb
  133. # is to add a link against the "inuxfb" library.
  134. QT5BASE_CONFIGURE_OPTS += $(if $(BR2_PACKAGE_QT5BASE_LINUXFB),--enable-linuxfb,-no-linuxfb)
  135. QT5BASE_CONFIGURE_OPTS += $(if $(BR2_PACKAGE_QT5BASE_DIRECTFB),-directfb,-no-directfb)
  136. QT5BASE_DEPENDENCIES += $(if $(BR2_PACKAGE_QT5BASE_DIRECTFB),directfb)
  137. ifeq ($(BR2_PACKAGE_QT5BASE_XCB),y)
  138. QT5BASE_CONFIGURE_OPTS += -xcb
  139. QT5BASE_CONFIGURE_OPTS += -xkbcommon
  140. QT5BASE_DEPENDENCIES += \
  141. libxcb \
  142. xcb-util-wm \
  143. xcb-util-image \
  144. xcb-util-keysyms \
  145. xlib_libX11 \
  146. libxkbcommon
  147. ifeq ($(BR2_PACKAGE_QT5BASE_WIDGETS),y)
  148. QT5BASE_DEPENDENCIES += xlib_libXext
  149. endif
  150. else
  151. QT5BASE_CONFIGURE_OPTS += -no-xcb
  152. endif
  153. ifeq ($(BR2_PACKAGE_QT5BASE_OPENGL_DESKTOP),y)
  154. QT5BASE_CONFIGURE_OPTS += -opengl desktop
  155. QT5BASE_DEPENDENCIES += libgl
  156. else ifeq ($(BR2_PACKAGE_QT5BASE_OPENGL_ES2),y)
  157. QT5BASE_CONFIGURE_OPTS += -opengl es2
  158. QT5BASE_DEPENDENCIES += libgles
  159. else
  160. QT5BASE_CONFIGURE_OPTS += -no-opengl
  161. endif
  162. QT5BASE_DEFAULT_QPA = $(call qstrip,$(BR2_PACKAGE_QT5BASE_DEFAULT_QPA))
  163. QT5BASE_CONFIGURE_OPTS += $(if $(QT5BASE_DEFAULT_QPA),-qpa $(QT5BASE_DEFAULT_QPA))
  164. ifeq ($(BR2_PACKAGE_QT5BASE_EGLFS),y)
  165. QT5BASE_CONFIGURE_OPTS += -eglfs
  166. QT5BASE_DEPENDENCIES += libegl
  167. else
  168. QT5BASE_CONFIGURE_OPTS += -no-eglfs
  169. endif
  170. QT5BASE_CONFIGURE_OPTS += $(if $(BR2_PACKAGE_OPENSSL),-openssl,-no-openssl)
  171. QT5BASE_DEPENDENCIES += $(if $(BR2_PACKAGE_OPENSSL),openssl)
  172. QT5BASE_CONFIGURE_OPTS += $(if $(BR2_PACKAGE_QT5BASE_FONTCONFIG),-fontconfig,-no-fontconfig)
  173. QT5BASE_DEPENDENCIES += $(if $(BR2_PACKAGE_QT5BASE_FONTCONFIG),fontconfig)
  174. QT5BASE_CONFIGURE_OPTS += $(if $(BR2_PACKAGE_QT5BASE_GIF),,-no-gif)
  175. QT5BASE_CONFIGURE_OPTS += $(if $(BR2_PACKAGE_QT5BASE_JPEG),-system-libjpeg,-no-libjpeg)
  176. QT5BASE_DEPENDENCIES += $(if $(BR2_PACKAGE_QT5BASE_JPEG),jpeg)
  177. QT5BASE_CONFIGURE_OPTS += $(if $(BR2_PACKAGE_QT5BASE_PNG),-system-libpng,-no-libpng)
  178. QT5BASE_DEPENDENCIES += $(if $(BR2_PACKAGE_QT5BASE_PNG),libpng)
  179. QT5BASE_CONFIGURE_OPTS += $(if $(BR2_PACKAGE_QT5BASE_DBUS),-dbus,-no-dbus)
  180. QT5BASE_DEPENDENCIES += $(if $(BR2_PACKAGE_QT5BASE_DBUS),dbus)
  181. QT5BASE_CONFIGURE_OPTS += $(if $(BR2_PACKAGE_QT5BASE_TSLIB),-tslib,-no-tslib)
  182. QT5BASE_DEPENDENCIES += $(if $(BR2_PACKAGE_QT5BASE_TSLIB),tslib)
  183. QT5BASE_CONFIGURE_OPTS += $(if $(BR2_PACKAGE_LIBGLIB2),-glib,-no-glib)
  184. QT5BASE_DEPENDENCIES += $(if $(BR2_PACKAGE_LIBGLIB2),libglib2)
  185. QT5BASE_CONFIGURE_OPTS += $(if $(BR2_PACKAGE_QT5BASE_ICU),-icu,-no-icu)
  186. QT5BASE_DEPENDENCIES += $(if $(BR2_PACKAGE_QT5BASE_ICU),icu)
  187. QT5BASE_CONFIGURE_OPTS += $(if $(BR2_PACKAGE_QT5BASE_EXAMPLES),-make,-nomake) examples
  188. ifeq ($(BR2_PACKAGE_LIBINPUT),y)
  189. QT5BASE_CONFIGURE_OPTS += -libinput
  190. QT5BASE_DEPENDENCIES += libinput
  191. else
  192. QT5BASE_CONFIGURE_OPTS += -no-libinput
  193. endif
  194. # only enable gtk support if libgtk3 X11 backend is enabled
  195. ifeq ($(BR2_PACKAGE_LIBGTK3)$(BR2_PACKAGE_LIBGTK3_X11),yy)
  196. QT5BASE_CONFIGURE_OPTS += -gtk
  197. QT5BASE_DEPENDENCIES += libgtk3
  198. else
  199. QT5BASE_CONFIGURE_OPTS += -no-gtk
  200. endif
  201. ifeq ($(BR2_PACKAGE_SYSTEMD),y)
  202. QT5BASE_CONFIGURE_OPTS += -journald
  203. QT5BASE_DEPENDENCIES += systemd
  204. else
  205. QT5BASE_CONFIGURE_OPTS += -no-journald
  206. endif
  207. # Build the list of libraries to be installed on the target
  208. QT5BASE_INSTALL_LIBS_y += Qt5Core
  209. QT5BASE_INSTALL_LIBS_$(BR2_PACKAGE_QT5BASE_XCB) += Qt5XcbQpa
  210. QT5BASE_INSTALL_LIBS_$(BR2_PACKAGE_QT5BASE_NETWORK) += Qt5Network
  211. QT5BASE_INSTALL_LIBS_$(BR2_PACKAGE_QT5BASE_CONCURRENT) += Qt5Concurrent
  212. QT5BASE_INSTALL_LIBS_$(BR2_PACKAGE_QT5BASE_SQL) += Qt5Sql
  213. QT5BASE_INSTALL_LIBS_$(BR2_PACKAGE_QT5BASE_TEST) += Qt5Test
  214. QT5BASE_INSTALL_LIBS_$(BR2_PACKAGE_QT5BASE_XML) += Qt5Xml
  215. QT5BASE_INSTALL_LIBS_$(BR2_PACKAGE_QT5BASE_OPENGL_LIB) += Qt5OpenGL
  216. QT5BASE_INSTALL_LIBS_$(BR2_PACKAGE_QT5BASE_EGLFS) += Qt5EglFSDeviceIntegration
  217. ifeq ($(BR2_PACKAGE_MESA3D_OPENGL_EGL),y)
  218. QT5BASE_INSTALL_LIBS_$(BR2_PACKAGE_QT5BASE_EGLFS) += Qt5EglFsKmsSupport
  219. endif
  220. ifeq ($(BR2_PACKAGE_GCNANO_BINARIES),y)
  221. QT5BASE_INSTALL_LIBS_$(BR2_PACKAGE_QT5BASE_EGLFS) += Qt5EglFsKmsSupport
  222. endif
  223. QT5BASE_INSTALL_LIBS_$(BR2_PACKAGE_QT5BASE_GUI) += Qt5Gui
  224. QT5BASE_INSTALL_LIBS_$(BR2_PACKAGE_QT5BASE_WIDGETS) += Qt5Widgets
  225. QT5BASE_INSTALL_LIBS_$(BR2_PACKAGE_QT5BASE_PRINTSUPPORT) += Qt5PrintSupport
  226. QT5BASE_INSTALL_LIBS_$(BR2_PACKAGE_QT5BASE_DBUS) += Qt5DBus
  227. ifeq ($(BR2_PACKAGE_IMX_GPU_VIV),y)
  228. # use vivante backend
  229. QT5BASE_EGLFS_DEVICE = EGLFS_DEVICE_INTEGRATION = eglfs_viv
  230. else ifeq ($(BR2_PACKAGE_SUNXI_MALI_MAINLINE),y)
  231. # use mali backend
  232. QT5BASE_EGLFS_DEVICE = EGLFS_DEVICE_INTEGRATION = eglfs_mali
  233. endif
  234. ifneq ($(QT5BASE_CONFIG_FILE),)
  235. define QT5BASE_CONFIGURE_CONFIG_FILE
  236. cp $(QT5BASE_CONFIG_FILE) $(@D)/src/corelib/global/qconfig-buildroot.h
  237. endef
  238. endif
  239. QT5BASE_ARCH_CONFIG_FILE = $(@D)/mkspecs/devices/linux-buildroot-g++/arch.conf
  240. ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
  241. # Qt 5.8 needs atomics, which on various architectures are in -latomic
  242. define QT5BASE_CONFIGURE_ARCH_CONFIG
  243. printf 'LIBS += -latomic\n' >$(QT5BASE_ARCH_CONFIG_FILE)
  244. endef
  245. endif
  246. # This allows to use ccache when available
  247. define QT5BASE_CONFIGURE_HOSTCC
  248. $(SED) 's,^QMAKE_CC\s*=.*,QMAKE_CC = $(HOSTCC),' $(@D)/mkspecs/common/g++-base.conf
  249. $(SED) 's,^QMAKE_CXX\s*=.*,QMAKE_CXX = $(HOSTCXX),' $(@D)/mkspecs/common/g++-base.conf
  250. endef
  251. # Must be last so can override all options set by Buildroot
  252. QT5BASE_CONFIGURE_OPTS += $(call qstrip,$(BR2_PACKAGE_QT5BASE_CUSTOM_CONF_OPTS))
  253. define QT5BASE_CONFIGURE_CMDS
  254. mkdir -p $(@D)/mkspecs/devices/linux-buildroot-g++/
  255. sed 's/@EGLFS_DEVICE@/$(QT5BASE_EGLFS_DEVICE)/g' \
  256. $(QT5BASE_PKGDIR)/qmake.conf.in > \
  257. $(@D)/mkspecs/devices/linux-buildroot-g++/qmake.conf
  258. $(INSTALL) -m 0644 -D $(QT5BASE_PKGDIR)/qplatformdefs.h \
  259. $(@D)/mkspecs/devices/linux-buildroot-g++/qplatformdefs.h
  260. $(QT5BASE_CONFIGURE_CONFIG_FILE)
  261. touch $(QT5BASE_ARCH_CONFIG_FILE)
  262. $(QT5BASE_CONFIGURE_ARCH_CONFIG)
  263. $(QT5BASE_CONFIGURE_HOSTCC)
  264. (cd $(@D); \
  265. $(TARGET_MAKE_ENV) \
  266. PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
  267. MAKEFLAGS="-j$(PARALLEL_JOBS) $(MAKEFLAGS)" \
  268. ./configure \
  269. -v \
  270. -prefix /usr \
  271. -hostprefix $(HOST_DIR) \
  272. -headerdir /usr/include/qt5 \
  273. -sysroot $(STAGING_DIR) \
  274. -plugindir /usr/lib/qt/plugins \
  275. -examplesdir /usr/lib/qt/examples \
  276. -no-rpath \
  277. -nomake tests \
  278. -device buildroot \
  279. -device-option CROSS_COMPILE="$(TARGET_CROSS)" \
  280. -device-option BR_COMPILER_CFLAGS="$(QT5BASE_CFLAGS)" \
  281. -device-option BR_COMPILER_CXXFLAGS="$(QT5BASE_CXXFLAGS)" \
  282. $(QT5BASE_CONFIGURE_OPTS) \
  283. )
  284. endef
  285. define QT5BASE_BUILD_CMDS
  286. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)
  287. endef
  288. # The file "qt.conf" can be used to override the hard-coded paths that are
  289. # compiled into the Qt library. We need it to make "qmake" relocatable.
  290. define QT5BASE_INSTALL_QT_CONF
  291. sed -e "s|@@HOST_DIR@@|$(HOST_DIR)|" -e "s|@@STAGING_DIR@@|$(STAGING_DIR)|" \
  292. $(QT5BASE_PKGDIR)/qt.conf.in > $(HOST_DIR)/bin/qt.conf
  293. endef
  294. define QT5BASE_INSTALL_STAGING_CMDS
  295. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) install
  296. $(QT5BASE_INSTALL_QT_CONF)
  297. endef
  298. define QT5BASE_INSTALL_TARGET_LIBS
  299. for lib in $(QT5BASE_INSTALL_LIBS_y); do \
  300. cp -dpf $(STAGING_DIR)/usr/lib/lib$${lib}.so.* $(TARGET_DIR)/usr/lib || exit 1 ; \
  301. done
  302. endef
  303. define QT5BASE_INSTALL_TARGET_PLUGINS
  304. if [ -d $(STAGING_DIR)/usr/lib/qt/plugins/ ] ; then \
  305. mkdir -p $(TARGET_DIR)/usr/lib/qt/plugins ; \
  306. cp -dpfr $(STAGING_DIR)/usr/lib/qt/plugins/* $(TARGET_DIR)/usr/lib/qt/plugins ; \
  307. fi
  308. endef
  309. define QT5BASE_INSTALL_TARGET_EXAMPLES
  310. if [ -d $(STAGING_DIR)/usr/lib/qt/examples/ ] ; then \
  311. mkdir -p $(TARGET_DIR)/usr/lib/qt/examples ; \
  312. cp -dpfr $(STAGING_DIR)/usr/lib/qt/examples/* $(TARGET_DIR)/usr/lib/qt/examples ; \
  313. fi
  314. endef
  315. ifeq ($(BR2_STATIC_LIBS),y)
  316. define QT5BASE_INSTALL_TARGET_CMDS
  317. $(QT5BASE_INSTALL_TARGET_EXAMPLES)
  318. endef
  319. else
  320. define QT5BASE_INSTALL_TARGET_CMDS
  321. $(QT5BASE_INSTALL_TARGET_LIBS)
  322. $(QT5BASE_INSTALL_TARGET_PLUGINS)
  323. $(QT5BASE_INSTALL_TARGET_EXAMPLES)
  324. endef
  325. endif
  326. $(eval $(generic-package))