Blame m4/acinclude.m4

Packit 7838c8
dnl ---------------------------------------------------------------------------
Packit 7838c8
dnl Message output
Packit 7838c8
dnl ---------------------------------------------------------------------------
Packit 7838c8
AC_DEFUN([LOC_MSG],[echo "$1"])
Packit 7838c8
Packit 7838c8
dnl ---------------------------------------------------------------------------
Packit 7838c8
dnl Available from the GNU Autoconf Macro Archive at:
Packit 7838c8
dnl http://www.gnu.org/software/ac-archive/vl_prog_cc_warnings.html
Packit 7838c8
dnl ---------------------------------------------------------------------------
Packit 7838c8
Packit 7838c8
dnl @synopsis VL_PROG_CC_WARNINGS([ANSI])
Packit 7838c8
dnl
Packit 7838c8
dnl Enables a reasonable set of warnings for the C compiler.
Packit 7838c8
dnl Optionally, if the first argument is nonempty, turns on flags which
Packit 7838c8
dnl enforce and/or enable proper ANSI C if such are known with the
Packit 7838c8
dnl compiler used.
Packit 7838c8
dnl
Packit 7838c8
dnl Currently this macro knows about GCC, Solaris C compiler, Digital
Packit 7838c8
dnl Unix C compiler, C for AIX Compiler, HP-UX C compiler, IRIX C
Packit 7838c8
dnl compiler, NEC SX-5 (Super-UX 10) C compiler, and Cray J90 (Unicos
Packit 7838c8
dnl 10.0.0.8) C compiler.
Packit 7838c8
dnl
Packit 7838c8
dnl @category C
Packit 7838c8
dnl @author Ville Laurikari <vl@iki.fi>
Packit 7838c8
dnl @version 2002-04-04
Packit 7838c8
dnl @license AllPermissive
Packit 7838c8
Packit 7838c8
AC_DEFUN([VL_PROG_CC_WARNINGS], [
Packit 7838c8
  ansi=$1
Packit 7838c8
  if test -z "$ansi"; then
Packit 7838c8
    msg="for C compiler warning flags"
Packit 7838c8
  else
Packit 7838c8
    msg="for C compiler warning and ANSI conformance flags"
Packit 7838c8
  fi
Packit 7838c8
  AC_CACHE_CHECK($msg, vl_cv_prog_cc_warnings, [
Packit 7838c8
    if test -n "$CC"; then
Packit 7838c8
      cat > conftest.c <
Packit 7838c8
int main(int argc, char **argv) { return 0; }
Packit 7838c8
EOF
Packit 7838c8
Packit 7838c8
      dnl GCC. -W option has been renamed in -wextra in latest gcc versions.
Packit 7838c8
      if test "$GCC" = "yes"; then
Packit 7838c8
        if test -z "$ansi"; then
Packit 7838c8
          vl_cv_prog_cc_warnings="-Wall -W"
Packit 7838c8
        else
Packit 7838c8
          vl_cv_prog_cc_warnings="-Wall -W -ansi -pedantic"
Packit 7838c8
        fi
Packit 7838c8
Packit 7838c8
      dnl Most compilers print some kind of a version string with some command
Packit 7838c8
      dnl line options (often "-V").  The version string should be checked
Packit 7838c8
      dnl before doing a test compilation run with compiler-specific flags.
Packit 7838c8
      dnl This is because some compilers (like the Cray compiler) only
Packit 7838c8
      dnl produce a warning message for unknown flags instead of returning
Packit 7838c8
      dnl an error, resulting in a false positive.  Also, compilers may do
Packit 7838c8
      dnl erratic things when invoked with flags meant for a different
Packit 7838c8
      dnl compiler.
Packit 7838c8
Packit 7838c8
      dnl Solaris C compiler
Packit 7838c8
      elif $CC -V 2>&1 | grep -i "WorkShop" > /dev/null 2>&1 &&
Packit 7838c8
           $CC -c -v -Xc conftest.c > /dev/null 2>&1 &&
Packit 7838c8
           test -f conftest.o; then
Packit 7838c8
        if test -z "$ansi"; then
Packit 7838c8
          vl_cv_prog_cc_warnings="-v"
Packit 7838c8
        else
Packit 7838c8
          vl_cv_prog_cc_warnings="-v -Xc"
Packit 7838c8
        fi
Packit 7838c8
Packit 7838c8
      dnl Digital Unix C compiler
Packit 7838c8
      elif $CC -V 2>&1 | grep -i "Digital UNIX Compiler" > /dev/null 2>&1 &&
Packit 7838c8
           $CC -c -verbose -w0 -warnprotos -std1 conftest.c > /dev/null 2>&1 &&
Packit 7838c8
           test -f conftest.o; then
Packit 7838c8
        if test -z "$ansi"; then
Packit 7838c8
          vl_cv_prog_cc_warnings="-verbose -w0 -warnprotos"
Packit 7838c8
        else
Packit 7838c8
          vl_cv_prog_cc_warnings="-verbose -w0 -warnprotos -std1"
Packit 7838c8
        fi
Packit 7838c8
Packit 7838c8
      dnl C for AIX Compiler
Packit 7838c8
      elif $CC 2>&1 | grep -i "C for AIX Compiler" > /dev/null 2>&1 &&
Packit 7838c8
           $CC -c -qlanglvl=ansi -qinfo=all conftest.c > /dev/null 2>&1 &&
Packit 7838c8
           test -f conftest.o; then
Packit 7838c8
        if test -z "$ansi"; then
Packit 7838c8
          vl_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd"
Packit 7838c8
        else
Packit 7838c8
          vl_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd -qlanglvl=ansi"
Packit 7838c8
        fi
Packit 7838c8
Packit 7838c8
      dnl IRIX C compiler
Packit 7838c8
      elif $CC -version 2>&1 | grep -i "MIPSpro Compilers" > /dev/null 2>&1 &&
Packit 7838c8
           $CC -c -fullwarn -ansi -ansiE conftest.c > /dev/null 2>&1 &&
Packit 7838c8
           test -f conftest.o; then
Packit 7838c8
        if test -z "$ansi"; then
Packit 7838c8
          vl_cv_prog_cc_warnings="-fullwarn"
Packit 7838c8
        else
Packit 7838c8
          vl_cv_prog_cc_warnings="-fullwarn -ansi -ansiE"
Packit 7838c8
        fi
Packit 7838c8
Packit 7838c8
      dnl HP-UX C compiler
Packit 7838c8
      elif what $CC 2>&1 | grep -i "HP C Compiler" > /dev/null 2>&1 &&
Packit 7838c8
           $CC -c -Aa +w1 conftest.c > /dev/null 2>&1 &&
Packit 7838c8
           test -f conftest.o; then
Packit 7838c8
        if test -z "$ansi"; then
Packit 7838c8
          vl_cv_prog_cc_warnings="+w1"
Packit 7838c8
        else
Packit 7838c8
          vl_cv_prog_cc_warnings="+w1 -Aa"
Packit 7838c8
        fi
Packit 7838c8
Packit 7838c8
      dnl The NEC SX-5 (Super-UX 10) C compiler
Packit 7838c8
      elif $CC -V 2>&1 | grep "/SX" > /dev/null 2>&1 &&
Packit 7838c8
           $CC -c -pvctl[,]fullmsg -Xc conftest.c > /dev/null 2>&1 &&
Packit 7838c8
           test -f conftest.o; then
Packit 7838c8
        if test -z "$ansi"; then
Packit 7838c8
          vl_cv_prog_cc_warnings="-pvctl[,]fullmsg"
Packit 7838c8
        else
Packit 7838c8
          vl_cv_prog_cc_warnings="-pvctl[,]fullmsg -Xc"
Packit 7838c8
        fi
Packit 7838c8
Packit 7838c8
      dnl The Cray C compiler (Unicos)
Packit 7838c8
      elif $CC -V 2>&1 | grep -i "Cray" > /dev/null 2>&1 &&
Packit 7838c8
           $CC -c -h msglevel 2 conftest.c > /dev/null 2>&1 &&
Packit 7838c8
           test -f conftest.o; then
Packit 7838c8
        if test -z "$ansi"; then
Packit 7838c8
          vl_cv_prog_cc_warnings="-h msglevel 2"
Packit 7838c8
        else
Packit 7838c8
          vl_cv_prog_cc_warnings="-h msglevel 2 -h conform"
Packit 7838c8
        fi
Packit 7838c8
Packit 7838c8
      fi
Packit 7838c8
      rm -f conftest.*
Packit 7838c8
    fi
Packit 7838c8
    if test -n "$vl_cv_prog_cc_warnings"; then
Packit 7838c8
      CFLAGS="$CFLAGS $vl_cv_prog_cc_warnings"
Packit 7838c8
    else
Packit 7838c8
      vl_cv_prog_cc_warnings="unknown"
Packit 7838c8
    fi
Packit 7838c8
  ])
Packit 7838c8
])dnl
Packit 7838c8
Packit 7838c8
dnl ---------------------------------------------------------------------------
Packit 7838c8
dnl Available from the GNU Autoconf Macro Archive at:
Packit 7838c8
dnl http://autoconf-archive.cryp.to/ax_lang_compiler_ms.html
Packit 7838c8
dnl ---------------------------------------------------------------------------
Packit 7838c8
Packit 7838c8
dnl @synopsis AX_LANG_COMPILER_MS
Packit 7838c8
dnl
Packit 7838c8
dnl Check whether the compiler for the current language is Microsoft.
Packit 7838c8
dnl
Packit 7838c8
dnl This macro is modeled after _AC_LANG_COMPILER_GNU in the GNU
Packit 7838c8
dnl Autoconf implementation.
Packit 7838c8
dnl
Packit 7838c8
dnl @category InstalledPackages
Packit 7838c8
dnl @author Braden McDaniel <braden@endoframe.com>
Packit 7838c8
dnl @version 2004-11-15
Packit 7838c8
dnl @license AllPermissive
Packit 7838c8
Packit 7838c8
AC_DEFUN([AX_LANG_COMPILER_MS],
Packit 7838c8
[AC_CACHE_CHECK([whether we are using the Microsoft _AC_LANG compiler],
Packit 7838c8
                [ax_cv_[]_AC_LANG_ABBREV[]_compiler_ms],
Packit 7838c8
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef _MSC_VER
Packit 7838c8
       choke me
Packit 7838c8
#endif
Packit 7838c8
]])],
Packit 7838c8
                   [ax_compiler_ms=yes],
