1
2AC_DEFUN([SV_MODULE_REQUIRED],
3[
4SV_MODULE_MODULE=$1
5SV_MODULE_VERSION_TEST="$2"
6SV_MODULE_HEADER=$3
7SV_MODULE_LIB=$4
8SV_MODULE_FUNC=$5
9SV_MODULE_HAVE=HAVE_$(echo $1 | tr '[a-z]' '[A-Z]')
10SV_MODULE_FAILED=1
11if test -n "$$1_LIBS" ; then
12   AC_MSG_NOTICE([User set ${SV_MODULE_MODULE}_LIBS explicitly, skipping test for $SV_MODULE_MODULE])
13   CXXFLAGS="$CXXFLAGS $$1_CFLAGS"
14   LIBS="$LIBS $$1_LIBS"
15   SV_MODULE_FAILED=""
16fi
17if test -z "$SV_MODULE_VERSION_TEST" ; then
18   SV_MODULE_VERSION_TEST=$SV_MODULE_MODULE
19fi
20if test -n "$SV_MODULE_FAILED" && test -n "$PKG_CONFIG"; then
21   PKG_CHECK_MODULES($1,[$SV_MODULE_VERSION_TEST],[HAVES="$HAVES $SV_MODULE_HAVE";CXXFLAGS="$CXXFLAGS $$1_CFLAGS";LIBS="$LIBS $$1_LIBS";SV_MODULE_FAILED=""],[AC_MSG_NOTICE([Failed to find required module $SV_MODULE_MODULE using pkg-config, trying again by old-fashioned means])])
22fi
23if test -n "$SV_MODULE_FAILED"; then
24   AC_CHECK_HEADER([$SV_MODULE_HEADER],[HAVES="$HAVES $SV_MODULE_HAVE"],[AC_MSG_ERROR([Failed to find header $SV_MODULE_HEADER for required module $SV_MODULE_MODULE])])
25   if test -n "$SV_MODULE_LIB"; then
26     AC_CHECK_LIB([$SV_MODULE_LIB],[$SV_MODULE_FUNC],[LIBS="$LIBS -l$SV_MODULE_LIB"],[AC_MSG_ERROR([Failed to find library $SV_MODULE_LIB for required module $SV_MODULE_MODULE])])
27   fi
28fi
29])
30
31AC_DEFUN([SV_MODULE_OPTIONAL],
32[
33AC_ARG_WITH([$4],
34            [AS_HELP_STRING([--with-$4],
35                            [Enable support for $1 [default=no]])],
36            [],
37            [with_$4=no])
38AS_IF([test "x$with_$4" = xyes], [SV_MODULE_REQUIRED($1,$2,$3,$4,$5)])
39])
40
41# Check for Qt.  The only part of Qt we use directly is qmake.
42
43AC_DEFUN([SV_CHECK_QT],
44[
45AC_REQUIRE([AC_PROG_CXX])
46
47if test x$QMAKE = x ; then
48   	AC_CHECK_PROG(QMAKE, qmake-qt5, $QTDIR/bin/qmake-qt5,,$QTDIR/bin/)
49fi
50if test x$QMAKE = x ; then
51   	AC_CHECK_PROG(QMAKE, qt5-qmake, $QTDIR/bin/qt5-qmake,,$QTDIR/bin/)
52fi
53if test x$QMAKE = x ; then
54   	AC_CHECK_PROG(QMAKE, qmake, $QTDIR/bin/qmake,,$QTDIR/bin/)
55fi
56if test x$QMAKE = x ; then
57	AC_CHECK_PROG(QMAKE, qmake.exe, $QTDIR/bin/qmake.exe,,$QTDIR/bin/)
58fi
59if test x$QMAKE = x ; then
60   	AC_CHECK_PROG(QMAKE, qmake-qt5, qmake-qt5,,$PATH)
61fi
62if test x$QMAKE = x ; then
63   	AC_CHECK_PROG(QMAKE, qt5-qmake, qt5-qmake,,$PATH)
64fi
65if test x$QMAKE = x ; then
66   	AC_CHECK_PROG(QMAKE, qmake, qmake,,$PATH)
67fi
68if test x$QMAKE = x ; then
69   	AC_MSG_ERROR([
70Failed to find the required qmake-qt5 or qmake program.  Please
71ensure you have the necessary Qt5 development files installed, and
72if necessary set QTDIR to the location of your Qt5 installation.
73])
74fi
75
76# Suitable versions of qmake should print out something like:
77#
78#   QMake version 2.01a
79#   Using Qt version 4.6.3 in /usr/lib
80#
81# This may be translated, so we check only for the numbers (2.x and 4.x
82# in that order).
83#
84QMAKE_VERSION_OUTPUT=`$QMAKE -v`
85case "$QMAKE_VERSION_OUTPUT" in
86     *5.*) ;;
87     *) AC_MSG_WARN([
88 *** The version of qmake found in "$QMAKE" looks like it might be
89     from the wrong version of Qt (Qt5 is required).  Please check
90     that this is the correct version of qmake for Qt5 builds.
91])
92esac
93
94case "`uname`" in
95     *Darwin*) QMAKE="$QMAKE -spec macx-g++";;
96esac
97
98])
99
100# From autoconf archive:
101
102# ============================================================================
103#  http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
104# ============================================================================
105#
106# SYNOPSIS
107#
108#   AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional])
109#
110# DESCRIPTION
111#
112#   Check for baseline language coverage in the compiler for the C++11
113#   standard; if necessary, add switches to CXXFLAGS to enable support.
114#
115#   The first argument, if specified, indicates whether you insist on an
116#   extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
117#   -std=c++11).  If neither is specified, you get whatever works, with
118#   preference for an extended mode.
119#
120#   The second argument, if specified 'mandatory' or if left unspecified,
121#   indicates that baseline C++11 support is required and that the macro
122#   should error out if no mode with that support is found.  If specified
123#   'optional', then configuration proceeds regardless, after defining
124#   HAVE_CXX11 if and only if a supporting mode is found.
125#
126# LICENSE
127#
128#   Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
129#   Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
130#   Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
131#   Copyright (c) 2014 Alexey Sokolov <sokolov@google.com>
132#
133#   Copying and distribution of this file, with or without modification, are
134#   permitted in any medium without royalty provided the copyright notice
135#   and this notice are preserved. This file is offered as-is, without any
136#   warranty.
137
138m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [[
139  template <typename T>
140    struct check
141    {
142      static_assert(sizeof(int) <= sizeof(T), "not big enough");
143    };
144
145    struct Base {
146    virtual void f() {}
147    };
148    struct Child : public Base {
149    virtual void f() override {}
150    };
151
152    typedef check<check<bool>> right_angle_brackets;
153
154    int a;
155    decltype(a) b;
156
157    typedef check<int> check_type;
158    check_type c;
159    check_type&& cr = static_cast<check_type&&>(c);
160
161    auto d = a;
162    auto l = [](){};
163]])
164
165AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
166  m4_if([$1], [], [],
167        [$1], [ext], [],
168        [$1], [noext], [],
169        [m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl
170  m4_if([$2], [], [ax_cxx_compile_cxx11_required=true],
171        [$2], [mandatory], [ax_cxx_compile_cxx11_required=true],
172        [$2], [optional], [ax_cxx_compile_cxx11_required=false],
173        [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])
174  AC_LANG_PUSH([C++])dnl
175  ac_success=no
176  AC_CACHE_CHECK(whether $CXX supports C++11 features by default,
177  ax_cv_cxx_compile_cxx11,
178  [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
179    [ax_cv_cxx_compile_cxx11=yes],
180    [ax_cv_cxx_compile_cxx11=no])])
181  if test x$ax_cv_cxx_compile_cxx11 = xyes; then
182    ac_success=yes
183  fi
184
185  m4_if([$1], [noext], [], [dnl
186  if test x$ac_success = xno; then
187    for switch in -std=gnu++11 -std=gnu++0x; do
188      cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
189      AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
190                     $cachevar,
191        [ac_save_CXXFLAGS="$CXXFLAGS"
192         CXXFLAGS="$CXXFLAGS $switch"
193         AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
194          [eval $cachevar=yes],
195          [eval $cachevar=no])
196         CXXFLAGS="$ac_save_CXXFLAGS"])
197      if eval test x\$$cachevar = xyes; then
198        CXXFLAGS="$CXXFLAGS $switch"
199        ac_success=yes
200        break
201      fi
202    done
203  fi])
204
205  m4_if([$1], [ext], [], [dnl
206  if test x$ac_success = xno; then
207    for switch in -std=c++11 -std=c++0x; do
208      cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
209      AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
210                     $cachevar,
211        [ac_save_CXXFLAGS="$CXXFLAGS"
212         CXXFLAGS="$CXXFLAGS $switch"
213         AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
214          [eval $cachevar=yes],
215          [eval $cachevar=no])
216         CXXFLAGS="$ac_save_CXXFLAGS"])
217      if eval test x\$$cachevar = xyes; then
218        CXXFLAGS="$CXXFLAGS $switch"
219        ac_success=yes
220        break
221      fi
222    done
223  fi])
224  AC_LANG_POP([C++])
225  if test x$ax_cxx_compile_cxx11_required = xtrue; then
226    if test x$ac_success = xno; then
227      AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
228    fi
229  else
230    if test x$ac_success = xno; then
231      HAVE_CXX11=0
232      AC_MSG_NOTICE([No compiler with C++11 support was found])
233    else
234      HAVE_CXX11=1
235      AC_DEFINE(HAVE_CXX11,1,
236                [define if the compiler supports basic C++11 syntax])
237    fi
238
239    AC_SUBST(HAVE_CXX11)
240  fi
241])
242
243# ===========================================================================
244#  https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
245# ===========================================================================
246#
247# SYNOPSIS
248#
249#   AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
250#
251# DESCRIPTION
252#
253#   Check whether the given FLAG works with the current language's compiler
254#   or gives an error.  (Warnings, however, are ignored)
255#
256#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
257#   success/failure.
258#
259#   If EXTRA-FLAGS is defined, it is added to the current language's default
260#   flags (e.g. CFLAGS) when the check is done.  The check is thus made with
261#   the flags: "CFLAGS EXTRA-FLAGS FLAG".  This can for example be used to
262#   force the compiler to issue an error when a bad flag is given.
263#
264#   INPUT gives an alternative input source to AC_COMPILE_IFELSE.
265#
266#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
267#   macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
268#
269# LICENSE
270#
271#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
272#   Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
273#
274#   Copying and distribution of this file, with or without modification, are
275#   permitted in any medium without royalty provided the copyright notice
276#   and this notice are preserved.  This file is offered as-is, without any
277#   warranty.
278
279AC_DEFUN([AX_CHECK_COMPILE_FLAG],
280[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
281AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
282AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
283  ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
284  _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
285  AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
286    [AS_VAR_SET(CACHEVAR,[yes])],
287    [AS_VAR_SET(CACHEVAR,[no])])
288  _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
289AS_VAR_IF(CACHEVAR,yes,
290  [m4_default([$2], :)],
291  [m4_default([$3], :)])
292AS_VAR_POPDEF([CACHEVAR])dnl
293])dnl AX_CHECK_COMPILE_FLAGS
294