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