Packit 7838c8
                   [ax_compiler_ms=no])
Packit 7838c8
ax_cv_[]_AC_LANG_ABBREV[]_compiler_ms=$ax_compiler_ms
Packit 7838c8
])])
Packit 7838c8
Packit 7838c8
dnl ---------------------------------------------------------------------------
Packit 7838c8
dnl Available from the GNU Autoconf Macro Archive at:
Packit 7838c8
dnl http://www.gnu.org/software/ac-archive/ax_check_gl.html
Packit 7838c8
dnl ---------------------------------------------------------------------------
Packit 7838c8
Packit 7838c8
dnl SYNOPSIS
Packit 7838c8
dnl
Packit 7838c8
dnl   AX_CHECK_GL
Packit 7838c8
dnl
Packit 7838c8
dnl DESCRIPTION
Packit 7838c8
dnl
Packit 7838c8
dnl   Check for an OpenGL implementation. If GL is found, the required
Packit 7838c8
dnl   compiler and linker flags are included in the output variables
Packit 7838c8
dnl   "GL_CFLAGS" and "GL_LIBS", respectively. If no usable GL implementation
Packit 7838c8
dnl   is found, "no_gl" is set to "yes".
Packit 7838c8
dnl
Packit 7838c8
dnl   If the header "GL/gl.h" is found, "HAVE_GL_GL_H" is defined. If the
Packit 7838c8
dnl   header "OpenGL/gl.h" is found, HAVE_OPENGL_GL_H is defined. These
Packit 7838c8
dnl   preprocessor definitions may not be mutually exclusive.
Packit 7838c8
dnl
Packit 7838c8
dnl LICENSE
Packit 7838c8
dnl
Packit 7838c8
dnl   Copyright (c) 2009 Braden McDaniel <braden@endoframe.com>
Packit 7838c8
dnl
Packit 7838c8
dnl   This program is free software; you can redistribute it and/or modify it
Packit 7838c8
dnl   under the terms of the GNU General Public License as published by the
Packit 7838c8
dnl   Free Software Foundation; either version 2 of the License, or (at your
Packit 7838c8
dnl   option) any later version.
Packit 7838c8
dnl
Packit 7838c8
dnl   This program is distributed in the hope that it will be useful, but
Packit 7838c8
dnl   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 7838c8
dnl   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Packit 7838c8
dnl   Public License for more details.
Packit 7838c8
dnl
Packit 7838c8
dnl   You should have received a copy of the GNU General Public License along
Packit 7838c8
dnl   with this program. If not, see <http://www.gnu.org/licenses/>.
Packit 7838c8
dnl
Packit 7838c8
dnl   As a special exception, the respective Autoconf Macro's copyright owner
Packit 7838c8
dnl   gives unlimited permission to copy, distribute and modify the configure
Packit 7838c8
dnl   scripts that are the output of Autoconf when processing the Macro. You
Packit 7838c8
dnl   need not follow the terms of the GNU General Public License when using
Packit 7838c8
dnl   or distributing such scripts, even though portions of the text of the
Packit 7838c8
dnl   Macro appear in them. The GNU General Public License (GPL) does govern
Packit 7838c8
dnl   all other use of the material that constitutes the Autoconf Macro.
Packit 7838c8
dnl
Packit 7838c8
dnl   This special exception to the GPL applies to versions of the Autoconf
Packit 7838c8
dnl   Macro released by the Autoconf Archive. When you make and distribute a
Packit 7838c8
dnl   modified version of the Autoconf Macro, you may extend this special
Packit 7838c8
dnl   exception to the GPL to apply to your modified version as well.
Packit 7838c8
Packit 7838c8
AC_DEFUN([AX_CHECK_GL],
Packit 7838c8
[AC_REQUIRE([AC_CANONICAL_HOST])
Packit 7838c8
AC_REQUIRE([AC_PATH_X])dnl
Packit 7838c8
AC_REQUIRE([AX_PTHREAD])dnl
Packit 7838c8
Packit 7838c8
AC_LANG_PUSH([C])
Packit 7838c8
AX_LANG_COMPILER_MS
Packit 7838c8
AS_IF([test X$ax_compiler_ms = Xno],
Packit 7838c8
      [GL_CFLAGS="${PTHREAD_CFLAGS}"; GL_LIBS="${PTHREAD_LIBS} -lm"])
Packit 7838c8
Packit 7838c8
dnl
Packit 7838c8
dnl Use x_includes and x_libraries if they have been set (presumably by
Packit 7838c8
dnl AC_PATH_X).
Packit 7838c8
dnl
Packit 7838c8
AS_IF([test "X$no_x" != "Xyes"],
Packit 7838c8
      [AS_IF([test -n "$x_includes"],
Packit 7838c8
             [GL_CFLAGS="-I${x_includes} ${GL_CFLAGS}"])]
Packit 7838c8
       AS_IF([test -n "$x_libraries"],
Packit 7838c8
             [GL_LIBS="-L${x_libraries} -lX11 ${GL_LIBS}"]))
Packit 7838c8
Packit 7838c8
ax_save_CPPFLAGS="${CPPFLAGS}"
Packit 7838c8
CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
Packit 7838c8
AC_CHECK_HEADERS([GL/gl.h OpenGL/gl.h])
Packit 7838c8
CPPFLAGS="${ax_save_CPPFLAGS}"
Packit 7838c8
Packit 7838c8
AC_CHECK_HEADERS([windows.h])
Packit 7838c8
Packit 7838c8
m4_define([AX_CHECK_GL_PROGRAM],
Packit 7838c8
          [AC_LANG_PROGRAM([[
Packit 7838c8
# if defined(HAVE_WINDOWS_H) && defined(_WIN32)
Packit 7838c8
#   include <windows.h>
Packit 7838c8
# endif
Packit 7838c8
# ifdef HAVE_GL_GL_H
Packit 7838c8
#   include <GL/gl.h>
Packit 7838c8
# elif defined(HAVE_OPENGL_GL_H)
Packit 7838c8
#   include <OpenGL/gl.h>
Packit 7838c8
# else
Packit 7838c8
#   error no gl.h
Packit 7838c8
# endif]],
Packit 7838c8
                           [[glBegin(0)]])])
Packit 7838c8
Packit 7838c8
AC_CACHE_CHECK([for OpenGL library], [ax_cv_check_gl_libgl],
Packit 7838c8
[ax_cv_check_gl_libgl="no"
Packit 7838c8
case $host_cpu in
Packit 7838c8
  x86_64) ax_check_gl_libdir=lib64 ;;
Packit 7838c8
  *)      ax_check_gl_libdir=lib ;;
Packit 7838c8
esac
Packit 7838c8
ax_save_CPPFLAGS="${CPPFLAGS}"
Packit 7838c8
CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
Packit 7838c8
ax_save_LIBS="${LIBS}"
Packit 7838c8
LIBS=""
Packit 7838c8
ax_check_libs="-lopengl32 -lGL"
Packit 7838c8
for ax_lib in ${ax_check_libs}; do
Packit 7838c8
  AS_IF([test X$ax_compiler_ms = Xyes],
Packit 7838c8
        [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`],
Packit 7838c8
        [ax_try_lib="${ax_lib}"])
Packit 7838c8
  LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}"
Packit 7838c8
AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
Packit 7838c8
               [ax_cv_check_gl_libgl="${ax_try_lib}"; break],
Packit 7838c8
               [ax_check_gl_nvidia_flags="-L/usr/${ax_check_gl_libdir}/nvidia" LIBS="${ax_try_lib} ${ax_check_gl_nvidia_flags} ${GL_LIBS} ${ax_save_LIBS}"
Packit 7838c8
AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
Packit 7838c8
               [ax_cv_check_gl_libgl="${ax_try_lib} ${ax_check_gl_nvidia_flags}"; break],
Packit 7838c8
               [ax_check_gl_dylib_flag='-dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib' LIBS="${ax_try_lib} ${ax_check_gl_dylib_flag} ${GL_LIBS} ${ax_save_LIBS}"
Packit 7838c8
AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
Packit 7838c8
               [ax_cv_check_gl_libgl="${ax_try_lib} ${ax_check_gl_dylib_flag}"; break])])])
Packit 7838c8
done
Packit 7838c8
Packit 7838c8
AS_IF([test "X$ax_cv_check_gl_libgl" = Xno -a "X$no_x" = Xyes],
Packit 7838c8
[LIBS='-framework OpenGL'
Packit 7838c8
AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
Packit 7838c8
               [ax_cv_check_gl_libgl="$LIBS"])])
Packit 7838c8
Packit 7838c8
LIBS=${ax_save_LIBS}
Packit 7838c8
CPPFLAGS=${ax_save_CPPFLAGS}])
Packit 7838c8
Packit 7838c8
AS_IF([test "X$ax_cv_check_gl_libgl" = Xno],
Packit 7838c8
      [no_gl=yes; GL_CFLAGS=""; GL_LIBS=""],
Packit 7838c8
      [GL_LIBS="${ax_cv_check_gl_libgl} ${GL_LIBS}"])
Packit 7838c8
AC_LANG_POP([C])
Packit 7838c8
Packit 7838c8
AC_SUBST([GL_CFLAGS])
Packit 7838c8
AC_SUBST([GL_LIBS])
Packit 7838c8
])dnl
Packit 7838c8
Packit 7838c8
dnl ---------------------------------------------------------------------------
Packit 7838c8
dnl Available from the GNU Autoconf Macro Archive at:
Packit 7838c8
dnl http://www.gnu.org/software/ac-archive/ax_check_glu.html
Packit 7838c8
dnl ---------------------------------------------------------------------------
Packit 7838c8
Packit 7838c8
dnl SYNOPSIS
Packit 7838c8
dnl
Packit 7838c8
dnl   AX_CHECK_GLU
Packit 7838c8
dnl
Packit 7838c8
dnl DESCRIPTION
Packit 7838c8
dnl
Packit 7838c8
dnl   Check for GLU. If GLU is found, the required preprocessor and linker
Packit 7838c8
dnl   flags are included in the output variables "GLU_CFLAGS" and "GLU_LIBS",
Packit 7838c8
dnl   respectively. If no GLU implementation is found, "no_glu" is set to
Packit 7838c8
dnl   "yes".
Packit 7838c8
dnl
Packit 7838c8
dnl   If the header "GL/glu.h" is found, "HAVE_GL_GLU_H" is defined. If the
Packit 7838c8
dnl   header "OpenGL/glu.h" is found, HAVE_OPENGL_GLU_H is defined. These
Packit 7838c8
dnl   preprocessor definitions may not be mutually exclusive.
Packit 7838c8
dnl
Packit 7838c8
dnl   Some implementations (in particular, some versions of Mac OS X) are
Packit 7838c8
dnl   known to treat the GLU tesselator callback function type as "GLvoid
Packit 7838c8
dnl   (*)(...)" rather than the standard "GLvoid (*)()". If the former
Packit 7838c8
dnl   condition is detected, this macro defines "HAVE_VARARGS_GLU_TESSCB".
Packit 7838c8
dnl
Packit 7838c8
dnl LICENSE
Packit 7838c8
dnl
Packit 7838c8
dnl   Copyright (c) 2009 Braden McDaniel <braden@endoframe.com>
Packit 7838c8
dnl
Packit 7838c8
dnl   This program is free software; you can redistribute it and/or modify it
Packit 7838c8
dnl   under the terms of the GNU General Public License as published by the
Packit 7838c8
dnl   Free Software Foundation; either version 2 of the License, or (at your
Packit 7838c8
dnl   option) any later version.
Packit 7838c8
dnl
Packit 7838c8
dnl   This program is distributed in the hope that it will be useful, but
Packit 7838c8
dnl   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 7838c8
dnl   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Packit 7838c8
dnl   Public License for more details.
Packit 7838c8
dnl
Packit 7838c8
dnl   You should have received a copy of the GNU General Public License along
Packit 7838c8
dnl   with this program. If not, see <http://www.gnu.org/licenses/>.
Packit 7838c8
dnl
Packit 7838c8
dnl   As a special exception, the respective Autoconf Macro's copyright owner
Packit 7838c8
dnl   gives unlimited permission to copy, distribute and modify the configure
Packit 7838c8
dnl   scripts that are the output of Autoconf when processing the Macro. You
Packit 7838c8
dnl   need not follow the terms of the GNU General Public License when using
Packit 7838c8
dnl   or distributing such scripts, even though portions of the text of the
Packit 7838c8
dnl   Macro appear in them. The GNU General Public License (GPL) does govern
Packit 7838c8
dnl   all other use of the material that constitutes the Autoconf Macro.
Packit 7838c8
dnl
Packit 7838c8
dnl   This special exception to the GPL applies to versions of the Autoconf
Packit 7838c8
dnl   Macro released by the Autoconf Archive. When you make and distribute a
Packit 7838c8
dnl   modified version of the Autoconf Macro, you may extend this special
Packit 7838c8
dnl   exception to the GPL to apply to your modified version as well.
Packit 7838c8
Packit 7838c8
AC_DEFUN([AX_CHECK_GLU],
Packit 7838c8
[AC_REQUIRE([AX_CHECK_GL])dnl
Packit 7838c8
AC_REQUIRE([AC_PROG_CXX])dnl
Packit 7838c8
GLU_CFLAGS="${GL_CFLAGS}"
Packit 7838c8
Packit 7838c8
ax_save_CPPFLAGS="${CPPFLAGS}"
Packit 7838c8
CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
Packit 7838c8
AC_CHECK_HEADERS([GL/glu.h OpenGL/glu.h])
Packit 7838c8
CPPFLAGS="${ax_save_CPPFLAGS}"
Packit 7838c8
Packit 7838c8
m4_define([AX_CHECK_GLU_PROGRAM],
Packit 7838c8
          [AC_LANG_PROGRAM([[
Packit 7838c8
# if defined(HAVE_WINDOWS_H) && defined(_WIN32)
Packit 7838c8
#   include <windows.h>
Packit 7838c8
# endif
Packit 7838c8
# ifdef HAVE_GL_GLU_H
Packit 7838c8
#   include <GL/glu.h>
Packit 7838c8
# elif defined(HAVE_OPENGL_GLU_H)
Packit 7838c8
#   include <OpenGL/glu.h>
Packit 7838c8
# else
Packit 7838c8
#   error no glu.h
Packit 7838c8
# endif]],
Packit 7838c8
                           [[gluBeginCurve(0)]])])
Packit 7838c8
Packit 7838c8
AC_CACHE_CHECK([for OpenGL Utility library], [ax_cv_check_glu_libglu],
Packit 7838c8
[ax_cv_check_glu_libglu="no"
Packit 7838c8
ax_save_CPPFLAGS="${CPPFLAGS}"
Packit 7838c8
CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
Packit 7838c8
ax_save_LIBS="${LIBS}"
Packit 7838c8
Packit 7838c8
dnl
Packit 7838c8
dnl First, check for the possibility that everything we need is already in
Packit 7838c8
dnl GL_LIBS.
Packit 7838c8
dnl
Packit 7838c8
LIBS="${GL_LIBS} ${ax_save_LIBS}"
Packit 7838c8
dnl
Packit 7838c8
dnl libGLU typically links with libstdc++ on POSIX platforms.
Packit 7838c8
dnl However, setting the language to C++ means that test program
Packit 7838c8
dnl source is named "conftest.cc"; and Microsoft cl doesn't know what
Packit 7838c8
dnl to do with such a file.
Packit 7838c8
dnl
Packit 7838c8
AC_LANG_PUSH([C++])
Packit 7838c8
AS_IF([test X$ax_compiler_ms = Xyes],
Packit 7838c8
      [AC_LANG_PUSH([C])])
Packit 7838c8
AC_LINK_IFELSE(
Packit 7838c8
[AX_CHECK_GLU_PROGRAM],
Packit 7838c8
[ax_cv_check_glu_libglu=yes],
Packit 7838c8
[LIBS=""
Packit 7838c8
ax_check_libs="-lglu32 -lGLU"
Packit 7838c8
for ax_lib in ${ax_check_libs}; do
Packit 7838c8
  AS_IF([test X$ax_compiler_ms = Xyes],
Packit 7838c8
        [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`],
Packit 7838c8
        [ax_try_lib="${ax_lib}"])
Packit 7838c8
  LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}"
Packit 7838c8
  AC_LINK_IFELSE([AX_CHECK_GLU_PROGRAM],
Packit 7838c8
                 [ax_cv_check_glu_libglu="${ax_try_lib}"; break])
Packit 7838c8
done
Packit 7838c8
])
Packit 7838c8
AS_IF([test X$ax_compiler_ms = Xyes],
Packit 7838c8
      [AC_LANG_POP([C])])
Packit 7838c8
AC_LANG_POP([C++])
Packit 7838c8
Packit 7838c8
LIBS=${ax_save_LIBS}
Packit 7838c8
CPPFLAGS=${ax_save_CPPFLAGS}])
Packit 7838c8
AS_IF([test "X$ax_cv_check_glu_libglu" = Xno],
Packit 7838c8
      [no_glu=yes; GLU_CFLAGS=""; GLU_LIBS=""],
Packit 7838c8
      [AS_IF([test "X$ax_cv_check_glu_libglu" = Xyes],
Packit 7838c8
             [GLU_LIBS="$GL_LIBS"],
Packit 7838c8
             [GLU_LIBS="${ax_cv_check_glu_libglu} ${GL_LIBS}"])])
