-https://github.com/BrianAker/m4
+https://github.com/TangentOrg/ddm4
Common m4 files that I use.
-Brian Aker, brian@tangent.org
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_add_am_macro.html
+# https://www.gnu.org/software/autoconf-archive/ax_add_am_macro.html
# ===========================================================================
#
# SYNOPSIS
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 9
+#serial 10
AC_DEFUN([AX_ADD_AM_MACRO],[
AC_REQUIRE([AX_AM_MACROS])
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_am_jobserver.html
+# https://www.gnu.org/software/autoconf-archive/ax_am_jobserver.html
# ===========================================================================
#
# SYNOPSIS
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 7
+#serial 8
AC_DEFUN([AX_AM_JOBSERVER], [
AC_REQUIRE([AX_COUNT_CPUS])
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_am_macros.html
+# https://www.gnu.org/software/autoconf-archive/ax_am_macros.html
# ===========================================================================
#
# SYNOPSIS
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 9
+#serial 11
AC_DEFUN([AX_AM_MACROS],
[
AMINCLUDE="aminclude.am"
AC_SUBST(AMINCLUDE)
AC_MSG_NOTICE([creating $AMINCLUDE])
-AMINCLUDE_TIME=`date`
+AMINCLUDE_TIME=`LC_ALL=C date`
AX_PRINT_TO_FILE([$AMINCLUDE],[[
# generated automatically by configure from AX_AUTOMAKE_MACROS
# on $AMINCLUDE_TIME
-# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html
-# ===========================================================================
+# ============================================================================
+# https://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html
+# ============================================================================
#
# SYNOPSIS
#
-# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS])
+# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
+# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
+#
# NOTE: This macro depends on the AX_APPEND_FLAG and
# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with
# AX_APPEND_LINK_FLAGS.
#
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
-# This program is free software: you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation, either version 3 of the License, or (at your
-# option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# As a special exception, the respective Autoconf Macro's copyright owner
-# gives unlimited permission to copy, distribute and modify the configure
-# scripts that are the output of Autoconf when processing the Macro. You
-# need not follow the terms of the GNU General Public License when using
-# or distributing such scripts, even though portions of the text of the
-# Macro appear in them. The GNU General Public License (GPL) does govern
-# all other use of the material that constitutes the Autoconf Macro.
-#
-# This special exception to the GPL applies to versions of the Autoconf
-# Macro released by the Autoconf Archive. When you make and distribute a
-# modified version of the Autoconf Macro, you may extend this special
-# exception to the GPL to apply to your modified version as well.
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
-#serial 3
+#serial 7
AC_DEFUN([AX_APPEND_COMPILE_FLAGS],
-[AC_REQUIRE([AX_CHECK_COMPILE_FLAG])
-AC_REQUIRE([AX_APPEND_FLAG])
+[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
+AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
for flag in $1; do
- AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3])
+ AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3], [$4])
done
])dnl AX_APPEND_COMPILE_FLAGS
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html
+# https://www.gnu.org/software/autoconf-archive/ax_append_flag.html
# ===========================================================================
#
# SYNOPSIS
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
-# This program is free software: you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation, either version 3 of the License, or (at your
-# option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# As a special exception, the respective Autoconf Macro's copyright owner
-# gives unlimited permission to copy, distribute and modify the configure
-# scripts that are the output of Autoconf when processing the Macro. You
-# need not follow the terms of the GNU General Public License when using
-# or distributing such scripts, even though portions of the text of the
-# Macro appear in them. The GNU General Public License (GPL) does govern
-# all other use of the material that constitutes the Autoconf Macro.
-#
-# This special exception to the GPL applies to versions of the Autoconf
-# Macro released by the Autoconf Archive. When you make and distribute a
-# modified version of the Autoconf Macro, you may extend this special
-# exception to the GPL to apply to your modified version as well.
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
-#serial 2
+#serial 8
AC_DEFUN([AX_APPEND_FLAG],
-[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
-AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])dnl
-AS_VAR_SET_IF(FLAGS,
- [case " AS_VAR_GET(FLAGS) " in
- *" $1 "*)
- AC_RUN_LOG([: FLAGS already contains $1])
- ;;
- *)
- AC_RUN_LOG([: FLAGS="$FLAGS $1"])
- AS_VAR_SET(FLAGS, ["AS_VAR_GET(FLAGS) $1"])
- ;;
- esac],
- [AS_VAR_SET(FLAGS,["$1"])])
+[dnl
+AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
+AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
+AS_VAR_SET_IF(FLAGS,[
+ AS_CASE([" AS_VAR_GET(FLAGS) "],
+ [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
+ [
+ AS_VAR_APPEND(FLAGS,[" $1"])
+ AC_RUN_LOG([: FLAGS="$FLAGS"])
+ ])
+ ],
+ [
+ AS_VAR_SET(FLAGS,[$1])
+ AC_RUN_LOG([: FLAGS="$FLAGS"])
+ ])
AS_VAR_POPDEF([FLAGS])dnl
])dnl AX_APPEND_FLAG
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_append_link_flags.html
+# https://www.gnu.org/software/autoconf-archive/ax_append_link_flags.html
# ===========================================================================
#
# SYNOPSIS
#
-# AX_APPEND_LINK_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS])
+# AX_APPEND_LINK_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# EXTRA-FLAGS FLAG". This can for example be used to force the linker to
# issue an error when a bad flag is given.
#
+# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
+#
# NOTE: This macro depends on the AX_APPEND_FLAG and AX_CHECK_LINK_FLAG.
# Please keep this macro in sync with AX_APPEND_COMPILE_FLAGS.
#
#
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
-# This program is free software: you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation, either version 3 of the License, or (at your
-# option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# As a special exception, the respective Autoconf Macro's copyright owner
-# gives unlimited permission to copy, distribute and modify the configure
-# scripts that are the output of Autoconf when processing the Macro. You
-# need not follow the terms of the GNU General Public License when using
-# or distributing such scripts, even though portions of the text of the
-# Macro appear in them. The GNU General Public License (GPL) does govern
-# all other use of the material that constitutes the Autoconf Macro.
-#
-# This special exception to the GPL applies to versions of the Autoconf
-# Macro released by the Autoconf Archive. When you make and distribute a
-# modified version of the Autoconf Macro, you may extend this special
-# exception to the GPL to apply to your modified version as well.
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
-#serial 3
+#serial 7
AC_DEFUN([AX_APPEND_LINK_FLAGS],
-[AC_REQUIRE([AX_CHECK_LINK_FLAG])
-AC_REQUIRE([AX_APPEND_FLAG])
+[AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
+AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
for flag in $1; do
- AX_CHECK_LINK_FLAG([$flag], [AX_APPEND_FLAG([$flag], [m4_default([$2], [LDFLAGS])])], [], [$3])
+ AX_CHECK_LINK_FLAG([$flag], [AX_APPEND_FLAG([$flag], [m4_default([$2], [LDFLAGS])])], [], [$3], [$4])
done
])dnl AX_APPEND_LINK_FLAGS
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_append_to_file.html
+# https://www.gnu.org/software/autoconf-archive/ax_append_to_file.html
# ===========================================================================
#
# SYNOPSIS
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 8
+#serial 9
AC_DEFUN([AX_APPEND_TO_FILE],[
AC_REQUIRE([AX_FILE_ESCAPES])
-printf "$2\n" >> "$1"
+printf "%s" "$2" >> "$1"
])
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
+# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
# ===========================================================================
#
# SYNOPSIS
#
-# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS])
+# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
+# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
+#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
-# This program is free software: you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation, either version 3 of the License, or (at your
-# option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# As a special exception, the respective Autoconf Macro's copyright owner
-# gives unlimited permission to copy, distribute and modify the configure
-# scripts that are the output of Autoconf when processing the Macro. You
-# need not follow the terms of the GNU General Public License when using
-# or distributing such scripts, even though portions of the text of the
-# Macro appear in them. The GNU General Public License (GPL) does govern
-# all other use of the material that constitutes the Autoconf Macro.
-#
-# This special exception to the GPL applies to versions of the Autoconf
-# Macro released by the Autoconf Archive. When you make and distribute a
-# modified version of the Autoconf Macro, you may extend this special
-# exception to the GPL to apply to your modified version as well.
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
-#serial 2
+#serial 6
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
-[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
+[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+ AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
-AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
+AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
AS_IF([test "$]AS_TR_SH([ax_cv_have_]$1)[" = "yes"],
[AC_DEFINE([HAVE_]$1, [1], [Define to 1 if ]$1[ is found])
+ AC_SUBST($1[_CPPFLAGS])
+ AC_SUBST($1[_LDFLAGS])
+ AC_SUBST($1[_LIB],[-l]$3)
ifelse([$4], , :, [$4])],
[ifelse([$5], , :, [$5])])
])
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
+# https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
# ===========================================================================
#
# SYNOPSIS
#
-# AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS])
+# AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# EXTRA-FLAGS FLAG". This can for example be used to force the linker to
# issue an error when a bad flag is given.
#
+# INPUT gives an alternative input source to AC_LINK_IFELSE.
+#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
-# This program is free software: you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation, either version 3 of the License, or (at your
-# option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# As a special exception, the respective Autoconf Macro's copyright owner
-# gives unlimited permission to copy, distribute and modify the configure
-# scripts that are the output of Autoconf when processing the Macro. You
-# need not follow the terms of the GNU General Public License when using
-# or distributing such scripts, even though portions of the text of the
-# Macro appear in them. The GNU General Public License (GPL) does govern
-# all other use of the material that constitutes the Autoconf Macro.
-#
-# This special exception to the GPL applies to versions of the Autoconf
-# Macro released by the Autoconf Archive. When you make and distribute a
-# modified version of the Autoconf Macro, you may extend this special
-# exception to the GPL to apply to your modified version as well.
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
-#serial 2
+#serial 6
AC_DEFUN([AX_CHECK_LINK_FLAG],
-[AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
+[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
ax_check_save_flags=$LDFLAGS
LDFLAGS="$LDFLAGS $4 $1"
- AC_LINK_IFELSE([AC_LANG_PROGRAM()],
+ AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
LDFLAGS=$ax_check_save_flags])
-AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
+AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html
+# https://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html
# ===========================================================================
#
# SYNOPSIS
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
-# with this program. If not, see <http://www.gnu.org/licenses/>.
+# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
-#serial 12
+#serial 17
AC_DEFUN([AX_COMPILER_VENDOR],
[AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
+ dnl Please add if possible support to ax_compiler_version.m4
[# note: don't check for gcc first since some other compilers define __GNUC__
vendors="intel: __ICC,__ECC,__INTEL_COMPILER
ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__
pathscale: __PATHCC__,__PATHSCALE__
clang: __clang__
+ cray: _CRAYC
fujitsu: __FUJITSU
+ sdcc: SDCC, __SDCC
gnu: __GNUC__
sun: __SUNPRO_C,__SUNPRO_CC
hp: __HP_cc,__HP_aCC
dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER
- borland: __BORLANDC__,__TURBOC__
+ borland: __BORLANDC__,__CODEGEARC__,__TURBOC__
comeau: __COMO__
- cray: _CRAYC
kai: __KCC
lcc: __LCC__
sgi: __sgi,sgi
metrowerks: __MWERKS__
watcom: __WATCOMC__
portland: __PGI
+ tcc: __TINYC__
unknown: UNKNOWN"
for ventest in $vendors; do
case $ventest in
# ===========================================================================
-# https://github.com/BrianAker/ddm4/
+# https://www.gnu.org/software/autoconf-archive/ax_compiler_version.html
# ===========================================================================
#
# SYNOPSIS
#
-# AX_COMPILER_VERSION()
+# AX_COMPILER_VERSION
#
# DESCRIPTION
#
-# Capture version of C/C++ compiler
+# This macro retrieves the compiler version and returns it in the cache
+# variable $ax_cv_c_compiler_version for C and $ax_cv_cxx_compiler_version
+# for C++.
+#
+# Version is returned as epoch:major.minor.patchversion
+#
+# Epoch is used in order to have an increasing version number in case of
+# marketing change.
+#
+# Epoch use: * borland compiler use chronologically 0turboc for turboc
+# era,
+#
+# 1borlanc BORLANDC++ before 5, 2cppbuilder for cppbuilder era,
+# 3borlancpp for return of BORLANDC++ (after version 5.5),
+# 4cppbuilder for cppbuilder with year version,
+# and 5xe for XE era.
+#
+# An empty string is returned otherwise.
#
# LICENSE
#
-# Copyright (C) 2012 Brian Aker
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-#
-# * The names of its contributors may not be used to endorse or
-# promote products derived from this software without specific prior
-# written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#serial 5
-AC_DEFUN([_C_COMPILER_VERSION],
- [AC_MSG_CHECKING([C Compiler version])
-
- AS_CASE(["$ax_cv_c_compiler_vendor"],
- [sun],[ax_c_compiler_version=`$CC -V 2>&1 | sed 1q`],
- [intel],[ax_c_compiler_version=`$CC --version 2>&1 | sed 1q`],
- [clang],[ax_c_compiler_version=`$CC --version 2>&1 | sed 1q`],
- [gnu],[ax_c_compiler_version=`$CC --version | sed 1q`],
- [mingw],[ax_c_compiler_version=`$CC --version | sed 1q`],
- [ax_c_compiler_version="unknown: $ax_cv_c_compiler_vendor"])
-
- AC_MSG_RESULT(["$ax_c_compiler_version"])
- AC_SUBST([CC_VERSION_VENDOR],["$ax_cv_c_compiler_vendor"])
- AC_SUBST([CC_VERSION],["$ax_c_compiler_version"])
- ])
-
-AC_DEFUN([_CXX_COMPILER_VERSION],
- [AC_MSG_CHECKING([C++ Compiler version])
-
- AS_CASE(["$ax_cv_c_compiler_vendor"],
- [sun],[ax_cxx_compiler_version=`$CXX -V 2>&1 | sed 1q`],
- [intel],[ax_cxx_compiler_version=`$CXX --version 2>&1 | sed 1q`],
- [clang],[ax_cxx_compiler_version=`$CXX --version 2>&1 | sed 1q`],
- [gnu],[ax_cxx_compiler_version=`$CXX --version | sed 1q`],
- [mingw],[ax_cxx_compiler_version=`$CXX --version | sed 1q`],
- [ax_cxx_compiler_version="unknown: $ax_cv_c_compiler_vendor"])
-
- AC_MSG_RESULT(["$ax_cxx_compiler_version"])
- AC_SUBST([CXX_VERSION_VENDOR],["$ax_cv_c_compiler_vendor"])
- AC_SUBST([CXX_VERSION],["$ax_cxx_compiler_version"])
+# Copyright (c) 2014 Bastien ROUCARIES <roucaries.bastien+autoconf@gmail.com>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 12
+
+# for intel
+AC_DEFUN([_AX_COMPILER_VERSION_INTEL],
+ [ dnl
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ [__INTEL_COMPILER/100],,
+ AC_MSG_FAILURE([[[$0]] unknown intel compiler version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ [(__INTEL_COMPILER%100)/10],,
+ AC_MSG_FAILURE([[[$0]] unknown intel compiler version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ [(__INTEL_COMPILER%10)],,
+ AC_MSG_FAILURE([[[$0]] unknown intel compiler version]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
+ ])
+
+# for IBM
+AC_DEFUN([_AX_COMPILER_VERSION_IBM],
+ [ dnl
+ dnl check between z/OS C/C++ and XL C/C++
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([],
+ [
+ #if defined(__COMPILER_VER__)
+ choke me;
+ #endif
+ ])],
+ [
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ [__xlC__/100],,
+ AC_MSG_FAILURE([[[$0]] unknown IBM compiler major version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ [__xlC__%100],,
+ AC_MSG_FAILURE([[[$0]] unknown IBM compiler minor version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ [__xlC_ver__/0x100],,
+ AC_MSG_FAILURE([[[$0]] unknown IBM compiler patch version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_build,
+ [__xlC_ver__%0x100],,
+ AC_MSG_FAILURE([[[$0]] unknown IBM compiler build version]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_build"
+ ],
+ [
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ [__xlC__%1000],,
+ AC_MSG_FAILURE([[[$0]] unknown IBM compiler patch version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ [(__xlC__/10000)%10],,
+ AC_MSG_FAILURE([[[$0]] unknown IBM compiler minor version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ [(__xlC__/100000)%10],,
+ AC_MSG_FAILURE([[[$0]] unknown IBM compiler major version]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
+ ])
+])
+
+# for pathscale
+AC_DEFUN([_AX_COMPILER_VERSION_PATHSCALE],[
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ __PATHCC__,,
+ AC_MSG_FAILURE([[[$0]] unknown pathscale major]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ __PATHCC_MINOR__,,
+ AC_MSG_FAILURE([[[$0]] unknown pathscale minor]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ [__PATHCC_PATCHLEVEL__],,
+ AC_MSG_FAILURE([[[$0]] unknown pathscale patch level]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
+ ])
+
+# for clang
+AC_DEFUN([_AX_COMPILER_VERSION_CLANG],[
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ __clang_major__,,
+ AC_MSG_FAILURE([[[$0]] unknown clang major]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ __clang_minor__,,
+ AC_MSG_FAILURE([[[$0]] unknown clang minor]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ [__clang_patchlevel__],,0)
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
+ ])
+
+# for crayc
+AC_DEFUN([_AX_COMPILER_VERSION_CRAY],[
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ _RELEASE,,
+ AC_MSG_FAILURE([[[$0]] unknown crayc release]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ _RELEASE_MINOR,,
+ AC_MSG_FAILURE([[[$0]] unknown crayc minor]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor"
+ ])
+
+# for fujitsu
+AC_DEFUN([_AX_COMPILER_VERSION_FUJITSU],[
+ AC_COMPUTE_INT(ax_cv_[]_AC_LANG_ABBREV[]_compiler_version,
+ __FCC_VERSION,,
+ AC_MSG_FAILURE([[[$0]]unknown fujitsu release]))
+ ])
+
+# for GNU
+AC_DEFUN([_AX_COMPILER_VERSION_GNU],[
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ __GNUC__,,
+ AC_MSG_FAILURE([[[$0]] unknown gcc major]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ __GNUC_MINOR__,,
+ AC_MSG_FAILURE([[[$0]] unknown gcc minor]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ [__GNUC_PATCHLEVEL__],,
+ AC_MSG_FAILURE([[[$0]] unknown gcc patch level]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
+ ])
+
+# For sun
+AC_DEFUN([_AX_COMPILER_VERSION_SUN],[
+ m4_define([_AX_COMPILER_VERSION_SUN_NUMBER],
+ [
+ #if defined(__SUNPRO_CC)
+ __SUNPRO_CC
+ #else
+ __SUNPRO_C
+ #endif
+ ])
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_until59,
+ !!(_AX_COMPILER_VERSION_SUN_NUMBER < 0x1000),,
+ AC_MSG_FAILURE([[[$0]] unknown sun release version]))
+ AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_until59" = X1],
+ [dnl
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ _AX_COMPILER_VERSION_SUN_NUMBER % 0x10,,
+ AC_MSG_FAILURE([[[$0]] unknown sun patch version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ (_AX_COMPILER_VERSION_SUN_NUMBER / 0x10) % 0x10,,
+ AC_MSG_FAILURE([[[$0]] unknown sun minor version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ (_AX_COMPILER_VERSION_SUN_NUMBER / 0x100),,
+ AC_MSG_FAILURE([[[$0]] unknown sun major version]))
+ ],
+ [dnl
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ _AX_COMPILER_VERSION_SUN_NUMBER % 0x10,,
+ AC_MSG_FAILURE([[[$0]] unknown sun patch version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ (_AX_COMPILER_VERSION_SUN_NUMBER / 0x100) % 0x100,,
+ AC_MSG_FAILURE([[[$0]] unknown sun minor version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ (_AX_COMPILER_VERSION_SUN_NUMBER / 0x1000),,
+ AC_MSG_FAILURE([[[$0]] unknown sun major version]))
+ ])
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
+])
+
+AC_DEFUN([_AX_COMPILER_VERSION_HP],[
+ m4_define([_AX_COMPILER_VERSION_HP_NUMBER],
+ [
+ #if defined(__HP_cc)
+ __HP_cc
+ #else
+ __HP_aCC
+ #endif
+ ])
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_untilA0121,
+ !!(_AX_COMPILER_VERSION_HP_NUMBER <= 1),,
+ AC_MSG_FAILURE([[[$0]] unknown hp release version]))
+ AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_untilA0121" = X1],
+ [dnl By default output last version with this behavior.
+ dnl it is so old
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="01.21.00"
+ ],
+ [dnl
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ (_AX_COMPILER_VERSION_HP_NUMBER % 100),,
+ AC_MSG_FAILURE([[[$0]] unknown hp release version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ ((_AX_COMPILER_VERSION_HP_NUMBER / 100)%100),,
+ AC_MSG_FAILURE([[[$0]] unknown hp minor version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ ((_AX_COMPILER_VERSION_HP_NUMBER / 10000)%100),,
+ AC_MSG_FAILURE([[[$0]] unknown hp major version]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
])
+])
+
+AC_DEFUN([_AX_COMPILER_VERSION_DEC],[dnl
+ m4_define([_AX_COMPILER_VERSION_DEC_NUMBER],
+ [
+ #if defined(__DECC_VER)
+ __DECC_VER
+ #else
+ __DECCXX_VER
+ #endif
+ ])
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ (_AX_COMPILER_VERSION_DEC_NUMBER % 10000),,
+ AC_MSG_FAILURE([[[$0]] unknown dec release version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ ((_AX_COMPILER_VERSION_DEC_NUMBER / 100000UL)%100),,
+ AC_MSG_FAILURE([[[$0]] unknown dec minor version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ ((_AX_COMPILER_VERSION_DEC_NUMBER / 10000000UL)%100),,
+ AC_MSG_FAILURE([[[$0]] unknown dec major version]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
+ ])
-AC_DEFUN([AX_COMPILER_VERSION],
- [AC_REQUIRE([AX_COMPILER_VENDOR])
-
- AC_MSG_CHECKING([MINGW])
- AC_CHECK_DECL([__MINGW32__],
- [MINGW=yes
- ax_c_compiler_version_vendor=mingw],
- [MINGW=no])
- AC_MSG_RESULT([$MINGW])
-
- AC_REQUIRE([_C_COMPILER_VERSION])
- AC_REQUIRE([_CXX_COMPILER_VERSION])
- AS_IF([test "x$GCC" = xyes],
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#if !defined(__GNUC__) || (__GNUC__ < 4) || ((__GNUC__ >= 4) && (__GNUC_MINOR__ < 7))
-# error GCC is Too Old!
-#endif
- ]])],
- [ac_c_gcc_recent=yes],
- [ac_c_gcc_recent=no])
+# borland
+AC_DEFUN([_AX_COMPILER_VERSION_BORLAND],[dnl
+ m4_define([_AX_COMPILER_VERSION_TURBOC_NUMBER],
+ [
+ #if defined(__TURBOC__)
+ __TURBOC__
+ #else
+ choke me
+ #endif
+ ])
+ m4_define([_AX_COMPILER_VERSION_BORLANDC_NUMBER],
+ [
+ #if defined(__BORLANDC__)
+ __BORLANDC__
+ #else
+ __CODEGEARC__
+ #endif
+ ])
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(,
+ _AX_COMPILER_VERSION_TURBOC_NUMBER)],
+ [dnl TURBOC
+ AC_COMPUTE_INT(
+ _ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw,
+ _AX_COMPILER_VERSION_TURBOC_NUMBER,,
+ AC_MSG_FAILURE([[[$0]] unknown turboc version]))
+ AS_IF(
+ [test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw -lt 661 || test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw -gt 1023],
+ [dnl compute normal version
+ AC_COMPUTE_INT(
+ _ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ _AX_COMPILER_VERSION_TURBOC_NUMBER % 0x100,,
+ AC_MSG_FAILURE([[[$0]] unknown turboc minor version]))
+ AC_COMPUTE_INT(
+ _ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ (_AX_COMPILER_VERSION_TURBOC_NUMBER/0x100)%0x100,,
+ AC_MSG_FAILURE([[[$0]] unknown turboc major version]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor"],
+ [dnl special version
+ AS_CASE([$_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw],
+ [661],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:1.00"],
+ [662],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:1.01"],
+ [663],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:2.00"],
+ [
+ AC_MSG_WARN([[[$0]] unknown turboc version between 0x295 and 0x400 please report bug])
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=""
+ ])
])
+ ],
+ # borlandc
+ [
+ AC_COMPUTE_INT(
+ _ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw,
+ _AX_COMPILER_VERSION_BORLANDC_NUMBER,,
+ AC_MSG_FAILURE([[[$0]] unknown borlandc version]))
+ AS_CASE([$_ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw],
+ dnl BORLANDC++ before 5.5
+ [512] ,[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:2.00"],
+ [1024],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.00"],
+ [1024],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.00"],
+ [1040],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.1"],
+ [1106],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:4.0"],
+ [1280],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:5.0"],
+ [1312],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:5.02"],
+ dnl C++ Builder era
+ [1328],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="2cppbuilder:3.0"],
+ [1344],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="2cppbuilder:4.0"],
+ dnl BORLANDC++ after 5.5
+ [1360],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.5"],
+ [1361],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.51"],
+ [1378],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.6.4"],
+ dnl C++ Builder with year number
+ [1392],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2006"],
+ [1424],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2007"],
+ [1555],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2009"],
+ [1569],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2010"],
+ dnl XE version
+ [1584],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe"],
+ [1600],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:2"],
+ [1616],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:3"],
+ [1632],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:4"],
+ [
+ AC_MSG_WARN([[[$0]] Unknown borlandc compiler version $_ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw please report bug])
+ ])
+ ])
+ ])
+
+# COMO
+AC_DEFUN([_AX_COMPILER_VERSION_COMEAU],
+ [ dnl
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ [__COMO_VERSION__%100],,
+ AC_MSG_FAILURE([[[$0]] unknown comeau compiler minor version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ [(__COMO_VERSION__/100)%10],,
+ AC_MSG_FAILURE([[[$0]] unknown comeau compiler major version]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor"
+ ])
+
+# KAI
+AC_DEFUN([_AX_COMPILER_VERSION_KAI],[
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ [__KCC_VERSION%100],,
+ AC_MSG_FAILURE([[[$0]] unknown kay compiler patch version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ [(__KCC_VERSION/100)%10],,
+ AC_MSG_FAILURE([[[$0]] unknown kay compiler minor version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ [(__KCC_VERSION/1000)%10],,
+ AC_MSG_FAILURE([[[$0]] unknown kay compiler major version]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
+ ])
+
+dnl LCC
+dnl LCC does not output version...
+
+# SGI
+AC_DEFUN([_AX_COMPILER_VERSION_SGI],[
+ m4_define([_AX_COMPILER_VERSION_SGI_NUMBER],
+ [
+ #if defined(_COMPILER_VERSION)
+ _COMPILER_VERSION
+ #else
+ _SGI_COMPILER_VERSION
+ #endif
+ ])
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ [_AX_COMPILER_VERSION_SGI_NUMBER%10],,
+ AC_MSG_FAILURE([[[$0]] unknown SGI compiler patch version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ [(_AX_COMPILER_VERSION_SGI_NUMBER/10)%10],,
+ AC_MSG_FAILURE([[[$0]] unknown SGI compiler minor version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ [(_AX_COMPILER_VERSION_SGI_NUMBER/100)%10],,
+ AC_MSG_FAILURE([[[$0]] unknown SGI compiler major version]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
+ ])
+
+# microsoft
+AC_DEFUN([_AX_COMPILER_VERSION_MICROSOFT],[
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ _MSC_VER%100,,
+ AC_MSG_FAILURE([[[$0]] unknown microsoft compiler minor version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ (_MSC_VER/100)%100,,
+ AC_MSG_FAILURE([[[$0]] unknown microsoft compiler major version]))
+ dnl could be overridden
+ _ax_[]_AC_LANG_ABBREV[]_compiler_version_patch=0
+ _ax_[]_AC_LANG_ABBREV[]_compiler_version_build=0
+ # special case for version 6
+ AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major" = "X12"],
+ [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ _MSC_FULL_VER%1000,,
+ _ax_[]_AC_LANG_ABBREV[]_compiler_version_patch=0)])
+ # for version 7
+ AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major" = "X13"],
+ [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ _MSC_FULL_VER%1000,,
+ AC_MSG_FAILURE([[[$0]] unknown microsoft compiler patch version]))
+ ])
+ # for version > 8
+ AS_IF([test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_major -ge 14],
+ [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ _MSC_FULL_VER%10000,,
+ AC_MSG_FAILURE([[[$0]] unknown microsoft compiler patch version]))
+ ])
+ AS_IF([test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_major -ge 15],
+ [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_build,
+ _MSC_BUILD,,
+ AC_MSG_FAILURE([[[$0]] unknown microsoft compiler build version]))
+ ])
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_build"
+ ])
+
+# for metrowerks
+AC_DEFUN([_AX_COMPILER_VERSION_METROWERKS],[dnl
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ __MWERKS__%0x100,,
+ AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler patch version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ (__MWERKS__/0x100)%0x10,,
+ AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler minor version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ (__MWERKS__/0x1000)%0x10,,
+ AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler major version]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
+ ])
+
+# for watcom
+AC_DEFUN([_AX_COMPILER_VERSION_WATCOM],[dnl
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ __WATCOMC__%100,,
+ AC_MSG_FAILURE([[[$0]] unknown watcom compiler minor version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ (__WATCOMC__/100)%100,,
+ AC_MSG_FAILURE([[[$0]] unknown watcom compiler major version]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor"
+ ])
+
+# for PGI
+AC_DEFUN([_AX_COMPILER_VERSION_PORTLAND],[
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ __PGIC__,,
+ AC_MSG_FAILURE([[[$0]] unknown pgi major]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ __PGIC_MINOR__,,
+ AC_MSG_FAILURE([[[$0]] unknown pgi minor]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ [__PGIC_PATCHLEVEL__],,
+ AC_MSG_FAILURE([[[$0]] unknown pgi patch level]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
+ ])
+
+# tcc
+AC_DEFUN([_AX_COMPILER_VERSION_TCC],[
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=[`tcc -v | $SED 's/^[ ]*tcc[ ]\+version[ ]\+\([0-9.]\+\).*/\1/g'`]
+ ])
+
+# for GNU
+AC_DEFUN([_AX_COMPILER_VERSION_SDCC],[
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ /* avoid parse error with comments */
+ #if(defined(__SDCC_VERSION_MAJOR))
+ __SDCC_VERSION_MAJOR
+ #else
+ SDCC/100
+ #endif
+ ,,
+ AC_MSG_FAILURE([[[$0]] unknown sdcc major]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ /* avoid parse error with comments */
+ #if(defined(__SDCC_VERSION_MINOR))
+ __SDCC_VERSION_MINOR
+ #else
+ (SDCC%100)/10
+ #endif
+ ,,
+ AC_MSG_FAILURE([[[$0]] unknown sdcc minor]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ [
+ /* avoid parse error with comments */
+ #if(defined(__SDCC_VERSION_PATCH))
+ __SDCC_VERSION_PATCH
+ #elsif(defined(_SDCC_VERSION_PATCHLEVEL))
+ __SDCC_VERSION_PATCHLEVEL
+ #else
+ SDCC%10
+ #endif
+ ],,
+ AC_MSG_FAILURE([[[$0]] unknown sdcc patch level]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
+ ])
+
+# main entry point
+AC_DEFUN([AX_COMPILER_VERSION],[dnl
+ AC_REQUIRE([AX_COMPILER_VENDOR])
+ AC_REQUIRE([AC_PROG_SED])
+ AC_CACHE_CHECK([for _AC_LANG compiler version],
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version,
+ [ dnl
+ AS_CASE([$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor],
+ [intel],[_AX_COMPILER_VERSION_INTEL],
+ [ibm],[_AX_COMPILER_VERSION_IBM],
+ [pathscale],[_AX_COMPILER_VERSION_PATHSCALE],
+ [clang],[_AX_COMPILER_VERSION_CLANG],
+ [cray],[_AX_COMPILER_VERSION_CRAY],
+ [fujitsu],[_AX_COMPILER_VERSION_FUJITSU],
+ [gnu],[_AX_COMPILER_VERSION_GNU],
+ [sun],[_AX_COMPILER_VERSION_SUN],
+ [hp],[_AX_COMPILER_VERSION_HP],
+ [dec],[_AX_COMPILER_VERSION_DEC],
+ [borland],[_AX_COMPILER_VERSION_BORLAND],
+ [comeau],[_AX_COMPILER_VERSION_COMEAU],
+ [kai],[_AX_COMPILER_VERSION_KAI],
+ [sgi],[_AX_COMPILER_VERSION_SGI],
+ [microsoft],[_AX_COMPILER_VERSION_MICROSOFT],
+ [metrowerks],[_AX_COMPILER_VERSION_METROWERKS],
+ [watcom],[_AX_COMPILER_VERSION_WATCOM],
+ [portland],[_AX_COMPILER_VERSION_PORTLAND],
+ [tcc],[_AX_COMPILER_VERSION_TCC],
+ [sdcc],[_AX_COMPILER_VERSION_SDCC],
+ [ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=""])
])
+])
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_count_cpus.html
+# https://www.gnu.org/software/autoconf-archive/ax_count_cpus.html
# ===========================================================================
#
# SYNOPSIS
#
-# AX_COUNT_CPUS
+# AX_COUNT_CPUS([ACTION-IF-DETECTED],[ACTION-IF-NOT-DETECTED])
#
# DESCRIPTION
#
-# Attempt to count the number of processors present on the machine. If the
-# detection fails, then a value of 1 is assumed.
+# Attempt to count the number of logical processor cores (including
+# virtual and HT cores) currently available to use on the machine and
+# place detected value in CPU_COUNT variable.
#
-# The value is placed in the CPU_COUNT variable.
+# On successful detection, ACTION-IF-DETECTED is executed if present. If
+# the detection fails, then ACTION-IF-NOT-DETECTED is triggered. The
+# default ACTION-IF-NOT-DETECTED is to set CPU_COUNT to 1.
#
# LICENSE
#
+# Copyright (c) 2014,2016 Karlson2k (Evgeny Grin) <k2k@narod.ru>
# Copyright (c) 2012 Brian Aker <brian@tangent.org>
# Copyright (c) 2008 Michael Paul Bailey <jinxidoru@byu.net>
# Copyright (c) 2008 Christophe Tournayre <turn3r@users.sourceforge.net>
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 10
+#serial 22
- AC_DEFUN([AX_COUNT_CPUS],[
- AC_REQUIRE([AC_CANONICAL_HOST])
- AC_REQUIRE([AC_PROG_EGREP])
+ AC_DEFUN([AX_COUNT_CPUS],[dnl
+ AC_REQUIRE([AC_CANONICAL_HOST])dnl
+ AC_REQUIRE([AC_PROG_EGREP])dnl
AC_MSG_CHECKING([the number of available CPUs])
CPU_COUNT="0"
- AS_CASE([$host_os],[
- *darwin*],[
- AS_IF([test -x /usr/sbin/sysctl],[
- sysctl_a=`/usr/sbin/sysctl -a 2>/dev/null| grep -c hw.cpu`
- AS_IF([test sysctl_a],[
- CPU_COUNT=`/usr/sbin/sysctl -n hw.ncpu`
- ])
- ])],[
- *linux*],[
- AS_IF([test "x$CPU_COUNT" = "x0" -a -e /proc/cpuinfo],[
- AS_IF([test "x$CPU_COUNT" = "x0" -a -e /proc/cpuinfo],[
- CPU_COUNT=`$EGREP -c '^processor' /proc/cpuinfo`
- ])
- ])
- ])
-
- AS_IF([test "x$CPU_COUNT" = "x0"],[
- CPU_COUNT="1"
- AC_MSG_RESULT( [unable to detect (assuming 1)] )
- ],[
- AC_MSG_RESULT( $CPU_COUNT )
- ])
- ])
+ # Try generic methods
+
+ # 'getconf' is POSIX utility, but '_NPROCESSORS_ONLN' and
+ # 'NPROCESSORS_ONLN' are platform-specific
+ command -v getconf >/dev/null 2>&1 && \
+ CPU_COUNT=`getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null` || CPU_COUNT="0"
+ AS_IF([[test "$CPU_COUNT" -gt "0" 2>/dev/null || ! command -v nproc >/dev/null 2>&1]],[[: # empty]],[dnl
+ # 'nproc' is part of GNU Coreutils and is widely available
+ CPU_COUNT=`OMP_NUM_THREADS='' nproc 2>/dev/null` || CPU_COUNT=`nproc 2>/dev/null` || CPU_COUNT="0"
+ ])dnl
+
+ AS_IF([[test "$CPU_COUNT" -gt "0" 2>/dev/null]],[[: # empty]],[dnl
+ # Try platform-specific preferred methods
+ AS_CASE([[$host_os]],dnl
+ [[*linux*]],[[CPU_COUNT=`lscpu -p 2>/dev/null | $EGREP -e '^@<:@0-9@:>@+,' -c` || CPU_COUNT="0"]],dnl
+ [[*darwin*]],[[CPU_COUNT=`sysctl -n hw.logicalcpu 2>/dev/null` || CPU_COUNT="0"]],dnl
+ [[freebsd*]],[[command -v sysctl >/dev/null 2>&1 && CPU_COUNT=`sysctl -n kern.smp.cpus 2>/dev/null` || CPU_COUNT="0"]],dnl
+ [[netbsd*]], [[command -v sysctl >/dev/null 2>&1 && CPU_COUNT=`sysctl -n hw.ncpuonline 2>/dev/null` || CPU_COUNT="0"]],dnl
+ [[solaris*]],[[command -v psrinfo >/dev/null 2>&1 && CPU_COUNT=`psrinfo 2>/dev/null | $EGREP -e '^@<:@0-9@:>@.*on-line' -c 2>/dev/null` || CPU_COUNT="0"]],dnl
+ [[mingw*]],[[CPU_COUNT=`ls -qpU1 /proc/registry/HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/System/CentralProcessor/ 2>/dev/null | $EGREP -e '^@<:@0-9@:>@+/' -c` || CPU_COUNT="0"]],dnl
+ [[msys*]],[[CPU_COUNT=`ls -qpU1 /proc/registry/HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/System/CentralProcessor/ 2>/dev/null | $EGREP -e '^@<:@0-9@:>@+/' -c` || CPU_COUNT="0"]],dnl
+ [[cygwin*]],[[CPU_COUNT=`ls -qpU1 /proc/registry/HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/System/CentralProcessor/ 2>/dev/null | $EGREP -e '^@<:@0-9@:>@+/' -c` || CPU_COUNT="0"]]dnl
+ )dnl
+ ])dnl
+
+ AS_IF([[test "$CPU_COUNT" -gt "0" 2>/dev/null || ! command -v sysctl >/dev/null 2>&1]],[[: # empty]],[dnl
+ # Try less preferred generic method
+ # 'hw.ncpu' exist on many platforms, but not on GNU/Linux
+ CPU_COUNT=`sysctl -n hw.ncpu 2>/dev/null` || CPU_COUNT="0"
+ ])dnl
+
+ AS_IF([[test "$CPU_COUNT" -gt "0" 2>/dev/null]],[[: # empty]],[dnl
+ # Try platform-specific fallback methods
+ # They can be less accurate and slower then preferred methods
+ AS_CASE([[$host_os]],dnl
+ [[*linux*]],[[CPU_COUNT=`$EGREP -e '^processor' -c /proc/cpuinfo 2>/dev/null` || CPU_COUNT="0"]],dnl
+ [[*darwin*]],[[CPU_COUNT=`system_profiler SPHardwareDataType 2>/dev/null | $EGREP -i -e 'number of cores:'|cut -d : -f 2 -s|tr -d ' '` || CPU_COUNT="0"]],dnl
+ [[freebsd*]],[[CPU_COUNT=`dmesg 2>/dev/null| $EGREP -e '^cpu@<:@0-9@:>@+: '|sort -u|$EGREP -e '^' -c` || CPU_COUNT="0"]],dnl
+ [[netbsd*]], [[CPU_COUNT=`command -v cpuctl >/dev/null 2>&1 && cpuctl list 2>/dev/null| $EGREP -e '^@<:@0-9@:>@+ .* online ' -c` || \
+ CPU_COUNT=`dmesg 2>/dev/null| $EGREP -e '^cpu@<:@0-9@:>@+ at'|sort -u|$EGREP -e '^' -c` || CPU_COUNT="0"]],dnl
+ [[solaris*]],[[command -v kstat >/dev/null 2>&1 && CPU_COUNT=`kstat -m cpu_info -s state -p 2>/dev/null | $EGREP -c -e 'on-line'` || \
+ CPU_COUNT=`kstat -m cpu_info 2>/dev/null | $EGREP -c -e 'module: cpu_info'` || CPU_COUNT="0"]],dnl
+ [[mingw*]],[AS_IF([[CPU_COUNT=`reg query 'HKLM\\Hardware\\Description\\System\\CentralProcessor' 2>/dev/null | $EGREP -e '\\\\@<:@0-9@:>@+$' -c`]],dnl
+ [[: # empty]],[[test "$NUMBER_OF_PROCESSORS" -gt "0" 2>/dev/null && CPU_COUNT="$NUMBER_OF_PROCESSORS"]])],dnl
+ [[msys*]],[[test "$NUMBER_OF_PROCESSORS" -gt "0" 2>/dev/null && CPU_COUNT="$NUMBER_OF_PROCESSORS"]],dnl
+ [[cygwin*]],[[test "$NUMBER_OF_PROCESSORS" -gt "0" 2>/dev/null && CPU_COUNT="$NUMBER_OF_PROCESSORS"]]dnl
+ )dnl
+ ])dnl
+
+ AS_IF([[test "x$CPU_COUNT" != "x0" && test "$CPU_COUNT" -gt 0 2>/dev/null]],[dnl
+ AC_MSG_RESULT([[$CPU_COUNT]])
+ m4_ifvaln([$1],[$1],)dnl
+ ],[dnl
+ m4_ifval([$2],[dnl
+ AS_UNSET([[CPU_COUNT]])
+ AC_MSG_RESULT([[unable to detect]])
+ $2
+ ], [dnl
+ CPU_COUNT="1"
+ AC_MSG_RESULT([[unable to detect (assuming 1)]])
+ ])dnl
+ ])dnl
+ ])dnl
#
# LICENSE
#
-# Copyright (C) 2012 Brian Aker
+# Copyright (C) 2012-2014 Brian Aker
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#serial 6
+#serial 8
AC_DEFUN([AX_DEBUG],
[AC_PREREQ([2.63])dnl
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
[Add debug code/turns off optimizations (yes|no) @<:@default=no@:>@])],
- [ax_enable_debug=yes
- AC_DEFINE([DEBUG],[1],[Define to 1 to enable debugging code.])
- AX_CHECK_LIBRARY([MCHECK],[mcheck.h],[mcheck],[AX_APPEND_LINK_FLAGS([-lmcheck])])
- AX_ADD_AM_MACRO([--debug],[AM_YFLAGS])
- AX_ADD_AM_MACRO([-D_GLIBCXX_DEBUG],[AM_CPPFLAGS])],
- [ax_enable_debug=no
- AC_SUBST([MCHECK])
- AC_DEFINE([DEBUG],[0],[Define to 1 to enable debugging code.])])
+ [ax_enable_debug=$enableval],
+ [ax_enable_debug=no])
+
+ AS_IF([test "x$ax_enable_debug" = xyes],
+ [AC_DEFINE([DEBUG],[1],[Define to 1 to enable debugging code.])
+ AX_ADD_AM_MACRO([AM_YFLAGS += --debug])
+ AX_ADD_AM_MACRO([AM_CPPFLAGS += -D_GLIBCXX_DEBUG])],
+ [AC_SUBST([MCHECK])
+ AC_DEFINE([DEBUG],[0],[Define to 1 to enable debugging code.])])
AC_MSG_CHECKING([for debug])
AC_MSG_RESULT([$ax_enable_debug])
--- /dev/null
+#serial 2
+
+AC_DEFUN([AX_DLOPEN],
+ [AS_IF([test "x$enable_shared" = xyes],
+ [AX_CHECK_LIBRARY([DL],[dlfcn.h],[dl],
+ [AC_DEFINE([HAVE_LIBDL],[1],[Have dlopen])
+ AC_CHECK_LIB([dl],[dlopen],[AC_DEFINE([HAVE_DLOPEN],[1],[Have dlopen])])
+ AC_CHECK_LIB([dl],[dladdr],[AC_DEFINE([HAVE_DLADDR],[1],[Have dladdr])])])])
+ ])
+
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_file_escapes.html
+# https://www.gnu.org/software/autoconf-archive/ax_file_escapes.html
# ===========================================================================
#
# SYNOPSIS
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 7
+#serial 8
AC_DEFUN([AX_FILE_ESCAPES],[
AX_DOLLAR="\$"
--- /dev/null
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_gcc_version.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_GCC_VERSION
+#
+# DESCRIPTION
+#
+# This macro retrieves the gcc version and returns it in the GCC_VERSION
+# variable if available, an empty string otherwise.
+#
+# LICENSE
+#
+# Copyright (c) 2009 Francesco Salvestrini <salvestrini@users.sourceforge.net>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 8
+
+AC_DEFUN([AX_GCC_VERSION], [
+ GCC_VERSION=""
+ AX_GCC_OPTION([-dumpversion],[],[],[
+ ax_gcc_version_option=yes
+ ],[
+ ax_gcc_version_option=no
+ ])
+ AS_IF([test "x$GCC" = "xyes"],[
+ AS_IF([test "x$ax_gcc_version_option" != "xno"],[
+ AC_CACHE_CHECK([gcc version],[ax_cv_gcc_version],[
+ ax_cv_gcc_version="`$CC -dumpversion`"
+ AS_IF([test "x$ax_cv_gcc_version" = "x"],[
+ ax_cv_gcc_version=""
+ ])
+ ])
+ GCC_VERSION=$ax_cv_gcc_version
+ ])
+ ])
+ AC_SUBST([GCC_VERSION])
+])
#
# Any compiler flag that "hardens" or tests code. C99 is assumed.
#
-# NOTE: Implementation based on AX_APPEND_FLAG.
-#
# LICENSE
#
-# Copyright (C) 2012-2013 Brian Aker
+# Copyright (C) 2012-2019 Brian Aker
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# -Wdeclaration-after-statement is counter to C99
# _APPEND_COMPILE_FLAGS_ERROR([-pedantic])
-#serial 13
+#serial 17
AC_DEFUN([_SET_SANITIZE_FLAGS],
[AS_IF([test "x$MINGW" != xyes],[
])
])
-AC_DEFUN([_WARNINGS_AS_ERRORS],
- [AC_CACHE_CHECK([if all warnings into errors],[ac_cv_warnings_as_errors],
- [AS_IF([test "x$ac_cv_vcs_checkout" = xyes],[ac_cv_warnings_as_errors=yes],
- [ac_cv_warnings_as_errors=no])
- ])
- ])
-
# Note: Should this be LIBS or LDFLAGS?
AC_DEFUN([_APPEND_LINK_FLAGS_ERROR],
[AX_APPEND_LINK_FLAGS([$1],[LDFLAGS],[-Werror])
# Everything above this does the heavy lifting, while what follows does the specifics.
AC_DEFUN([_HARDEN_LINKER_FLAGS],
- [AS_IF([test "$CC" != "clang"],
- [_APPEND_LINK_FLAGS_ERROR([-z relro -z now])
- AS_IF([test "x$ac_cv_warnings_as_errors" = xyes],[AX_APPEND_LINK_FLAGS([-Werror])])
+ [AS_IF([test "$ax_cv_c_compiler_vendor" != "clang"],
+ [_APPEND_LINK_FLAGS_ERROR(["-z relro" "-z now"])
AS_IF([test "x$ac_cv_vcs_checkout" = xyes],
[_APPEND_LINK_FLAGS_ERROR([-rdynamic])
# AX_APPEND_LINK_FLAGS([--coverage])])
+ AS_IF([test "x$ac_cv_warnings_as_errors" = xyes],[AX_APPEND_LINK_FLAGS([-Werror])])
])
])
[AC_LANG_PUSH([C])dnl
AS_IF([test "x$ax_enable_debug" = xyes],
- [CFLAGS=''
- _APPEND_COMPILE_FLAGS_ERROR([-H])
+ [
+ #_APPEND_COMPILE_FLAGS_ERROR([-H])
_APPEND_COMPILE_FLAGS_ERROR([-g])
_APPEND_COMPILE_FLAGS_ERROR([-g3])
_APPEND_COMPILE_FLAGS_ERROR([-fno-eliminate-unused-debug-types])
[_APPEND_COMPILE_FLAGS_ERROR([-Wno-unknown-pragmas])
_APPEND_COMPILE_FLAGS_ERROR([-Wno-pragmas])])
- AS_IF([test "$CC" = "clang"],[_APPEND_COMPILE_FLAGS_ERROR([-Qunused-arguments])])
+ AS_IF([test "$ax_cv_c_compiler_vendor" = "clang"],[_APPEND_COMPILE_FLAGS_ERROR([-Qunused-arguments])])
_APPEND_COMPILE_FLAGS_ERROR([-Wall])
_APPEND_COMPILE_FLAGS_ERROR([-Wextra])
_APPEND_COMPILE_FLAGS_ERROR([-Wthis-test-should-fail])
# Anything below this comment please keep sorted.
# _APPEND_COMPILE_FLAGS_ERROR([-Wmissing-format-attribute])
- _APPEND_COMPILE_FLAGS_ERROR([-Wunsuffixed-float-constants])
- _APPEND_COMPILE_FLAGS_ERROR([-Wjump-misses-init])
_APPEND_COMPILE_FLAGS_ERROR([-Wno-attributes])
_APPEND_COMPILE_FLAGS_ERROR([-Waddress])
_APPEND_COMPILE_FLAGS_ERROR([-Wvarargs])
_APPEND_COMPILE_FLAGS_ERROR([-Wformat-security])
_APPEND_COMPILE_FLAGS_ERROR([-Wformat=2])
_APPEND_COMPILE_FLAGS_ERROR([-Wformat-y2k])
- _APPEND_COMPILE_FLAGS_ERROR([-Wlogical-op])
- _APPEND_COMPILE_FLAGS_ERROR([-Wmaybe-uninitialized])
_APPEND_COMPILE_FLAGS_ERROR([-Wmissing-field-initializers])
AS_IF([test "x$MINGW" = xyes],
[_APPEND_COMPILE_FLAGS_ERROR([-Wno-missing-noreturn])],
[_APPEND_COMPILE_FLAGS_ERROR([-Wmissing-noreturn])])
_APPEND_COMPILE_FLAGS_ERROR([-Wmissing-prototypes])
_APPEND_COMPILE_FLAGS_ERROR([-Wnested-externs])
- _APPEND_COMPILE_FLAGS_ERROR([-Wnormalized=id])
- _APPEND_COMPILE_FLAGS_ERROR([-Woverride-init])
_APPEND_COMPILE_FLAGS_ERROR([-Wpointer-arith])
_APPEND_COMPILE_FLAGS_ERROR([-Wpointer-sign])
AS_IF([test "x$MINGW" = xyes],
_APPEND_COMPILE_FLAGS_ERROR([-Wstrict-overflow=1])
_APPEND_COMPILE_FLAGS_ERROR([-Wstrict-prototypes])
_APPEND_COMPILE_FLAGS_ERROR([-Wswitch-enum])
- _APPEND_COMPILE_FLAGS_ERROR([-Wtrampolines])
_APPEND_COMPILE_FLAGS_ERROR([-Wundef])
- _APPEND_COMPILE_FLAGS_ERROR([-Wunsafe-loop-optimizations])
- _APPEND_COMPILE_FLAGS_ERROR([-funsafe-loop-optimizations])
- _APPEND_COMPILE_FLAGS_ERROR([-Wclobbered])
_APPEND_COMPILE_FLAGS_ERROR([-Wunused])
_APPEND_COMPILE_FLAGS_ERROR([-Wunused-result])
_APPEND_COMPILE_FLAGS_ERROR([-Wunused-variable])
_APPEND_COMPILE_FLAGS_ERROR([-Wunused-local-typedefs])
_APPEND_COMPILE_FLAGS_ERROR([-Wwrite-strings])
_APPEND_COMPILE_FLAGS_ERROR([-fwrapv])
+ _APPEND_COMPILE_FLAGS_ERROR([-fmudflapt])
_APPEND_COMPILE_FLAGS_ERROR([-pipe])
- _APPEND_COMPILE_FLAGS_ERROR([-fPIE -pie])
+ AS_IF([test "x$MINGW" = xyes],
+ [],
+ [_APPEND_COMPILE_FLAGS_ERROR([-fPIE -pie])])
_APPEND_COMPILE_FLAGS_ERROR([-Wsizeof-pointer-memaccess])
_APPEND_COMPILE_FLAGS_ERROR([-Wpacked])
-# _APPEND_COMPILE_FLAGS_ERROR([-Wlong-long])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wlong-long])
+ _APPEND_COMPILE_FLAGS_ERROR([ftrapv])
+ # Stop error when using -pie on library builds
+ _APPEND_COMPILE_FLAGS_ERROR([-Wno-unused-command-line-argument])
# GCC 4.5 removed this.
# _APPEND_COMPILE_FLAGS_ERROR([-Wunreachable-code])
])])])])
AS_IF([test "x$ac_cv_warnings_as_errors" = xyes],
- [AX_APPEND_FLAG([-Werror])])
+ [AX_APPEND_COMPILE_FLAGS([-Werror])])
AC_LANG_POP([C])
])
[AC_LANG_PUSH([C++])
AS_IF([test "x$ax_enable_debug" = xyes],
[CXXFLAGS=''
- _APPEND_COMPILE_FLAGS_ERROR([-H])
+ #_APPEND_COMPILE_FLAGS_ERROR([-H])
_APPEND_COMPILE_FLAGS_ERROR([-g])
_APPEND_COMPILE_FLAGS_ERROR([-g3])
_APPEND_COMPILE_FLAGS_ERROR([-fno-inline])
[_APPEND_COMPILE_FLAGS_ERROR([-Wno-unknown-pragmas])
_APPEND_COMPILE_FLAGS_ERROR([-Wno-pragmas])])
- AS_IF([test "$CXX" = "clang++"],[_APPEND_COMPILE_FLAGS_ERROR([-Qunused-arguments])])
+ AS_IF([test "$ax_cv_c_compiler_vendor" = "clang"],[_APPEND_COMPILE_FLAGS_ERROR([-Qunused-arguments])])
_APPEND_COMPILE_FLAGS_ERROR([-Wall])
_APPEND_COMPILE_FLAGS_ERROR([-Wextra])
_APPEND_COMPILE_FLAGS_ERROR([-Wunsafe-loop-optimizations])
_APPEND_COMPILE_FLAGS_ERROR([-funsafe-loop-optimizations])
_APPEND_COMPILE_FLAGS_ERROR([-Wc++11-compat])
-# _APPEND_COMPILE_FLAGS_ERROR([-Weffc++])
-# _APPEND_COMPILE_FLAGS_ERROR([-Wold-style-cast])
+# Disabled due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55837
+# _APPEND_COMPILE_FLAGS_ERROR([-Weffc++])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wold-style-cast])
_APPEND_COMPILE_FLAGS_ERROR([-Wclobbered])
_APPEND_COMPILE_FLAGS_ERROR([-Wunused])
_APPEND_COMPILE_FLAGS_ERROR([-Wunused-result])
_APPEND_COMPILE_FLAGS_ERROR([-Wwrite-strings])
_APPEND_COMPILE_FLAGS_ERROR([-Wformat-security])
_APPEND_COMPILE_FLAGS_ERROR([-fwrapv])
+ _APPEND_COMPILE_FLAGS_ERROR([-fmudflapt])
_APPEND_COMPILE_FLAGS_ERROR([-pipe])
- _APPEND_COMPILE_FLAGS_ERROR([-fPIE -pie])
+ AS_IF([test "x$MINGW" = xyes],
+ [],
+ [_APPEND_COMPILE_FLAGS_ERROR([-fPIE -pie])])
_APPEND_COMPILE_FLAGS_ERROR([-Wsizeof-pointer-memaccess])
_APPEND_COMPILE_FLAGS_ERROR([-Wpacked])
-# _APPEND_COMPILE_FLAGS_ERROR([-Wlong-long])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wlong-long])
# GCC 4.5 removed this.
# _APPEND_COMPILE_FLAGS_ERROR([-Wunreachable-code])
_SET_SANITIZE_FLAGS
AS_IF([test "x$ac_cv_warnings_as_errors" = xyes],
- [AX_APPEND_FLAG([-Werror])])
+ [AX_APPEND_COMPILE_FLAGS([-Werror])])
AC_LANG_POP([C++])
])
[AC_PREREQ([2.63])dnl
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AX_COMPILER_VERSION])
+ AC_REQUIRE([AX_DEBUG])
AC_REQUIRE([AX_ASSERT])
- _WARNINGS_AS_ERRORS
_AX_HARDEN_SANITIZE
AC_REQUIRE([gl_VISIBILITY])
AS_IF([test -n "$CFLAG_VISIBILITY"],[CPPFLAGS="$CPPFLAGS $CFLAG_VISIBILITY"])
- _WARNINGS_AS_ERRORS
_HARDEN_LINKER_FLAGS
_HARDEN_CC_COMPILER_FLAGS
_HARDEN_CXX_COMPILER_FLAGS
--- /dev/null
+# https://github.com/BrianAker/ddm4
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_LIBUV([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+#
+# DESCRIPTION
+#
+# libuv library
+#
+# LICENSE
+#
+# Copyright (c) 2012 Brian Aker <brian@tangent.org>
+# Copyright (c) 2014 Andrew Hutchings <andrew@linuxjedi.co.uk>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 1
+
+AC_DEFUN([AX_LIBUV],
+ [AC_PREREQ([2.63])dnl
+ AC_CACHE_CHECK([test for a working libuv],[ax_cv_libuv],
+ [AX_SAVE_FLAGS
+ LIBS="-luv $LIBS"
+ AC_LANG_PUSH([C])
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#include <uv.h>
+ ]],[[
+ uv_loop_t *loop;
+ loop = uv_loop_new();
+ ]])],
+ [ax_cv_libuv=yes],
+ [ax_cv_libuv=no],
+ [AC_MSG_WARN([test program execution failed])])
+ AC_LANG_POP
+ AX_RESTORE_FLAGS
+ ])
+
+ AS_IF([test "x$ax_cv_libuv" = "xyes"],
+ [AC_SUBST([LIBUV_LIB],[-luv])
+ AC_DEFINE([HAVE_LIBUV],[1],[Define if uv_loop_new is present in uv.h.])],
+ [AC_DEFINE([HAVE_LIBUV],[0],[Define if uv_loop_new is present in uv.h.])])
+
+ AM_CONDITIONAL(HAVE_LIBUV, test "x$ax_cv_libuv" = "xyes")
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+ AS_IF([test "x$ax_cv_libuv" = xyes],
+ [$1],
+ [$2])
+ ])
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#serial 4
+#serial 5
AC_DEFUN([AX_PROG_MEMCACHED],
[AX_WITH_PROG([MEMCACHED_BINARY],[memcached],[unknown])
ax_memcached_success=
+ ax_memcached_version=
+ AC_MSG_CHECKING([for memcached version])
AS_IF([test x"$MEMCACHED_BINARY" != xunknown],
[AS_IF([test -x "$MEMCACHED_BINARY"],
[ax_memcached_version=`$MEMCACHED_BINARY -h | sed 1q | awk '{print \$ 2 }' | sed 's|[\-a-z0-9]*$||' | awk -F. '{printf "%d.%d.%d", $[]1, $[]2, $[]3}'`
AS_IF([test -n "$ax_memcached_version"],
[ax_memcached_success='ok'
- AC_MSG_RESULT([memcached version "$ax_memcached_version"])
AC_DEFINE_UNQUOTED([MEMCACHED_VERSION],"$ax_memcached_version",[Memcached binary version])])
])
])
+ AC_MSG_RESULT(["$ax_memcached_version"])
AS_IF([test -n "$ax_memcached_success"],
[AC_DEFINE([HAVE_MEMCACHED_BINARY], [1], [If Memcached binary is available])
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_print_to_file.html
+# https://www.gnu.org/software/autoconf-archive/ax_print_to_file.html
# ===========================================================================
#
# SYNOPSIS
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 7
+#serial 8
AC_DEFUN([AX_PRINT_TO_FILE],[
AC_REQUIRE([AX_FILE_ESCAPES])
--- /dev/null
+# ===========================================================================
+# https://github.com/BrianAker/ddm4/
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_PRINTF_STRERROR()
+#
+# DESCRIPTION
+#
+# Check to see if printf() has %m implemented (i.e. can handle strerror
+# internally)
+#
+# LICENSE
+#
+# Copyright (C) 2013 Brian Aker All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#
+# * The names of its contributors may not be used to endorse or
+# promote products derived from this software without specific prior
+# written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#serial 2
+
+AC_DEFUN([AX_PRINTF_STRERROR],
+ [AC_PREREQ([2.63])dnl
+ AC_CACHE_CHECK([printf() has strerror option],
+ [ax_cv_have_printf_strerror],
+ [AC_LANG_PUSH([C++])
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <cstdio>
+ #include <cstddef>
+ #include <cstdlib>
+ #include <cstring>
+ #include <cerrno>
+ ]],
+ [[char buffer[1024]; errno=0; snprintf(buffer, sizeof(buffer), "%m"); if (strcmp("Success", buffer) !=0 ) return EXIT_FAILURE;]])],
+ [ax_cv_have_printf_strerror=yes],
+ [ax_cv_have_printf_strerror=no],
+ [ax_cv_have_printf_strerror=no])
+ AC_LANG_POP])
+ AC_MSG_RESULT(["$ax_cv_have_printf_strerror"])
+ AS_IF([test "x$ax_cv_have_printf_strerror" = xyes],
+ [AC_DEFINE([HAVE_PRINTF_STRERROR],[1],[define if printf supports directly print errno])])
+ ])
--- /dev/null
+# ===========================================================================
+# https://github.com/BrianAker/ddm4
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_PROG_VALGRIND([tool],[options],[ACTION-IF-FOUND], [ACTION-IF-NOT_FOUND])
+#
+# DESCRIPTION
+#
+# Look for valgrind and make sure it is a recent version of it.
+#
+# LICENSE
+#
+# Copyright (c) 2012-2013 Brian Aker <brian@tangent.org>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 1
+
+AC_DEFUN([AX_PROG_VALGRIND],
+ [AX_WITH_PROG([VALGRIND],[valgrind],[:])
+ AS_IF([test x"VALGRIND" = x":"],
+ [VALGRIND=],
+ [AS_IF([test -x "$VALGRIND"],
+ [AC_MSG_CHECKING([Checking to see if $VALGRIND is recent])
+ junk=`$VALGRIND --version &> version_file`
+ ax_valgrind_version=`head -1 version_file`
+ rm version_file
+ AC_MSG_RESULT([$VALGRIND is version "$ax_valgrind_version"])
+ ])
+ ])
+
+ AS_IF([test -n "${VALGRIND}"],
+ [AC_SUBST([VALGRIND])
+ LIBTOOL_COMMAND="\${LIBTOOL} --mode=execute"
+ AC_SUBST([LIBTOOL_COMMAND])
+ AX_ADD_AM_MACRO([[TESTS_ENVIRONMENT=\"\${LIBTOOL_COMMAND} \${VALGRIND} --tool=$1 $2\"]])
+ ifelse([$3], , :, [$3])],
+ [ifelse([$4], , :, [$4])])
+ ])
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_pthread.html
+# https://www.gnu.org/software/autoconf-archive/ax_pthread.html
# ===========================================================================
#
# SYNOPSIS
# is necessary on AIX to use the special cc_r compiler alias.)
#
# NOTE: You are assumed to not only compile your program with these flags,
-# but also link it with them as well. e.g. you should link with
+# but also to link with them as well. For example, you might link with
# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
#
-# If you are only building threads programs, you may wish to use these
+# If you are only building threaded programs, you may wish to use these
# variables in your default LIBS, CFLAGS, and CC:
#
# LIBS="$PTHREAD_LIBS $LIBS"
# CC="$PTHREAD_CC"
#
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
-# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
-# (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
+# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to
+# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
#
# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
-# with this program. If not, see <http://www.gnu.org/licenses/>.
+# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
-#serial 23
+#serial 24
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
AC_DEFUN([AX_PTHREAD], [
AC_REQUIRE([AC_CANONICAL_HOST])
+AC_REQUIRE([AC_PROG_CC])
+AC_REQUIRE([AC_PROG_SED])
AC_LANG_PUSH([C])
ax_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h
-# requires special compiler flags (e.g. on True64 or Sequent).
+# requires special compiler flags (e.g. on Tru64 or Sequent).
# It gets checked for in the link test anyway.
# First of all, check if the user has set any of the PTHREAD_LIBS,
# etcetera environment variables, and if threads linking works using
# them:
-if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
- save_CFLAGS="$CFLAGS"
+if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then
+ ax_pthread_save_CC="$CC"
+ ax_pthread_save_CFLAGS="$CFLAGS"
+ ax_pthread_save_LIBS="$LIBS"
+ AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"])
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
- save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
- AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
- AC_TRY_LINK_FUNC([pthread_join], [ax_pthread_ok=yes])
+ AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS])
+ AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes])
AC_MSG_RESULT([$ax_pthread_ok])
- if test x"$ax_pthread_ok" = xno; then
+ if test "x$ax_pthread_ok" = "xno"; then
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
fi
- LIBS="$save_LIBS"
- CFLAGS="$save_CFLAGS"
+ CC="$ax_pthread_save_CC"
+ CFLAGS="$ax_pthread_save_CFLAGS"
+ LIBS="$ax_pthread_save_LIBS"
fi
# We must check for the threads library under a number of different
# which indicates that we try without any flags at all, and "pthread-config"
# which is a program returning the flags for the Pth emulation library.
-ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
+ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
# The ordering *is* (sometimes) important. Some notes on the
# individual items follow:
# none: in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
-# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
-# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
-# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
-# -pthreads: Solaris/gcc
-# -mthreads: Mingw32/gcc, Lynx/gcc
+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64
+# (Note: HP C rejects this with "bad form for `-t' option")
+# -pthreads: Solaris/gcc (Note: HP C also rejects)
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
-# doesn't hurt to check since this sometimes defines pthreads too;
-# also defines -D_REENTRANT)
-# ... -mt is also the pthreads flag for HP/aCC
+# doesn't hurt to check since this sometimes defines pthreads and
+# -D_REENTRANT too), HP C (must be checked before -lpthread, which
+# is present but should not be used directly; and before -mthreads,
+# because the compiler interprets this as "-mt" + "-hreads")
+# -mthreads: Mingw32/gcc, Lynx/gcc
# pthread: Linux, etcetera
# --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library)
-case ${host_os} in
+case $host_os in
+
+ freebsd*)
+
+ # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+ # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+
+ ax_pthread_flags="-kthread lthread $ax_pthread_flags"
+ ;;
+
+ hpux*)
+
+ # From the cc(1) man page: "[-mt] Sets various -D flags to enable
+ # multi-threading and also sets -lpthread."
+
+ ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags"
+ ;;
+
+ openedition*)
+
+ # IBM z/OS requires a feature-test macro to be defined in order to
+ # enable POSIX threads at all, so give the user a hint if this is
+ # not set. (We don't define these ourselves, as they can affect
+ # other portions of the system API in unpredictable ways.)
+
+ AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING],
+ [
+# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)
+ AX_PTHREAD_ZOS_MISSING
+# endif
+ ],
+ [AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])])
+ ;;
+
solaris*)
# On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based
- # tests will erroneously succeed. (We need to link with -pthreads/-mt/
- # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
- # a function called by this macro, so we could check for that, but
- # who knows whether they'll stub that too in a future libc.) So,
- # we'll just look for -pthreads and -lpthread first:
+ # tests will erroneously succeed. (N.B.: The stubs are missing
+ # pthread_cleanup_push, or rather a function called by this macro,
+ # so we could check for that, but who knows whether they'll stub
+ # that too in a future libc.) So we'll check first for the
+ # standard Solaris way of linking pthreads (-mt -lpthread).
+
+ ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags"
+ ;;
+esac
+
+# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)
- ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
+AS_IF([test "x$GCC" = "xyes"],
+ [ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"])
+
+# The presence of a feature test macro requesting re-entrant function
+# definitions is, on some systems, a strong hint that pthreads support is
+# correctly enabled
+
+case $host_os in
+ darwin* | hpux* | linux* | osf* | solaris*)
+ ax_pthread_check_macro="_REENTRANT"
;;
- darwin*)
- ax_pthread_flags="none -pthread $ax_pthread_flags"
+ aix*)
+ ax_pthread_check_macro="_THREAD_SAFE"
+ ;;
+
+ *)
+ ax_pthread_check_macro="--"
;;
esac
+AS_IF([test "x$ax_pthread_check_macro" = "x--"],
+ [ax_pthread_check_cond=0],
+ [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"])
+
+# Are we compiling with Clang?
+
+AC_CACHE_CHECK([whether $CC is Clang],
+ [ax_cv_PTHREAD_CLANG],
+ [ax_cv_PTHREAD_CLANG=no
+ # Note that Autoconf sets GCC=yes for Clang as well as GCC
+ if test "x$GCC" = "xyes"; then
+ AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG],
+ [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */
+# if defined(__clang__) && defined(__llvm__)
+ AX_PTHREAD_CC_IS_CLANG
+# endif
+ ],
+ [ax_cv_PTHREAD_CLANG=yes])
+ fi
+ ])
+ax_pthread_clang="$ax_cv_PTHREAD_CLANG"
+
+ax_pthread_clang_warning=no
+
+# Clang needs special handling, because older versions handle the -pthread
+# option in a rather... idiosyncratic way
+
+if test "x$ax_pthread_clang" = "xyes"; then
+
+ # Clang takes -pthread; it has never supported any other flag
+
+ # (Note 1: This will need to be revisited if a system that Clang
+ # supports has POSIX threads in a separate library. This tends not
+ # to be the way of modern systems, but it's conceivable.)
+
+ # (Note 2: On some systems, notably Darwin, -pthread is not needed
+ # to get POSIX threads support; the API is always present and
+ # active. We could reasonably leave PTHREAD_CFLAGS empty. But
+ # -pthread does define _REENTRANT, and while the Darwin headers
+ # ignore this macro, third-party headers might not.)
+
+ PTHREAD_CFLAGS="-pthread"
+ PTHREAD_LIBS=
+
+ ax_pthread_ok=yes
+
+ # However, older versions of Clang make a point of warning the user
+ # that, in an invocation where only linking and no compilation is
+ # taking place, the -pthread option has no effect ("argument unused
+ # during compilation"). They expect -pthread to be passed in only
+ # when source code is being compiled.
+ #
+ # Problem is, this is at odds with the way Automake and most other
+ # C build frameworks function, which is that the same flags used in
+ # compilation (CFLAGS) are also used in linking. Many systems
+ # supported by AX_PTHREAD require exactly this for POSIX threads
+ # support, and in fact it is often not straightforward to specify a
+ # flag that is used only in the compilation phase and not in
+ # linking. Such a scenario is extremely rare in practice.
+ #
+ # Even though use of the -pthread flag in linking would only print
+ # a warning, this can be a nuisance for well-run software projects
+ # that build with -Werror. So if the active version of Clang has
+ # this misfeature, we search for an option to squash it.
+
+ AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread],
+ [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG],
+ [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown
+ # Create an alternate version of $ac_link that compiles and
+ # links in two steps (.c -> .o, .o -> exe) instead of one
+ # (.c -> exe), because the warning occurs only in the second
+ # step
+ ax_pthread_save_ac_link="$ac_link"
+ ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g'
+ ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"`
+ ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)"
+ ax_pthread_save_CFLAGS="$CFLAGS"
+ for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do
+ AS_IF([test "x$ax_pthread_try" = "xunknown"], [break])
+ CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS"
+ ac_link="$ax_pthread_save_ac_link"
+ AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
+ [ac_link="$ax_pthread_2step_ac_link"
+ AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
+ [break])
+ ])
+ done
+ ac_link="$ax_pthread_save_ac_link"
+ CFLAGS="$ax_pthread_save_CFLAGS"
+ AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no])
+ ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"
+ ])
-# Clang doesn't consider unrecognized options an error unless we specify
-# -Werror. We throw in some extra Clang-specific options to ensure that
-# this doesn't happen for GCC, which also accepts -Werror.
+ case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in
+ no | unknown) ;;
+ *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;;
+ esac
-AC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags])
-save_CFLAGS="$CFLAGS"
-ax_pthread_extra_flags="-Werror"
-CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument"
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])],
- [AC_MSG_RESULT([yes])],
- [ax_pthread_extra_flags=
- AC_MSG_RESULT([no])])
-CFLAGS="$save_CFLAGS"
+fi # $ax_pthread_clang = yes
-if test x"$ax_pthread_ok" = xno; then
-for flag in $ax_pthread_flags; do
+if test "x$ax_pthread_ok" = "xno"; then
+for ax_pthread_try_flag in $ax_pthread_flags; do
- case $flag in
+ case $ax_pthread_try_flag in
none)
AC_MSG_CHECKING([whether pthreads work without any flags])
;;
+ -mt,pthread)
+ AC_MSG_CHECKING([whether pthreads work with -mt -lpthread])
+ PTHREAD_CFLAGS="-mt"
+ PTHREAD_LIBS="-lpthread"
+ ;;
+
-*)
- AC_MSG_CHECKING([whether pthreads work with $flag])
- PTHREAD_CFLAGS="$flag"
+ AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag])
+ PTHREAD_CFLAGS="$ax_pthread_try_flag"
;;
pthread-config)
AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
- if test x"$ax_pthread_config" = xno; then continue; fi
+ AS_IF([test "x$ax_pthread_config" = "xno"], [continue])
PTHREAD_CFLAGS="`pthread-config --cflags`"
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
;;
*)
- AC_MSG_CHECKING([for the pthreads library -l$flag])
- PTHREAD_LIBS="-l$flag"
+ AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag])
+ PTHREAD_LIBS="-l$ax_pthread_try_flag"
;;
esac
- save_LIBS="$LIBS"
- save_CFLAGS="$CFLAGS"
+ ax_pthread_save_CFLAGS="$CFLAGS"
+ ax_pthread_save_LIBS="$LIBS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
- CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags"
# Check for various functions. We must include pthread.h,
# since some functions may be macros. (On the Sequent, we
# pthread_cleanup_push because it is one of the few pthread
# functions on Solaris that doesn't have a non-functional libc stub.
# We try pthread_create on general principles.
+
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
+# if $ax_pthread_check_cond
+# error "$ax_pthread_check_macro must be defined"
+# endif
static void routine(void *a) { a = 0; }
static void *start_routine(void *a) { return a; }],
[pthread_t th; pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_cleanup_push(routine, 0);
pthread_cleanup_pop(0) /* ; */])],
- [ax_pthread_ok=yes],
- [])
+ [ax_pthread_ok=yes],
+ [])
- LIBS="$save_LIBS"
- CFLAGS="$save_CFLAGS"
+ CFLAGS="$ax_pthread_save_CFLAGS"
+ LIBS="$ax_pthread_save_LIBS"
AC_MSG_RESULT([$ax_pthread_ok])
- if test "x$ax_pthread_ok" = xyes; then
- break;
- fi
+ AS_IF([test "x$ax_pthread_ok" = "xyes"], [break])
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
fi
# Various other checks:
-if test "x$ax_pthread_ok" = xyes; then
- save_LIBS="$LIBS"
- LIBS="$PTHREAD_LIBS $LIBS"
- save_CFLAGS="$CFLAGS"
+if test "x$ax_pthread_ok" = "xyes"; then
+ ax_pthread_save_CFLAGS="$CFLAGS"
+ ax_pthread_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+ LIBS="$PTHREAD_LIBS $LIBS"
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
- AC_MSG_CHECKING([for joinable pthread attribute])
- attr_name=unknown
- for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
- AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
- [int attr = $attr; return attr /* ; */])],
- [attr_name=$attr; break],
- [])
- done
- AC_MSG_RESULT([$attr_name])
- if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
- AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name],
- [Define to necessary symbol if this constant
- uses a non-standard name on your system.])
- fi
-
- AC_MSG_CHECKING([if more special flags are required for pthreads])
- flag=no
- case ${host_os} in
- aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";;
- osf* | hpux*) flag="-D_REENTRANT";;
- solaris*)
- if test "$GCC" = "yes"; then
- flag="-D_REENTRANT"
- else
- # TODO: What about Clang on Solaris?
- flag="-mt -D_REENTRANT"
- fi
- ;;
- esac
- AC_MSG_RESULT([$flag])
- if test "x$flag" != xno; then
- PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
- fi
+ AC_CACHE_CHECK([for joinable pthread attribute],
+ [ax_cv_PTHREAD_JOINABLE_ATTR],
+ [ax_cv_PTHREAD_JOINABLE_ATTR=unknown
+ for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
+ [int attr = $ax_pthread_attr; return attr /* ; */])],
+ [ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break],
+ [])
+ done
+ ])
+ AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \
+ test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \
+ test "x$ax_pthread_joinable_attr_defined" != "xyes"],
+ [AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE],
+ [$ax_cv_PTHREAD_JOINABLE_ATTR],
+ [Define to necessary symbol if this constant
+ uses a non-standard name on your system.])
+ ax_pthread_joinable_attr_defined=yes
+ ])
+
+ AC_CACHE_CHECK([whether more special flags are required for pthreads],
+ [ax_cv_PTHREAD_SPECIAL_FLAGS],
+ [ax_cv_PTHREAD_SPECIAL_FLAGS=no
+ case $host_os in
+ solaris*)
+ ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS"
+ ;;
+ esac
+ ])
+ AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \
+ test "x$ax_pthread_special_flags_added" != "xyes"],
+ [PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS"
+ ax_pthread_special_flags_added=yes])
AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
- [ax_cv_PTHREAD_PRIO_INHERIT], [
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
- [[int i = PTHREAD_PRIO_INHERIT;]])],
- [ax_cv_PTHREAD_PRIO_INHERIT=yes],
- [ax_cv_PTHREAD_PRIO_INHERIT=no])
+ [ax_cv_PTHREAD_PRIO_INHERIT],
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
+ [[int i = PTHREAD_PRIO_INHERIT;]])],
+ [ax_cv_PTHREAD_PRIO_INHERIT=yes],
+ [ax_cv_PTHREAD_PRIO_INHERIT=no])
])
- AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"],
- [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])])
+ AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \
+ test "x$ax_pthread_prio_inherit_defined" != "xyes"],
+ [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])
+ ax_pthread_prio_inherit_defined=yes
+ ])
- LIBS="$save_LIBS"
- CFLAGS="$save_CFLAGS"
+ CFLAGS="$ax_pthread_save_CFLAGS"
+ LIBS="$ax_pthread_save_LIBS"
# More AIX lossage: compile with *_r variant
- if test "x$GCC" != xyes; then
+ if test "x$GCC" != "xyes"; then
case $host_os in
aix*)
AS_CASE(["x/$CC"],
- [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
- [#handle absolute path differently from PATH based program lookup
- AS_CASE(["x$CC"],
- [x/*],
- [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
- [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
+ [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
+ [#handle absolute path differently from PATH based program lookup
+ AS_CASE(["x$CC"],
+ [x/*],
+ [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
+ [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
;;
esac
fi
AC_SUBST([PTHREAD_CC])
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
-if test x"$ax_pthread_ok" = xyes; then
+if test "x$ax_pthread_ok" = "xyes"; then
ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
:
else
--- /dev/null
+# ===========================================================================
+# https://www.gnu.org/software/autoconf-archive/ax_require_defined.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_REQUIRE_DEFINED(MACRO)
+#
+# DESCRIPTION
+#
+# AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
+# been defined and thus are available for use. This avoids random issues
+# where a macro isn't expanded. Instead the configure script emits a
+# non-fatal:
+#
+# ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
+#
+# It's like AC_REQUIRE except it doesn't expand the required macro.
+#
+# Here's an example:
+#
+# AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
+#
+# LICENSE
+#
+# Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 2
+
+AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
+ m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
+])dnl AX_REQUIRE_DEFINED
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_restore_flags.html
+# https://www.gnu.org/software/autoconf-archive/ax_restore_flags.html
# ===========================================================================
#
# SYNOPSIS
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 6
+#serial 7
# save one flag in name space
AC_DEFUN([_AX_RESTORE_ONE_FLAG],[dnl
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_save_flags.html
+# https://www.gnu.org/software/autoconf-archive/ax_save_flags.html
# ===========================================================================
#
# SYNOPSIS
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 7
+#serial 8
# list of flag to save
AC_DEFUN([_AX_SAVE_FLAGS_LIST],[dnl
--- /dev/null
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_switch_flags.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_SWITCH_FLAGS(newnamespace,[oldnamespace])
+#
+# DESCRIPTION
+#
+# Switch common compilation flags from temporary variables between two
+# compilation namespace.
+#
+# Compilation flags includes: CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS, LIBS,
+# OBJCFLAGS.
+#
+# By default these flags are restored to a global (empty) namespace, but
+# user could restore from specific NAMESPACE by using
+# AX_RESTORE_FLAGS(NAMESPACE) macro.
+#
+# Typical usage is like:
+#
+# AX_SAVE_FLAGS(beginprogram)
+# CPPFLAGS="-Imypackagespath ${CPPFLAGS}"
+# AX_SWITCH_FLAGS(mypackage,beginprogram)
+#
+# LICENSE
+#
+# Copyright (c) 2009 Filippo Giunchedi <filippo@esaurito.net>
+# Copyright (c) 2011 Russ Allbery <rra@stanford.edu>
+# Copyright (c) 2013 Bastien ROUCARIES <roucaries.bastien+autoconf@gmail.com>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 2
+
+AC_DEFUN([AX_SWITCH_FLAGS], [
+ AC_REQUIRE(AX_SAVE_FLAGS)
+ AC_REQUIRE(AX_RESTORE_FLAGS)
+ AS_IF([test "X$1" = "X"], AC_MSG_ERROR(newnamespace is empty)]
+ AX_SAVE_FLAGS($1[])
+ AX_RESTORE_FLAGS($2[])
+])
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_with_prog.html
+# https://www.gnu.org/software/autoconf-archive/ax_with_prog.html
# ===========================================================================
#
# SYNOPSIS
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 16
+#serial 17
AC_DEFUN([AX_WITH_PROG],[
AC_PREREQ([2.61])
+++ /dev/null
-AC_DEFUN([CONFIG_EXTRA], [
-
-AH_TOP([
-#pragma once
-
-/* _SYS_FEATURE_TESTS_H is Solaris, _FEATURES_H is GCC */
-#if defined( _SYS_FEATURE_TESTS_H) || defined(_FEATURES_H)
-#error "You should include mem_config.h as your first include file"
-#endif
-
-])
-
-AH_BOTTOM([
-
-#ifndef __STDC_FORMAT_MACROS
-# define __STDC_FORMAT_MACROS
-#endif
-
-#if defined(__cplusplus)
-# include CINTTYPES_H
-#else
-# include <inttypes.h>
-#endif
-
-#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
-# define HAVE_ULONG 1
-typedef unsigned long int ulong;
-#endif
-
-])
-
-])dnl CONFIG_EXTRA
--- /dev/null
+# SYNOPSIS
+#
+# CONFIG_EXTRA
+#
+# DESCRIPTION
+#
+# Adds required extras to config.h
+#
+# LICENSE
+#
+# Copyright (C) 2014 Andrew Hutchings
+# Based on bottom.m4 from libdrizzle
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#
+# * The names of its contributors may not be used to endorse or
+# promote products derived from this software without specific prior
+# written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#serial 1
+
+AC_DEFUN([CONFIG_EXTRA], [
+
+AH_TOP([
+#pragma once
+
+/* _SYS_FEATURE_TESTS_H is Solaris, _FEATURES_H is GCC */
+#if defined( _SYS_FEATURE_TESTS_H) || defined(_FEATURES_H)
+# error "You should include config.h as your first include file"
+#endif
+
+])
+])dnl CONFIG_EXTRA