annotate acinclude.m4 @ 399:a3912193ce69 tip

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