Collection of DPF-based plugins for packaging
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.

210 lines
6.2KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_have_qt.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_HAVE_QT
  8. #
  9. # DESCRIPTION
  10. #
  11. # Searches $PATH and queries qmake for Qt include files, libraries and Qt
  12. # binary utilities. The macro only supports Qt5 or later.
  13. #
  14. # The following shell variable is set to either "yes" or "no":
  15. #
  16. # have_qt
  17. #
  18. # Additionally, the following variables are exported:
  19. #
  20. # QT_CXXFLAGS
  21. # QT_LIBS
  22. # QT_MOC
  23. # QT_UIC
  24. # QT_RCC
  25. # QT_LRELEASE
  26. # QT_LUPDATE
  27. # QT_DIR
  28. #
  29. # which respectively contain an "-I" flag pointing to the Qt include
  30. # directory, link flags necessary to link with Qt and X, the full path to
  31. # the meta object compiler and the user interface compiler both, and
  32. # finally the variable QTDIR as Qt likes to see it defined.
  33. #
  34. # Example lines for Makefile.in:
  35. #
  36. # CXXFLAGS = @QT_CXXFLAGS@
  37. # MOC = @QT_MOC@
  38. #
  39. # After the variables have been set, a trial compile and link is performed
  40. # to check the correct functioning of the meta object compiler. This test
  41. # may fail when the different detected elements stem from different
  42. # releases of the Qt framework. In that case, an error message is emitted
  43. # and configure stops.
  44. #
  45. # No common variables such as $LIBS or $CFLAGS are polluted.
  46. #
  47. # LICENSE
  48. #
  49. # Copyright (c) 2008 Bastiaan Veelo <Bastiaan@Veelo.net>
  50. # Copyright (c) 2014 Alex Henrie <alexhenrie24@gmail.com>
  51. #
  52. # Copying and distribution of this file, with or without modification, are
  53. # permitted in any medium without royalty provided the copyright notice
  54. # and this notice are preserved. This file is offered as-is, without any
  55. # warranty.
  56. #serial 17
  57. AU_ALIAS([BNV_HAVE_QT], [AX_HAVE_QT])
  58. AC_DEFUN([AX_HAVE_QT],
  59. [
  60. AC_REQUIRE([AC_PROG_CXX])
  61. AC_REQUIRE([AC_PATH_X])
  62. AC_REQUIRE([AC_PATH_XTRA])
  63. AC_MSG_CHECKING(for Qt)
  64. # If we have Qt5 or later in the path, we're golden
  65. ver=`qmake --version | grep -o "Qt version ."`
  66. if test "$ver" ">" "Qt version 4"; then
  67. have_qt=yes
  68. # This pro file dumps qmake's variables, but it only works on Qt 5 or later
  69. am_have_qt_dir=`mktemp -d`
  70. am_have_qt_pro="$am_have_qt_dir/test.pro"
  71. am_have_qt_makefile="$am_have_qt_dir/Makefile"
  72. # http://qt-project.org/doc/qt-5/qmake-variable-reference.html#qt
  73. cat > $am_have_qt_pro << EOF
  74. win32 {
  75. CONFIG -= debug_and_release
  76. CONFIG += release
  77. }
  78. qtHaveModule(gui): QT += gui
  79. qtHaveModule(opengl): QT += opengl
  80. percent.target = %
  81. percent.commands = @echo -n "\$(\$(@))\ "
  82. QMAKE_EXTRA_TARGETS += percent
  83. EOF
  84. qmake $am_have_qt_pro -o $am_have_qt_makefile
  85. QT_CXXFLAGS=`cd $am_have_qt_dir; make -s -f $am_have_qt_makefile CXXFLAGS INCPATH`
  86. QT_LIBS=`cd $am_have_qt_dir; make -s -f $am_have_qt_makefile LIBS`
  87. rm $am_have_qt_pro $am_have_qt_makefile
  88. rmdir $am_have_qt_dir
  89. # Look for specific tools in $PATH
  90. QT_MOC=`which moc`
  91. QT_UIC=`which uic`
  92. QT_RCC=`which rcc`
  93. QT_LRELEASE=`which lrelease`
  94. QT_LUPDATE=`which lupdate`
  95. # Get Qt version from qmake
  96. QT_DIR=`qmake --version | grep -o -E /.+`
  97. # All variables are defined, report the result
  98. AC_MSG_RESULT([$have_qt:
  99. QT_CXXFLAGS=$QT_CXXFLAGS
  100. QT_DIR=$QT_DIR
  101. QT_LIBS=$QT_LIBS
  102. QT_UIC=$QT_UIC
  103. QT_MOC=$QT_MOC
  104. QT_RCC=$QT_RCC
  105. QT_LRELEASE=$QT_LRELEASE
  106. QT_LUPDATE=$QT_LUPDATE])
  107. else
  108. # Qt was not found
  109. have_qt=no
  110. QT_CXXFLAGS=
  111. QT_DIR=
  112. QT_LIBS=
  113. QT_UIC=
  114. QT_MOC=
  115. QT_RCC=
  116. QT_LRELEASE=
  117. QT_LUPDATE=
  118. AC_MSG_RESULT($have_qt)
  119. fi
  120. AC_SUBST(QT_CXXFLAGS)
  121. AC_SUBST(QT_DIR)
  122. AC_SUBST(QT_LIBS)
  123. AC_SUBST(QT_UIC)
  124. AC_SUBST(QT_MOC)
  125. AC_SUBST(QT_RCC)
  126. AC_SUBST(QT_LRELEASE)
  127. AC_SUBST(QT_LUPDATE)
  128. #### Being paranoid:
  129. if test x"$have_qt" = xyes; then
  130. AC_MSG_CHECKING(correct functioning of Qt installation)
  131. AC_CACHE_VAL(ax_cv_qt_test_result,
  132. [
  133. cat > ax_qt_test.h << EOF
  134. #include <qobject.h>
  135. class Test : public QObject
  136. {
  137. Q_OBJECT
  138. public:
  139. Test() {}
  140. ~Test() {}
  141. public slots:
  142. void receive() {}
  143. signals:
  144. void send();
  145. };
  146. EOF
  147. cat > ax_qt_main.$ac_ext << EOF
  148. #include "ax_qt_test.h"
  149. #include <qapplication.h>
  150. int main( int argc, char **argv )
  151. {
  152. QApplication app( argc, argv );
  153. Test t;
  154. QObject::connect( &t, SIGNAL(send()), &t, SLOT(receive()) );
  155. }
  156. EOF
  157. ax_cv_qt_test_result="failure"
  158. ax_try_1="$QT_MOC ax_qt_test.h -o moc_ax_qt_test.$ac_ext >/dev/null 2>/dev/null"
  159. AC_TRY_EVAL(ax_try_1)
  160. if test x"$ac_status" != x0; then
  161. echo "$ax_err_1" >&AS_MESSAGE_LOG_FD
  162. echo "configure: could not run $QT_MOC on:" >&AS_MESSAGE_LOG_FD
  163. cat ax_qt_test.h >&AS_MESSAGE_LOG_FD
  164. else
  165. ax_try_2="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o moc_ax_qt_test.o moc_ax_qt_test.$ac_ext >/dev/null 2>/dev/null"
  166. AC_TRY_EVAL(ax_try_2)
  167. if test x"$ac_status" != x0; then
  168. echo "$ax_err_2" >&AS_MESSAGE_LOG_FD
  169. echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD
  170. cat moc_ax_qt_test.$ac_ext >&AS_MESSAGE_LOG_FD
  171. else
  172. ax_try_3="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o ax_qt_main.o ax_qt_main.$ac_ext >/dev/null 2>/dev/null"
  173. AC_TRY_EVAL(ax_try_3)
  174. if test x"$ac_status" != x0; then
  175. echo "$ax_err_3" >&AS_MESSAGE_LOG_FD
  176. echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD
  177. cat ax_qt_main.$ac_ext >&AS_MESSAGE_LOG_FD
  178. else
  179. ax_try_4="$CXX -o ax_qt_main ax_qt_main.o moc_ax_qt_test.o $QT_LIBS $LIBS >/dev/null 2>/dev/null"
  180. AC_TRY_EVAL(ax_try_4)
  181. if test x"$ac_status" != x0; then
  182. echo "$ax_err_4" >&AS_MESSAGE_LOG_FD
  183. else
  184. ax_cv_qt_test_result="success"
  185. fi
  186. fi
  187. fi
  188. fi
  189. ])dnl AC_CACHE_VAL ax_cv_qt_test_result
  190. AC_MSG_RESULT([$ax_cv_qt_test_result])
  191. if test x"$ax_cv_qt_test_result" = "xfailure"; then
  192. AC_MSG_ERROR([Failed to find matching components of a complete
  193. Qt installation. Try using more options,
  194. see ./configure --help.])
  195. fi
  196. rm -f ax_qt_test.h moc_ax_qt_test.$ac_ext moc_ax_qt_test.o \
  197. ax_qt_main.$ac_ext ax_qt_main.o ax_qt_main
  198. fi
  199. ])