Packit 7838c8
AC_SUBST([GLU_CFLAGS])
Packit 7838c8
AC_SUBST([GLU_LIBS])
Packit 7838c8
Packit 7838c8
dnl
Packit 7838c8
dnl Some versions of Mac OS X include a broken interpretation of the GLU
Packit 7838c8
dnl tesselation callback function signature.
Packit 7838c8
dnl
Packit 7838c8
AS_IF([test "X$ax_cv_check_glu_libglu" != Xno],
Packit 7838c8
[AC_CACHE_CHECK([for varargs GLU tesselator callback function type],
Packit 7838c8
                [ax_cv_varargs_glu_tesscb],
Packit 7838c8
[ax_cv_varargs_glu_tesscb=no
Packit 7838c8
ax_save_CFLAGS="$CFLAGS"
Packit 7838c8
CFLAGS="$GL_CFLAGS $CFLAGS"
Packit 7838c8
AC_COMPILE_IFELSE(
Packit 7838c8
[AC_LANG_PROGRAM([[
Packit 7838c8
# ifdef HAVE_GL_GLU_H
Packit 7838c8
#   include <GL/glu.h>
Packit 7838c8
# else
Packit 7838c8
#   include <OpenGL/glu.h>
Packit 7838c8
# endif]],
Packit 7838c8
                 [[GLvoid (*func)(...); gluTessCallback(0, 0, func)]])],
Packit 7838c8
[ax_cv_varargs_glu_tesscb=yes])
Packit 7838c8
CFLAGS="$ax_save_CFLAGS"])
Packit 7838c8
AS_IF([test X$ax_cv_varargs_glu_tesscb = Xyes],
Packit 7838c8
      [AC_DEFINE([HAVE_VARARGS_GLU_TESSCB], [1],
Packit 7838c8
                 [Use nonstandard varargs form for the GLU tesselator callback])])])
Packit 7838c8
])
Packit 7838c8
Packit 7838c8
dnl ---------------------------------------------------------------------------
Packit 7838c8
dnl Available from the GNU Autoconf Macro Archive at:
Packit 7838c8
dnl http://www.gnu.org/software/ac-archive/ax_check_glut.html
Packit 7838c8
dnl ---------------------------------------------------------------------------
Packit 7838c8
Packit 7838c8
dnl
Packit 7838c8
dnl SYNOPSIS
Packit 7838c8
dnl
Packit 7838c8
dnl   AX_CHECK_GLUT
Packit 7838c8
dnl
Packit 7838c8
dnl DESCRIPTION
Packit 7838c8
dnl
Packit 7838c8
dnl   Check for GLUT. If GLUT is found, the required compiler and linker flags
Packit 7838c8
dnl   are included in the output variables "GLUT_CFLAGS" and "GLUT_LIBS",
Packit 7838c8
dnl   respectively. If GLUT is not found, "no_glut" is set to "yes".
Packit 7838c8
dnl
Packit 7838c8
dnl   If the header "GL/glut.h" is found, "HAVE_GL_GLUT_H" is defined. If the
Packit 7838c8
dnl   header "GLUT/glut.h" is found, HAVE_GLUT_GLUT_H is defined. These
Packit 7838c8
dnl   preprocessor definitions may not be mutually exclusive.
Packit 7838c8
dnl
Packit 7838c8
dnl LICENSE
Packit 7838c8
dnl
Packit 7838c8
dnl   Copyright (c) 2009 Braden McDaniel <braden@endoframe.com>
Packit 7838c8
dnl
Packit 7838c8
dnl   This program is free software; you can redistribute it and/or modify it
Packit 7838c8
dnl   under the terms of the GNU General Public License as published by the
Packit 7838c8
dnl   Free Software Foundation; either version 2 of the License, or (at your
Packit 7838c8
dnl   option) any later version.
Packit 7838c8
dnl
Packit 7838c8
dnl   This program is distributed in the hope that it will be useful, but
Packit 7838c8
dnl   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 7838c8
dnl   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Packit 7838c8
dnl   Public License for more details.
Packit 7838c8
dnl
Packit 7838c8
dnl   You should have received a copy of the GNU General Public License along
Packit 7838c8
dnl   with this program. If not, see <http://www.gnu.org/licenses/>.
Packit 7838c8
dnl
Packit 7838c8
dnl   As a special exception, the respective Autoconf Macro's copyright owner
Packit 7838c8
dnl   gives unlimited permission to copy, distribute and modify the configure
Packit 7838c8
dnl   scripts that are the output of Autoconf when processing the Macro. You
Packit 7838c8
dnl   need not follow the terms of the GNU General Public License when using
Packit 7838c8
dnl   or distributing such scripts, even though portions of the text of the
Packit 7838c8
dnl   Macro appear in them. The GNU General Public License (GPL) does govern
Packit 7838c8
dnl   all other use of the material that constitutes the Autoconf Macro.
Packit 7838c8
dnl
Packit 7838c8
dnl   This special exception to the GPL applies to versions of the Autoconf
Packit 7838c8
dnl   Macro released by the Autoconf Archive. When you make and distribute a
Packit 7838c8
dnl   modified version of the Autoconf Macro, you may extend this special
Packit 7838c8
dnl   exception to the GPL to apply to your modified version as well.
Packit 7838c8
Packit 7838c8
AC_DEFUN([AX_CHECK_GLUT],
Packit 7838c8
[AC_REQUIRE([AX_CHECK_GLU])dnl
Packit 7838c8
AC_REQUIRE([AC_PATH_XTRA])dnl
Packit 7838c8
Packit 7838c8
ax_save_CPPFLAGS="${CPPFLAGS}"
Packit 7838c8
CPPFLAGS="${GLU_CFLAGS} ${CPPFLAGS}"
Packit 7838c8
AC_CHECK_HEADERS([GL/glut.h GLUT/glut.h])
Packit 7838c8
CPPFLAGS="${ax_save_CPPFLAGS}"
Packit 7838c8
Packit 7838c8
GLUT_CFLAGS=${GLU_CFLAGS}
Packit 7838c8
GLUT_LIBS=${GLU_LIBS}
Packit 7838c8
Packit 7838c8
m4_define([AX_CHECK_GLUT_PROGRAM],
Packit 7838c8
          [AC_LANG_PROGRAM([[
Packit 7838c8
# if HAVE_WINDOWS_H && defined(_WIN32)
Packit 7838c8
#   include <windows.h>
Packit 7838c8
# endif
Packit 7838c8
# ifdef HAVE_GL_GLUT_H
Packit 7838c8
#   include <GL/glut.h>
Packit 7838c8
# elif defined(HAVE_GLUT_GLUT_H)
Packit 7838c8
#   include <GLUT/glut.h>
Packit 7838c8
# else
Packit 7838c8
#   error no glut.h
Packit 7838c8
# endif]],
Packit 7838c8
                           [[glutMainLoop()]])])
Packit 7838c8
Packit 7838c8
dnl
Packit 7838c8
dnl If X is present, assume GLUT depends on it.
Packit 7838c8
dnl
Packit 7838c8
AS_IF([test X$no_x != Xyes],
Packit 7838c8
      [GLUT_LIBS="${X_PRE_LIBS} -lXi ${X_EXTRA_LIBS} ${GLUT_LIBS}"])
Packit 7838c8
Packit 7838c8
AC_CACHE_CHECK([for GLUT library], [ax_cv_check_glut_libglut],
Packit 7838c8
[ax_cv_check_glut_libglut="no"
Packit 7838c8
AC_LANG_PUSH(C)
Packit 7838c8
ax_save_CPPFLAGS="${CPPFLAGS}"
Packit 7838c8
CPPFLAGS="${GLUT_CFLAGS} ${CPPFLAGS}"
Packit 7838c8
ax_save_LIBS="${LIBS}"
Packit 7838c8
LIBS=""
Packit 7838c8
ax_check_libs="-lglut32 -lglut"
Packit 7838c8
for ax_lib in ${ax_check_libs}; do
Packit 7838c8
  AS_IF([test X$ax_compiler_ms = Xyes],
Packit 7838c8
        [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`],
Packit 7838c8
        [ax_try_lib="${ax_lib}"])
Packit 7838c8
  LIBS="${ax_try_lib} ${GLUT_LIBS} ${ax_save_LIBS}"
Packit 7838c8
  AC_LINK_IFELSE([AX_CHECK_GLUT_PROGRAM],
Packit 7838c8
                 [ax_cv_check_glut_libglut="${ax_try_lib}"; break])
Packit 7838c8
done
Packit 7838c8
Packit 7838c8
AS_IF([test "X$ax_cv_check_glut_libglut" = Xno -a "X$no_x" = Xyes],
Packit 7838c8
[LIBS='-framework GLUT'
Packit 7838c8
AC_LINK_IFELSE([AX_CHECK_GLUT_PROGRAM],
Packit 7838c8
               [ax_cv_check_glut_libglut="$LIBS"])])
Packit 7838c8
Packit 7838c8
CPPFLAGS="${ax_save_CPPFLAGS}"
Packit 7838c8
LIBS="${ax_save_LIBS}"
Packit 7838c8
AC_LANG_POP(C)])
Packit 7838c8
Packit 7838c8
AS_IF([test "X$ax_cv_check_glut_libglut" = Xno],
Packit 7838c8
      [no_glut="yes"; GLUT_CFLAGS=""; GLUT_LIBS=""],
Packit 7838c8
      [GLUT_LIBS="${ax_cv_check_glut_libglut} ${GLUT_LIBS}"])
Packit 7838c8
Packit 7838c8
AC_SUBST([GLUT_CFLAGS])
Packit 7838c8
AC_SUBST([GLUT_LIBS])
Packit 7838c8
])dnl
Packit 7838c8
Packit 7838c8
dnl ---------------------------------------------------------------------------
Packit 7838c8
dnl Available from the GNU Autoconf Macro Archive at:
Packit 7838c8
dnl http://www.gnu.org/software/autoconf-archive/ax_pthread.html
Packit 7838c8
dnl ---------------------------------------------------------------------------
Packit 7838c8
Packit 7838c8
dnl SYNOPSIS
Packit 7838c8
dnl
Packit 7838c8
dnl   AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
Packit 7838c8
dnl
Packit 7838c8
dnl DESCRIPTION
Packit 7838c8
dnl
Packit 7838c8
dnl   This macro figures out how to build C programs using POSIX threads. It
Packit 7838c8
dnl   sets the PTHREAD_LIBS output variable to the threads library and linker
Packit 7838c8
dnl   flags, and the PTHREAD_CFLAGS output variable to any special C compiler
Packit 7838c8
dnl   flags that are needed. (The user can also force certain compiler
Packit 7838c8
dnl   flags/libs to be tested by setting these environment variables.)
Packit 7838c8
dnl
Packit 7838c8
dnl   Also sets PTHREAD_CC to any special C compiler that is needed for
Packit 7838c8
dnl   multi-threaded programs (defaults to the value of CC otherwise). (This
Packit 7838c8
dnl   is necessary on AIX to use the special cc_r compiler alias.)
Packit 7838c8
dnl
Packit 7838c8
dnl   NOTE: You are assumed to not only compile your program with these flags,
Packit 7838c8
dnl   but also link it with them as well. e.g. you should link with
Packit 7838c8
dnl   $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
Packit 7838c8
dnl
Packit 7838c8
dnl   If you are only building threads programs, you may wish to use these
Packit 7838c8
dnl   variables in your default LIBS, CFLAGS, and CC:
Packit 7838c8
dnl
Packit 7838c8
dnl     LIBS="$PTHREAD_LIBS $LIBS"
Packit 7838c8
dnl     CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
Packit 7838c8
dnl     CC="$PTHREAD_CC"
Packit 7838c8
dnl
Packit 7838c8
dnl   In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
Packit 7838c8
dnl   has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
Packit 7838c8
dnl   (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
Packit 7838c8
dnl
Packit 7838c8
dnl   ACTION-IF-FOUND is a list of shell commands to run if a threads library
Packit 7838c8
dnl   is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
Packit 7838c8
dnl   is not found. If ACTION-IF-FOUND is not specified, the default action
Packit 7838c8
dnl   will define HAVE_PTHREAD.
Packit 7838c8
dnl
Packit 7838c8
dnl   Please let the authors know if this macro fails on any platform, or if
Packit 7838c8
dnl   you have any other suggestions or comments. This macro was based on work
Packit 7838c8
dnl   by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
Packit 7838c8
dnl   from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
Packit 7838c8
dnl   Alejandro Forero Cuervo to the autoconf macro repository. We are also
Packit 7838c8
dnl   grateful for the helpful feedback of numerous users.
Packit 7838c8
dnl
Packit 7838c8
dnl LICENSE
Packit 7838c8
dnl
Packit 7838c8
dnl   Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
Packit 7838c8
dnl
Packit 7838c8
dnl   This program is free software: you can redistribute it and/or modify it
Packit 7838c8
dnl   under the terms of the GNU General Public License as published by the
Packit 7838c8
dnl   Free Software Foundation, either version 3 of the License, or (at your
Packit 7838c8
dnl   option) any later version.
Packit 7838c8
dnl
Packit 7838c8
dnl   This program is distributed in the hope that it will be useful, but
Packit 7838c8
dnl   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 7838c8
dnl   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Packit 7838c8
dnl   Public License for more details.
Packit 7838c8
dnl
Packit 7838c8
dnl   You should have received a copy of the GNU General Public License along
Packit 7838c8
dnl   with this program. If not, see <http://www.gnu.org/licenses/>.
Packit 7838c8
dnl
Packit 7838c8
dnl   As a special exception, the respective Autoconf Macro's copyright owner
Packit 7838c8
dnl   gives unlimited permission to copy, distribute and modify the configure
Packit 7838c8
dnl   scripts that are the output of Autoconf when processing the Macro. You
Packit 7838c8
dnl   need not follow the terms of the GNU General Public License when using
Packit 7838c8
dnl   or distributing such scripts, even though portions of the text of the
Packit 7838c8
dnl   Macro appear in them. The GNU General Public License (GPL) does govern
Packit 7838c8
dnl   all other use of the material that constitutes the Autoconf Macro.
Packit 7838c8
dnl
Packit 7838c8
dnl   This special exception to the GPL applies to versions of the Autoconf
Packit 7838c8
dnl   Macro released by the Autoconf Archive. When you make and distribute a
Packit 7838c8
dnl   modified version of the Autoconf Macro, you may extend this special
Packit 7838c8
dnl   exception to the GPL to apply to your modified version as well.
Packit 7838c8
Packit 7838c8
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
Packit 7838c8
AC_DEFUN([AX_PTHREAD], [
Packit 7838c8
AC_REQUIRE([AC_CANONICAL_HOST])
Packit 7838c8
AC_LANG_SAVE
Packit 7838c8
AC_LANG_C
Packit 7838c8
ax_pthread_ok=no
Packit 7838c8
Packit 7838c8
dnl We used to check for pthread.h first, but this fails if pthread.h
Packit 7838c8
dnl requires special compiler flags (e.g. on True64 or Sequent).
Packit 7838c8
dnl It gets checked for in the link test anyway.
Packit 7838c8
Packit 7838c8
dnl First of all, check if the user has set any of the PTHREAD_LIBS,
Packit 7838c8
dnl etcetera environment variables, and if threads linking works using
Packit 7838c8
dnl them:
Packit 7838c8
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
Packit 7838c8
        save_CFLAGS="$CFLAGS"
Packit 7838c8
        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
Packit 7838c8
        save_LIBS="$LIBS"
Packit 7838c8
        LIBS="$PTHREAD_LIBS $LIBS"
Packit 7838c8
        AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
Packit 7838c8
        AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes)
Packit 7838c8
        AC_MSG_RESULT($ax_pthread_ok)
Packit 7838c8
        if test x"$ax_pthread_ok" = xno; then
Packit 7838c8
                PTHREAD_LIBS=""
Packit 7838c8
                PTHREAD_CFLAGS=""
Packit 7838c8
        fi
Packit 7838c8
        LIBS="$save_LIBS"
Packit 7838c8
        CFLAGS="$save_CFLAGS"
Packit 7838c8
fi
Packit 7838c8
Packit 7838c8
dnl We must check for the threads library under a number of different
Packit 7838c8
dnl names; the ordering is very important because some systems
Packit 7838c8
dnl (e.g. DEC) have both -lpthread and -lpthreads, where one of the
Packit 7838c8
dnl libraries is broken (non-POSIX).
Packit 7838c8
Packit 7838c8
dnl Create a list of thread flags to try.  Items starting with a "-" are
Packit 7838c8
dnl C compiler flags, and other items are library names, except for "none"
Packit 7838c8
dnl which indicates that we try without any flags at all, and "pthread-config"
Packit 7838c8
dnl which is a program returning the flags for the Pth emulation library.
Packit 7838c8
Packit 7838c8
ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
Packit 7838c8
Packit 7838c8
dnl The ordering *is* (sometimes) important.  Some notes on the
Packit 7838c8
dnl individual items follow:
Packit 7838c8
Packit 7838c8
dnl pthreads: AIX (must check this before -lpthread)
Packit 7838c8
dnl none: in case threads are in libc; should be tried before -Kthread and
Packit 7838c8
dnl       other compiler flags to prevent continual compiler warnings
Packit 7838c8
dnl -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
Packit 7838c8
dnl -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
Packit 7838c8
dnl lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
Packit 7838c8
dnl -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
Packit 7838c8
dnl -pthreads: Solaris/gcc
Packit 7838c8
dnl -mthreads: Mingw32/gcc, Lynx/gcc
Packit 7838c8
dnl -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
Packit 7838c8
dnl      doesn't hurt to check since this sometimes defines pthreads too;
Packit 7838c8
dnl      also defines -D_REENTRANT)
Packit 7838c8
dnl      ... -mt is also the pthreads flag for HP/aCC
Packit 7838c8
dnl pthread: Linux, etcetera
Packit 7838c8
dnl --thread-safe: KAI C++
Packit 7838c8
dnl pthread-config: use pthread-config program (for GNU Pth library)
Packit 7838c8
Packit 7838c8
case "${host_cpu}-${host_os}" in
Packit 7838c8
        *solaris*)
Packit 7838c8
Packit 7838c8
        dnl On Solaris (at least, for some versions), libc contains stubbed
Packit 7838c8
        dnl (non-functional) versions of the pthreads routines, so link-based
Packit 7838c8
        dnl tests will erroneously succeed.  (We need to link with -pthreads/-mt/
Packit 7838c8
        dnl -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
Packit 7838c8
        dnl a function called by this macro, so we could check for that, but
Packit 7838c8
        dnl who knows whether they'll stub that too in a future libc.)  So,
Packit 7838c8
        dnl we'll just look for -pthreads and -lpthread first:
Packit 7838c8
Packit 7838c8
        ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
Packit 7838c8
        ;;
Packit 7838c8
Packit 7838c8
	*-darwin*)
Packit 7838c8
	ax_pthread_flags="-pthread $ax_pthread_flags"
Packit 7838c8
	;;
Packit 7838c8
esac
Packit 7838c8
Packit 7838c8
if test x"$ax_pthread_ok" = xno; then
Packit 7838c8
for flag in $ax_pthread_flags; do
Packit 7838c8
Packit 7838c8
        case $flag in
Packit 7838c8
                none)
Packit 7838c8
                AC_MSG_CHECKING([whether pthreads work without any flags])
Packit 7838c8
                ;;
Packit 7838c8
Packit 7838c8
                -*)
Packit 7838c8
                AC_MSG_CHECKING([whether pthreads work with $flag])
Packit 7838c8
                PTHREAD_CFLAGS="$flag"
Packit 7838c8
                ;;
Packit 7838c8
Packit 7838c8
		pthread-config)
Packit 7838c8
		AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no)
Packit 7838c8
		if test x"$ax_pthread_config" = xno; then continue; fi
Packit 7838c8
		PTHREAD_CFLAGS="`pthread-config --cflags`"
Packit 7838c8
		PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
Packit 7838c8
		;;
Packit 7838c8
Packit 7838c8
                *)
Packit 7838c8
                AC_MSG_CHECKING([for the pthreads library -l$flag])
Packit 7838c8
                PTHREAD_LIBS="-l$flag"
Packit 7838c8
                ;;
Packit 7838c8
        esac
Packit 7838c8
Packit 7838c8
        save_LIBS="$LIBS"
Packit 7838c8
        save_CFLAGS="$CFLAGS"
Packit 7838c8
        LIBS="$PTHREAD_LIBS $LIBS"
Packit 7838c8
        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
Packit 7838c8
Packit 7838c8
        dnl Check for various functions.  We must include pthread.h,
Packit 7838c8
        dnl since some functions may be macros.  (On the Sequent, we
Packit 7838c8
        dnl need a special flag -Kthread to make this header compile.)
Packit 7838c8
        dnl We check for pthread_join because it is in -lpthread on IRIX
Packit 7838c8
        dnl while pthread_create is in libc.  We check for pthread_attr_init
Packit 7838c8
        dnl due to DEC craziness with -lpthreads.  We check for
Packit 7838c8
        dnl pthread_cleanup_push because it is one of the few pthread
Packit 7838c8
        dnl functions on Solaris that doesn't have a non-functional libc stub.
Packit 7838c8
        dnl We try pthread_create on general principles.
Packit 7838c8
        AC_TRY_LINK([#include <pthread.h>
Packit 7838c8
	             static void routine(void* a) {a=0;}
Packit 7838c8
	             static void* start_routine(void* a) {return a;}],
Packit 7838c8
                    [pthread_t th; pthread_attr_t attr;
Packit 7838c8
                     pthread_create(&th,0,start_routine,0);
Packit 7838c8
                     pthread_join(th, 0);
Packit 7838c8
                     pthread_attr_init(&attr);
Packit 7838c8
                     pthread_cleanup_push(routine, 0);
Packit 7838c8
                     pthread_cleanup_pop(0); ],
Packit 7838c8
                    [ax_pthread_ok=yes])
Packit 7838c8
Packit 7838c8
        LIBS="$save_LIBS"
Packit 7838c8
        CFLAGS="$save_CFLAGS"
Packit 7838c8
Packit 7838c8
        AC_MSG_RESULT($ax_pthread_ok)
Packit 7838c8
        if test "x$ax_pthread_ok" = xyes; then
Packit 7838c8
                break;
Packit 7838c8
        fi
Packit 7838c8
Packit 7838c8
        PTHREAD_LIBS=""
Packit 7838c8
        PTHREAD_CFLAGS=""
Packit 7838c8
done
Packit 7838c8
fi
Packit 7838c8
Packit 7838c8
dnl Various other checks:
Packit 7838c8
if test "x$ax_pthread_ok" = xyes; then
Packit 7838c8
        save_LIBS="$LIBS"
Packit 7838c8
        LIBS="$PTHREAD_LIBS $LIBS"
Packit 7838c8
        save_CFLAGS="$CFLAGS"
Packit 7838c8
        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
Packit 7838c8
Packit 7838c8
        dnl Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
Packit 7838c8
	AC_MSG_CHECKING([for joinable pthread attribute])
Packit 7838c8
	attr_name=unknown
Packit 7838c8
	for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
Packit 7838c8
	    AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
Packit 7838c8
                        [attr_name=$attr; break])
Packit 7838c8
	done
Packit 7838c8
        AC_MSG_RESULT($attr_name)
Packit 7838c8
        if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
Packit 7838c8
            AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
Packit 7838c8
                               [Define to necessary symbol if this constant
Packit 7838c8
                                uses a non-standard name on your system.])
Packit 7838c8
        fi
Packit 7838c8
Packit 7838c8
        AC_MSG_CHECKING([if more special flags are required for pthreads])
Packit 7838c8
        flag=no
Packit 7838c8
        case "${host_cpu}-${host_os}" in
Packit 7838c8
            *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
Packit 7838c8
            *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
Packit 7838c8
        esac
Packit 7838c8
        AC_MSG_RESULT(${flag})
Packit 7838c8
        if test "x$flag" != xno; then
Packit 7838c8
            PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
Packit 7838c8
        fi
Packit 7838c8
Packit 7838c8
        LIBS="$save_LIBS"
Packit 7838c8
        CFLAGS="$save_CFLAGS"
Packit 7838c8
Packit 7838c8
        dnl More AIX lossage: must compile with xlc_r or cc_r
Packit 7838c8
	if test x"$GCC" != xyes; then
Packit 7838c8
          AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
Packit 7838c8
        else
Packit 7838c8
          PTHREAD_CC=$CC
Packit 7838c8
	fi
Packit 7838c8
else
Packit 7838c8
        PTHREAD_CC="$CC"
Packit 7838c8
fi
Packit 7838c8
Packit 7838c8
AC_SUBST(PTHREAD_LIBS)
Packit 7838c8
AC_SUBST(PTHREAD_CFLAGS)
Packit 7838c8
AC_SUBST(PTHREAD_CC)
Packit 7838c8
Packit 7838c8
dnl Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
Packit 7838c8
if test x"$ax_pthread_ok" = xyes; then
Packit 7838c8
        ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
Packit 7838c8
        :
Packit 7838c8
else
Packit 7838c8
        ax_pthread_ok=no
Packit 7838c8
        $2
Packit 7838c8
fi
Packit 7838c8
AC_LANG_RESTORE
Packit 7838c8
])dnl AX_PTHREAD