dnl Initial configure.in by Rodrigo Hernandez dnl Modified in 26/10/2005 by Rodrigo Hernandez AC_INIT(ODE,0.5.0,ode@q12.org) AC_CANONICAL_HOST AC_CANONICAL_TARGET AM_INIT_AUTOMAKE(ODE,0.5.0) AM_CONFIG_HEADER(include/ode/config.h) AC_C_BIGENDIAN AC_PATH_X AC_PATH_XTRA ODE_CURRENT=0 ODE_REVISION=5 ODE_AGE=0 ODE_RELEASE=[$ODE_CURRENT].[$ODE_REVISION].[$ODE_AGE] AC_SUBST(ODE_CURRENT) AC_SUBST(ODE_REVISION) AC_SUBST(ODE_AGE) AC_SUBST(ODE_RELEASE) 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 AC_ARG_WITH(arch, [ --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) 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 ) AC_MSG_CHECKING(if OPCODE support is requested) AC_ARG_WITH(opcode,AC_HELP_STRING([--with-opcode], [Configure ODE to work with the OPCODE collision detection library for trimesh support]), opcode=$withval,opcode=no) AC_MSG_RESULT($opcode) AM_CONDITIONAL(OPCODE, test x$opcode = xyes) AC_MSG_CHECKING(if cylinder support is requested) AC_ARG_WITH(cylinder,AC_HELP_STRING([--with-cylinder], [Configure ODE to have non capped cylinder support]), cylinder=$withval,cylinder=no) AC_MSG_RESULT($cylinder) AM_CONDITIONAL(CYLINDER, test x$cylinder = xyes) dnl Check Precision, define the dInfinity constant--------------------------/ AC_MSG_CHECKING(if double precision is requested) AC_ARG_WITH(double-precision,AC_HELP_STRING([--with-double-precision], [Cofigure ODE to work with double precision, if not specified, single precision is used]), precision=$withval,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. 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 #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 #define dInfinity DBL_MAX int main() { if (dInfinity > 1e10 && -dInfinity < -1e10 && -dInfinity < dInfinity) return 0; else return -1; } ],dinfinity=DBL_MAX,,) else dnl default to SINGLE. AC_DEFINE(dSINGLE,,[Use single precision]) dnl Check from lest likelly to more likelly. 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 #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 #define dInfinity FLT_MAX int main() { if (dInfinity > 1e10f && -dInfinity < -1e10f && -dInfinity < dInfinity) return 0; else return -1; } ],dinfinity=FLT_MAX,,) 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 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,) 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) 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,) 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) 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=$withval,release=no) if test "x$release" == xyes then CFLAGS="-fomit-frame-pointer -ffast-math" CPPFLAGS="-fomit-frame-pointer -ffast-math" CXXFLAGS="-fomit-frame-pointer -ffast-math" else CFLAGS="-g" CPPFLAGS="-g" CXXFLAGS="-g" fi AC_MSG_RESULT($release) 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 Check for OpenGL AC_CHECK_HEADERS(GL/gl.h GL/glu.h GL/glext.h,,, [[#if HAVE_GL_GL_H #include #endif #if HAVE_GL_GLU_H #include #endif ]]) AC_CHECK_LIB(GL, main,[GL_LIBS="$GL_LIBS -lGL"]) AC_CHECK_LIB(GLU, main,[GL_LIBS="$GL_LIBS -lGLU"]) AC_CHECK_LIB(opengl32, main,[GL_LIBS="$GL_LIBS -lopengl32"]) AC_CHECK_LIB(glu32, main,[GL_LIBS="$GL_LIBS -lglu32"]) 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"]) 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"]) dnl Decide which version of the drawstuff library we should build AC_MSG_CHECKING(which drawstuff lib to build) case "$host_os" in cygwin* | mingw*) drawstuff="Win32" # if in a Windows enviroment ;; *) drawstuff="X11" # if anything else default to X11 ;; esac AC_MSG_RESULT($drawstuff) AM_CONDITIONAL(WIN32, test x$drawstuff = xWin32) AM_CONDITIONAL(X11, test x$drawstuff = xX11) AC_SUBST(DRAWSTUFF) 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, [ --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]) AC_FUNC_ALLOCA AC_FUNC_MALLOC AC_FUNC_OBSTACK AC_FUNC_REALLOC AC_FUNC_SELECT_ARGTYPES AC_FUNC_VPRINTF 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 #endif #if defined(HAVE_IEEEFP_H) && !defined(__CYGWIN__) // This header creates conflicts with math.h in Cygwin. #include #endif #ifdef HAVE_STDIO_H #include #endif #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_MATH_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STDARG_H #include #endif #ifdef HAVE_MALLOC_H #include #endif #ifdef HAVE_VALUES_H #include #endif #ifdef HAVE_FLOAT_H #include #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 */ #if defined(DLL_EXPORT) && defined(WIN32) #define DLL __declspec( dllexport ) #elif !defined(DLL_EXPORT) && defined(WIN32) #define DLL __declspec( dllimport ) #else #define DLL #endif #endif /* #define ODE_CONFIG_H */ ]) AC_MSG_CHECKING(for the suffix of shared libraries) case "$host_os" in hpux9* | hpux10* | hpux11*) # taken from ltconfig so_ext=".sl" DLLDEFINE="" ;; cygwin* | mingw*) so_ext=".dll" DLLDEFINE="-DDLL_EXPORT" ;; *apple*) # For Mac OS X so_ext=".dylib" DLLDEFINE="" ;; *) so_ext=".so" DLLDEFINE="" ;; esac AC_MSG_RESULT($so_ext) AC_DEFINE_UNQUOTED(SO_EXT,"$so_ext",[The extension for shared libraries.]) AC_SUBST(so_ext) 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/test/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 " Support cylinder: $cylinder" echo " Is this a Pentium: $pentium" echo " Is the CPU x86-64: $cpu64" echo " Is this a release build: $release" echo " Headers will be installed in $prefix/include/ode" echo " Libraries will be installed in $prefix/lib"