C++ Library containing a lot of needful things: Stack Trace, Command Line Parser, Resource Handling, Configuration Files, Unix Command Execution, Directories, Regular Expressions, Tokenizer, Function Trace, Standard Extensions.
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.

ax_check_qt.m4 9.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. # SYNOPSIS
  2. #
  3. # Check if a module exists:
  4. # AX_CHECK_QT([qt_prefix], [list-of-qt-modules], [optional-modules] [flags])
  5. #
  6. # Abort if a module does not exist:
  7. # AX_REQUIRE_QT([qt_prefix], [list-of-qt-modules], [optional-modules] [flags])
  8. #
  9. # DESCRIPTIONS
  10. #
  11. # qt_prefix
  12. #
  13. # Each call to AX_CHECK_QT should have a different prefix
  14. # value (with a few exceptions discussed later on). This value,
  15. # usually provided in uppercase, is used as prefix to the
  16. # variables holding the compiler flags and libraries reported by
  17. # pkg-config.
  18. #
  19. # For instance, if your prefix was to be FOO you'll be provided
  20. # two variables FOO_CFLAGS and FOO_LIBS.
  21. #
  22. # This will also be used as message during the configure checks:
  23. # checking for FOO....
  24. #
  25. # list-of-modules
  26. #
  27. # A single call to the macro can check for the presence of one or
  28. # more qt modules; you'll see later how to make good use of this
  29. # feature. Each entry in the list can have a version comparison
  30. # specifier, with the same syntax as the Requires keyword in the
  31. # data files themselves.
  32. #
  33. # optional-modules
  34. #
  35. # Optional list of more, optional modules, e.g. modules that
  36. # exist only in Qt5, but not in Qt4, such as QtWidgets or
  37. # QtWebKitWidgets
  38. #
  39. # flags
  40. #
  41. # Optional flages, space separated from this list:
  42. #
  43. # manualflags
  44. #
  45. # CXXFLAGS, CPPFLAGS and LIBS variables are not
  46. # automatically expanded, but you need to add the
  47. # qt_prefix_CXXFLAGS, qt_prefix_CPPFLAGS and qt_prefix_LIBS
  48. # variables manually where you need them. This is useful,
  49. # if some build targets need a feature and some don't.
  50. AC_DEFUN([AX_CXX_QT_TOOL], [
  51. PKG_PROG_PKG_CONFIG
  52. if test -z "${HAVE_$1}"; then
  53. HAVE_$1=1
  54. AC_MSG_CHECKING([for $2])
  55. AC_ARG_VAR([$1], [path to Qt tool $2])
  56. for package in Qt5Core QtCore; do
  57. if test -x "${$1}"; then
  58. break
  59. fi
  60. tool=$(${PKG_CONFIG} --variable=$2_location $package 2> /dev/null)
  61. if test -x "${tool}"; then
  62. $1="${tool}"
  63. break
  64. fi
  65. tool=$(${PKG_CONFIG} --variable=host_bins $package 2> /dev/null)
  66. if test -n "$tool"; then
  67. for name in $2 $2-qt5 $2-qt4; do
  68. if test -x "${tool}/${name}"; then
  69. $1="${tool}/${name}"
  70. break
  71. fi
  72. done
  73. fi
  74. done
  75. if ! test -x "${$1}"; then
  76. if which "$2" > /dev/null; then
  77. $1=$2
  78. elif which "$2-qt5" > /dev/null; then
  79. $1=$2-qt5
  80. elif which "$2" > /dev/null; then
  81. $1=$2
  82. elif which "$2-qt4" > /dev/null; then
  83. $1=$2-qt4
  84. else
  85. HAVE_$1=0
  86. unset $1
  87. fi
  88. fi
  89. AC_SUBST($1)
  90. AM_CONDITIONAL(HAVE_$1, test $HAVE_[$1] -eq 1)
  91. if test $HAVE_$1 -eq 1; then
  92. AC_MSG_RESULT([$$1])
  93. else
  94. AC_MSG_RESULT([not found])
  95. fi
  96. fi
  97. ])
  98. AC_DEFUN([AX_CXX_QT_TOOLS], [
  99. AX_CXX_QT_TOOL(QMAKE, qmake)
  100. AX_CXX_QT_TOOL(MOC, moc)
  101. AX_CXX_QT_TOOL(UIC, uic)
  102. AX_CXX_QT_TOOL(RCC, rcc)
  103. AX_CXX_QT_TOOL(LUPDATE, lupdate)
  104. AX_CXX_QT_TOOL(LRELEASE, lrelease)
  105. ])
  106. AC_DEFUN([AX_CHECK_QT], [
  107. qt_modules="$2"
  108. qt_modules_optional="$3"
  109. qt_flags="$4"
  110. AX_CXX_QT_TOOLS
  111. HAVE_$1=0
  112. PKG_PROG_PKG_CONFIG
  113. PKG_CHECK_MODULES([$1]5, [${qt_modules//Qt/Qt5}], [
  114. HAVE_$1=1
  115. AC_DEFINE([HAVE_$1])
  116. QTDIR=$(${PKG_CONFIG} --variable=prefix Qt5Core)
  117. qt_host_bins=$(${PKG_CONFIG} --variable=host_bins Qt5Core)
  118. qt_libdir=$(${PKG_CONFIG} --variable=libdir Qt5Core)
  119. if test -d "${qt_libdir}" -a -d "${qt_libdir}/plugins"; then
  120. QT_PLUGIN_PATH="${qt_libdir}/plugins"
  121. elif test -d "${qt_libdir}/qt5" -a -d "${qt_libdir}/qt5/plugins"; then
  122. QT_PLUGIN_PATH="${qt_libdir}/qt5/plugins"
  123. elif test -d "${qt_host_bins}" -a -d "${qt_host_bins}/../plugins"; then
  124. QT_PLUGIN_PATH="${qt_host_bins}/../plugins"
  125. elif test -d "${QTDIR}/plugins; then
  126. QT_PLUGIN_PATH="${QTDIR}/plugins"
  127. elif test -d "${QTDIR}/share/qt5/plugins; then
  128. QT_PLUGIN_PATH="${QTDIR}/share/qt5/plugins"
  129. fi
  130. MOC_FLAGS+=" -DHAVE_$1=1 ${[$1]5_CFLAGS}"
  131. [$1]_CPPFLAGS="${[$1]5_CFLAGS}"
  132. [$1]_CXXFLAGS="${[$1]5_CFLAGS}"
  133. [$1]_LIBS="${[$1]5_LIBS}"
  134. AC_SUBST([$1]_CPPFLAGS)
  135. AC_SUBST([$1]_CXXFLAGS)
  136. if test "${qt_flags/manualflags/}" = "${qt_flags}"; then
  137. CPPFLAGS+=" ${[$1]_CPPFLAGS}"
  138. CXXFLAGS+=" ${[$1]_CXXFLAGS}"
  139. LIBS+=" ${[$1]_LIBS}"
  140. AC_MSG_NOTICE([Adding flags for $1])
  141. else
  142. AC_MSG_NOTICE([To enable $1, add $1_CPPFLAGS, $1_CXXFLAGS and $1_LIBS])
  143. fi
  144. PKG_REQUIREMENTS+=" ${qt_modules//Qt/Qt5}"
  145. if test -n "${qt_modules_optional}"; then
  146. PKG_CHECK_MODULES([$1]5_OPTIONAL, [${qt_modules_optional//Qt/Qt5}], [
  147. MOC_FLAGS+=" ${[$1]5_OPTIONAL_CFLAGS}"
  148. [$1]_CPPFLAGS+=" ${[$1]5_OPTIONAL_CFLAGS}"
  149. [$1]_CXXFLAGS+=" ${[$1]5_OPTIONAL_CFLAGS}"
  150. [$1]_LIBS+=" ${[$1]5_OPTIONAL_LIBS}"
  151. AC_SUBST([$1]_CPPFLAGS)
  152. AC_SUBST([$1]_CXXFLAGS)
  153. if test "${qt_flags/manualflags/}" = "${qt_flags}"; then
  154. CPPFLAGS+=" ${[$1]5_OPTIONAL_CFLAGS}"
  155. CXXFLAGS+=" ${[$1]5_OPTIONAL_CFLAGS}"
  156. LIBS+=" ${[$1]5_OPTIONAL_LIBS}"
  157. AC_MSG_NOTICE([Adding flags for $1])
  158. else
  159. AC_MSG_NOTICE([To enable $1, add $1_CPPFLAGS, $1_CXXFLAGS and $1_LIBS])
  160. fi
  161. PKG_REQUIREMENTS+=" ${qt_modules_optional//Qt/Qt5}"
  162. ], [
  163. AC_MSG_NOTICE([Not found: ${qt_modules_optional//Qt/Qt5}])
  164. ])
  165. fi
  166. ], [
  167. PKG_CHECK_MODULES([$1], [${qt_modules}], [
  168. HAVE_$1=1
  169. AC_DEFINE([HAVE_$1])
  170. QTDIR=$(${PKG_CONFIG} --variable=prefix QtCore)
  171. qt_host_bins=$(${PKG_CONFIG} --variable=host_bins QtCore)
  172. qt_libdir=$(${PKG_CONFIG} --variable=libdir QtCore)
  173. if test -d "${qt_libdir}" -a -d "${qt_libdir}/plugins"; then
  174. QT_PLUGIN_PATH="${qt_libdir}/plugins"
  175. elif test -d "${qt_libdir}/qt5" -a -d "${qt_libdir}/qt5/plugins"; then
  176. QT_PLUGIN_PATH="${qt_libdir}/qt5/plugins"
  177. elif test -d "${qt_host_bins}" -a -d "${qt_host_bins}/../plugins"; then
  178. QT_PLUGIN_PATH="${qt_host_bins}/../plugins"
  179. elif test -d "${QTDIR}/plugins; then
  180. QT_PLUGIN_PATH="${QTDIR}/plugins"
  181. elif test -d "${QTDIR}/share/qt5/plugins; then
  182. QT_PLUGIN_PATH="${QTDIR}/share/qt5/plugins"
  183. fi
  184. MOC_FLAGS+=" -DHAVE_$1=1 ${$1_CFLAGS}"
  185. [$1]_CPPFLAGS="${[$1]_CFLAGS}"
  186. [$1]_CXXFLAGS="${[$1]_CFLAGS}"
  187. AC_SUBST([$1]_CPPFLAGS)
  188. AC_SUBST([$1]_CXXFLAGS)
  189. if test "${qt_flags/manualflags/}" = "${qt_flags}"; then
  190. CPPFLAGS+=" ${[$1]_CPPFLAGS}"
  191. CXXFLAGS+=" ${[$1]_CXXFLAGS}"
  192. LIBS+=" ${[$1]_LIBS}"
  193. AC_MSG_NOTICE([Adding flags for $1])
  194. else
  195. AC_MSG_NOTICE([To enable $1, add $1_CPPFLAGS, $1_CXXFLAGS and $1_LIBS])
  196. fi
  197. PKG_REQUIREMENTS+=" ${qt_modules}"
  198. if test -n "$3"; then
  199. PKG_CHECK_MODULES($1_OPTIONAL, [${qt_modules_optional}], [
  200. MOC_FLAGS+="${$1_OPTIONAL_CFLAGS}"
  201. [$1]_CPPFLAGS+=" ${$1_OPTIONAL_CFLAGS}"
  202. [$1]_CXXFLAGS+=" ${$1_OPTIONAL_CFLAGS}"
  203. [$1]_LIBS+=" ${$1_OPTIONAL_LIBS}"
  204. AC_SUBST([$1]_CPPFLAGS)
  205. AC_SUBST([$1]_CXXFLAGS)
  206. if test "${qt_flags/manualflags/}" = "${qt_flags}"; then
  207. CPPFLAGS+=" ${$1_OPTIONAL_CFLAGS}"
  208. CXXFLAGS+=" ${$1_OPTIONAL_CFLAGS}"
  209. LIBS+=" ${$1_OPTIONAL_LIBS}"
  210. AC_MSG_NOTICE([Adding flags for $1])
  211. else
  212. AC_MSG_NOTICE([To enable $1, add $1_CPPFLAGS, $1_CXXFLAGS and $1_LIBS])
  213. fi
  214. PKG_REQUIREMENTS+=" ${qt_modules_optional}"
  215. ], [
  216. AC_MSG_NOTICE([Not found: ${qt_modules_optional}])
  217. ])
  218. fi
  219. ], [HAVE_$1=0])
  220. ])
  221. AM_CONDITIONAL(HAVE_$1, test $HAVE_[$1] -eq 1)
  222. AX_CHECK_VALID_CXX_FLAG([-fPIC -fPIE], [position independent code flag])
  223. if test -n "${MINGW}"; then
  224. AX_CHECK_VALID_CXX_FLAG([-Wl,-subsystem,windows], [windows console flag])
  225. fi
  226. test "x$prefix" = xNONE && prefix=$ac_default_prefix
  227. AC_ARG_WITH([qt-plugin-path],
  228. [AS_HELP_STRING([--with-qt-plugin-path=PATH],
  229. [define a different qt plugin path, current @<:@default=check@:>@])],
  230. [QT_PLUGIN_PATH=$with_qt_plugin_path],
  231. [])
  232. AC_MSG_NOTICE([Qt Plugins are installed to ${QT_PLUGIN_PATH}])
  233. AC_SUBST(QTDIR)
  234. AC_SUBST(QT_PLUGIN_PATH)
  235. AC_SUBST(CPPFLAGS)
  236. AC_SUBST(MOC_FLAGS)
  237. AC_SUBST(CXXFLAGS)
  238. AC_SUBST(PKG_REQUIREMENTS)
  239. AX_ADDITIONAL_QT_RULES_HACK='
  240. #### Begin: Appended by $0
  241. LANGUAGE_FILE_BASE ?= translations
  242. ui_%.hxx: %.ui
  243. $(UIC) -o [$][@] $<
  244. moc_%.cxx: %.hxx
  245. $(MOC) $(MOC_FLAGS) -o [$][@] $<
  246. qrc_%.cxx: %.qrc
  247. $(RCC) -o [$][@] -name ${<:%.qrc=%} $<
  248. #%.qrc: %
  249. # cwd=$$(pwd) && cd $< && $(RCC) -project -o $${cwd}/[$][@]
  250. %.qm: %.ts
  251. ${LRELEASE} $< -qm [$][@]
  252. %.ts: ${LANGUAGE_FILES}
  253. ${LUPDATE} -no-obsolete \
  254. -target-language [$]{@:${LANGUAGE_FILE_BASE}_%.ts=%} \
  255. [$][^] \
  256. -ts [$][@]
  257. #### End: $0
  258. '
  259. ])
  260. AC_DEFUN([AX_REQUIRE_QT], [
  261. AX_CHECK_QT([$1], [$2], [$3], [$4])
  262. if ! test "$HAVE_$1" -eq 1; then
  263. AC_MSG_ERROR([Required Qt modules not found: $2])
  264. fi
  265. ])
  266. # Omit Qt Keywords
  267. # AX_QT_NO_KEYWORDS
  268. AC_DEFUN([AX_QT_NO_KEYWORDS], [
  269. CPPFLAGS+=" -DQT_NO_KEYWORDS"
  270. ])
  271. AC_DEFUN([AX_INIT_QT], [
  272. if test -n "${AX_ADDITIONAL_QT_RULES_HACK}"; then
  273. for f in $(find test examples src -name makefile.in); do
  274. test -f "$f" && cat >> "$f" <<EOF
  275. ${AX_ADDITIONAL_QT_RULES_HACK}
  276. EOF
  277. done
  278. fi
  279. ])