aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ode-0.9/configure.in
blob: 96eea67787a5b6e7277699a969938dfd1948c6af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
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