You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

starwels_qt.m4 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. dnl Copyright (c) 2013-2016 The Starwels developers
  2. dnl Distributed under the MIT software license, see the accompanying
  3. dnl file COPYING or http://www.opensource.org/licenses/mit-license.php.
  4. dnl Helper for cases where a qt dependency is not met.
  5. dnl Output: If qt version is auto, set starwels_enable_qt to false. Else, exit.
  6. AC_DEFUN([STARWELS_QT_FAIL],[
  7. if test "x$starwels_qt_want_version" = "xauto" && test x$starwels_qt_force != xyes; then
  8. if test x$starwels_enable_qt != xno; then
  9. AC_MSG_WARN([$1; starwels-qt frontend will not be built])
  10. fi
  11. starwels_enable_qt=no
  12. starwels_enable_qt_test=no
  13. else
  14. AC_MSG_ERROR([$1])
  15. fi
  16. ])
  17. AC_DEFUN([STARWELS_QT_CHECK],[
  18. if test "x$starwels_enable_qt" != "xno" && test x$starwels_qt_want_version != xno; then
  19. true
  20. $1
  21. else
  22. true
  23. $2
  24. fi
  25. ])
  26. dnl STARWELS_QT_PATH_PROGS([FOO], [foo foo2], [/path/to/search/first], [continue if missing])
  27. dnl Helper for finding the path of programs needed for Qt.
  28. dnl Inputs: $1: Variable to be set
  29. dnl Inputs: $2: List of programs to search for
  30. dnl Inputs: $3: Look for $2 here before $PATH
  31. dnl Inputs: $4: If "yes", don't fail if $2 is not found.
  32. dnl Output: $1 is set to the path of $2 if found. $2 are searched in order.
  33. AC_DEFUN([STARWELS_QT_PATH_PROGS],[
  34. STARWELS_QT_CHECK([
  35. if test "x$3" != "x"; then
  36. AC_PATH_PROGS($1,$2,,$3)
  37. else
  38. AC_PATH_PROGS($1,$2)
  39. fi
  40. if test "x$$1" = "x" && test "x$4" != "xyes"; then
  41. STARWELS_QT_FAIL([$1 not found])
  42. fi
  43. ])
  44. ])
  45. dnl Initialize qt input.
  46. dnl This must be called before any other STARWELS_QT* macros to ensure that
  47. dnl input variables are set correctly.
  48. dnl CAUTION: Do not use this inside of a conditional.
  49. AC_DEFUN([STARWELS_QT_INIT],[
  50. dnl enable qt support
  51. AC_ARG_WITH([gui],
  52. [AS_HELP_STRING([--with-gui@<:@=no|qt4|qt5|auto@:>@],
  53. [build starwels-qt GUI (default=auto, qt5 tried first)])],
  54. [
  55. starwels_qt_want_version=$withval
  56. if test x$starwels_qt_want_version = xyes; then
  57. starwels_qt_force=yes
  58. starwels_qt_want_version=auto
  59. fi
  60. ],
  61. [starwels_qt_want_version=auto])
  62. AC_ARG_WITH([qt-incdir],[AS_HELP_STRING([--with-qt-incdir=INC_DIR],[specify qt include path (overridden by pkgconfig)])], [qt_include_path=$withval], [])
  63. AC_ARG_WITH([qt-libdir],[AS_HELP_STRING([--with-qt-libdir=LIB_DIR],[specify qt lib path (overridden by pkgconfig)])], [qt_lib_path=$withval], [])
  64. AC_ARG_WITH([qt-plugindir],[AS_HELP_STRING([--with-qt-plugindir=PLUGIN_DIR],[specify qt plugin path (overridden by pkgconfig)])], [qt_plugin_path=$withval], [])
  65. AC_ARG_WITH([qt-translationdir],[AS_HELP_STRING([--with-qt-translationdir=PLUGIN_DIR],[specify qt translation path (overridden by pkgconfig)])], [qt_translation_path=$withval], [])
  66. AC_ARG_WITH([qt-bindir],[AS_HELP_STRING([--with-qt-bindir=BIN_DIR],[specify qt bin path])], [qt_bin_path=$withval], [])
  67. AC_ARG_WITH([qtdbus],
  68. [AS_HELP_STRING([--with-qtdbus],
  69. [enable DBus support (default is yes if qt is enabled and QtDBus is found)])],
  70. [use_dbus=$withval],
  71. [use_dbus=auto])
  72. AC_SUBST(QT_TRANSLATION_DIR,$qt_translation_path)
  73. ])
  74. dnl Find the appropriate version of Qt libraries and includes.
  75. dnl Inputs: $1: Whether or not pkg-config should be used. yes|no. Default: yes.
  76. dnl Inputs: $2: If $1 is "yes" and --with-gui=auto, which qt version should be
  77. dnl tried first.
  78. dnl Outputs: See _STARWELS_QT_FIND_LIBS_*
  79. dnl Outputs: Sets variables for all qt-related tools.
  80. dnl Outputs: starwels_enable_qt, starwels_enable_qt_dbus, starwels_enable_qt_test
  81. AC_DEFUN([STARWELS_QT_CONFIGURE],[
  82. use_pkgconfig=$1
  83. if test x$use_pkgconfig = x; then
  84. use_pkgconfig=yes
  85. fi
  86. if test x$use_pkgconfig = xyes; then
  87. STARWELS_QT_CHECK([_STARWELS_QT_FIND_LIBS_WITH_PKGCONFIG([$2])])
  88. else
  89. STARWELS_QT_CHECK([_STARWELS_QT_FIND_LIBS_WITHOUT_PKGCONFIG])
  90. fi
  91. dnl This is ugly and complicated. Yuck. Works as follows:
  92. dnl We can't discern whether Qt4 builds are static or not. For Qt5, we can
  93. dnl check a header to find out. When Qt is built statically, some plugins must
  94. dnl be linked into the final binary as well. These plugins have changed between
  95. dnl Qt4 and Qt5. With Qt5, languages moved into core and the WindowsIntegration
  96. dnl plugin was added. Since we can't tell if Qt4 is static or not, it is
  97. dnl assumed for windows builds.
  98. dnl _STARWELS_QT_CHECK_STATIC_PLUGINS does a quick link-check and appends the
  99. dnl results to QT_LIBS.
  100. STARWELS_QT_CHECK([
  101. TEMP_CPPFLAGS=$CPPFLAGS
  102. TEMP_CXXFLAGS=$CXXFLAGS
  103. CPPFLAGS="$QT_INCLUDES $CPPFLAGS"
  104. CXXFLAGS="$PIC_FLAGS $CXXFLAGS"
  105. if test x$starwels_qt_got_major_vers = x5; then
  106. _STARWELS_QT_IS_STATIC
  107. if test x$starwels_cv_static_qt = xyes; then
  108. _STARWELS_QT_FIND_STATIC_PLUGINS
  109. AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static])
  110. AC_CACHE_CHECK(for Qt < 5.4, starwels_cv_need_acc_widget,[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  111. [[#include <QtCore>]],[[
  112. #if QT_VERSION >= 0x050400
  113. choke;
  114. #endif
  115. ]])],
  116. [starwels_cv_need_acc_widget=yes],
  117. [starwels_cv_need_acc_widget=no])
  118. ])
  119. if test "x$starwels_cv_need_acc_widget" = "xyes"; then
  120. _STARWELS_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(AccessibleFactory)], [-lqtaccessiblewidgets])
  121. fi
  122. _STARWELS_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QMinimalIntegrationPlugin)],[-lqminimal])
  123. AC_DEFINE(QT_QPA_PLATFORM_MINIMAL, 1, [Define this symbol if the minimal qt platform exists])
  124. if test x$TARGET_OS = xwindows; then
  125. _STARWELS_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)],[-lqwindows])
  126. AC_DEFINE(QT_QPA_PLATFORM_WINDOWS, 1, [Define this symbol if the qt platform is windows])
  127. elif test x$TARGET_OS = xlinux; then
  128. _STARWELS_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)],[-lqxcb -lxcb-static])
  129. AC_DEFINE(QT_QPA_PLATFORM_XCB, 1, [Define this symbol if the qt platform is xcb])
  130. elif test x$TARGET_OS = xdarwin; then
  131. AX_CHECK_LINK_FLAG([[-framework IOKit]],[QT_LIBS="$QT_LIBS -framework IOKit"],[AC_MSG_ERROR(could not iokit framework)])
  132. _STARWELS_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin)],[-lqcocoa])
  133. AC_DEFINE(QT_QPA_PLATFORM_COCOA, 1, [Define this symbol if the qt platform is cocoa])
  134. fi
  135. fi
  136. else
  137. if test x$TARGET_OS = xwindows; then
  138. AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static])
  139. _STARWELS_QT_CHECK_STATIC_PLUGINS([
  140. Q_IMPORT_PLUGIN(qcncodecs)
  141. Q_IMPORT_PLUGIN(qjpcodecs)
  142. Q_IMPORT_PLUGIN(qtwcodecs)
  143. Q_IMPORT_PLUGIN(qkrcodecs)
  144. Q_IMPORT_PLUGIN(AccessibleFactory)],
  145. [-lqcncodecs -lqjpcodecs -lqtwcodecs -lqkrcodecs -lqtaccessiblewidgets])
  146. fi
  147. fi
  148. CPPFLAGS=$TEMP_CPPFLAGS
  149. CXXFLAGS=$TEMP_CXXFLAGS
  150. ])
  151. if test x$use_pkgconfig$qt_bin_path = xyes; then
  152. if test x$starwels_qt_got_major_vers = x5; then
  153. qt_bin_path="`$PKG_CONFIG --variable=host_bins Qt5Core 2>/dev/null`"
  154. fi
  155. fi
  156. if test x$use_hardening != xno; then
  157. STARWELS_QT_CHECK([
  158. AC_MSG_CHECKING(whether -fPIE can be used with this Qt config)
  159. TEMP_CPPFLAGS=$CPPFLAGS
  160. TEMP_CXXFLAGS=$CXXFLAGS
  161. CPPFLAGS="$QT_INCLUDES $CPPFLAGS"
  162. CXXFLAGS="$PIE_FLAGS $CXXFLAGS"
  163. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <QtCore/qconfig.h>]],
  164. [[
  165. #if defined(QT_REDUCE_RELOCATIONS)
  166. choke;
  167. #endif
  168. ]])],
  169. [ AC_MSG_RESULT(yes); QT_PIE_FLAGS=$PIE_FLAGS ],
  170. [ AC_MSG_RESULT(no); QT_PIE_FLAGS=$PIC_FLAGS]
  171. )
  172. CPPFLAGS=$TEMP_CPPFLAGS
  173. CXXFLAGS=$TEMP_CXXFLAGS
  174. ])
  175. else
  176. STARWELS_QT_CHECK([
  177. AC_MSG_CHECKING(whether -fPIC is needed with this Qt config)
  178. TEMP_CPPFLAGS=$CPPFLAGS
  179. CPPFLAGS="$QT_INCLUDES $CPPFLAGS"
  180. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <QtCore/qconfig.h>]],
  181. [[
  182. #if defined(QT_REDUCE_RELOCATIONS)
  183. choke;
  184. #endif
  185. ]])],
  186. [ AC_MSG_RESULT(no)],
  187. [ AC_MSG_RESULT(yes); QT_PIE_FLAGS=$PIC_FLAGS]
  188. )
  189. CPPFLAGS=$TEMP_CPPFLAGS
  190. ])
  191. fi
  192. STARWELS_QT_PATH_PROGS([MOC], [moc-qt${starwels_qt_got_major_vers} moc${starwels_qt_got_major_vers} moc], $qt_bin_path)
  193. STARWELS_QT_PATH_PROGS([UIC], [uic-qt${starwels_qt_got_major_vers} uic${starwels_qt_got_major_vers} uic], $qt_bin_path)
  194. STARWELS_QT_PATH_PROGS([RCC], [rcc-qt${starwels_qt_got_major_vers} rcc${starwels_qt_got_major_vers} rcc], $qt_bin_path)
  195. STARWELS_QT_PATH_PROGS([LRELEASE], [lrelease-qt${starwels_qt_got_major_vers} lrelease${starwels_qt_got_major_vers} lrelease], $qt_bin_path)
  196. STARWELS_QT_PATH_PROGS([LUPDATE], [lupdate-qt${starwels_qt_got_major_vers} lupdate${starwels_qt_got_major_vers} lupdate],$qt_bin_path, yes)
  197. MOC_DEFS='-DHAVE_CONFIG_H -I$(srcdir)'
  198. case $host in
  199. *darwin*)
  200. STARWELS_QT_CHECK([
  201. MOC_DEFS="${MOC_DEFS} -DQ_OS_MAC"
  202. base_frameworks="-framework Foundation -framework ApplicationServices -framework AppKit"
  203. AX_CHECK_LINK_FLAG([[$base_frameworks]],[QT_LIBS="$QT_LIBS $base_frameworks"],[AC_MSG_ERROR(could not find base frameworks)])
  204. ])
  205. ;;
  206. *mingw*)
  207. STARWELS_QT_CHECK([
  208. AX_CHECK_LINK_FLAG([[-mwindows]],[QT_LDFLAGS="$QT_LDFLAGS -mwindows"],[AC_MSG_WARN(-mwindows linker support not detected)])
  209. ])
  210. esac
  211. dnl enable qt support
  212. AC_MSG_CHECKING(whether to build ]AC_PACKAGE_NAME[ GUI)
  213. STARWELS_QT_CHECK([
  214. starwels_enable_qt=yes
  215. starwels_enable_qt_test=yes
  216. if test x$have_qt_test = xno; then
  217. starwels_enable_qt_test=no
  218. fi
  219. starwels_enable_qt_dbus=no
  220. if test x$use_dbus != xno && test x$have_qt_dbus = xyes; then
  221. starwels_enable_qt_dbus=yes
  222. fi
  223. if test x$use_dbus = xyes && test x$have_qt_dbus = xno; then
  224. AC_MSG_ERROR("libQtDBus not found. Install libQtDBus or remove --with-qtdbus.")
  225. fi
  226. if test x$LUPDATE = x; then
  227. AC_MSG_WARN("lupdate is required to update qt translations")
  228. fi
  229. ],[
  230. starwels_enable_qt=no
  231. ])
  232. AC_MSG_RESULT([$starwels_enable_qt (Qt${starwels_qt_got_major_vers})])
  233. AC_SUBST(QT_PIE_FLAGS)
  234. AC_SUBST(QT_INCLUDES)
  235. AC_SUBST(QT_LIBS)
  236. AC_SUBST(QT_LDFLAGS)
  237. AC_SUBST(QT_DBUS_INCLUDES)
  238. AC_SUBST(QT_DBUS_LIBS)
  239. AC_SUBST(QT_TEST_INCLUDES)
  240. AC_SUBST(QT_TEST_LIBS)
  241. AC_SUBST(QT_SELECT, qt${starwels_qt_got_major_vers})
  242. AC_SUBST(MOC_DEFS)
  243. ])
  244. dnl All macros below are internal and should _not_ be used from the main
  245. dnl configure.ac.
  246. dnl ----
  247. dnl Internal. Check if the included version of Qt is Qt5.
  248. dnl Requires: INCLUDES must be populated as necessary.
  249. dnl Output: starwels_cv_qt5=yes|no
  250. AC_DEFUN([_STARWELS_QT_CHECK_QT5],[
  251. AC_CACHE_CHECK(for Qt 5, starwels_cv_qt5,[
  252. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  253. [[#include <QtCore>]],
  254. [[
  255. #if QT_VERSION < 0x050000
  256. choke me
  257. #else
  258. return 0;
  259. #endif
  260. ]])],
  261. [starwels_cv_qt5=yes],
  262. [starwels_cv_qt5=no])
  263. ])])
  264. dnl Internal. Check if the linked version of Qt was built as static libs.
  265. dnl Requires: Qt5. This check cannot determine if Qt4 is static.
  266. dnl Requires: INCLUDES and LIBS must be populated as necessary.
  267. dnl Output: starwels_cv_static_qt=yes|no
  268. dnl Output: Defines QT_STATICPLUGIN if plugins are static.
  269. AC_DEFUN([_STARWELS_QT_IS_STATIC],[
  270. AC_CACHE_CHECK(for static Qt, starwels_cv_static_qt,[
  271. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  272. [[#include <QtCore>]],
  273. [[
  274. #if defined(QT_STATIC)
  275. return 0;
  276. #else
  277. choke me
  278. #endif
  279. ]])],
  280. [starwels_cv_static_qt=yes],
  281. [starwels_cv_static_qt=no])
  282. ])
  283. if test xstarwels_cv_static_qt = xyes; then
  284. AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol for static Qt plugins])
  285. fi
  286. ])
  287. dnl Internal. Check if the link-requirements for static plugins are met.
  288. dnl Requires: INCLUDES and LIBS must be populated as necessary.
  289. dnl Inputs: $1: A series of Q_IMPORT_PLUGIN().
  290. dnl Inputs: $2: The libraries that resolve $1.
  291. dnl Output: QT_LIBS is prepended or configure exits.
  292. AC_DEFUN([_STARWELS_QT_CHECK_STATIC_PLUGINS],[
  293. AC_MSG_CHECKING(for static Qt plugins: $2)
  294. CHECK_STATIC_PLUGINS_TEMP_LIBS="$LIBS"
  295. LIBS="$2 $QT_LIBS $LIBS"
  296. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  297. #define QT_STATICPLUGIN
  298. #include <QtPlugin>
  299. $1]],
  300. [[return 0;]])],
  301. [AC_MSG_RESULT(yes); QT_LIBS="$2 $QT_LIBS"],
  302. [AC_MSG_RESULT(no); STARWELS_QT_FAIL(Could not resolve: $2)])
  303. LIBS="$CHECK_STATIC_PLUGINS_TEMP_LIBS"
  304. ])
  305. dnl Internal. Find paths necessary for linking qt static plugins
  306. dnl Inputs: starwels_qt_got_major_vers. 4 or 5.
  307. dnl Inputs: qt_plugin_path. optional.
  308. dnl Outputs: QT_LIBS is appended
  309. AC_DEFUN([_STARWELS_QT_FIND_STATIC_PLUGINS],[
  310. if test x$starwels_qt_got_major_vers = x5; then
  311. if test x$qt_plugin_path != x; then
  312. QT_LIBS="$QT_LIBS -L$qt_plugin_path/platforms"
  313. if test -d "$qt_plugin_path/accessible"; then
  314. QT_LIBS="$QT_LIBS -L$qt_plugin_path/accessible"
  315. fi
  316. fi
  317. if test x$use_pkgconfig = xyes; then
  318. : dnl
  319. m4_ifdef([PKG_CHECK_MODULES],[
  320. PKG_CHECK_MODULES([QTPLATFORM], [Qt5PlatformSupport], [QT_LIBS="$QTPLATFORM_LIBS $QT_LIBS"])
  321. if test x$TARGET_OS = xlinux; then
  322. PKG_CHECK_MODULES([X11XCB], [x11-xcb], [QT_LIBS="$X11XCB_LIBS $QT_LIBS"])
  323. if ${PKG_CONFIG} --exists "Qt5Core >= 5.5" 2>/dev/null; then
  324. PKG_CHECK_MODULES([QTXCBQPA], [Qt5XcbQpa], [QT_LIBS="$QTXCBQPA_LIBS $QT_LIBS"])
  325. fi
  326. elif test x$TARGET_OS = xdarwin; then
  327. PKG_CHECK_MODULES([QTPRINT], [Qt5PrintSupport], [QT_LIBS="$QTPRINT_LIBS $QT_LIBS"])
  328. fi
  329. ])
  330. else
  331. if test x$TARGET_OS = xwindows; then
  332. AC_CACHE_CHECK(for Qt >= 5.6, starwels_cv_need_platformsupport,[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  333. [[#include <QtCore>]],[[
  334. #if QT_VERSION < 0x050600
  335. choke;
  336. #endif
  337. ]])],
  338. [starwels_cv_need_platformsupport=yes],
  339. [starwels_cv_need_platformsupport=no])
  340. ])
  341. if test x$starwels_cv_need_platformsupport = xyes; then
  342. STARWELS_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}PlatformSupport],[main],,STARWELS_QT_FAIL(lib$QT_LIB_PREFIXPlatformSupport not found)))
  343. fi
  344. fi
  345. fi
  346. else
  347. if test x$qt_plugin_path != x; then
  348. QT_LIBS="$QT_LIBS -L$qt_plugin_path/accessible"
  349. QT_LIBS="$QT_LIBS -L$qt_plugin_path/codecs"
  350. fi
  351. fi
  352. ])
  353. dnl Internal. Find Qt libraries using pkg-config.
  354. dnl Inputs: starwels_qt_want_version (from --with-gui=). The version to check
  355. dnl first.
  356. dnl Inputs: $1: If starwels_qt_want_version is "auto", check for this version
  357. dnl first.
  358. dnl Outputs: All necessary QT_* variables are set.
  359. dnl Outputs: starwels_qt_got_major_vers is set to "4" or "5".
  360. dnl Outputs: have_qt_test and have_qt_dbus are set (if applicable) to yes|no.
  361. AC_DEFUN([_STARWELS_QT_FIND_LIBS_WITH_PKGCONFIG],[
  362. m4_ifdef([PKG_CHECK_MODULES],[
  363. auto_priority_version=$1
  364. if test x$auto_priority_version = x; then
  365. auto_priority_version=qt5
  366. fi
  367. if test x$starwels_qt_want_version = xqt5 || ( test x$starwels_qt_want_version = xauto && test x$auto_priority_version = xqt5 ); then
  368. QT_LIB_PREFIX=Qt5
  369. starwels_qt_got_major_vers=5
  370. else
  371. QT_LIB_PREFIX=Qt
  372. starwels_qt_got_major_vers=4
  373. fi
  374. qt5_modules="Qt5Core Qt5Gui Qt5Network Qt5Widgets"
  375. qt4_modules="QtCore QtGui QtNetwork"
  376. STARWELS_QT_CHECK([
  377. if test x$starwels_qt_want_version = xqt5 || ( test x$starwels_qt_want_version = xauto && test x$auto_priority_version = xqt5 ); then
  378. PKG_CHECK_MODULES([QT5], [$qt5_modules], [QT_INCLUDES="$QT5_CFLAGS"; QT_LIBS="$QT5_LIBS" have_qt=yes],[have_qt=no])
  379. elif test x$starwels_qt_want_version = xqt4 || ( test x$starwels_qt_want_version = xauto && test x$auto_priority_version = xqt4 ); then
  380. PKG_CHECK_MODULES([QT4], [$qt4_modules], [QT_INCLUDES="$QT4_CFLAGS"; QT_LIBS="$QT4_LIBS" ; have_qt=yes], [have_qt=no])
  381. fi
  382. dnl qt version is set to 'auto' and the preferred version wasn't found. Now try the other.
  383. if test x$have_qt = xno && test x$starwels_qt_want_version = xauto; then
  384. if test x$auto_priority_version = xqt5; then
  385. PKG_CHECK_MODULES([QT4], [$qt4_modules], [QT_INCLUDES="$QT4_CFLAGS"; QT_LIBS="$QT4_LIBS" ; have_qt=yes; QT_LIB_PREFIX=Qt; starwels_qt_got_major_vers=4], [have_qt=no])
  386. else
  387. PKG_CHECK_MODULES([QT5], [$qt5_modules], [QT_INCLUDES="$QT5_CFLAGS"; QT_LIBS="$QT5_LIBS" ; have_qt=yes; QT_LIB_PREFIX=Qt5; starwels_qt_got_major_vers=5], [have_qt=no])
  388. fi
  389. fi
  390. if test x$have_qt != xyes; then
  391. have_qt=no
  392. STARWELS_QT_FAIL([Qt dependencies not found])
  393. fi
  394. ])
  395. STARWELS_QT_CHECK([
  396. PKG_CHECK_MODULES([QT_TEST], [${QT_LIB_PREFIX}Test], [QT_TEST_INCLUDES="$QT_TEST_CFLAGS"; have_qt_test=yes], [have_qt_test=no])
  397. if test x$use_dbus != xno; then
  398. PKG_CHECK_MODULES([QT_DBUS], [${QT_LIB_PREFIX}DBus], [QT_DBUS_INCLUDES="$QT_DBUS_CFLAGS"; have_qt_dbus=yes], [have_qt_dbus=no])
  399. fi
  400. ])
  401. ])
  402. true; dnl
  403. ])
  404. dnl Internal. Find Qt libraries without using pkg-config. Version is deduced
  405. dnl from the discovered headers.
  406. dnl Inputs: starwels_qt_want_version (from --with-gui=). The version to use.
  407. dnl If "auto", the version will be discovered by _STARWELS_QT_CHECK_QT5.
  408. dnl Outputs: All necessary QT_* variables are set.
  409. dnl Outputs: starwels_qt_got_major_vers is set to "4" or "5".
  410. dnl Outputs: have_qt_test and have_qt_dbus are set (if applicable) to yes|no.
  411. AC_DEFUN([_STARWELS_QT_FIND_LIBS_WITHOUT_PKGCONFIG],[
  412. TEMP_CPPFLAGS="$CPPFLAGS"
  413. TEMP_CXXFLAGS="$CXXFLAGS"
  414. CXXFLAGS="$PIC_FLAGS $CXXFLAGS"
  415. TEMP_LIBS="$LIBS"
  416. STARWELS_QT_CHECK([
  417. if test x$qt_include_path != x; then
  418. QT_INCLUDES="-I$qt_include_path -I$qt_include_path/QtCore -I$qt_include_path/QtGui -I$qt_include_path/QtWidgets -I$qt_include_path/QtNetwork -I$qt_include_path/QtTest -I$qt_include_path/QtDBus"
  419. CPPFLAGS="$QT_INCLUDES $CPPFLAGS"
  420. fi
  421. ])
  422. STARWELS_QT_CHECK([AC_CHECK_HEADER([QtPlugin],,STARWELS_QT_FAIL(QtCore headers missing))])
  423. STARWELS_QT_CHECK([AC_CHECK_HEADER([QApplication],, STARWELS_QT_FAIL(QtGui headers missing))])
  424. STARWELS_QT_CHECK([AC_CHECK_HEADER([QLocalSocket],, STARWELS_QT_FAIL(QtNetwork headers missing))])
  425. STARWELS_QT_CHECK([
  426. if test x$starwels_qt_want_version = xauto; then
  427. _STARWELS_QT_CHECK_QT5
  428. fi
  429. if test x$starwels_cv_qt5 = xyes || test x$starwels_qt_want_version = xqt5; then
  430. QT_LIB_PREFIX=Qt5
  431. starwels_qt_got_major_vers=5
  432. else
  433. QT_LIB_PREFIX=Qt
  434. starwels_qt_got_major_vers=4
  435. fi
  436. ])
  437. STARWELS_QT_CHECK([
  438. LIBS=
  439. if test x$qt_lib_path != x; then
  440. LIBS="$LIBS -L$qt_lib_path"
  441. fi
  442. if test x$TARGET_OS = xwindows; then
  443. AC_CHECK_LIB([imm32], [main],, STARWELS_QT_FAIL(libimm32 not found))
  444. fi
  445. ])
  446. STARWELS_QT_CHECK(AC_CHECK_LIB([z] ,[main],,AC_MSG_WARN([zlib not found. Assuming qt has it built-in])))
  447. STARWELS_QT_CHECK(AC_SEARCH_LIBS([png_error] ,[qtpng png],,AC_MSG_WARN([libpng not found. Assuming qt has it built-in])))
  448. STARWELS_QT_CHECK(AC_SEARCH_LIBS([jpeg_create_decompress] ,[qtjpeg jpeg],,AC_MSG_WARN([libjpeg not found. Assuming qt has it built-in])))
  449. STARWELS_QT_CHECK(AC_SEARCH_LIBS([pcre16_exec], [qtpcre pcre16],,AC_MSG_WARN([libpcre16 not found. Assuming qt has it built-in])))
  450. STARWELS_QT_CHECK(AC_SEARCH_LIBS([hb_ot_tags_from_script] ,[qtharfbuzzng harfbuzz],,AC_MSG_WARN([libharfbuzz not found. Assuming qt has it built-in or support is disabled])))
  451. STARWELS_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Core] ,[main],,STARWELS_QT_FAIL(lib$QT_LIB_PREFIXCore not found)))
  452. STARWELS_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Gui] ,[main],,STARWELS_QT_FAIL(lib$QT_LIB_PREFIXGui not found)))
  453. STARWELS_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Network],[main],,STARWELS_QT_FAIL(lib$QT_LIB_PREFIXNetwork not found)))
  454. if test x$starwels_qt_got_major_vers = x5; then
  455. STARWELS_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Widgets],[main],,STARWELS_QT_FAIL(lib$QT_LIB_PREFIXWidgets not found)))
  456. fi
  457. QT_LIBS="$LIBS"
  458. LIBS="$TEMP_LIBS"
  459. STARWELS_QT_CHECK([
  460. LIBS=
  461. if test x$qt_lib_path != x; then
  462. LIBS="-L$qt_lib_path"
  463. fi
  464. AC_CHECK_LIB([${QT_LIB_PREFIX}Test], [main],, have_qt_test=no)
  465. AC_CHECK_HEADER([QTest],, have_qt_test=no)
  466. QT_TEST_LIBS="$LIBS"
  467. if test x$use_dbus != xno; then
  468. LIBS=
  469. if test x$qt_lib_path != x; then
  470. LIBS="-L$qt_lib_path"
  471. fi
  472. AC_CHECK_LIB([${QT_LIB_PREFIX}DBus], [main],, have_qt_dbus=no)
  473. AC_CHECK_HEADER([QtDBus],, have_qt_dbus=no)
  474. QT_DBUS_LIBS="$LIBS"
  475. fi
  476. ])
  477. CPPFLAGS="$TEMP_CPPFLAGS"
  478. CXXFLAGS="$TEMP_CXXFLAGS"
  479. LIBS="$TEMP_LIBS"
  480. ])