OpenSimMirror/libraries/ode-0.9/configure.in

581 lines
15 KiB
Plaintext
Raw Normal View History

2007-10-19 05:24:38 +00:00
dnl Initial configure.in by Rodrigo Hernandez
dnl Modified in 26/10/2005 by Rodrigo Hernandez
dnl AC_INIT does not take a macro as a version nr: set it separately! - Bram
AC_INIT(ODE,0.9.0,ode@ode.org)
dnl When upgrading version nr, also change the AC_INIT line! - Bram
ODE_CURRENT=0
ODE_REVISION=9
ODE_AGE=0
ODE_RELEASE=[$ODE_CURRENT].[$ODE_REVISION].[$ODE_AGE]
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE(ODE,[$ODE_RELEASE])
AM_CONFIG_HEADER(include/ode/config.h)
dnl Set CFLAGS to zero, so that we avoid getting the gratis -g -O2
CFLAGS=
CXXFLAGS=
AC_C_BIGENDIAN
AC_PATH_X
AC_PATH_XTRA
ODE_SONAME=libode.so.[$ODE_CURRENT]
AC_SUBST(ODE_CURRENT)
AC_SUBST(ODE_REVISION)
AC_SUBST(ODE_AGE)
AC_SUBST(ODE_RELEASE)
AC_SUBST(ODE_SONAME)
dnl This is needed because we have subdirectories
AC_PROG_MAKE_SET
AC_PROG_CXX
AC_PROG_INSTALL
AC_CHECK_TOOLS([WINDRES], [windres])
AC_C_CONST
AC_C_INLINE
AC_C_VOLATILE
AC_HEADER_STDBOOL
AC_PROG_RANLIB
AC_TYPE_SIZE_T
dnl Check if using sonames is requested
dnl THIS IS TEMPORARY!
AC_MSG_CHECKING(if a soname should be set)
AC_ARG_ENABLE(soname,AC_HELP_STRING([--enable-soname],
[Configure ODE shared library to set the soname field on ELF files]),
use_soname=$enableval,use_soname=no)
AC_MSG_RESULT($use_soname)
AM_CONDITIONAL(USE_SONAME, test x$use_soname = xyes)
dnl Check if we want to build demos
AC_MSG_CHECKING(if tests should be built)
AC_ARG_ENABLE(demos,AC_HELP_STRING([--enable-demos], [build tests]), enable_demos=$enableval,enable_demos=yes)
AC_MSG_RESULT($enable_demos)
AM_CONDITIONAL(ENABLE_DEMOS, test x$enable_demos = xyes)
AC_ARG_WITH(arch,AC_HELP_STRING([--with-arch=[arch]],
[build for $arch, where arch is any of the -march flags passed to gcc, without the -march, for example --with-arch=pentium3]),
arch=$withval,arch=no)
ARCHFLAGS=""
if test "x$arch" != xno
then
ARCHFLAGS="-march=$arch"
fi
AC_SUBST(ARCHFLAGS)
dnl Decide whether or not SSE is available
dnl Why dont we compile and run programs like we do to find out if
dnl this is a Pentium machine further down? simple!
dnl this may NOT be the machine on which the code is going to run in,
dnl so allow users to compile programs for their target machine.
case "$arch" in
pentium3 | pentium4 | athlon* )
AC_DEFINE(HAVE_SSE,,[Use SSE Optimizations])
;;
dnl this space available for other architectures specific extensions and/or
dnl other Intel based extensions such as 3DNow, SSE2, MMX, etc.
esac
dnl check for required headers
AC_CHECK_HEADERS( alloca.h ieeefp.h stdio.h stdlib.h math.h string.h stdarg.h malloc.h values.h float.h time.h sys/time.h )
opcode=no
gimpact=no
AC_ARG_WITH(trimesh,AC_HELP_STRING([--with-trimesh=[opcode|gimpact|none]],
[use the specified system for trimesh support.]),
trimesh=$withval,trimesh=opcode
)
if test "$trimesh" = opcode
then
opcode=yes
fi
if test "$trimesh" = gimpact
then
gimpact=yes
fi
AM_CONDITIONAL(OPCODE, test $opcode = yes)
AM_CONDITIONAL(GIMPACT, test $gimpact = yes)
AM_CONDITIONAL(TRIMESH, test $opcode = yes -o $gimpact = yes)
AC_MSG_CHECKING(if gyroscopic term should be used)
AC_ARG_ENABLE(gyroscopic,AC_HELP_STRING([--disable-gyroscopic],
[Configure ODE to work without gyroscopic term (may improve stability)]),
gyroscopic=$enableval,gyroscopic=yes)
AC_MSG_RESULT($gyroscopic)
if test x"$gyroscopic" = xyes
then
AC_DEFINE(dGYROSCOPIC,,[Use gyroscopic terms])
fi
dnl Check Precision, define the dInfinity constant--------------------------/
AC_MSG_CHECKING(if double precision is requested)
AC_ARG_ENABLE(double-precision,AC_HELP_STRING([--enable-double-precision],
[Configure ODE to work with double precision, if not specified, single precision is used]),
precision=$enableval,precision=no)
if test "$precision" != no
then
dnl DOUBLE was chosen
AC_DEFINE(dDOUBLE,,[Use double precision])
dnl Check from lest likelly to more likelly.
if test "$build_os" == "$target_os"
then
AC_TRY_RUN([
#define dInfinity 1e20
int main()
{
if (dInfinity > 1e10 && -dInfinity < -1e10 && -dInfinity < dInfinity)
return 0;
else return -1;
}
],dinfinity=1e20,,)
AC_TRY_RUN([
#define dInfinity 1.7976931348623157e+308
int main()
{
if (dInfinity > 1e10 && -dInfinity < -1e10 && -dInfinity < dInfinity)
return 0;
else return -1;
}
],dinfinity=1.7976931348623157e+308,,)
AC_TRY_RUN([
#include <float.h>
#define dInfinity HUGE_VAL
int main()
{
if (dInfinity > 1e10 && -dInfinity < -1e10 && -dInfinity < dInfinity)
return 0;
else return -1;
}
],dinfinity=HUGE_VAL,,)
AC_TRY_RUN([
#include <float.h>
#define dInfinity DBL_MAX
int main()
{
if (dInfinity > 1e10 && -dInfinity < -1e10 && -dInfinity < dInfinity)
return 0;
else return -1;
}
],dinfinity=DBL_MAX,,)
else
#cross-compiling, use a reasonable value. We should add an option for setting this.
dinfinity=DBL_MAX
fi
else
dnl default to SINGLE.
AC_DEFINE(dSINGLE,,[Use single precision])
dnl Check from lest likelly to more likelly.
if test "$build_os" == "$target_os"
then
AC_TRY_RUN([
#define dInfinity 1e20f
int main()
{
if (dInfinity > 1e10f && -dInfinity < -1e10f && -dInfinity < dInfinity)
return 0;
else return -1;
}
],dinfinity=1e20f,,)
AC_TRY_RUN([
#define dInfinity 3.402823466e+38F
int main()
{
if (dInfinity > 1e10f && -dInfinity < -1e10f && -dInfinity < dInfinity)
return 0;
else return -1;
}
],dinfinity=3.402823466e+38F,,)
AC_TRY_RUN([
#include <float.h>
#define dInfinity HUGE_VALF
int main()
{
if (dInfinity > 1e10f && -dInfinity < -1e10f && -dInfinity < dInfinity)
return 0;
else return -1;
}
],dinfinity=HUGE_VALF,,)
AC_TRY_RUN([
#include <float.h>
#define dInfinity FLT_MAX
int main()
{
if (dInfinity > 1e10f && -dInfinity < -1e10f && -dInfinity < dInfinity)
return 0;
else return -1;
}
],dinfinity=FLT_MAX,,)
#cross-compiling, use a reasonable value. We should add an option for setting this.
dinfinity=FLT_MAX
fi
fi
AC_MSG_RESULT($precision)
AC_DEFINE_UNQUOTED(dInfinity,${dinfinity},[dInfinity Constant])
AC_MSG_CHECKING(for appropriate dInfinity constant)
AC_MSG_RESULT($dinfinity)
dnl --------------------------------------------------------------------------/
dnl Define dEpsilon
AC_CHECK_HEADER(float.h,[have_float_h=yes],[have_float_h=no])
AC_MSG_CHECKING(for appropriate dEpsilon constant)
if test "x$have_float_h" == xyes
then
if test $precision == yes
then
dEpsilon=DBL_EPSILON
else
dEpsilon=FLT_EPSILON
fi
else
if test $precision == yes
then
dEpsilon=2.2204460492503131e-16
else
dEpsilon=1.19209290e-07f
fi
fi
AC_DEFINE_UNQUOTED(dEpsilon,${dEpsilon},[dEpsilon Constant])
AC_MSG_RESULT($dEpsilon)
dnl Check for PENTIUM
if test "$build_os" == "$target_os"
then
AC_MSG_CHECKING(for a Pentium CPU)
AC_TRY_RUN([
int main()
{
asm ("mov \$0,%%eax;\n"
"cpuid\n" : : : "%eax");
return 0;
};
],pentium=yes,pentium=no,)
else
pentium=no
fi
if test "x$pentium" == xyes
then
AC_DEFINE(PENTIUM,1,[is this a pentium on a gcc-based platform?])
fi
AC_MSG_RESULT($pentium)
dnl Check for 64bit CPU
AC_MSG_CHECKING(for a x86-64 CPU)
if test "$build_os" == "$target_os"
then
AC_TRY_RUN([
int main()
{
int a = 0;
int * pa = &a;
asm ("mov %0,%%rax\n"
"movl (%%rax),%%eax\n"
: : "r"(pa) : "%rax");
return 0;
};
],cpu64=yes,cpu64=no,)
else
cpu64=no
fi
if test "x$cpu64" == xyes
then
AC_DEFINE(X86_64_SYSTEM,1,[is this a X86_64 system on a gcc-based platform?])
fi
AC_MSG_RESULT($cpu64)
AM_CONDITIONAL(X86_64_SYSTEM, test x$cpu64 = xyes)
AC_MSG_CHECKING(if building a release library)
AC_ARG_ENABLE(release,AC_HELP_STRING([--enable-release],
[build a release library with -fomit-frame-pointer and -ffast-math]),
release=$enableval,release=no)
if test "x$release" == xyes
then
CFLAGS="$CFLAGS -fomit-frame-pointer -ffast-math"
CPPFLAGS="$CPPFLAGS -fomit-frame-pointer -ffast-math"
CXXFLAGS="$CXXFLAGS -fomit-frame-pointer -ffast-math"
AC_DEFINE(dNODEBUG,,[Disable debug output])
fi
AC_MSG_RESULT($release)
AC_MSG_CHECKING(if building a debug library)
AC_ARG_ENABLE(debug,AC_HELP_STRING([--enable-debug],
[Add debug symbols to the library with -g]),
debug=$enableval,debug=yes)
if test "x$debug" == xyes
then
CFLAGS="$CFLAGS -g"
CPPFLAGS="$CPPFLAGS -g"
CXXFLAGS="$CXXFLAGS -g"
fi
AC_MSG_RESULT($debug)
dnl Check variable type sizes
AC_CHECK_SIZEOF(char)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(long int)
AC_CHECK_SIZEOF(void*)
dnl Set some Platform Specific Variables
case "$host_os" in
cygwin* | mingw*)
so_ext=".dll"
DLLDEFINE="-DODE_DLL"
SHARED_LDFLAGS="-shared"
drawstuff="Win32" # if in a Windows enviroment
;;
*apple* | *darwin*) # For Mac OS X
so_ext=".dylib"
DLLDEFINE=""
SHARED_LDFLAGS="-dynamiclib"
drawstuff="OSX"
dnl We need to use C++ compilation and linking for ode on Mac
dnl Might as well do it for all code.
CC="$CXX"
LINK="$CXXLINK"
;;
*)
drawstuff="X11" # if anything else default to X11
if test x$use_soname = xyes; then
so_ext=".so.$ODE_RELEASE"
else
so_ext=".so"
fi
DLLDEFINE=""
SHARED_LDFLAGS="-shared"
;;
esac
dnl Set Conditionals
AM_CONDITIONAL(WIN32, test x$drawstuff = xWin32)
AM_CONDITIONAL(X11, test x$drawstuff = xX11)
AM_CONDITIONAL(OSX, test x$drawstuff = xOSX)
dnl Set Drawstuff variables
AC_MSG_CHECKING(which drawstuff lib to build)
AC_MSG_RESULT($drawstuff)
AC_SUBST(DRAWSTUFF)
dnl Set shared library variables
AC_MSG_CHECKING(for the suffix of shared libraries)
AC_MSG_RESULT($so_ext)
AC_DEFINE_UNQUOTED(SO_EXT,"$so_ext",[The extension for shared libraries.])
AC_SUBST(so_ext)
AC_SUBST(SHARED_LDFLAGS)
dnl Check for AC_PATH_X variables
if test "X$x_includes" != "XNONE"; then
CFLAGS="$CFLAGS -I$x_includes"
CXXFLAGS="$CXXFLAGS -I$x_includes"
fi
if test "X$x_libraries" != "XNONE"; then
CFLAGS="$CFLAGS -L$x_libraries"
CXXFLAGS="$CXXFLAGS -L$x_libraries"
fi
dnl Check for OpenGL
if test "x$drawstuff" = "xOSX"; then
AC_DEFINE([HAVE_APPLE_OPENGL_FRAMEWORK], [1],
[Use the Apple OpenGL framework.])
GL_LIBS="-framework OpenGL -framework Carbon -framework AGL"
else
AC_CHECK_HEADERS(GL/gl.h GL/glu.h GL/glext.h,,,
[[#if HAVE_GL_GL_H
#include <GL/gl.h>
#endif
#if HAVE_GL_GLU_H
#include <GL/glu.h>
#endif
]])
AC_CHECK_LIB(GL, main,[GL_LIBS="$GL_LIBS -lGL"])
TEMP_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $GL_LIBS"
AC_CHECK_LIB(GLU, main,[GL_LIBS="$GL_LIBS -lGLU"])
LDFLAGS="$TEMP_LDFLAGS"
AC_CHECK_LIB(opengl32, main,[GL_LIBS="$GL_LIBS -lopengl32"])
AC_CHECK_LIB(glu32, main,[GL_LIBS="$GL_LIBS -lglu32"])
AC_CHECK_LIB(Xmu, main,[GL_LIBS="$GL_LIBS -lXmu"])
AC_CHECK_LIB(Xi, main,[GL_LIBS="$GL_LIBS -lXi"])
AC_CHECK_LIB(X, main,[GL_LIBS="$GL_LIBS -lX"])
AC_CHECK_LIB(X11, main,[GL_LIBS="$GL_LIBS -lX11"])
fi
AC_SUBST(GL_LIBS)
dnl Add some Windows libraries if found
AC_CHECK_LIB(comctl32,main,[LIBS="$LIBS -lcomctl32"])
AC_CHECK_LIB(kernel32,main,[LIBS="$LIBS -lkernel32"])
AC_CHECK_LIB(user32,main,[LIBS="$LIBS -luser32"])
AC_CHECK_LIB(gdi32,main,[LIBS="$LIBS -lgdi32"])
AC_CHECK_LIB(winmm,main,[LIBS="$LIBS -lwinmm"])
dnl Add math and standard c++ lib just in case
AC_CHECK_LIB(stdc++,main,[LIBS="$LIBS -lstdc++"])
AC_CHECK_LIB(m,main,[LIBS="$LIBS -lm"])
AC_CHECK_LIB(pthread,main,[LIBS="$LIBS -lpthread"])
TOPDIR=`cd $srcdir;pwd`
AC_SUBST(TOPDIR)
dnl Check if the user wants to profile ODE using gprof
AC_MSG_CHECKING(for gprof)
AC_ARG_ENABLE(gprof,
AC_HELP_STRING([--enable-gprof],[enable profiling with gprof]),
gprof=$enableval,gprof=no)
if test "$gprof" != no
then
CFLAGS="-pg $CFLAGS"
CPPFLAGS="-pg $CPPFLAGS"
CXXFLAGS="-pg $CXXFLAGS"
AC_CHECK_LIB(gmon, main,[LIBS="$LIBS -lgmon"])
AC_MSG_RESULT(enabled)
else
AC_MSG_RESULT(no)
fi
dnl Check for autoscan sugested functions
AC_CHECK_FUNCS([floor memmove memset select sqrt sqrtf sinf cosf fabsf atan2f fmodf copysignf copysign snprintf vsnprintf gettimeofday isnan isnanf _isnan _isnanf __isnan __isnanf])
if test "$build_os" == "$target_os"
then
AC_FUNC_ALLOCA
AC_FUNC_MALLOC
AC_FUNC_OBSTACK
AC_FUNC_REALLOC
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_VPRINTF
fi
dnl include found system headers into config.h
AH_TOP([
#ifndef ODE_CONFIG_H
#define ODE_CONFIG_H
])
AH_BOTTOM([
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#if defined(HAVE_IEEEFP_H) && !defined(__CYGWIN__)
// This header creates conflicts with math.h in Cygwin.
#include <ieeefp.h>
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_MATH_H
#include <math.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_STDARG_H
#include <stdarg.h>
#endif
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_VALUES_H
#include <values.h>
#endif
#ifdef HAVE_FLOAT_H
#include <float.h>
#endif
#if SIZEOF_CHAR == 1
typedef char int8;
typedef unsigned char uint8;
#else
#error "expecting sizeof(char) == 1"
#endif
#if SIZEOF_SHORT == 2
typedef short int16;
typedef unsigned short uint16;
#else
#error "can not find 2 byte integer type"
#endif
/* integer types (we assume int >= 32 bits) */
#if SIZEOF_INT == 4
typedef short int32;
typedef unsigned short uint32;
#else
#error "can not find 4 byte integer type"
#endif
/* an integer type that we can safely cast a pointer to and
* from without loss of bits.
*/
#if SIZEOF_SHORT == SIZEOF_VOIDP
typedef unsigned short intP;
#elif SIZEOF_INT == SIZEOF_VOIDP
typedef unsigned int intP;
#elif SIZEOF_LONG_INT == SIZEOF_VOIDP
typedef unsigned long int intP;
#endif
/*
Handle Windows DLL odities
Its easier to export all symbols using the -shared flag
for MinGW than differentiating with declspec,
so only do it for MSVC
*/
#if defined(ODE_DLL) && defined(WIN32) && defined(_MSC_VER)
#define ODE_API __declspec( dllexport )
#elif !defined(ODE_DLL) && defined(WIN32) && defined(MSC_VER)
#define ODE_API __declspec( dllimport )
#else
#define ODE_API
#endif
#endif /* #define ODE_CONFIG_H */
])
dnl Finally write our Makefiles
AC_OUTPUT([
Makefile
include/Makefile
include/ode/Makefile
ode/Makefile
ode/src/Makefile
drawstuff/Makefile
drawstuff/src/Makefile
drawstuff/dstest/Makefile
ode/demo/Makefile
tests/Makefile
tests/CppTestHarness/Makefile
ode-config
])
chmod +x ode-config
dnl Print some useful information
echo "Configuration:"
echo " Target system type: $target"
echo " Build system type: $build"
echo " Host system type: $host"
echo " Use double precision: $precision"
echo " Use OPCODE: $opcode"
echo " Use GIMPACT: $gimpact"
echo " Use gyroscopic term: $gyroscopic"
echo " Is this a Pentium: $pentium"
echo " Is the CPU x86-64: $cpu64"
echo " Is this a release build: $release"
echo " Adding debug symbols: $debug"
echo " Using SONAME: $use_soname"
echo " Headers will be installed in $prefix/include/ode"
echo " Libraries will be installed in $prefix/lib"
if test $gimpact = yes -a $precision = yes
then
echo "WARNING! Double precision not yet supported for GIMPACT"
fi