diff --git a/ax_check_qt.m4 b/ax_check_qt.m4 new file mode 100644 index 0000000..26d9b4e --- /dev/null +++ b/ax_check_qt.m4 @@ -0,0 +1,72 @@ +# SYNOPSIS +# +# AX_CXX_CHECK_QT([qt_prefix], [list-of-qt-modules]) +# +# DESCRIPTIONS +# +# qt_prefix +# +# Each call to AX_CXX_CHECK_QT should have a different prefix +# value (with a few exceptions discussed later on). This value, +# usually provided in uppercase, is used as prefix to the +# variables holding the compiler flags and libraries reported by +# pkg-config. +# +# For instance, if your prefix was to be FOO you'll be provided +# two variables FOO_CFLAGS and FOO_LIBS. +# +# This will also be used as message during the configure checks: +# checking for FOO.... +# +# list-of-modules +# +# A single call to the macro can check for the presence of one or +# more qt modules; you'll see later how to make good use of this +# feature. Each entry in the list can have a version comparison +# specifier, with the same syntax as the Requires keyword in the +# data files themselves. + +AC_DEFUN([AX_CXX_QT_TOOL], [ + AC_ARG_VAR([$1], [path to Qt tool $2]) + $1=${$1:-$(pkg-config --variable=$2_location Qt5Core)} + $1=${$1:-$(pkg-config --variable=host_bins Qt5Core)/$2} + $1=${$1:-$(pkg-config --variable=$2_location QtCore)} + $1=${$1:-$(pkg-config --variable=host_bins QtCore)/$2} + if ! which "$$1" > /dev/null; then + if which "$2" > /dev/null; then + $1=$2 + else + if test -n "$$1"; then + AC_MSG_ERROR([Missing Qt program: $2 (tested: $$1)]) + else + AC_MSG_ERROR([Missing Qt program: $2 (specify variable $1)]) + fi + fi + fi + AC_SUBST($1) + AC_MSG_NOTICE([using $$1 for $2]) +]) + +AC_DEFUN([AX_CXX_QT_TOOLS], [ + AX_CXX_QT_TOOL(MOC, moc) + AX_CXX_QT_TOOL(UIC, uic) + AX_CXX_QT_TOOL(RCC, rcc) + AX_CXX_QT_TOOL(LUPDATE, lupdate) + AX_CXX_QT_TOOL(LRELEASE, lrelease) +]) + +AC_DEFUN([AX_CXX_CHECK_QT], [ + qt_modules="$2" + AX_CXX_QT_TOOLS + HAVE_$1=0 + PKG_CHECK_MODULES([$1], [${qt_modules//Qt/Qt5}], [ + HAVE_$1=1 + AC_DEFINE([HAVE_$1]) + ], [ + PKG_CHECK_MODULES([$1], [${qt_modules}], [ + HAVE_$1=1 + AC_DEFINE([HAVE_$1]) + ]) + ]) + AM_CONDITIONAL(HAVE_$1, test $HAVE_$1 -eq 1) +]) diff --git a/configure.in b/configure.in index 935e2e4..f325714 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,6 @@ # $Id$ m4_include(ax_cxx_compile_stdcxx_11.m4) +m4_include(ax_check_qt.m4) AC_ALIAS([AC_DEFINE_DIR], [AX_DEFINE_DIR]) AC_DEFUN([AX_DEFINE_DIR], [ prefix_NONE= @@ -108,49 +109,7 @@ case $host in have_proxy=1]) ;; esac -PKG_CHECK_MODULES([QT], [Qt5Core Qt5Gui Qt5Widgets Qt5Network], - [AC_DEFINE([HAVE_QT]) - UIC=${UIC:-$(pkg-config --variable=uic_location Qt5Core)} - MOC=${MOC:-$(pkg-config --variable=moc_location Qt5Core)} - RCC=${RCC:-$(pkg-config --variable=rcc_location Qt5Core)} - LUPDATE=${LUPDATE:-$(pkg-config --variable=lupdate_location Qt5Core)} - LRELEASE=${LRELEASE:-$(pkg-config --variable=lrelease_location Qt5Core)} - CPPFLAGS+=" -DQT_NETWORK_LIB ${QT_CFLAGS}" - LIBS+=" ${QT_LIBS}" - have_qt=1], - [PKG_CHECK_MODULES([QT], [QtCore QtGui QtNetwork], - [AC_DEFINE([HAVE_QT]) - UIC=${UIC:-$(pkg-config --variable=uic_location QtCore)} - MOC=${MOC:-$(pkg-config --variable=moc_location QtCore)} - RCC=${RCC:-$(pkg-config --variable=rcc_location QtCore)} - LUPDATE=${LUPDATE:-$(pkg-config --variable=lupdate_location QtCore)} - LRELEASE=${LRELEASE:-$(pkg-config --variable=lrelease_location QtCore)} - CPPFLAGS+=" -DQT_NETWORK_LIB ${QT_CFLAGS}" - LIBS+=" ${QT_LIBS}" - have_qt=1], - [have_qt=0])]) -AM_CONDITIONAL(HAVE_QT, test "$have_qt" = "1") -if test "$have_qt" = "1" \ - && ! which "$UIC" "$MOC" "$RCC" "$LUPDATE" "$LRELEASE"; then - if test -n "$MOC" \ - && which "${UIC:=${MOC/moc/uic}}" "${RCC:=${MOC/moc/rcc}}" \ - "${LUPDATE:=${MOC/moc/lupdate}}" \ - "${LRELEASE:=${MOC/moc/lrelease}}"; then - AC_MSG_NOTICE([Detected: "$UIC" "$MOC" "$RCC" "$LUPDATE" "$LRELEASE"]) - else - AC_MSG_ERROR([Missing QT Programs. - - Needed: uic moc rcc lupdate lrelease - - Found: $UIC $MOC $RCC $LUPDATE $LRELEASE -You can specify the missing programs by passing one of the variables: - \$UIC \$MOC \$RCC \$LUPDATE \$LRELEASE -Often it is sufficient to specify MOC=/path/to/moc ./configure)]) - fi -fi -AC_SUBST(UIC) -AC_SUBST(MOC) -AC_SUBST(RCC) -AC_SUBST(LUPDATE) -AC_SUBST(LRELEASE) +AX_CXX_CHECK_QT([QT], [Qt5Core Qt5Gui Qt5Widgets Qt5Network]) AC_ARG_VAR(LUPDATE_ARGS, [arguments for qt lupdate command, e.g. -no-obsolete]) AC_ARG_ENABLE(pedantic,