1# **************************************************************************
2
3# FIXME: try to fix all problems with spaces in directory names;
4# whether it's the src dir, the install/build dir or directories with
5# dependent libraries. Alternatively, we should at least detect and
6# warn/exit. Ditto goes for all our other software modules aswell, of
7# course. 20020519 mortene.
8
9# FIXME: need to figure out when libstdc++ is necessary to link. GCC
10# 3.2 on Solaris seems to demand it, or we'll get unresolved symbols.
11# 20021128 mortene.
12
13# **************************************************************************
14
15# release version number info
16m4_define([COIN_MAJOR], [4])
17m4_define([COIN_MINOR], [0])
18m4_define([COIN_MICRO], [0])
19m4_define([COIN_BETA], [])
20
21# This is probably a more correct setup, but will be harder to keep if
22# we want major and minor to grow slowly (but is that any point?)
23# 20010807 larsa
24m4_define([COIN_ABI_CURRENT], [m4_eval((COIN_MAJOR*20)+COIN_MINOR)])
25m4_define([COIN_ABI_REVISION], [COIN_MICRO])
26m4_define([COIN_ABI_AGE], [COIN_MINOR])
27
28# only used on Linux for debian packages
29m4_define([SO_NUMBER], [m4_eval(COIN_MAJOR*20)])
30
31# For Mac OS X Compiler Frameworks:
32m4_define([MAC_FRAMEWORK_NAME_DEFAULT], [Inventor])
33m4_define([MAC_FRAMEWORK_PREFIX_DEFAULT], [/Library/Frameworks])
34m4_define([MAC_FRAMEWORK_VERSION_DEFAULT], [D])
35
36# **************************************************************************
37
38AC_PREREQ(2.50)
39
40AC_INIT([Coin], [COIN_MAJOR.COIN_MINOR.COIN_MICRO[]COIN_BETA],
41  [coin-support@coin3d.org])
42
43AC_CONFIG_AUX_DIR(cfg)
44AC_CONFIG_SRCDIR(src/misc/SoDB.cpp)
45
46# FIXME: detect and exit upon this problem (as seen reported on
47# coin-bugs): the install prefix is set to the same directory as the
48# build directory (or also as the srccode dir). 20020129 mortene.
49
50
51AH_TOP([
52#ifndef COIN_INTERNAL
53#error this is a private header file
54#endif
55
56#include <unconfig.h>
57#include <setup.h>
58])
59
60AC_CANONICAL_SYSTEM
61
62# For include/Inventor/system/inttypes.h.
63AC_DEFINE_UNQUOTED(COIN_CONFIGURE_BUILD, SIM_AS_TR_CPP([$build]), [Build system.])
64AC_DEFINE_UNQUOTED(COIN_CONFIGURE_HOST, SIM_AS_TR_CPP([$host]), [Build host system.])
65AC_DEFINE_UNQUOTED(COIN_CONFIGURE_TARGET, SIM_AS_TR_CPP([$target]), [Build target system.])
66
67# date used by debian setup
68SIM_AC_DATE_RFC822([RFC822_DATE])
69AC_SUBST([RFC822_DATE])
70
71# date used by redhat setup
72SIM_AC_ISO8601_DATE([coin_configure_date])
73AC_SUBST([coin_configure_date])
74
75SIM_AC_MSVC_DSP_ENABLE_OPTION
76
77# If the Microsoft Visual C++ cl.exe compiler is available, set us up for
78# compiling with it and to generate an MSWindows .dll file.
79
80SIM_AC_SETUP_MSVCPP_IFELSE
81
82# **************************************************************************
83# Mac OS X: gcc
84
85# old-compat
86AC_ARG_WITH([framework],
87  [  --without-framework     (deprecated: use --disable-framework)],
88  [case "$withval" in
89  no | false ) enable_framework=false ;;
90  * ) ;;
91  esac])
92
93sim_ac_framework_name="MAC_FRAMEWORK_NAME_DEFAULT"
94AC_ARG_ENABLE([framework],
95  [AC_HELP_STRING([--disable-framework],
96                  [Do 'UNIX-style' installation on Mac OS X])],
97  [case $enableval in
98  no | false ) sim_ac_framework=false ;;
99  * ) sim_ac_framework=true ;;
100  esac],
101  [case $host_os in
102  darwin* ) sim_ac_framework=true ;;
103  * ) sim_ac_framework=false ;;
104  esac])
105
106AC_ARG_WITH([framework-prefix],
107  [  --with-framework-prefix=<path>  (default: "MAC_FRAMEWORK_PREFIX_DEFAULT")],
108  [sim_ac_framework_prefix="$withval"
109  if test x"$sim_ac_framework_prefix" = x""; then
110    sim_ac_framework_prefix=\${prefix}
111  fi],
112  [sim_ac_framework_prefix="MAC_FRAMEWORK_PREFIX_DEFAULT"])
113
114sim_ac_framework_version="MAC_FRAMEWORK_VERSION_DEFAULT"
115
116AC_SUBST([MAC_FRAMEWORK], [$sim_ac_framework])
117AC_SUBST([MAC_FRAMEWORK_NAME], [$sim_ac_framework_name])
118AC_SUBST([MAC_FRAMEWORK_PREFIX], [$sim_ac_framework_prefix])
119AC_SUBST([MAC_FRAMEWORK_VERSION], [$sim_ac_framework_version])
120
121AC_SUBST([nop], [])
122
123frameworkdir=
124if $sim_ac_framework; then
125  frameworkdir="${sim_ac_framework_prefix}/${sim_ac_framework_name}.framework"
126  includedir="$frameworkdir/Resources/include"
127fi
128
129ivincludedir=$includedir
130
131AC_SUBST([ivincludedir])
132AC_SUBST([frameworkdir])
133
134# **************************************************************************
135
136ac_build_year=$(date +%Y)
137
138
139AC_SUBST([COIN_BUILD_YEAR], $ac_build_year)
140AC_SUBST([COIN_MAJOR_VERSION], [COIN_MAJOR])
141AC_SUBST([COIN_MINOR_VERSION], [COIN_MINOR])
142AC_SUBST([COIN_MICRO_VERSION], [COIN_MICRO])
143AC_SUBST([COIN_BETA_VERSION], [COIN_BETA])
144AC_SUBST([COIN_VERSION], [$COIN_MAJOR_VERSION.$COIN_MINOR_VERSION.$COIN_MICRO_VERSION$COIN_BETA_VERSION])
145VERSION=$COIN_VERSION
146
147SIM_AC_CONFIGURATION_SETTING([Library version], [$COIN_VERSION])
148
149# Libtool versioning
150AC_SUBST([LT_CURRENT], [COIN_ABI_CURRENT])
151AC_SUBST([LT_REVISION], [COIN_ABI_REVISION])
152AC_SUBST([LT_AGE], [COIN_ABI_AGE])
153
154AC_SUBST([COIN_SO_VERSION], [SO_NUMBER])
155
156#  These are for include/Inventor/C/basic.h.
157
158AC_DEFINE_UNQUOTED([COIN_MAJOR_VERSION], [$COIN_MAJOR_VERSION],
159  [define this to the libCoin major version number])
160AC_DEFINE_UNQUOTED([COIN_MINOR_VERSION], [$COIN_MINOR_VERSION],
161  [define this to the libCoin minor version number])
162AC_DEFINE_UNQUOTED([COIN_MICRO_VERSION], [$COIN_MICRO_VERSION],
163  [define this to the libCoin release version number])
164AC_DEFINE_UNQUOTED([COIN_VERSION], ["$COIN_VERSION"],
165  [define this to the full libCoin major.minor.micro version number])
166if test x"$COIN_BETA_VERSION" = x""; then :; else
167  AC_DEFINE_UNQUOTED([COIN_BETA_VERSION], [$COIN_BETA_VERSION],
168    [define this to the libCoin beta version letter])
169fi
170
171# *******************************************************************
172# Miscellaneous options and initializations.
173
174coin_build_dir=`pwd`
175coin_src_dir=`cd "$srcdir"; pwd`
176coin_w32_build_dir=`cygpath -w "$coin_build_dir" 2>/dev/null || echo "$coin_build_dir"`
177coin_w32_src_dir=`cygpath -w "$coin_src_dir" 2>/dev/null || echo "$coin_src_dir"`
178
179SIM_AC_RELATIVE_SRC_DIR
180
181# *******************************************************************
182# set up configure options for "make distcheck" mode - we want to
183# ensure that all options that can be turned on works...
184
185AC_MSG_CHECKING([for distcheck mode])
186case "$prefix:$coin_build_dir" in
187*/=inst:*/=build )
188  enable_threads=yes
189  enable_threadsafe=yes
190  enable_html=yes
191  enable_man=yes
192  enable_3ds_import=yes
193  enable_debug=no
194  AC_MSG_RESULT([yes])
195  ;;
196* )
197  AC_MSG_RESULT([no])
198  ;;
199esac
200
201# **************************************************************************
202#  Locate C++ compiler and set C++ as the default language to use
203#  in tests. The configure script will automatically terminate if
204#  it doesn't find a C++ compiler.
205AC_PROG_CC
206
207# AC_OBJEXT
208# AC_EXEEXT
209
210# **************************************************************************
211# NOTE: if we touch CFLAGS/CXXFLAGS before AC_PROG_CC is invoked, the -g
212# flag will be lost  20020104 larsa
213
214if $BUILD_WITH_MSVC; then
215  SIM_AC_SETUP_MSVCRT([
216    CPPFLAGS="$CPPFLAGS $sim_ac_msvcrt_CPPFLAGS"
217    CFLAGS="$CFLAGS $sim_ac_msvcrt_CFLAGS"
218    CXXFLAGS="$CXXFLAGS $sim_ac_msvcrt_CXXFLAGS"
219    LDFLAGS="$LDFLAGS $sim_ac_msvcrt_LDFLAGS"
220    LIBS="$LIBS $sim_ac_msvcrt_LIBS"
221    # sim_ac_msvcrt_LIBLIBS is set up at the end
222    # sim_ac_msvcrt_LIBLDFLAGS is set up at the end
223  ])
224fi
225
226AC_SUBST([COIN_MSVC_LIBC], [$sim_ac_msvcrt])
227AC_SUBST([BUILD_WITH_MSVC])
228
229# **************************************************************************
230# Universal Binary support (Mac OS X)
231
232SIM_AC_UNIVERSAL_BINARIES
233
234# **************************************************************************
235
236AM_INIT_AUTOMAKE(Coin, $VERSION)
237
238#  Default to not building a static library.
239#  Can be overridden by the user with --enable-static.
240AM_DISABLE_STATIC
241
242#  Turn off default maintainer make-rules -- use ./bootstrap instead.
243AM_MAINTAINER_MODE
244
245if $BUILD_WITH_MSVC; then
246  RANLIB=:
247  export RANLIB
248fi
249
250# **************************************************************************
251#  Locate C++ compiler and set C++ as the default language to use
252#  in tests. The configure script will automatically terminate if
253#  it doesn't find a C++ compiler.
254#
255#  Note that due to bugs in the libtool.m4 set of checks (of libtool v1.4.2)
256#  that makes AC_PROG_LIBTOOL dependent on the current compiler being a C
257#  compiler, we don't activate the C++ compiler until _after_ running
258#  AC_PROG_LIBTOOL.
259#
260#  (The specific checks we know not to work are the checks for "-c -o"
261#  compatibility, where only CFLAGS is set up (and not CXXFLAGS) before the
262#  check is run).
263
264AC_PROG_CXX
265AC_PROG_CXXCPP
266
267# Since the plan is to not compile pure C anymore, we can simplify by always
268# setting C++ mode in Coin's configure script.
269AC_LANG([C++])
270
271if $BUILD_WITH_MSVC; then
272  SIM_AC_MSC_VERSION
273
274  case "$sim_ac_msc_major_version" in
275  8 | 9) CPPFLAGS="$CPPFLAGS -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS" ;;
276  *)
277  esac
278fi
279
280SIM_AC_STRIP_EXIT_DECLARATION
281
282# **************************************************************************
283
284SIM_AC_MACOS10_DEPLOYMENT_TARGET
285
286if test x"$sim_ac_macos10_deployment_target_major_version" = x"10"; then
287  # AC_DEFINE() COIN_MACOS_10_# as needed here...
288  sim_ac_macosx=true
289  sim_ac_macosx_10_2ff=false
290  sim_ac_macosx_10_3ff=false
291  AC_DEFINE([COIN_MACOS_10], 1, [Define for Mac OS X builds])
292  if test 1 -le $sim_ac_macos10_deployment_target_minor_version; then
293    AC_DEFINE([COIN_MACOS_10_1], 1, [Define for Mac OS 10.1 builds])
294    sim_ac_macosx_10_2ff=false
295    sim_ac_macosx_10_3ff=false
296  fi
297  if test 2 -le $sim_ac_macos10_deployment_target_minor_version; then
298    AC_DEFINE([COIN_MACOS_10_2], 1, [Define for Mac OS 10.2 builds])
299    sim_ac_macosx_10_2ff=true
300    sim_ac_macosx_10_3ff=false
301    sim_ac_macosx_name="Jaguar"
302  fi
303  if test 3 -le $sim_ac_macos10_deployment_target_minor_version; then
304    #AC_DEFINE([COIN_MACOS_10_3], 1, [Define for Mac OS 10.3 builds])
305    sim_ac_macosx_10_2ff=true
306    sim_ac_macosx_10_3ff=true
307    sim_ac_macosx_name="Panther"
308  fi
309  if test 4 -le $sim_ac_macos10_deployment_target_minor_version; then
310    #AC_DEFINE([COIN_MACOS_10_4], 1, [Define for Mac OS 10.4 builds])
311    sim_ac_macosx_10_2ff=true
312    sim_ac_macosx_10_3ff=true
313    sim_ac_macosx_name="Tiger"
314  fi
315  if test 5 -le $sim_ac_macos10_deployment_target_minor_version; then
316    #AC_DEFINE([COIN_MACOS_10_5], 1, [Define for Mac OS 10.5 builds])
317    sim_ac_macosx_10_2ff=true
318    sim_ac_macosx_10_3ff=true
319    sim_ac_macosx_name="Leopard"
320  fi
321else
322  sim_ac_macosx=false
323  sim_ac_macosx_10_2ff=false
324  sim_ac_macosx_10_3ff=false
325  sim_ac_macosx_name=""
326fi
327
328AM_CONDITIONAL([MAC_FRAMEWORK], [$sim_ac_framework])
329if $sim_ac_framework; then
330  AC_DEFINE([COIN_MACOSX_FRAMEWORK], 1, [Define when building Mac OS X framework])
331fi
332
333AM_CONDITIONAL([MACOSX_10_2FF], [$sim_ac_macosx_10_2ff])
334AM_CONDITIONAL([MACOSX_10_3FF], [$sim_ac_macosx_10_3ff])
335AM_CONDITIONAL([MACOSX], [$sim_ac_macosx])
336AC_SUBST([MACOSX_10_2FF], [$sim_ac_macosx_10_2ff])
337AC_SUBST([MACOSX_NAME], [$sim_ac_macosx_name])
338
339# **************************************************************************
340#  Initialize libtool
341#
342# FIXME: this must be done even when we're not using libtool (as when
343# building with MSVC++), because that's where at least the enable_static
344# and enable_shared flags are set up. 20030324 mortene.
345AC_PROG_LIBTOOL
346
347# **************************************************************************
348#  These are used for constructing the coin-config file.
349AC_SUBST([COIN_EXTRA_CPPFLAGS], [$CPPFLAGS])
350AC_SUBST([COIN_EXTRA_CFLAGS], [$CFLAGS])
351AC_SUBST([COIN_EXTRA_CXXFLAGS], [$CXXFLAGS])
352AC_SUBST([COIN_EXTRA_LDFLAGS], [$LDFLAGS])
353AC_SUBST([COIN_EXTRA_LIBS], [$LIBS])
354
355# *******************************************************************
356# Compiler checking.
357
358## Make it possible for the user to turn off optimization flags for
359## the compiler before running the fatal error checks below.
360SIM_AC_COMPILER_OPTIMIZATION
361
362## Smoke out some known defunct compilers.
363SIM_AC_COMPILER_CPLUSPLUS_FATAL_ERRORS
364
365## See which way the compiler knows the name of the current function. ####
366SIM_AC_CHECK_VAR_FUNCTIONNAME
367
368SIM_AC_MAC_CPP_ADJUSTMENTS
369
370if test x"$prefix" = x"NONE"; then
371  prefix=/usr/local
372fi
373#
374# *******************************************************************
375# Enable/disable separate Coin modules
376
377sim_ac_enable_java_wrapper=false
378AC_ARG_ENABLE(
379  [java-wrapper],
380  AC_HELP_STRING([--enable-java-wrapper], [enable building java wrapper]), [
381  case $enableval in
382    yes | true) sim_ac_enable_java_wrapper=true ;;
383    no | false) sim_ac_enable_java_wrapper=false ;;
384    *) ;;
385  esac])
386
387AM_CONDITIONAL([BUILD_JAVA_WRAPPER], [$sim_ac_enable_java_wrapper])
388
389if $sim_ac_enable_java_wrapper; then
390  AC_DEFINE([HAVE_JAVA_WRAPPER], 1, [Define this if you build the Java wrapper])
391  SIM_AC_CONFIGURATION_SETTING([Generate Java wrapper], [Yes (not really)])
392else
393  SIM_AC_CONFIGURATION_SETTING([Generate Java wrapper], [No (default)])
394fi
395
396# *******************************************************************
397# See if we should build with 3ds import capabilities.
398
399sim_ac_enable_3ds_import=false
400AC_ARG_ENABLE(
401  [3ds-import],
402  AC_HELP_STRING([--enable-3ds-import], [enable 3ds import capabilities]), [
403  case $enableval in
404    yes | true) sim_ac_enable_3ds_import=true ;;
405    no | false) sim_ac_enable_3ds_import=false ;;
406    *) ;;
407  esac])
408
409HAVE_3DS_IMPORT_CAPABILITIES=1
410
411if $sim_ac_enable_3ds_import ; then
412  AC_DEFINE([HAVE_3DS_IMPORT_CAPABILITIES],, [for setup.h])
413  SIM_AC_CONFIGURATION_SETTING([3ds import capabilities], [Yes (warning: experimental)])
414else
415  HAVE_3DS_IMPORT_CAPABILITIES=0
416  SIM_AC_CONFIGURATION_SETTING([3ds import capabilities], [No  (enable with --enable-3ds-import)])
417fi
418AC_SUBST(HAVE_3DS_IMPORT_CAPABILITIES)
419
420AM_CONDITIONAL([BUILD_3DS_CAPABILITIES], [$sim_ac_enable_3ds_import])
421
422
423# *******************************************************************
424# Enable/disable system expat
425
426sim_ac_enable_system_expat=false
427AC_ARG_ENABLE(
428  [system-expat],
429  AC_HELP_STRING([--enable-system-expat], [enable use of system-expat]), [
430  case $enableval in
431    yes | true) sim_ac_enable_system_expat=true ;;
432    no | false) sim_ac_enable_system_expat=false ;;
433    *) ;;
434  esac])
435
436AM_CONDITIONAL([USE_SYSTEM_EXPAT], [$sim_ac_enable_system_expat])
437
438if $sim_ac_enable_system_expat; then
439  AC_DEFINE([HAVE_SYSTEM_EXPAT], 1, [Define this if you want to use a system installation of expat])
440  SIM_AC_CONFIGURATION_SETTING([Use system expat], [Yes])
441else
442  SIM_AC_CONFIGURATION_SETTING([Use system expat], [No (default)])
443fi
444
445# *******************************************************************
446# See if we should build with javascript capabilities.
447
448sim_ac_enable_javascript=true
449AC_ARG_ENABLE(
450  [javascript-api],
451  AC_HELP_STRING([--disable-javascript-api], [disable javascript capabilities]), [
452  case $enableval in
453    yes | true) sim_ac_enable_javascript=true ;;
454    no | false) sim_ac_enable_javascript=false ;;
455    *) ;;
456  esac])
457
458HAVE_JAVASCRIPT=1
459
460if $sim_ac_enable_javascript ; then
461  AC_DEFINE([COIN_HAVE_JAVASCRIPT],, [for setup.h])
462  SIM_AC_CONFIGURATION_SETTING([javascript capabilities], [Yes])
463else
464  HAVE_JAVASCRIPT=0
465  SIM_AC_CONFIGURATION_SETTING([javascript capabilities], [No (enable with --enable-javascript-api)])
466fi
467AC_SUBST(HAVE_JAVASCRIPT)
468
469# *******************************************************************
470# Query enabling/disabling various subsystems
471
472sim_ac_enable_nodekits=true
473
474AC_ARG_ENABLE(
475  [nodekits],
476  AC_HELP_STRING([--disable-nodekits], [disable nodekit support]), [
477  case $enableval in
478    yes | true) sim_ac_enable_nodekits=true ;;
479    no | false) sim_ac_enable_nodekits=false ;;
480    *) ;;
481  esac])
482
483sim_ac_enable_draggers=true
484
485AC_ARG_ENABLE(
486  [draggers],
487  AC_HELP_STRING([--disable-draggers], [disable dragger support]), [
488  case $enableval in
489    yes | true) sim_ac_enable_draggers=true ;;
490    no | false) sim_ac_enable_draggers=false ;;
491    *) ;;
492  esac])
493
494sim_ac_enable_manipulators=true
495
496AC_ARG_ENABLE(
497  [manipulators],
498  AC_HELP_STRING([--disable-manipulators], [disable manipulator support]), [
499  case $enableval in
500    yes | true) sim_ac_enable_manipulators=true ;;
501    no | false) sim_ac_enable_manipulators=false ;;
502    *) ;;
503  esac])
504
505HAVE_NODEKITS=1
506HAVE_DRAGGERS=1
507HAVE_MANIPULATORS=1
508
509if $sim_ac_enable_nodekits; then
510  AC_DEFINE([HAVE_NODEKITS],, [for setup.h])
511  SIM_AC_CONFIGURATION_SETTING([nodekit support], [Yes])
512else
513  HAVE_NODEKITS=0
514  HAVE_DRAGGERS=0
515  HAVE_MANIPULATORS=0
516  SIM_AC_CONFIGURATION_SETTING([nodekit support], [No  (this severely cripples Coin)])
517fi
518
519if $sim_ac_enable_draggers && test x"$HAVE_NODEKITS" = x"1"; then
520  AC_DEFINE([HAVE_DRAGGERS],, [for setup.h])
521  SIM_AC_CONFIGURATION_SETTING([dragger support], [Yes])
522else
523  HAVE_DRAGGERS=0
524  HAVE_MANIPULATORS=0
525  SIM_AC_CONFIGURATION_SETTING([dragger support], [No  (this severely cripples Coin)])
526fi
527
528if $sim_ac_enable_manipulators && test x"$HAVE_DRAGGERS" = x"1"; then
529  AC_DEFINE([HAVE_MANIPULATORS],, [for setup.h])
530  SIM_AC_CONFIGURATION_SETTING([manipulator support], [Yes])
531else
532  HAVE_MANIPULATORS=0
533  SIM_AC_CONFIGURATION_SETTING([manipulator support], [No  (this severely cripples Coin)])
534fi
535
536AC_SUBST(HAVE_NODEKITS)
537AC_SUBST(HAVE_DRAGGERS)
538AC_SUBST(HAVE_MANIPULATORS)
539
540# *******************************************************************
541
542sim_ac_enable_vrml97=true
543
544AC_ARG_ENABLE(
545  [vrml97],
546  AC_HELP_STRING([--disable-vrml97], [disable VRML97 support]), [
547  case $enableval in
548    yes | true) sim_ac_enable_vrml97=true ;;
549    no | false) sim_ac_enable_vrml97=false ;;
550    *) ;;
551  esac])
552
553HAVE_VRML97=1
554
555if $sim_ac_enable_vrml97 ; then
556  AC_DEFINE([HAVE_VRML97],, [for setup.h])
557  SIM_AC_CONFIGURATION_SETTING([VRML97 support], [Yes])
558else
559  HAVE_VRML97=0
560  SIM_AC_CONFIGURATION_SETTING([VRML97 support], [No  (enable with --enable-vrml97)])
561fi
562AC_SUBST(HAVE_VRML97)
563
564# *******************************************************************
565# Search for the "local GLU" extension
566
567enable_superglu=false
568
569if test -x ${srcdir}/src/extensions/superglu/configure; then
570  enable_superglu=true
571  AC_DEFINE(HAVE_SUPERGLU,1, [*EXPERIMENTAL* to use the GLU we've "appropriated" from SGI])
572  HAVE_SUPERGLU=1
573  AC_CONFIG_SUBDIRS([src/extensions/superglu])
574  CPPFLAGS="-I$coin_build_dir/src/extensions/superglu/include -I$coin_src_dir/src/extensions/superglu/include $CPPFLAGS"
575else
576  enable_superglu=false
577  HAVE_SUPERGLU=0
578fi
579AC_SUBST([HAVE_SUPERGLU])
580
581AC_SUBST([SUPERGLUPREFIX], [Super])
582export SUPERGLUPREFIX
583
584AM_CONDITIONAL(BUILD_WITH_SUPERGLU, $enable_superglu)
585
586# *******************************************************************
587
588AC_ARG_ENABLE([threads],
589  [AC_HELP_STRING([--disable-threads], [disable platform-independent multithreading abstraction classes])],
590  [case $enableval in
591  yes | true ) sim_ac_enable_threads=true ;;
592  no | false ) sim_ac_enable_threads=false ;;
593  *) AC_MSG_ERROR([invalid arg "$enableval" for --enable-threads option]) ;;
594  esac],
595  [sim_ac_enable_threads=true])
596
597HAVE_THREADS=0
598
599if $sim_ac_enable_threads; then
600
601  sim_ac_threads_api="none"
602
603  # Make it possible to explicitly turn off Win32 threads, to for instance
604  # use POSIX threads instead under Win32.
605  AC_ARG_ENABLE([w32threads],
606    [AC_HELP_STRING([--disable-w32threads], [never use Win32 threads, even when available])],
607    [case $enableval in
608    yes | true ) sim_ac_w32_enable_threads=true ;;
609    no | false ) sim_ac_w32_enable_threads=false ;;
610    *) AC_MSG_ERROR([invalid arg "$enableval" for --disable-w32threads option]) ;;
611    esac],
612    [sim_ac_w32_enable_threads=true])
613
614  sim_ac_win32_threads_available=false
615
616  # Check for platform-native Win32 thread API first.
617  if $sim_ac_w32_enable_threads; then
618    AC_MSG_CHECKING([for Win32 threads])
619    AC_TRY_LINK(
620     [#include <windows.h>],
621     [HANDLE h = CreateThread(NULL, 0, NULL, NULL, 0, NULL);
622      (void)SetThreadPriority(h, 0);
623      ExitThread(0);],
624     [sim_ac_win32_threads_available=true
625      sim_ac_threads_api="native Win32"
626      AC_DEFINE([USE_W32THREAD], , [define to use the Win32 threads API])
627      AC_DEFINE([COIN_THREADID_TYPE], DWORD, [System dependant thread ID type])])
628      # (we just ignore failure, as we fall through to POSIX threads)
629    AC_MSG_RESULT($sim_ac_win32_threads_available)
630  fi
631
632  if ! $sim_ac_win32_threads_available; then
633    SIM_AC_CHECK_PTHREAD([
634      AC_DEFINE([USE_PTHREAD], , [define to use the POSIX threads API])
635      AC_DEFINE([COIN_THREADID_TYPE], pthread_t, [System dependent thread ID type])
636      sim_ac_threads_api="POSIX"
637      COIN_EXTRA_CPPFLAGS="$COIN_EXTRA_CPPFLAGS $sim_ac_pthread_cppflags"
638      COIN_EXTRA_LDFLAGS="$COIN_EXTRA_LDFLAGS $sim_ac_pthread_ldflags"
639      COIN_EXTRA_LIBS="$sim_ac_pthread_libs $COIN_EXTRA_LIBS"
640    ])
641  fi
642
643  if test "$sim_ac_threads_api" = "none"; then
644    AC_MSG_ERROR([Could not find any usable native thread-handling API/library/devkit!  (If you do not want to enable the platform-independent thread-handling classes in Coin, specify the "--disable-threads" option to the configure script.)])
645  fi
646
647  HAVE_THREADS=1
648  AC_DEFINE([HAVE_THREADS],, [to use the platform-independent thread-handling abstractions])
649else
650  sim_ac_threads_api="Disabled  (enable with --enable-threads)"
651fi
652
653AC_SUBST([HAVE_THREADS])
654SIM_AC_CONFIGURATION_SETTING([System threads API], [$sim_ac_threads_api])
655
656AM_CONDITIONAL([BUILD_WITH_THREADS], [$sim_ac_enable_threads])
657
658# *******************************************************************
659# Thread safe library
660
661AC_ARG_ENABLE([threadsafe],
662  AC_HELP_STRING([--enable-threadsafe], [enable thread safe traversals]),
663  [case $enableval in
664  yes | true ) sim_ac_enable_threadsafe=true ;;
665  no | false ) sim_ac_enable_threadsafe=false ;;
666  *) AC_MSG_ERROR([invalid arg "$enableval" for --enable-threadsafe option]) ;;
667  esac],
668  [sim_ac_enable_threadsafe=false])
669
670HAVE_THREADSAFE=0
671
672if $sim_ac_enable_threadsafe; then
673  if test "$HAVE_THREADS" = "0"; then
674    AC_MSG_ERROR([You can not enable thread safe action traversals while at the same time disabling the portable thread-handling abstractions. You must use "--enable-threadsafe" with "--enable-threads".])
675  fi
676
677  HAVE_THREADSAFE=1
678  AC_DEFINE([COIN_THREADSAFE], 1, [for setup.h])
679  SIM_AC_CONFIGURATION_SETTING([Thread safe traversals], [Yes  (in development)])
680else
681  SIM_AC_CONFIGURATION_SETTING([Thread safe traversals], [No  (enable with --enable-threadsafe)])
682fi
683
684# for coin.cfg
685AC_SUBST([HAVE_THREADSAFE])
686
687# *******************************************************************
688# Headers we might want to use
689
690# We expect these to include their dependencies.
691#
692# A non-empty last argument indicates to Autoconf that we would like to heed
693# the result from compilation, not just pre-processing. (A space is enough
694# to indicate non-emptiness.)
695AC_CHECK_HEADERS(
696  [unistd.h sys/types.h inttypes.h stdint.h sys/param.h sys/time.h sys/timeb.h time.h io.h windows.h libgen.h direct.h strings.h ieeefp.h],
697  [], [], [])
698
699AC_MSG_CHECKING([for flex file adjustments])
700if test x"$ac_cv_header_unistd_h" != x"yes"; then
701  AC_MSG_RESULT([-DYY_NO_UNISTD_H])
702  CPPFLAGS="$CPPFLAGS -DYY_NO_UNISTD_H"
703else
704  AC_MSG_RESULT([none])
705fi
706
707SIM_AC_CHECK_HEADER_TLHELP32_H
708SIM_AC_CHECK_FUNC__SPLITPATH
709
710SIM_AC_CHECK_WIN32_API
711
712# Various systems (like MKS NuTCracker) needs explicit gdi32 linkage.
713if $sim_ac_have_win32_api; then
714  LIBS="$LIBS -lgdi32"
715  COIN_EXTRA_LIBS="$COIN_EXTRA_LIBS -lgdi32"
716fi
717
718# A non-empty last argument indicates to Autoconf that we would like to heed
719# the result from compilation, not just pre-processing. (A space is enough
720# to indicate non-emptiness.)
721AC_CHECK_HEADERS(
722  [sys/unistd.h],
723  [sim_ac_have_sys_unistd_h=true],
724  [sim_ac_have_sys_unistd_h=false],
725  [ ])
726
727if $sim_ac_have_sys_unistd_h; then
728  AC_MSG_CHECKING([for IN_PATH define conflict])
729  AC_TRY_COMPILE(
730   [#include <sys/unistd.h>],
731   [void * v; v = (void*) IN_PATH;],
732   [sim_ac_in_path_defined=true],
733   [sim_ac_in_path_defined=false])
734  if $sim_ac_in_path_defined; then
735    AC_MSG_RESULT([yes])
736    AC_DEFINE([COIN_UNDEF_IN_PATH_HACK],1,
737     [define to "remove" conflicting IN_PATH define from <sys/unistd.h>])
738  else
739    AC_MSG_RESULT([no])
740  fi
741fi
742
743# According to Coin user Ralf Corsepius, at least SunOS4 needs
744# to include sys/types.h before netinet/in.h. There have also
745# been a problem report for FreeBSD which seems to indicate
746# the same dependency on that platform aswell.
747#
748# FIXME: should we make this into a general macro
749# SIM_AC_CHECK_DEPENDENT_HEADER(HEADER, DEPENDONHEADERS..)? 20001025 mortene.
750#
751# FIXME2: is this really necessary? AC _CHECK_HEADER(S) tests by using the
752# preprocessor, not by doing a compile, so we could probably just
753# include netinet/in.h in the above list to AC _CHECK_HEADERS. We wouldn't
754# catch problems quiet so early on, though. 20001025 mortene.
755
756AC_CACHE_CHECK([for netinet/in.h], sim_cv_netinet_in_h, [
757  AC_TRY_CPP([
758    #ifdef HAVE_SYS_TYPES_H
759    #include <sys/types.h>
760    #endif /* HAVE_SYS_TYPES_H */
761    #include <netinet/in.h>],
762    [sim_cv_netinet_in_h=true], [sim_cv_netinet_in_h=false])])
763
764if $sim_cv_netinet_in_h; then
765  AC_DEFINE_UNQUOTED([HAVE_NETINET_IN_H], [1],
766    [Define if you have the <netinet/in.h> header file.])
767fi
768
769# For Inventor/system/inttypes.h.in.
770#
771# Note: this assumes AC_CHECK_HEADERS(sys/types.h stdint.h) has been done.
772#
773# FIXME: the header file checking should be AC_REQUIREd, if possible.
774# 20010711 mortene.
775
776SIM_AC_DEFINE_BYTESIZE_TYPES
777
778# *******************************************************************
779
780AC_MSG_CHECKING([for fstat() function])
781AC_TRY_LINK(
782 [#ifdef HAVE_SYS_STAT_H
783#include <sys/stat.h>
784#endif],
785 [struct stat sb;
786  int result = fstat(0, &sb);],
787 [AC_DEFINE(HAVE_FSTAT, 1, [define if fstat() is available])
788  AC_MSG_RESULT([available])],
789 [AC_MSG_RESULT([not available])])
790
791# *******************************************************************
792# We want to use BSD 4.3's isinf(), isnan(), finite() if they are
793# available.
794
795AC_MSG_CHECKING([for BSD 4.3 isinf() function])
796AC_TRY_LINK(
797 [#include <math.h>],
798 [int result = isinf(42.0);],
799 [AC_DEFINE(HAVE_ISINF, 1, [define if isinf() is available])
800  AC_MSG_RESULT([available])],
801 [AC_MSG_RESULT([not available])])
802
803AC_MSG_CHECKING([for BSD 4.3 isnan() function])
804AC_TRY_LINK(
805 [#include <math.h>],
806 [int result = isnan(42.0);],
807 [AC_DEFINE(HAVE_ISNAN, 1, [whether or not isnan() is available])
808  AC_MSG_RESULT([available])],
809 [AC_MSG_RESULT([not available])
810
811  AC_MSG_CHECKING([for _isnan() function])
812  AC_TRY_LINK(
813   [#include <math.h>],
814   [int result = _isnan(42.0);],
815   [AC_DEFINE(HAVE__ISNAN, 1, [whether or not _isnan() is available])
816    AC_MSG_RESULT([available])],
817   [AC_MSG_RESULT([not available])])
818])
819
820AC_MSG_CHECKING([for BSD 4.3 finite() function])
821AC_TRY_LINK(
822 [#include <math.h>],
823 [int result = finite(42.0);],
824 [AC_DEFINE(HAVE_FINITE, 1, [whether or not finite() is available])
825  AC_MSG_RESULT([available])],
826 [AC_MSG_RESULT([not available])
827
828  AC_MSG_CHECKING([for _finite() function])
829  AC_TRY_LINK(
830   [#include <math.h>],
831   [int result = _finite(42.0);],
832   [AC_DEFINE(HAVE__FINITE, 1, [whether or not _finite() is available])
833    AC_MSG_RESULT([available])],
834   [AC_MSG_RESULT([not available])])
835])
836
837AC_MSG_CHECKING([for fpclass() function])
838AC_TRY_LINK(
839[#ifdef HAVE_IEEEFP_H
840#include <ieeefp.h>
841#endif],
842 [int result = fpclass(42.0);],
843 [AC_DEFINE(HAVE_FPCLASS, 1, [whether or not fpclass() is available])
844  AC_MSG_RESULT([available])],
845 [AC_MSG_RESULT([not available])])
846
847AC_MSG_CHECKING([for _fpclass() function])
848AC_TRY_LINK(
849 [#include <math.h>],
850 [int result = _fpclass(42.0);],
851 [AC_DEFINE(HAVE__FPCLASS, 1, [whether or not _fpclass() is available])
852  AC_MSG_RESULT([available])],
853 [AC_MSG_RESULT([not available])])
854
855SIM_AC_CHECK_TYPEOF_STRUCT_MEMBER([
856#include <sys/types.h>
857#ifdef HAVE_TIME_H
858#include <time.h> // struct timeval (Linux)
859#endif // HAVE_TIME_H
860#ifdef HAVE_SYS_TIME_H
861#include <sys/time.h> // struct timeval (IRIX)
862#endif // HAVE_SYS_TIME_H
863#ifdef HAVE_WINDOWS_H
864#include <windows.h>
865#endif // HAVE_WINDOWS_H
866], [timeval], [tv_sec], [SIM_TIMEVAL_TV_SEC_T], [])
867
868SIM_AC_CHECK_TYPEOF_STRUCT_MEMBER([
869#include <sys/types.h>
870#ifdef HAVE_TIME_H
871#include <time.h> // struct timeval (Linux)
872#endif // HAVE_TIME_H
873#ifdef HAVE_SYS_TIME_H
874#include <sys/time.h> // struct timeval (IRIX)
875#endif // HAVE_SYS_TIME_H
876#ifdef HAVE_WINDOWS_H
877#include <windows.h>
878#endif // HAVE_WINDOWS_H
879], [timeval], [tv_usec], [SIM_TIMEVAL_TV_USEC_T], [])
880
881# *******************************************************************
882
883sim_ac_build_library=true
884AC_ARG_ENABLE(
885  [build],
886  [AC_HELP_STRING([--disable-build], [disable configuration for library build])],
887  [case $enableval in
888  no | false)
889   sim_ac_build_library=false
890   SIM_AC_CONFIGURATION_SETTING([Coin build type], [build disabled])
891   ;;
892  esac])
893
894AM_CONDITIONAL(BUILD_LIBRARY, $sim_ac_build_library)
895
896# *******************************************************************
897# * Do we want to build the documentation?
898# *******************************************************************
899
900AC_ARG_ENABLE(html,
901  AC_HELP_STRING([--enable-html], [build and install Coin HTML documentation]),
902  [case $enableval in
903    yes | true) want_html=yes ;;
904    *)          want_html=no ;;
905  esac],
906  [want_html=no])
907
908case $htmldir in
909/*)
910  # do nothing - absolute path
911  ;;
912*)
913  # expand $docdir and append /html
914  htmldir=`eval echo ${docdir}`/html
915  ;;
916esac
917
918AC_SUBST(htmldir)
919
920AC_ARG_ENABLE(man,
921  AC_HELP_STRING([--enable-man], [build and install Coin man pages]),
922  [case $enableval in
923    yes | true) want_man=yes ;;
924    *)          want_man=no ;;
925  esac],
926  [want_man=no])
927
928# Used in the Doxygen parameter file.
929AC_SUBST([COIN_DOC_HTML], [`echo $want_html | tr '[a-z]' '[A-Z]'`])
930AC_SUBST([coin_html_dir], [`pwd`/html])
931AC_SUBST([COIN_DOC_MAN], [`echo $want_man | tr '[a-z]' '[A-Z]'`])
932AC_SUBST([coin_man_dir], [`pwd`/man])
933
934AM_CONDITIONAL(BUILD_MANPAGES, test x"$want_man" = x"yes")
935AM_CONDITIONAL(BUILD_HTMLPAGES, test x"$want_html" = x"yes")
936
937if test x"$want_man" = x"yes"; then
938  SIM_AC_CONFIGURATION_SETTING([manpage installation], [$mandir])
939fi
940
941if test x"$want_html" = x"yes"; then
942  SIM_AC_CONFIGURATION_SETTING([HTML installation], [$htmldir])
943fi
944
945# Perl is used for the Doxygen-based doc generation, plus when making
946# NSIS installation packages.
947AC_PATH_PROG(sim_ac_perl_exe, perl, false, $PATH)
948
949if test x"$want_html" != xno -o x"$want_man" != xno; then
950  SIM_AC_DOXYGEN_TOOL([], [SIM_AC_ERROR([no-doxygen])])
951  if test x"$sim_ac_perl_exe" = xfalse; then
952    AC_MSG_ERROR([Could not find the Perl executable, which is needed for Doxygen doc generation.])
953  fi
954fi
955
956# path_tag is used to identify paths in docs/coin.doxygen that needs to be
957# transformed using cygpath under cygwin.
958
959case $host in
960*-cygwin) path_tag="<PATH>" ;;
961*)        path_tag= ;;
962esac
963
964AC_SUBST(path_tag)
965
966#Get all the doxygen source files
967. ${coin_src_dir}/docs/coin_doxygenfiles.inc
968
969#The AC_SUBST command will not accept multiline strings, so trick this
970#into a singleline string
971DOXYGEN_INPUT=$(echo ${DOXYGEN_INPUT})
972
973AC_SUBST(DOXYGEN_INPUT)
974
975sim_ac_makensis_exe=false
976case $host in
977*-cygwin)
978  AC_PATH_PROG([sim_ac_makensis_exe], [makensis], [false], [$PATH])
979  ;;
980esac
981
982AC_PATH_PROG([sim_ac_dpkg_buildpackage_exe],
983  [dpkg-buildpackage], [false], [$PATH])
984
985sim_ac_windows_packagable=true
986if test x"$sim_ac_perl_exe" = xfalse || test x"$sim_ac_makensis_exe" = xfalse; then
987  sim_ac_windows_packageable=false
988fi
989
990AM_CONDITIONAL([WIN_PACKAGEABLE], $sim_ac_windows_packageable)
991
992sim_ac_debian_packageable=true
993if test x"$sim_ac_dpkg_buildpackage_exe" = xfalse; then
994  sim_ac_debian_packageable=false
995fi
996
997AM_CONDITIONAL([DEB_PACKAGEABLE], [$sim_ac_debian_packageable])
998
999SIM_AC_PACKAGEMAKER_APP
1000AC_SUBST([sim_ac_packagemaker_app])
1001sim_ac_macosx_packageable=true
1002if test x"$sim_ac_packagemaker_app" = xfalse; then
1003  sim_ac_macosx_packageable=false
1004fi
1005
1006AM_CONDITIONAL([MACOSX_PACKAGEABLE], [$sim_ac_macosx_packageable])
1007
1008# *******************************************************************
1009# Configure an alternate installation?
1010
1011AC_ARG_WITH(
1012  [alternate],
1013  [AC_HELP_STRING([--with-alternate=string],
1014                  [specify name of alternate configuration])],
1015  [CONFIG=$withval],
1016  [CONFIG=default])
1017
1018AC_ARG_WITH(
1019  [suffix],
1020  [AC_HELP_STRING([--with-suffix=string],
1021                  [specify library name suffix (e.g. "_g")])],
1022  [SUFFIX=$withval],
1023  [SUFFIX=])
1024
1025AC_SUBST(CONFIG)
1026AC_SUBST(SUFFIX)
1027
1028# *******************************************************************
1029# * Check compiler features, bugs, etc.
1030# *******************************************************************
1031
1032# FIXME: the extra strict warning settings for GCC below should be
1033# placed in a macro, so they can be easily used from other src-code
1034# modules aswell. 20021218 mortene.
1035
1036SIM_AC_COMPILE_DEBUG([
1037  CPPFLAGS="$CPPFLAGS -DCOIN_DEBUG=1"
1038], [
1039  CPPFLAGS="$CPPFLAGS -DCOIN_DEBUG=0"
1040])
1041
1042SIM_AC_DEBUGSYMBOLS
1043SIM_AC_RTTI_SUPPORT
1044SIM_AC_EXCEPTION_HANDLING
1045SIM_AC_PROFILING_SUPPORT
1046SIM_AC_COMPILER_WARNINGS
1047SIM_AC_DETECT_COMMON_COMPILER_FLAGS
1048
1049# Disable bool type with MSVC.
1050#
1051# "/noBool" should not be part of the SIM_AC_DETECT_COMMON_COMPILER_FLAGS
1052# macro, because some projects will not compile properly with it.
1053# (Like at least SoQt, since the Qt headers defines the bool type, which
1054# will then cause a compiler error when q[whatever].h is included.)
1055
1056# The setting of /noBool for MSVC has been disabled because of problems with
1057# using <limits> with Visual C++ 6.  2007-10-03 larsa
1058# SIM_AC_COMPILER_NOBOOL([
1059#   sim_ac_compiler_CXXFLAGS="$sim_ac_compiler_CXXFLAGS $sim_ac_nobool_CXXFLAGS"
1060# ])
1061
1062#  Yep, this is important in case we want to add code to make
1063#  the API interface "Open Inventor strict", meaning the user must
1064#  use the exact same include files as under "real" Open Inventor.
1065#  We would then need to know that we are actually allowed to include
1066#  any file during internal build.
1067#
1068#  The COIN_INTERNAL define is also in use to detect
1069#  "inefficient including" internally.
1070
1071CPPFLAGS="$CPPFLAGS -DCOIN_INTERNAL"
1072
1073if $BUILD_WITH_MSVC; then
1074  case ${enable_static-no} in
1075  yes | true)  COIN_STATIC=true;
1076               enable_shared=no ;; # --enable-static-problem with autoconf 2.58
1077  *)           COIN_STATIC=false ;;
1078  esac
1079  case ${enable_shared-default} in
1080  default)     ;;
1081  yes | true)  COIN_STATIC=false ;;
1082  *)           COIN_STATIC=true ;;
1083  esac
1084fi
1085
1086# **************************************************************************
1087# Check for various system specifics.
1088
1089# Try to find snprintf() and vsnprintf() on the system.
1090SIM_AC_CHECK_NPRINTF
1091
1092# C99 va_copy() available?
1093AC_MSG_CHECKING([for va_copy() stdarg macro])
1094AC_TRY_LINK([#include <stdarg.h>
1095             static void hepp(int dummy, ...) {
1096             va_list l, c;
1097             va_start(l, dummy); va_copy(c, l); va_end(c); va_end(l); }
1098            ],
1099            [hepp(0, 1, 2); ],
1100  [AC_MSG_RESULT([yes])
1101  AC_DEFINE([HAVE_VA_COPY_MACRO], 1, [Define to use va_copy() when available])],
1102  [AC_MSG_RESULT([no])])
1103
1104# How to string quote.
1105SIM_AC_CHECK_MACRO_QUOTE([], [SIM_AC_ERROR([no-cpp-quoting])])
1106if test x"$sim_ac_quote_hash" = xyes; then
1107  AC_DEFINE([HAVE_HASH_QUOTING],1,
1108    [define if preprocessor can quote arguments with the hash symbol])
1109else
1110  if test x"$sim_ac_quote_apostrophes" = xyes; then
1111    AC_DEFINE([HAVE_APOSTROPHES_QUOTING],1,
1112      [define if preprocessor can quote arguments with apostophes])
1113  fi
1114fi
1115
1116# *******************************************************************
1117# Instead of getenv() on most Win32 platforms (not Windows CE).
1118
1119AC_MSG_CHECKING([for GetEnvironmentVariable() function])
1120AC_TRY_LINK([#include <windows.h>],
1121            [(void)GetEnvironmentVariable("FOOBAR", NULL, 0);],
1122  [AC_MSG_RESULT([yes])
1123  AC_DEFINE([HAVE_GETENVIRONMENTVARIABLE],1, [Define to use GetEnvironmentVariable() instead of getenv()])],
1124  [AC_MSG_RESULT([no])])
1125
1126# *******************************************************************
1127#
1128
1129sim_ac_save_LIBS=$LIBS
1130LIBS="$LIBS -lwinmm"
1131AC_MSG_CHECKING([for timeGetTime() function])
1132AC_TRY_LINK([
1133#ifdef HAVE_WINDOWS_H
1134#include <windows.h>
1135#endif
1136], [
1137  (void)timeGetTime();
1138], [
1139  AC_MSG_RESULT([yes])
1140  AC_DEFINE([HAVE_TIMEGETTIME],, [Define to use timeGetTime()])
1141  COIN_EXTRA_LIBS="$COIN_EXTRA_LIBS -lwinmm"
1142], [
1143  AC_MSG_RESULT([no])
1144  LIBS=$sim_ac_save_LIBS
1145])
1146
1147# *******************************************************************
1148# The MessageBox() Win32 API call is used in SoDB.cpp to throw up
1149# an error message when multiple Coin-instances are detected in the
1150# same process image.
1151
1152sim_ac_save_LIBS=$LIBS
1153LIBS="$LIBS -luser32"
1154AC_MSG_CHECKING([for MessageBox() function])
1155AC_TRY_LINK([
1156#ifdef HAVE_WINDOWS_H
1157#include <windows.h>
1158#endif
1159], [
1160  (void)MessageBox(NULL, NULL, NULL, 0);
1161], [
1162  AC_MSG_RESULT([yes])
1163  COIN_EXTRA_LIBS="$COIN_EXTRA_LIBS -luser32"
1164], [
1165  AC_MSG_RESULT([no])
1166  LIBS=$sim_ac_save_LIBS
1167])
1168
1169# *******************************************************************
1170# Test for misc functions to get systemtime with.
1171
1172AC_MSG_CHECKING([for QueryPerformanceCounter() function])
1173AC_TRY_LINK([
1174#ifdef HAVE_WINDOWS_H
1175#include <windows.h>
1176#endif
1177], [
1178  LARGE_INTEGER l;
1179  (void)QueryPerformanceFrequency(&l);
1180  (void)QueryPerformanceCounter(&l);
1181], [
1182  AC_MSG_RESULT([yes])
1183  AC_DEFINE([HAVE_QUERYPERFORMANCECOUNTER],1, [Define to use Win32 QueryPerformanceCounter()])
1184], [
1185  AC_MSG_RESULT([no])
1186])
1187
1188AC_MSG_CHECKING([for _ftime() function])
1189AC_TRY_LINK([
1190#include <windows.h>
1191#include <sys/types.h>
1192#include <sys/timeb.h>
1193], [
1194  struct _timeb timebuffer;
1195  _ftime(&timebuffer);
1196], [
1197  AC_MSG_RESULT([yes])
1198  AC_DEFINE([HAVE__FTIME],1, [Define to use Win32 _ftime()])
1199], [
1200  AC_MSG_RESULT([no])
1201])
1202
1203AC_MSG_CHECKING([for ftime() function])
1204AC_TRY_LINK([
1205#include <sys/timeb.h>
1206], [
1207  struct timeb timebuffer;
1208  ftime(&timebuffer);
1209], [
1210  # ftime() is not available in libSystem on Mac OS X < 10.4,
1211  # so don't use it when building the binary SDK.
1212  case ${MACOSX_DEPLOYMENT_TARGET} in
1213    10.[[0123]])
1214      AC_MSG_RESULT([yes (unused)])
1215      ;;
1216    *)
1217      AC_MSG_RESULT([yes])
1218      AC_DEFINE([HAVE_FTIME],1, [Define to use ftime()])
1219      ;;
1220  esac
1221], [
1222  AC_MSG_RESULT([no])
1223])
1224
1225AC_MSG_CHECKING([for _getcwd() function])
1226AC_TRY_LINK([
1227#include <direct.h>
1228], [
1229  char buf[512];
1230  _getcwd(buf, 512);
1231], [
1232  AC_MSG_RESULT([yes])
1233  AC_DEFINE([HAVE__GETCWD],1, [Define to use Win32 _getcwd()])
1234], [
1235  AC_MSG_RESULT([no])
1236])
1237
1238AC_MSG_CHECKING([for getcwd() function])
1239AC_TRY_LINK([
1240#include <unistd.h>
1241], [
1242  char buf[512];
1243  getcwd(buf, 512);
1244], [
1245  AC_MSG_RESULT([yes])
1246  AC_DEFINE([HAVE_GETCWD],1, [Define to use getcwd()])
1247], [
1248  AC_MSG_RESULT([no])
1249])
1250
1251AC_MSG_CHECKING([for gettimeofday() function])
1252AC_TRY_LINK([
1253#ifdef HAVE_TIME_H
1254#include <time.h>
1255#endif /* HAVE_TIME_H */
1256#ifdef HAVE_SYS_TIME_H
1257#include <sys/time.h>
1258#endif /* HAVE_SYS_TIME_H */
1259#ifdef HAVE_UNISTD_H
1260#include <unistd.h>
1261#endif /* HAVE_UNISTD_H */
1262#ifdef HAVE_SYS_UNISTD_H
1263#include <sys/unistd.h>
1264#endif /* HAVE_SYS_UNISTD_H */
1265], [
1266  struct timeval tmp;
1267  (void)gettimeofday(&tmp, NULL);
1268], [
1269  AC_MSG_RESULT([yes])
1270  AC_DEFINE([HAVE_GETTIMEOFDAY],1, [Define to use SVr4 / BSD4.3 gettimeofday()])
1271], [
1272  AC_MSG_RESULT([no])
1273])
1274
1275# *******************************************************************
1276# Test for misc functions, typically not part of neither ISO C or POSIX.
1277
1278AC_MSG_CHECKING([for strncasecmp() function])
1279AC_TRY_LINK([
1280#include <string.h>
1281], [
1282  (void)strncasecmp(NULL, NULL, 0);
1283], [
1284  AC_MSG_RESULT([yes])
1285  AC_DEFINE([HAVE_STRNCASECMP],1, [Define to use BSD4.3 strncasecmp()])
1286], [
1287  AC_MSG_RESULT([no])
1288])
1289
1290AC_MSG_CHECKING([for memmove() function])
1291AC_TRY_COMPILE(
1292 [#include <string.h>],
1293 [(void) memmove(0, 0, 0);],
1294 [AC_DEFINE(HAVE_MEMMOVE, 1, [define if memmove() is available])
1295  AC_MSG_RESULT([available])],
1296 [AC_MSG_RESULT([not available])])
1297
1298AC_MSG_CHECKING([for bcopy() function])
1299AC_TRY_COMPILE(
1300 [#ifdef HAVE_STRINGS_H
1301#include <strings.h>
1302#endif],
1303 [(void) bcopy(0, 0, 0);],
1304 [AC_DEFINE(HAVE_BCOPY, 1, [define if bcopy() is available])
1305  AC_MSG_RESULT([available])],
1306 [AC_MSG_RESULT([not available])])
1307
1308AC_MSG_CHECKING([for _logb() function])
1309AC_TRY_LINK([
1310#include <math.h>
1311#include <float.h>
1312], [
1313  (void)_logb(1.0);
1314], [
1315  AC_MSG_RESULT([yes])
1316  AC_DEFINE([HAVE__LOGB],1, [Define to use Win32 _logb()])
1317], [
1318  AC_MSG_RESULT([no])
1319])
1320
1321
1322# *******************************************************************
1323# * Test to see if dynamic linking through either the (Linux/IRIX/...)
1324# * dl library or the Win32 LoadLibrary() call is available.
1325# *******************************************************************
1326
1327coin_can_do_runtime_linking=false
1328
1329# On Mac OS X < 10.4, dlopen() is missing and has to be emulated; from
1330# 10.4 on, we can use dlopen() directly. Note that the latter does not
1331# obsolete the dyld check, since we also use other dyld functionility.
1332SIM_AC_CHECK_DYLD([
1333  AC_DEFINE_UNQUOTED([HAVE_DYLD_RUNTIME_BINDING],1,
1334                     [define if the Mac OS X dyld can be used for runtime binding])
1335    coin_can_do_runtime_linking=true
1336])
1337
1338case ${MACOSX_DEPLOYMENT_TARGET} in
1339  10.[[0123]])
1340    # Do *not* pick up dlopen() support when building on 10.4 for earlier
1341    # Mac OS X versions (< 10.4 did not support dlopen(), so we have to use
1342    # our own implementation based on built-in dyld functions there).
1343    ;;
1344  *)
1345    SIM_AC_CHECK_DL([
1346      AC_DEFINE_UNQUOTED([HAVE_DL_LIB],1, [define if you have the dl library])
1347      COIN_EXTRA_CPPFLAGS="$COIN_EXTRA_CPPFLAGS $sim_ac_dl_cppflags"
1348      COIN_EXTRA_LDFLAGS="$COIN_EXTRA_LDFLAGS $sim_ac_dl_ldflags"
1349      COIN_EXTRA_LIBS="$sim_ac_dl_libs $COIN_EXTRA_LIBS"
1350      coin_can_do_runtime_linking=true
1351    ])
1352    ;;
1353esac
1354
1355if ! $coin_can_do_runtime_linking; then
1356  SIM_AC_CHECK_LOADLIBRARY([
1357    AC_DEFINE_UNQUOTED([HAVE_WINDLL_RUNTIME_BINDING],1,
1358                       [define if the Win32 LoadLibrary method is available])
1359    coin_can_do_runtime_linking=true
1360  ])
1361fi
1362
1363if ! $coin_can_do_runtime_linking; then
1364  SIM_AC_CHECK_DLD([
1365    AC_DEFINE_UNQUOTED([HAVE_DLD_LIB],1,
1366                       [define if the DLD shared library loader is available])
1367    COIN_EXTRA_LIBS="$sim_ac_dld_libs $COIN_EXTRA_LIBS"
1368    coin_can_do_runtime_linking=true
1369  ])
1370fi
1371
1372if $coin_can_do_runtime_linking; then
1373  AC_DEFINE_UNQUOTED([HAVE_DYNAMIC_LINKING], 1,
1374                     [should be defined if there is some way of doing dynamic linking])
1375fi
1376
1377# *******************************************************************
1378# * Check for Boost headers (up to now only header only libraries are
1379# * used in Coin.
1380# *******************************************************************
1381
1382AX_BOOST_BASE([1.45.0], [
1383  CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
1384  COIN_EXTRA_CPPFLAGS="$COIN_EXTRA_CPPFLAGS $BOOST_CPPFLAGS"
1385], [])
1386
1387# *******************************************************************
1388# * Set us up for using the simage library (if wanted, and if
1389# * available).
1390# *******************************************************************
1391
1392AC_ARG_ENABLE([dl-simage],
1393  AC_HELP_STRING([--enable-dl-simage],
1394                 [use runtime dynamic linking for libsimage if possible [[default=yes]]]),
1395  [case "${enableval}" in
1396    yes | true) enable_dl_simage=true ;;
1397    no | false) enable_dl_simage=false ;;
1398    *) SIM_AC_ENABLE_ERROR([--enable-dl-simage]) ;;
1399  esac],
1400  [enable_dl_simage=true])
1401
1402if $enable_dl_simage && $coin_can_do_runtime_linking; then
1403  AC_DEFINE_UNQUOTED([SIMAGE_RUNTIME_LINKING],1,
1404    [define for runtime linking with simage])
1405  SIM_AC_CONFIGURATION_SETTING([simage linkage], [run-time binding])
1406else
1407  SIM_AC_HAVE_SIMAGE_IFELSE([
1408    AC_DEFINE([HAVE_LIBSIMAGE],1,
1409      [define if you have the simage library])
1410    CPPFLAGS="$CPPFLAGS $sim_ac_simage_cppflags"
1411    LDFLAGS="$LDFLAGS $sim_ac_simage_ldflags"
1412    LIBS="$sim_ac_simage_libs $LIBS"
1413    COIN_EXTRA_CPPFLAGS="$COIN_EXTRA_CPPFLAGS $sim_ac_simage_cppflags"
1414    COIN_EXTRA_LDFLAGS="$COIN_EXTRA_LDFLAGS $sim_ac_simage_ldflags"
1415    COIN_EXTRA_LIBS="$sim_ac_simage_libs $COIN_EXTRA_LIBS"
1416    SIM_AC_CONFIGURATION_SETTING([simage linkage], [link-time binding])
1417  ], [
1418    if $sim_ac_simage_desired; then
1419      AC_MSG_WARN(simage development system not found);
1420    fi
1421    SIM_AC_CONFIGURATION_SETTING([simage linkage], [no simage support])
1422  ])
1423fi
1424
1425# Check if sound is enabled
1426
1427sim_ac_enable_sound=true
1428
1429AC_ARG_ENABLE(
1430  [sound],
1431  AC_HELP_STRING([--disable-sound], [disable sound support]), [
1432  case $enableval in
1433    no | false) sim_ac_enable_sound=false ;;
1434    *) ;;
1435  esac])
1436
1437#  Check for openal (required for sound)
1438
1439AC_ARG_ENABLE([dl-openal],
1440  AC_HELP_STRING([--enable-dl-openal],
1441                 [use runtime dynamic linking for OpenAL if possible [[default=yes]]]),
1442  [case "${enableval}" in
1443    yes | true) enable_dl_openal=true ;;
1444    no | false) enable_dl_openal=false ;;
1445    *) SIM_AC_ENABLE_ERROR([--enable-dl-openal]) ;;
1446  esac],
1447  [enable_dl_openal=true])
1448
1449if $sim_ac_enable_sound && $enable_dl_openal && $coin_can_do_runtime_linking; then
1450  AC_DEFINE_UNQUOTED([OPENAL_RUNTIME_LINKING],1,
1451    [define for runtime linking with OpenAL])
1452  SIM_AC_CONFIGURATION_SETTING([OpenAL support], [Yes, run-time binding])
1453else
1454SIM_AC_HAVE_OPENAL_IFELSE([
1455  CPPFLAGS="$CPPFLAGS $sim_ac_openal_cppflags"
1456  LDFLAGS="$LDFLAGS $sim_ac_openal_ldflags"
1457  LIBS="$LIBS $sim_ac_openal_libs"
1458  COIN_EXTRA_CPPFLAGS="$COIN_EXTRA_CPPFLAGS $sim_ac_openal_cppflags"
1459  COIN_EXTRA_LDFLAGS="$COIN_EXTRA_LDFLAGS $sim_ac_openal_ldflags"
1460  COIN_EXTRA_LIBS="$COIN_EXTRA_LIBS $sim_ac_openal_libs"
1461  AC_DEFINE(HAVE_OPENAL, 1, [openal extensions available])
1462  SIM_AC_CONFIGURATION_SETTING([OpenAL support], [Yes, link-time binding])
1463], [
1464  if $sim_ac_enable_sound; then
1465    AC_MSG_WARN([openal is needed for sound])
1466    sim_ac_enable_sound=false
1467  fi
1468  SIM_AC_CONFIGURATION_SETTING([OpenAL support], [No])
1469])
1470fi
1471
1472HAVE_SOUND=1
1473
1474if $sim_ac_enable_sound ; then
1475  AC_DEFINE([HAVE_SOUND],, [for setup.h])
1476  SIM_AC_CONFIGURATION_SETTING([Sound support], [Yes])
1477else
1478  HAVE_SOUND=0
1479  SIM_AC_CONFIGURATION_SETTING([Sound support], [No  (enable with --enable-sound)])
1480fi
1481AC_SUBST(HAVE_SOUND)
1482
1483AM_CONDITIONAL([BUILD_WITH_SOUND], [$sim_ac_enable_sound])
1484
1485# ********************************************************************
1486# * Set us up for using the Fontconfig font library (if wanted, and if
1487# * available).
1488# ********************************************************************
1489
1490AC_ARG_ENABLE([dl-fontconfig],
1491  AC_HELP_STRING([--disable-dl-fontconfig],
1492                 [disable runtime dynamic linking for fontconfig if possible [[default=--enable-dl-fontconfig]]]),
1493  [case "${enableval}" in
1494    yes | true) enable_dl_fontconfig=true ;;
1495    no | false) enable_dl_fontconfig=false ;;
1496    *) SIM_AC_ENABLE_ERROR([--enable-dl-fontconfig]) ;;
1497  esac],
1498  [enable_dl_fontconfig=true])
1499
1500sim_ac_have_fontconfig=false
1501if $enable_dl_fontconfig && $coin_can_do_runtime_linking; then
1502  AC_DEFINE_UNQUOTED([FONTCONFIG_RUNTIME_LINKING], 1,
1503    [define for runtime linking with fontconfig])
1504  SIM_AC_CONFIGURATION_SETTING([Fontconfig support], [Yes, run-time binding])
1505else
1506  SIM_AC_HAVE_FONTCONFIG_IFELSE([
1507    AC_DEFINE(HAVE_FONTCONFIG, 1,
1508      [define if you have the fontconfig library])
1509    CPPFLAGS="$CPPFLAGS $sim_ac_fontconfig_cppflags"
1510    LDFLAGS="$LDFLAGS $sim_ac_fontconfig_ldflags"
1511    LIBS="$sim_ac_fontconfig_libs $LIBS"
1512    COIN_EXTRA_CPPFLAGS="$COIN_EXTRA_CPPFLAGS $sim_ac_fontconfig_cppflags"
1513    COIN_EXTRA_LDFLAGS="$COIN_EXTRA_LDFLAGS $sim_ac_fontconfig_ldflags"
1514    COIN_EXTRA_LIBS="$sim_ac_fontconfig_libs $COIN_EXTRA_LIBS"
1515    SIM_AC_CONFIGURATION_SETTING([Fontconfig support], [Yes, link-time binding])
1516  ], [
1517    if $sim_ac_fontconfig_desired; then
1518      SIM_AC_CONFIGURATION_SETTING([Fontconfig support], [No])
1519    fi
1520  ])
1521fi
1522
1523AM_CONDITIONAL(HAVE_FONTCONFIG, $sim_ac_have_fontconfig)
1524
1525# ********************************************************************
1526# * Set us up for using the SpiderMonkey javascript library (if wanted,
1527# * and if available).
1528# ********************************************************************
1529
1530AC_ARG_ENABLE([dl-spidermonkey],
1531  AC_HELP_STRING([--disable-dl-spidermonkey],
1532                 [disable runtime dynamic linking for SpiderMonkey if possible [[default=--enable-dl-spidermonkey]]]),
1533  [case "${enableval}" in
1534    yes | true) enable_dl_spidermonkey=true ;;
1535    no | false) enable_dl_spidermonkey=false ;;
1536    *) SIM_AC_ENABLE_ERROR([--enable-dl-spidermonkey]) ;;
1537  esac],
1538  [enable_dl_spidermonkey=true])
1539
1540sim_ac_have_spidermonkey=false
1541if $enable_dl_spidermonkey && $coin_can_do_runtime_linking; then
1542  AC_DEFINE_UNQUOTED([SPIDERMONKEY_RUNTIME_LINKING], 1,
1543    [define for runtime linking with SpiderMonkey])
1544  if $sim_ac_enable_javascript ; then
1545    SIM_AC_CONFIGURATION_SETTING([SpiderMonkey support], [Yes, run-time binding])
1546  fi
1547else
1548  SIM_AC_HAVE_SPIDERMONKEY_IFELSE([
1549    AC_DEFINE(HAVE_SPIDERMONKEY_VIA_LINKTIME_LINKING, 1,
1550      [define if you have the SpiderMonkey library])
1551    CPPFLAGS="$CPPFLAGS $sim_ac_spidermonkey_cppflags"
1552    LDFLAGS="$LDFLAGS $sim_ac_spidermonkey_ldflags"
1553    LIBS="$sim_ac_spidermonkey_libs $LIBS"
1554    COIN_EXTRA_CPPFLAGS="$COIN_EXTRA_CPPFLAGS $sim_ac_spidermonkey_cppflags"
1555    COIN_EXTRA_LDFLAGS="$COIN_EXTRA_LDFLAGS $sim_ac_spidermonkey_ldflags"
1556    COIN_EXTRA_LIBS="$sim_ac_spidermonkey_libs $COIN_EXTRA_LIBS"
1557    if $sim_ac_enable_javascript ; then
1558      SIM_AC_CONFIGURATION_SETTING([SpiderMonkey support], [Yes, link-time binding])
1559      sim_ac_have_spidermonkey=true
1560    fi
1561  ], [
1562    if $sim_ac_spidermonkey_desired; then
1563      SIM_AC_CONFIGURATION_SETTING([SpiderMonkey support], [No])
1564    fi
1565  ])
1566fi
1567
1568AM_CONDITIONAL(HAVE_SPIDERMONKEY_VIA_LINKTIME_LINKING, $sim_ac_have_spidermonkey)
1569
1570
1571# **************************************************************************
1572# Set us up for using TrueType fonts. Through the FreeType library (if
1573# wanted, and if available), and / or the Win32 API.
1574
1575if $sim_ac_have_win32_api; then
1576  SIM_AC_CONFIGURATION_SETTING([Win32 TrueType fonts], [Yes])
1577fi
1578
1579AC_ARG_ENABLE([dl-freetype],
1580  AC_HELP_STRING([--disable-dl-freetype],
1581                 [disable runtime dynamic linking for freetype if possible [[default=--enable-dl-freetype]]]),
1582  [case "${enableval}" in
1583    yes | true) enable_dl_freetype=true ;;
1584    no | false) enable_dl_freetype=false ;;
1585    *) SIM_AC_ENABLE_ERROR([--enable-dl-freetype]) ;;
1586  esac],
1587  [enable_dl_freetype=true])
1588
1589sim_ac_have_freetype=false
1590
1591if $enable_dl_freetype && $coin_can_do_runtime_linking; then
1592  AC_DEFINE_UNQUOTED([FREETYPE_RUNTIME_LINKING], 1,
1593    [define for runtime linking with freetype])
1594  SIM_AC_CONFIGURATION_SETTING([FreeType library], [Yes, run-time binding])
1595else
1596  SIM_AC_HAVE_FREETYPE_IFELSE([
1597    AC_DEFINE(HAVE_FREETYPE, 1, [define if you have the freetype library])
1598    CPPFLAGS="$CPPFLAGS $sim_ac_freetype_cppflags"
1599    LDFLAGS="$LDFLAGS $sim_ac_freetype_ldflags"
1600    LIBS="$sim_ac_freetype_libs $LIBS"
1601    COIN_EXTRA_CPPFLAGS="$COIN_EXTRA_CPPFLAGS $sim_ac_freetype_cppflags"
1602    COIN_EXTRA_LDFLAGS="$COIN_EXTRA_LDFLAGS $sim_ac_freetype_ldflags"
1603    COIN_EXTRA_LIBS="$sim_ac_freetype_libs $COIN_EXTRA_LIBS"
1604    SIM_AC_CONFIGURATION_SETTING([FreeType library], [Yes, link-time binding])
1605  ], [
1606    if $sim_ac_freetype_desired; then
1607      SIM_AC_CONFIGURATION_SETTING([FreeType library], [No])
1608    fi
1609  ])
1610fi
1611
1612AM_CONDITIONAL(HAVE_FREETYPE, $sim_ac_have_freetype)
1613
1614# **************************************************************************
1615# Set us up for using TrueType fonts through the Core Text framework
1616# on the Mac.
1617
1618#
1619# disabled until CoreText implementation is in place. 20100410 tamer.
1620#
1621
1622#AC_ARG_ENABLE([coretext],
1623#  AC_HELP_STRING([--disable-coretext],
1624#                 [disable usage of the CoreText framework on OS X [[default=--enable-coretext]]]),
1625#  [case "${enableval}" in
1626#    yes | true) enable_coretext=true ;;
1627#    no | false) enable_coretext=false ;;
1628#    *) SIM_AC_ENABLE_ERROR([--enable-coretext]) ;;
1629#  esac],
1630#  [enable_coretext=true])
1631#
1632#if $enable_coretext; then
1633#  SIM_AC_HAVE_CORETEXT_IFELSE([
1634#    AC_DEFINE(HAVE_CORETEXT, 1, [define if you have the CoreText framework])
1635#    CPPFLAGS="$CPPFLAGS $sim_ac_coretext_cppflags"
1636#    LDFLAGS="$LDFLAGS $sim_ac_coretext_ldflags"
1637#    LIBS="$sim_ac_coretext_libs $LIBS"
1638#    COIN_EXTRA_CPPFLAGS="$COIN_EXTRA_CPPFLAGS $sim_ac_coretext_cppflags"
1639#    COIN_EXTRA_LDFLAGS="$COIN_EXTRA_LDFLAGS $sim_ac_coretext_ldflags"
1640#    COIN_EXTRA_LIBS="$sim_ac_coretext_libs $COIN_EXTRA_LIBS"
1641#    SIM_AC_CONFIGURATION_SETTING([Core Text framework], [Yes])
1642#  ], [
1643#    SIM_AC_CONFIGURATION_SETTING([Coretext framework], [No])
1644#  ])
1645#fi
1646#
1647#AM_CONDITIONAL(HAVE_CORETEXT, $sim_ac_have_coretext)
1648
1649# *******************************************************************
1650# * Math library
1651# *******************************************************************
1652
1653SIM_AC_CHECK_MATHLIB(
1654  [COIN_EXTRA_LIBS="$COIN_EXTRA_LIBS $sim_ac_libm"],
1655  [SIM_AC_ERROR([no-math-library])])
1656
1657# *******************************************************************
1658# * Check for ilogb() after mathlib test
1659# *******************************************************************
1660AC_MSG_CHECKING([for ilogb() function])
1661AC_TRY_LINK([
1662#include <math.h>
1663], [
1664  (void)ilogb(1.0);
1665], [
1666  AC_MSG_RESULT([yes])
1667  AC_DEFINE([HAVE_ILOGB],1, [Define to use ilogb()])
1668], [
1669  AC_MSG_RESULT([no])
1670])
1671
1672# *******************************************************************
1673# * Handle the detection and inclusion of compression libraries
1674# *******************************************************************
1675
1676AC_ARG_ENABLE([dl-zlib],
1677  AC_HELP_STRING([--disable-dl-zlib],
1678                 [disable runtime dynamic linking for libz if possible [[default=--enable-dl-zlib]]]),
1679  [case "${enableval}" in
1680    yes | true) enable_dl_zlib=true ;;
1681    no | false) enable_dl_zlib=false ;;
1682    *) SIM_AC_ENABLE_ERROR([--enable-dl-zlib]) ;;
1683  esac],
1684  [enable_dl_zlib=true])
1685
1686if $enable_dl_zlib && $coin_can_do_runtime_linking; then
1687  AC_DEFINE_UNQUOTED([ZLIB_RUNTIME_LINKING],1,
1688    [define for runtime linking with zlib])
1689  SIM_AC_CONFIGURATION_SETTING([zlib support], [Yes, run-time binding])
1690else
1691  SIM_AC_HAVE_LIBZLIB_IFELSE([
1692    COIN_EXTRA_CPPFLAGS="$COIN_EXTRA_CPPFLAGS $sim_ac_libzlib_cppflags"
1693    COIN_EXTRA_LDFLAGS="$COIN_EXTRA_LDFLAGS $sim_ac_libzlib_ldflags"
1694    COIN_EXTRA_LIBS="$sim_ac_libzlib_libs $COIN_EXTRA_LIBS"
1695    CPPFLAGS="$CPPFLAGS $sim_ac_libzlib_cppflags"
1696    LDFLAGS="$LDFLAGS $sim_ac_libzlib_ldflags"
1697    LIBS="$sim_ac_libzlib_libs $LIBS"
1698    SIM_AC_CONFIGURATION_SETTING([zlib support], [Yes, link-time binding])
1699    AC_DEFINE([HAVE_ZLIB], 1, [Define to use zlib])
1700  ],[
1701    SIM_AC_CONFIGURATION_SETTING([zlib support], [No])
1702  ])
1703fi
1704
1705# Bug in gzdopen() on Mac OS X -> use gzopen() instead...
1706case $host_os in
1707  darwin* ) ;;
1708  * ) AC_DEFINE([HAVE_GZDOPEN], 1, [Define to use gzdopen()])
1709esac
1710
1711# *******************************************************************
1712
1713AC_ARG_ENABLE([dl-libbzip2],
1714  AC_HELP_STRING([--disable-dl-libbzip2],
1715                 [disable runtime dynamic linking for libz if possible [[default=--enable-dl-libbzip2]]]),
1716  [case "${enableval}" in
1717    yes | true) enable_dl_libbzip2=true ;;
1718    no | false) enable_dl_libbzip2=false ;;
1719    *) SIM_AC_ENABLE_ERROR([--enable-dl-libbzip2]) ;;
1720  esac],
1721  [enable_dl_libbzip2=true])
1722
1723if $enable_dl_libbzip2 && $coin_can_do_runtime_linking; then
1724  AC_DEFINE_UNQUOTED([LIBBZIP2_RUNTIME_LINKING],1,
1725    [define for runtime linking with zlib])
1726  SIM_AC_CONFIGURATION_SETTING([bzip2 support], [Yes, run-time binding])
1727else
1728  SIM_AC_HAVE_LIBBZIP2_IFELSE([
1729    COIN_EXTRA_CPPFLAGS="$COIN_EXTRA_CPPFLAGS $sim_ac_libbzip2_cppflags"
1730    COIN_EXTRA_LDFLAGS="$COIN_EXTRA_LDFLAGS $sim_ac_libbzip2_ldflags"
1731    COIN_EXTRA_LIBS="$sim_ac_libbzip2_libs $COIN_EXTRA_LIBS"
1732    CPPFLAGS="$CPPFLAGS $sim_ac_libbzip2_cppflags"
1733    LDFLAGS="$LDFLAGS $sim_ac_libbzip2_ldflags"
1734    LIBS="$sim_ac_libbzip2_libs $LIBS"
1735    SIM_AC_CONFIGURATION_SETTING([bzip2 support], [Yes, link-time binding])
1736    AC_DEFINE([HAVE_BZIP2], 1, [Define to use bzip2])
1737  ],[
1738    SIM_AC_CONFIGURATION_SETTING([bzip2 support], [No])
1739  ])
1740fi
1741
1742# *******************************************************************
1743# * EXPAT specific stuff.
1744# *******************************************************************
1745if test x"$sim_ac_have_win32_api" = x"false" && test x"$sim_ac_enable_system_expat" = x"false"; then
1746  AC_DEFINE([XML_DEV_URANDOM], 1, [Define to extract entropy from /dev/urandom])
1747fi
1748
1749# *******************************************************************
1750# * Handle the detection and inclusion of X11 libraries.
1751# *******************************************************************
1752
1753  SIM_AC_CHECK_X11([
1754    COIN_EXTRA_CPPFLAGS="$COIN_EXTRA_CPPFLAGS $sim_ac_x11_cppflags"
1755    COIN_EXTRA_LDFLAGS="$COIN_EXTRA_LDFLAGS $sim_ac_x11_ldflags"
1756    COIN_EXTRA_LIBS="$sim_ac_x11_libs $COIN_EXTRA_LIBS"])
1757
1758  if test x"$sim_ac_x11_avail" = xyes; then
1759    #  If the X11 shared memory extension is available, include it as
1760    #  the Mesa library has probably been linked against it.
1761    SIM_AC_CHECK_X11SHMEM(
1762      COIN_EXTRA_LIBS="$sim_ac_x11shmem_libs $COIN_EXTRA_LIBS"
1763    )
1764  fi
1765
1766  ## We need this extra, final X11 check to set up the HAVE_X11_AVAILABLE
1767  ## define -- the X_DISPLAY_MISSING define provided by the built-in
1768  ## Autoconf X11 check is not strict enough.
1769  SIM_AC_CHECK_X11_READY([AC_DEFINE([HAVE_X11_AVAILABLE],1,
1770                         [define if it is possible to build against X11])])
1771
1772# *******************************************************************
1773# * Test for installation of Mesa or OpenGL development system.
1774# *******************************************************************
1775
1776SIM_AC_CHECK_OPENGL(
1777  [
1778  AC_DEFINE([HAVE_OPENGL],1, [define if you have OpenGL])
1779
1780  COIN_EXTRA_CPPFLAGS="$COIN_EXTRA_CPPFLAGS $sim_ac_ogl_cppflags"
1781  COIN_EXTRA_LDFLAGS="$COIN_EXTRA_LDFLAGS $sim_ac_ogl_ldflags"
1782  COIN_EXTRA_LIBS="$sim_ac_ogl_libs $COIN_EXTRA_LIBS"
1783
1784  SIM_AC_CHECK_HEADER_GLEXT([
1785    CPPFLAGS="$CPPFLAGS $sim_ac_glext_cppflags"
1786    COIN_EXTRA_CPPFLAGS="$COIN_EXTRA_CPPFLAGS $sim_ac_glext_cppflags"
1787  ])
1788
1789  # *******************************************************************
1790  # Check what OpenGL->windowsystem bindings are available.
1791  #
1792  # If WGL is available, we don't want AGL nor GLX, as that has the
1793  # potential to cause harm: e.g. while we at one place in the code
1794  # might use WGL to create a context, other places we might use GLX to
1795  # make that same context current -- *kaboom*.
1796  #
1797  # (It is at least possible that both AGL and GLX are available at the
1798  # same time, or WGL and GLX, since X11 is a portable window system.)
1799  #
1800  # On Mac OS X/Darwin, we want to link either with GLX or AGL,
1801  # depending on whether Coin is built against X11 or not. (X11 is
1802  # only needed if you want to use SoXt, and must be enabled explicitly
1803  # by passing the --enable-darwin-x11 configure flag.)
1804  #
1805  # Else, the tests for WGL/GLX below are nested, so we're guaranteed
1806  # that only one of HAVE_WGL and HAVE_GLX will be set:
1807
1808  case $host_os in
1809    darwin* )
1810      if test x"$sim_ac_x11_avail" = xyes; then
1811        SIM_AC_HAVE_GLX_IFELSE([
1812          AC_DEFINE([HAVE_GLX], 1, [define if you have GLX X11 OpenGL bindings])
1813          ], [SIM_AC_CONFIGURATION_WARNING([Could not find or compile or link against GLX (OpenGL on X11) but X linkage was specified. The SoOffscreenRenderer functionality will be disabled. ])])
1814      else
1815        AC_ARG_ENABLE([agl],
1816          AC_HELP_STRING([--enable-agl],
1817                         [enable AGL on Mac OS X [[default=--disable-agl]]]),
1818          [case "${enableval}" in
1819            yes | true) sim_ac_enable_agl=true ;;
1820            no | false) sim_ac_enable_agl=false ;;
1821            *) SIM_AC_ENABLE_ERROR([--enable-agl]) ;;
1822           esac],
1823          [sim_ac_enable_agl=false])
1824        if $sim_ac_enable_agl; then
1825          SIM_AC_HAVE_AGL_IFELSE([
1826            AC_DEFINE([HAVE_AGL], 1, [define if you have AGL OpenGL bindings])
1827            LDFLAGS="$LDFLAGS $sim_ac_agl_ldflags"
1828            # indirect linking is not supported in static libs
1829            if $COIN_STATIC; then
1830              COIN_EXTRA_LDFLAGS="$COIN_EXTRA_LDFLAGS $sim_ac_agl_ldflags"
1831            fi
1832            AC_CHECK_HEADERS(
1833              [OpenGL/CGLCurrent.h],
1834              [],
1835              [AC_MSG_ERROR([AGL is available but CGL is not? Dude. Something went very wrong here. Please get in touch with us at coin-support@sim.no.])], [ ]
1836            )
1837            SIM_AC_HAVE_AGL_PBUFFER([AC_DEFINE_UNQUOTED([HAVE_AGL_PBUFFER],1,[define if AGL pBuffers are available on the system])])
1838          ], [])
1839        fi
1840        SIM_AC_HAVE_CGL_IFELSE(
1841          [AC_DEFINE([HAVE_CGL], 1, [define if you have CGL OpenGL bindings])],
1842          [])
1843        if test x"$sim_cv_have_cgl" != x"true" && test x"$sim_cv_have_agl" != x"false" ; then
1844          SIM_AC_CONFIGURATION_WARNING([Could not find or compile or link against AGL or CGL. The SoOffscreenRenderer functionality will be disabled.])
1845        fi
1846      fi
1847    ;;
1848    * )
1849    SIM_AC_HAVE_WGL_IFELSE([
1850      AC_DEFINE([HAVE_WGL], 1, [define if you have WGL Win32 OpenGL bindings])
1851      LIBS="$LIBS $sim_ac_wgl_libs"
1852      COIN_EXTRA_LIBS="$COIN_EXTRA_LIBS $sim_ac_wgl_libs"
1853    ], [SIM_AC_HAVE_GLX_IFELSE([
1854          AC_DEFINE([HAVE_GLX], 1, [define if you have GLX X11 OpenGL bindings])
1855        ], [
1856          SIM_AC_CONFIGURATION_WARNING([Could not find or compile or link against any usable window-system OpenGL binding, neither GLX (OpenGL on X11), nor WGL (OpenGL on Win32) nor AGL (OpenGL on Mac OS). The SoOffscreenRenderer functionality will be disabled. Note: this might be a configure bug. Check the file config.log.])
1857        ])
1858      ])
1859    ;;
1860  esac
1861
1862  # *******************************************************************
1863
1864  if $enable_superglu; then
1865    SIM_AC_CONFIGURATION_SETTING([GLU linkage], [superglu])
1866  else
1867    # *******************************************************************
1868    # ** Check if GLU should be loaded and linked at runtime (to avoid
1869    # ** install dependency libCoin -> libGLU).
1870    # *******************************************************************
1871    AC_ARG_ENABLE([dl-glu],
1872      AC_HELP_STRING([--enable-dl-glu],
1873                     [use runtime dynamic linking for GLU if possible [[default=yes]]]),
1874      [case "${enableval}" in
1875        yes | true) enable_dl_glu=true ;;
1876        no | false) enable_dl_glu=false ;;
1877        *) SIM_AC_ENABLE_ERROR([--enable-dl-glu]) ;;
1878      esac],
1879      [enable_dl_glu=true])
1880
1881    if $coin_can_do_runtime_linking && $enable_dl_glu; then
1882      # See if GLU is part of GL library (this is the case on Mac OS X
1883      # and BeOS, for instance) before setting us up for runtime linking.
1884      SIM_AC_GLU_READY_IFELSE([
1885        AC_DEFINE([GLU_IS_PART_OF_GL],1,
1886                  [define if GLU is part of the GL library])
1887        AC_DEFINE_UNQUOTED([GLU_RUNTIME_LINKING],1,
1888          [define for runtime linking with GLU])
1889        SIM_AC_CONFIGURATION_SETTING([GLU linkage],
1890                  [run-time binding, part of GL library])
1891      ], [
1892        AC_DEFINE_UNQUOTED([GLU_RUNTIME_LINKING],1,
1893          [define for runtime linking with GLU])
1894        SIM_AC_CONFIGURATION_SETTING([GLU linkage], [run-time binding])
1895      ])
1896    else
1897      # *******************************************************************
1898      # ** Check if GLU headers and lib is available on build host.
1899      # *******************************************************************
1900      SIM_AC_CHECK_GLU([
1901        AC_DEFINE([HAVE_GLU],1, [define if you have GLU])
1902        COIN_EXTRA_CPPFLAGS="$COIN_EXTRA_CPPFLAGS $sim_ac_glu_cppflags"
1903        COIN_EXTRA_LDFLAGS="$COIN_EXTRA_LDFLAGS $sim_ac_glu_ldflags"
1904        COIN_EXTRA_LIBS="$sim_ac_glu_libs $COIN_EXTRA_LIBS"
1905        SIM_AC_CONFIGURATION_SETTING([GLU linkage], [link-time binding])
1906      ], [
1907        SIM_AC_CONFIGURATION_SETTING([GLU linkage], [no GLU support])
1908      ])
1909    fi
1910  fi
1911  ], # OpenGL-linkage ok, end of block
1912  [ # Couldn't link with OpenGL:
1913    SIM_AC_ERROR([no-opengl])
1914    # FIXME: should perhaps be able to handle systems where OpenGL is not
1915    # available,  as it would be handy for making e.g. import/export-only
1916    # versions of the library. 20000123 mortene.
1917  ]
1918)
1919
1920# **************************************************************************
1921# Make name of dynamic GL library available to Coin source code (used in
1922# src/glue/dl.c, at least).
1923
1924# Will set $sim_ac_shlibext. Note: there's a dependency on this later in
1925# the configure script aswell.
1926SIM_AC_DYNLIB_EXT
1927
1928# **************************************************************************
1929# Cygwin has not got diffutils installed by default. Check if cmp is
1930# available.
1931AC_CHECK_PROG(cmp_avail,[cmp],[Yes])
1932if test x$cmp_avail = "x" ; then
1933    AC_MSG_ERROR([cmp must be available to complete the configure process.])
1934fi
1935
1936
1937AC_DEFINE_UNQUOTED([DYNAMIC_LIBRARY_EXTENSION], ["$sim_ac_shlibext"],
1938                   [define this to the dynamic library extension suffix on this system])
1939
1940AC_SUBST([LIBEXT], [$sim_ac_shlibext])
1941
1942sim_ac_opengl_dll_name=$sim_ac_ogl_lib
1943if test "$sim_ac_ogl_lib" = "opengl32"; then :; else
1944  sim_ac_opengl_dll_name="lib${sim_ac_opengl_dll_name}"
1945fi
1946sim_ac_opengl_dll_name="${sim_ac_opengl_dll_name}${sim_ac_shlibext}"
1947
1948AC_DEFINE_UNQUOTED([OPENGL_SYSTEM_LIBRARY_NAME], ["$sim_ac_opengl_dll_name"],
1949                   [define this to the dynamic library name of OpenGL])
1950
1951# *******************************************************************
1952# * Provide this nasty hack to help building Coin on platforms
1953# * where one can bump into the "Arg list too long" problem
1954# * (IBM AIX, SGI IRIX 6.2 and IRIX 6.5 with standard settings are
1955# * known to fail).
1956# *
1957# * This nasty hack also have a lot of positivie bieffects, such as
1958# * increasing optimization, and memory usage of the compiler, while
1959# * reducing the compile time for a release build.
1960# *******************************************************************
1961
1962AC_ARG_ENABLE(compact,
1963  AC_HELP_STRING([--enable-compact], [enable hack for compact compilation. Has the bieffect of increased optimalization, and reduced compile-time, for increased memory usage for a release build. [[default=no]]]),
1964  [case "${enableval}" in
1965    yes | true)  enable_compact=yes ;;
1966    no | false)  enable_compact=no ;;
1967    *) SIM_AC_ENABLE_ERROR([--enable-compact]) ;;
1968  esac],
1969  enable_compact=no)
1970
1971AM_CONDITIONAL(HACKING_COMPACT_BUILD, test x"$enable_compact" = x"yes")
1972
1973# *******************************************************************
1974# * Enable/disable compilation with the "incremental linking through
1975# * the use of dynamic libraries"-hack.
1976# *******************************************************************
1977
1978AC_ARG_ENABLE(hacking,
1979  AC_HELP_STRING([--enable-hacking],
1980                 [enable hacks for quick turn-around cycles during development [[default=no]]]),
1981  [case "${enableval}" in
1982    yes | true)  enable_hacking=yes ;;
1983    no | false)  enable_hacking=no ;;
1984    *) SIM_AC_ENABLE_ERROR([--enable-hacking]) ;;
1985  esac],
1986  enable_hacking=no)
1987
1988AM_CONDITIONAL(HACKING_DYNAMIC_MODULES, test x"$enable_hacking" = x"yes")
1989
1990# enable_hacking requires runtime symbol lookup, which is not available
1991# on Mac OS X < 10.3 and requires the deployment target to be >= 10.3.
1992sim_ac_macosx_use_dynamic_lookup=false
1993
1994if test x"$enable_hacking" = x"yes"; then
1995
1996  if test x"$sim_ac_macosx" = x"true"; then
1997    if test x"$sim_ac_macosx_10_3ff" = x"true"; then
1998      sim_ac_macosx_use_dynamic_lookup=true
1999      case ${MACOSX_DEPLOYMENT_TARGET} in
2000      10.[[345]])
2001        ;;
2002      *)
2003        SIM_AC_CONFIGURATION_WARNING([Using MACOSX_DEPLOYMENT_TARGET=10.3 (required by --enable-hacking)])
2004      ;;
2005      esac
2006      AC_SUBST([MACOSX_DEPLOYMENT_TARGET], [10.3])
2007    else
2008      AC_MSG_ERROR([--enable-hacking requires Mac OS X version >= 10.3])
2009    fi
2010  fi
2011
2012  for dir in \
2013    base actions bundles caches details draggers elements \
2014    elements/GL:glelements engines errors events fields fonts glue io \
2015    manips misc lists nodekits navigation nodes rendering shapenodes projectors \
2016    sensors shaders upgraders hardcopy shadows geo foreignfiles collision \
2017    xml xml/expat:expat profiler 3ds:format3ds scxml soscxml; \
2018  do
2019    case $dir in
2020    *:* )
2021      lib=`echo $dir | cut -d: -f2`
2022      dir=`echo $dir | cut -d: -f1`
2023      ;;
2024    * )
2025      lib=$dir
2026      ;;
2027    esac
2028    HACKING_LIBDIRS="$HACKING_LIBDIRS -L${coin_build_dir}/src/$dir/.libs"
2029    EXTRA_LIBS="$EXTRA_LIBS -l$lib${SUFFIX}LINKHACK"
2030  done
2031  if $sim_ac_enable_vrml97; then
2032    HACKING_LIBDIRS="$HACKING_LIBDIRS -L${coin_build_dir}/src/vrml97/.libs"
2033    EXTRA_LIBS="$EXTRA_LIBS -lvrml97${SUFFIX}LINKHACK"
2034  fi
2035  if $enable_superglu; then
2036    HACKING_LIBDIRS="$HACKING_LIBDIRS -L${coin_build_dir}/src/extensions/superglu/.libs"
2037    EXTRA_LIBS="$EXTRA_LIBS -l${SUPERGLUPREFIX}GLU"
2038  fi
2039  if $sim_ac_enable_threads; then
2040    HACKING_LIBDIRS="$HACKING_LIBDIRS -L${coin_build_dir}/src/threads/.libs"
2041    EXTRA_LIBS="$EXTRA_LIBS -lthreads${SUFFIX}LINKHACK"
2042  fi
2043  COIN_HACKING_LIBDIRS="$HACKING_LIBDIRS"
2044  COIN_EXTRA_LIBS="$EXTRA_LIBS $COIN_EXTRA_LIBS"
2045fi
2046
2047AC_SUBST(COIN_HACKING_LIBDIRS)
2048
2049# linker flag -undefined dynamic_lookup, needed for --enable-hacking
2050AM_CONDITIONAL([MACOSX_USE_DYNAMIC_LOOKUP],
2051               [test x$sim_ac_macosx_use_dynamic_lookup = xtrue])
2052
2053
2054# *******************************************************************
2055# * For exposing various build, src and installation paths to
2056# * misc configuration files under the $top_src_dir/build/ directory.
2057# *******************************************************************
2058
2059AC_SUBST([coin_build_dir])
2060AC_SUBST([coin_w32_build_dir])
2061AC_SUBST([coin_src_dir])
2062AC_SUBST([coin_w32_src_dir])
2063
2064# **************************************************************************
2065# Remove redundant options from certain option lists.
2066
2067SIM_AC_UNIQIFY_OPTION_LIST(COIN_EXTRA_CPPFLAGS, -I$includedir -I$includedir/Inventor/annex $COIN_EXTRA_CPPFLAGS)
2068SIM_AC_UNIQIFY_OPTION_LIST(COIN_EXTRA_LDFLAGS, -L$libdir $COIN_EXTRA_LDFLAGS)
2069SIM_AC_UNIQIFY_OPTION_LIST(COIN_EXTRA_LIBS, $COIN_EXTRA_LIBS)
2070SIM_AC_UNIQIFY_OPTION_LIST(CPPFLAGS, $CPPFLAGS)
2071SIM_AC_UNIQIFY_OPTION_LIST(LDFLAGS, $LDFLAGS)
2072SIM_AC_UNIQIFY_OPTION_LIST(LIBS, $LIBS)
2073
2074# **************************************************************************
2075# Remove gcc system directories includes from the CPPFLAGS.
2076
2077CPP_AC_SEARCH_ORDER_FILTER(CPPFLAGS, $CPPFLAGS)
2078CPP_AC_SEARCH_ORDER_FILTER(COIN_EXTRA_CPPFLAGS, $COIN_EXTRA_CPPFLAGS)
2079
2080AC_SUBST([LIBFLAGS], [])
2081AC_SUBST([COIN_TESTSUITE_EXTRA_CPPFLAGS], [])
2082AC_SUBST([COIN_TESTSUITE_EXTRA_LDFLAGS], [])
2083
2084# **************************************************************************
2085# setup for <Inventor/system/gl.h>
2086
2087# include windows.h?
2088if test x"$ac_cv_header_windows_h" = x"yes"; then
2089  sim_include_windows_h="#include <windows.h>"
2090else
2091  sim_include_windows_h="/* #include <windows.h> - not needed on system */"
2092fi
2093
2094# how to include gl.h
2095if test x"$ac_cv_header_GL_gl_h" = x"yes"; then
2096  sim_include_gl_h="#include <GL/gl.h>"
2097else
2098  if test x"$ac_cv_header_OpenGL_gl_h" = x"yes"; then
2099    sim_include_gl_h="#include <OpenGL/gl.h>"
2100  else
2101    sim_include_gl_h="#error \"don't know how to include gl.h header\""
2102  fi
2103fi
2104
2105if $enable_superglu; then
2106  sim_include_glu_h="/* #include <GL/glu.h> - not used, Coin linked with embedded SuperGLU */"
2107else
2108  if test x"$ac_cv_header_GL_glu_h" = x"yes"; then
2109    sim_include_glu_h="#include <GL/glu.h>"
2110  else
2111    if test x"$ac_cv_header_OpenGL_glu_h" = x"yes"; then
2112      sim_include_glu_h="#include <OpenGL/glu.h>"
2113    else
2114      sim_include_glu_h="/* #include <GL/glu.h> - not found on system */"
2115    fi
2116  fi
2117fi
2118
2119if test x"$ac_cv_header_GL_glext_h" = x"yes"; then
2120  sim_include_glext_h="#include <GL/glext.h>"
2121else
2122  if test x"$ac_cv_header_OpenGL_glext_h" = x"yes"; then
2123    sim_include_glext_h="#include <OpenGL/glext.h>"
2124  else
2125    sim_include_glext_h="/* #include <GL/glext.h> - not found on system */"
2126  fi
2127fi
2128
2129AC_SUBST([SIM_INCLUDE_WINDOWS_H], [$sim_include_windows_h])
2130AC_SUBST([SIM_INCLUDE_GL_H], [$sim_include_gl_h])
2131AC_SUBST([SIM_INCLUDE_GLU_H], [$sim_include_glu_h])
2132AC_SUBST([SIM_INCLUDE_GLEXT_H], [$sim_include_glext_h])
2133
2134# **************************************************************************
2135
2136# append compiler flags detected earlier, now that all configure tests
2137# are done...
2138
2139CFLAGS="$CFLAGS $sim_ac_compiler_CFLAGS"
2140CXXFLAGS="$CXXFLAGS $sim_ac_compiler_CXXFLAGS"
2141
2142# **************************************************************************
2143# Remaining setup based on platform.
2144
2145# check if compiler/linker handles __declspec()
2146sim_ac_win32_declspec_available=false
2147AC_MSG_CHECKING([for __declspec() support])
2148AC_TRY_LINK(
2149 [],
2150 [__declspec(dllimport) int foo;],
2151 [sim_ac_win32_declspec_available=true
2152  AC_MSG_RESULT([available])],
2153 [AC_MSG_RESULT([not available])])
2154
2155if $sim_ac_win32_declspec_available; then
2156  if $COIN_STATIC; then
2157    COIN_EXTRA_CPPFLAGS="$COIN_EXTRA_CPPFLAGS -DCOIN_NOT_DLL"
2158    COIN_EXTRA_LIBS="$COIN_EXTRA_LIBS $LIBS"
2159  else
2160    CPPFLAGS="-DCOIN_MAKE_DLL $CPPFLAGS"
2161    COIN_EXTRA_CPPFLAGS="$COIN_EXTRA_CPPFLAGS -DCOIN_DLL"
2162  fi
2163fi
2164
2165AM_CONDITIONAL(BUILD_WITH_MSVC, $BUILD_WITH_MSVC)
2166
2167COIN_COMPILER="$CXX"
2168
2169if $BUILD_WITH_MSVC; then
2170  COIN_TESTSUITE_EXTRA_CPPFLAGS="/Fdtestsuite.pdb /EHsc"
2171  COIN_TESTSUITE_EXTRA_LDFLAGS="/SUBSYSTEM:console /DEBUG"
2172  rm -f vc60.pdb
2173  LIBFLAGS="$LIBFLAGS $sim_ac_msvcrt_LIBLDFLAGS"
2174  LIBS="$LIBS $sim_ac_msvcrt_LIBLIBS"
2175
2176  debugfile="`pwd`/src/coin${COIN_MAJOR_VERSION}${SUFFIX}.pdb"
2177  debugfile=`cygpath -w "$debugfile" | sed 's,\\\\,\\\\\\\\,g'`
2178
2179  if $COIN_STATIC; then
2180    LIBS=
2181    LIBFLAGS="-LIB $LIBFLAGS"
2182    LIBFLAGS="$LIBFLAGS /OUT:coin$COIN_MAJOR_VERSION$SUFFIX.lib"
2183    case $enable_symbols in
2184    no | false)
2185      SIM_AC_CONFIGURATION_SETTING([Coin build type], [static .lib, no symbols])
2186      ;;
2187    *)
2188      SIM_AC_CONFIGURATION_SETTING([Coin build type], [static .lib, with symbols])
2189      CFLAGS="-g $CFLAGS"
2190      CXXFLAGS="-g $CXXFLAGS"
2191      ;;
2192    esac
2193  else
2194    LIBFLAGS="-DLL /INCREMENTAL:NO $LIBFLAGS"
2195    case $enable_debug in
2196    no | false)
2197      release_string=" (release)"
2198      debug_flag=" /DEBUG"
2199      ;;
2200    *)
2201      release_string=""
2202      debug_flag=" /DEBUG"
2203      ;;
2204    esac
2205    case $enable_symbols in
2206    no | false)
2207      SIM_AC_CONFIGURATION_SETTING([Coin build type],
2208                                   [dynamic .dll${release_string}])
2209      LIBFLAGS="$LIBFLAGS ${debug_flag}"
2210      ;;
2211    *)
2212      SIM_AC_CONFIGURATION_SETTING([Coin build type],
2213                                   [dynamic .dll${release_string} + .pdb])
2214      CFLAGS="-g $CFLAGS"
2215      CXXFLAGS="-g $CXXFLAGS"
2216      LIBFLAGS="$LIBFLAGS ${debug_flag} /PDB:coin$COIN_MAJOR_VERSION$SUFFIX.pdb"
2217      ;;
2218    esac
2219    LIBFLAGS="$LIBFLAGS /OUT:coin$COIN_MAJOR_VERSION$SUFFIX.dll"
2220  fi
2221  SIM_AC_CONFIGURATION_SETTING([C library version], [$sim_ac_msvcrt])
2222
2223  # We use a version suffix on the .dll-file, so several incompatible
2224  # (major) versions can be installed on a system.
2225  #
2226  # BTW, when linking DLLs, the 3rd-party .lib files will be
2227  # linked into the .dll file. I believe it is still advisable to
2228  # list all libs used upon `coin-config --libs`, as we can then
2229  # also use them from "parent" code (remember that their interfaces
2230  # is not exposed from the DLL) without any fuss.
2231  sim_ac_coin_noextname="coin${COIN_MAJOR_VERSION}${SUFFIX}"
2232  if test -n "$COIN_EXTRA_LIBS"; then
2233    COIN_EXTRA_LIBS="-l${sim_ac_coin_noextname} $COIN_EXTRA_LIBS"
2234  else
2235    COIN_EXTRA_LIBS="-l${sim_ac_coin_noextname}"
2236  fi
2237
2238  sim_ac_coin_dll_name="${sim_ac_coin_noextname}${sim_ac_shlibext}"
2239
2240else
2241  COIN_EXTRA_LIBS="-lCoin${SUFFIX} $COIN_EXTRA_LIBS"
2242  sim_ac_coin_dll_name="libCoin${SUFFIX}${sim_ac_shlibext}"
2243fi
2244
2245if $BUILD_WITH_MSVC; then
2246  # we'll use the installed wrapper when we use the coin-config script later
2247  # so we can remove the source code hierarchy
2248  COIN_COMPILER="wrapmsvc"
2249fi
2250
2251AC_DEFINE_UNQUOTED([COIN_SYSTEM_LIBRARY_NAME], ["$sim_ac_coin_dll_name"],
2252                   [define this to the dynamic library name of Coin])
2253
2254sim_ac_path_problem=true # until proven otherwise
2255eval "sim_ac_pb_prefix=${prefix}"
2256if test x"$sim_ac_pb_prefix" = x"NONE"; then sim_ac_pb_prefix=/usr/local; fi
2257eval "sim_ac_pb_exec_prefix=${exec_prefix}"
2258if test x"$sim_ac_pb_exec_prefix" = x"NONE"; then sim_ac_pb_exec_prefix="$prefix"; fi
2259eval "sim_ac_pb_bindir=${bindir}"
2260if test -d "${sim_ac_pb_bindir}"; then
2261  # search by inode id seems safer than strings because of noncanonical paths
2262  ( eval set dummy `ls -id "${sim_ac_pb_bindir}" 2>/dev/null`;
2263    findinode=$2;
2264    IFS=:; for dir in $PATH; do
2265      # inode=`ls -id "$dir" 2>/dev/null | sed 's/^\([ ]*\)\([0-9]*\).*/\2/g'`;
2266      eval set dummy `ls -id "$dir" 2>/dev/null`;
2267      inode=$2;
2268      test x"$inode" = x"$findinode" && exit 0;
2269    done; exit 1 ) && sim_ac_path_problem=false
2270fi
2271if $sim_ac_path_problem; then
2272  ( IFS=:; for dir in $PATH; do
2273      test x"$dir" = x"${sim_ac_pb_bindir}" && exit 0;
2274    done; exit 1 ) && sim_ac_path_problem=false
2275fi
2276
2277
2278# ***********************************************************
2279# Mac OS X tweaks
2280#
2281
2282# We use CoreFoundation calls multiple places in Coin
2283[case $host_os in
2284darwin* ) LDFLAGS="$LDFLAGS -Wl,-framework,CoreFoundation" ;;
2285* ) ;;
2286esac]
2287
2288# Disallow static libraries in framework (doesn't make sense)
2289if $sim_ac_framework; then
2290  if test x$enable_static = xyes; then
2291    AC_MSG_ERROR([Creation of static libraries requested, but this is incompatible with the Mac OS X framework setup. Use --without-framework to do UNIX-style build.])
2292  fi
2293fi
2294
2295if $sim_ac_framework; then
2296  SIM_AC_CONFIGURATION_SETTING([Coin build type], [Mac OS X framework])
2297elif $sim_ac_path_problem; then
2298  SIM_AC_CONFIGURATION_WARNING([Your \$PATH variable does not appear to include \"$prefix/bin\"])
2299fi
2300
2301if $sim_ac_framework; then
2302
2303  # set up the Coin-related flags
2304  COIN_EXTRA_CPPFLAGS=
2305  if test x"$sim_ac_framework_prefix" != x"MAC_FRAMEWORK_PREFIX_DEFAULT"; then
2306    COIN_EXTRA_CPPFLAGS="-F$sim_ac_framework_prefix"
2307  fi
2308
2309  COIN_EXTRA_CFLAGS=
2310  COIN_EXTRA_CXXFLAGS=
2311  COIN_EXTRA_FP_LDFLAGS=
2312  if test x"$enable_hacking" = x"yes"; then
2313    COIN_EXTRA_LDFLAGS="-L$frameworkdir/Libraries"
2314  else
2315    # we don't want -lCoin when doing framework build
2316    COIN_EXTRA_LIBS=
2317    COIN_EXTRA_LDFLAGS=
2318    if test x"$sim_ac_framework_prefix" != x"MAC_FRAMEWORK_PREFIX_DEFAULT"; then
2319      COIN_EXTRA_FP_LDFLAGS="-Wl,-F$sim_ac_framework_prefix"
2320    fi
2321  fi
2322  COIN_EXTRA_LDFLAGS="$COIN_EXTRA_FP_LDFLAGS -Wl,-framework,$MAC_FRAMEWORK_NAME $COIN_EXTRA_LDFLAGS"
2323  # adjust for OpenGL usage
2324  COIN_EXTRA_CPPFLAGS="$COIN_EXTRA_CPPFLAGS $sim_ac_ogl_cppflags"
2325  COIN_EXTRA_LDFLAGS="$COIN_EXTRA_LDFLAGS $sim_ac_ogl_ldflags"
2326  COIN_EXTRA_LIBS="$sim_ac_ogl_libs $COIN_EXTRA_LIBS"
2327  # adjust for simage usage
2328  COIN_EXTRA_LDFLAGS="$COIN_EXTRA_LDFLAGS $sim_ac_simage_ldflags"
2329  COIN_EXTRA_LIBS="$sim_ac_simage_libs $COIN_EXTRA_LIBS"
2330  # adjust for OpenAL usage
2331  COIN_EXTRA_LIBS="$COIN_EXTRA_LIBS $sim_ac_openal_libs"
2332fi
2333
2334case "$sim_ac_framework:$sim_ac_make_dsp" in
2335true:* | *:true )
2336  ;;
2337* )
2338  SIM_AC_CONFIGURATION_SETTING([Installation prefix], [$prefix])
2339  ;;
2340esac
2341
2342AC_SUBST([COIN_COMPILER])
2343AC_SUBST([ac_compiler_gnu])
2344
2345SIM_AC_MSVC_DSP_SETUP([COIN], [Coin], [coin], [-I$coin_build_dir -I$coin_build_dir/include -I$coin_src_dir/include -I$coin_build_dir/src -I$coin_src_dir/src -I$coin_src_dir/include/Inventor/annex])
2346
2347# **************************************************************************
2348
2349AM_CONFIG_HEADER([src/discard.h src/config.h src/setup.h])
2350AC_CONFIG_FILES([src/Coin.rc])
2351
2352# SIM_AC_COIN_CONFIG_H_CHECK
2353
2354# **************************************************************************
2355
2356AC_CONFIG_FILES([
2357        Makefile
2358        bin/Makefile
2359        include/Makefile
2360        include/Inventor/Makefile
2361        include/Inventor/C/Makefile
2362        include/Inventor/C/XML/Makefile
2363        include/Inventor/C/base/Makefile
2364        include/Inventor/C/errors/Makefile
2365        include/Inventor/C/glue/Makefile
2366        include/Inventor/C/threads/Makefile
2367        include/Inventor/VRMLnodes/Makefile
2368        include/Inventor/actions/Makefile
2369        include/Inventor/bundles/Makefile
2370        include/Inventor/caches/Makefile
2371        include/Inventor/collision/Makefile
2372        include/Inventor/details/Makefile
2373        include/Inventor/draggers/Makefile
2374        include/Inventor/elements/Makefile
2375        include/Inventor/engines/Makefile
2376        include/Inventor/errors/Makefile
2377        include/Inventor/events/Makefile
2378        include/Inventor/fields/Makefile
2379        include/Inventor/lists/Makefile
2380        include/Inventor/lock/Makefile
2381        include/Inventor/manips/Makefile
2382        include/Inventor/misc/Makefile
2383        include/Inventor/navigation/Makefile
2384        include/Inventor/nodekits/Makefile
2385        include/Inventor/nodes/Makefile
2386        include/Inventor/projectors/Makefile
2387        include/Inventor/sensors/Makefile
2388        include/Inventor/system/Makefile
2389        include/Inventor/threads/Makefile
2390        include/Inventor/tools/Makefile
2391        include/Inventor/scxml/Makefile
2392        include/Inventor/annex/Makefile
2393        include/Inventor/annex/HardCopy/Makefile
2394        include/Inventor/annex/ForeignFiles/Makefile
2395        include/Inventor/annex/FXViz/Makefile
2396        include/Inventor/annex/FXViz/elements/Makefile
2397        include/Inventor/annex/FXViz/nodes/Makefile
2398        include/Inventor/annex/Profiler/Makefile
2399        include/Inventor/annex/Profiler/elements/Makefile
2400        include/Inventor/annex/Profiler/engines/Makefile
2401        include/Inventor/annex/Profiler/nodes/Makefile
2402        include/Inventor/annex/Profiler/nodekits/Makefile
2403        include/Inventor/annex/Profiler/utils/Makefile
2404        data/Makefile
2405        data/draggerDefaults/Makefile
2406        data/shaders/Makefile
2407        data/shaders/lights/Makefile
2408        data/shaders/vsm/Makefile
2409        data/scxml/Makefile
2410        data/scxml/navigation/Makefile
2411        man/Makefile
2412        man/man1/Makefile
2413        man/man3/Makefile
2414        html/Makefile
2415        src/Makefile
2416        src/base/Makefile
2417        src/actions/Makefile
2418        src/bundles/Makefile
2419        src/caches/Makefile
2420        src/collision/Makefile
2421        src/details/Makefile
2422        src/draggers/Makefile
2423        src/elements/Makefile
2424        src/elements/GL/Makefile
2425        src/engines/Makefile
2426        src/errors/Makefile
2427        src/events/Makefile
2428        src/fields/Makefile
2429        src/fonts/Makefile
2430        src/glue/Makefile
2431        src/io/Makefile
2432        src/manips/Makefile
2433        src/misc/Makefile
2434        src/rendering/Makefile
2435        src/lists/Makefile
2436        src/navigation/Makefile
2437        src/nodekits/Makefile
2438        src/nodes/Makefile
2439        src/projectors/Makefile
2440        src/3ds/Makefile
2441        src/sensors/Makefile
2442        src/upgraders/Makefile
2443        src/shapenodes/Makefile
2444        src/threads/Makefile
2445        src/extensions/Makefile
2446        src/vrml97/Makefile
2447        src/hardcopy/Makefile
2448        src/shaders/Makefile
2449        src/shadows/Makefile
2450        src/geo/Makefile
2451        src/foreignfiles/Makefile
2452        src/xml/Makefile
2453        src/xml/expat/Makefile
2454        src/profiler/Makefile
2455        src/scxml/Makefile
2456        src/soscxml/Makefile
2457        src/doc/Makefile
2458        testsuite/Makefile
2459        cfg/gendsp.pl
2460])
2461
2462AC_OUTPUT
2463
2464if test -f cfg/gendsp.pl; then
2465  chmod +x cfg/gendsp.pl
2466fi
2467
2468# in case someone has the old generated SbBasic.h lying about...
2469if test -f include/Inventor/SbBasic.h; then
2470  if cmp -s $srcdir/include/Inventor/SbBasic.h include/Inventor/SbBasic.h; then
2471    :
2472  else
2473    rm include/Inventor/SbBasic.h
2474  fi
2475fi
2476
2477# *******************************************************************
2478# * Platform-specific stuff.
2479# *******************************************************************
2480
2481if $sim_ac_build_library; then
2482  ac_coin_untested_platform=true
2483  ac_coin_not_sim_platform=true
2484else
2485  ac_coin_untested_platform=false
2486  ac_coin_not_sim_platform=false
2487fi
2488
2489case "$host_os" in
2490  irix6.2)
2491    case $CXX in
2492    CC | */CC ) ac_coin_untested_platform=false ;;
2493    esac
2494    ;;
2495  irix6.5)
2496    case $CXX in
2497    CC | */CC )
2498      ac_coin_untested_platform=false
2499      ac_coin_not_sim_platform=false
2500      ;;
2501    esac
2502    ;;
2503  aix*)
2504    case $CXX in
2505    xlC | */xlC ) ac_coin_untested_platform=false ;;
2506    esac
2507    ;;
2508  solaris*)
2509    case $CXX in
2510    g++ ) ac_coin_untested_platform=false ;;
2511    CC )
2512      ac_coin_untested_platform=false
2513      ac_coin_not_sim_platform=false
2514      ;;
2515    esac
2516    ;;
2517  hpux10.20)
2518    case $CXX in
2519    aCC | */aCC ) ac_coin_untested_platform=false ;;
2520    esac
2521    ;;
2522  linux-gnu)
2523    case "$host_cpu" in
2524    i?86)
2525      ac_coin_untested_platform=false
2526      ac_coin_not_sim_platform=false
2527    ;;
2528    x86_64)
2529      ac_coin_untested_platform=false
2530      ac_coin_not_sim_platform=false
2531    ;;
2532    ia64)
2533      case "$CXX" in
2534      g++)
2535        ac_coin_untested_platform=false
2536        ;;
2537      esac
2538    ;;
2539    esac
2540    ;;
2541  cygwin*)
2542    case "$CXX" in
2543    *wrapmsvc* )
2544      ac_coin_untested_platform=false
2545      ac_coin_not_sim_platform=false
2546    ;;
2547    esac
2548    ;;
2549  darwin*)
2550    case "$CXX" in
2551      c++ | g++)
2552        ac_coin_untested_platform=false
2553        ac_coin_not_sim_platform=false
2554      ;;
2555    esac
2556    ;;
2557  beos)
2558    case "$host_cpu" in
2559      i?86)
2560        if test "$CXX" = c++; then ac_coin_untested_platform=false; fi
2561        ;;
2562    esac
2563    ;;
2564esac
2565
2566case "$CXX" in
2567*gendsp* )
2568  ac_coin_untested_platform=false
2569  ac_coin_not_sim_platform=false
2570  ;;
2571esac
2572
2573if $ac_coin_untested_platform; then
2574  echo
2575  echo "************************* WARNING ****************************"
2576  echo "*"
2577  echo "* We have not tested Coin on the $host_os $host_cpu"
2578  echo "* platform with the $CXX C++ compiler. Please report"
2579  echo "* back to us at <coin-support@coin3d.org> how it works out."
2580  echo "*"
2581  echo "**************************************************************"
2582  echo
2583else
2584  if $ac_coin_not_sim_platform; then
2585    echo
2586    echo "NOTE: This platform ($host_os $host_cpu with the $CXX C++ compiler)"
2587    echo "      is not among our internal development systems. Please let us"
2588    echo "      know at <coin-support@coin3d.org> if you run into any problems."
2589    echo
2590  fi
2591fi
2592
2593if $sim_ac_build_library; then
2594  case "$host_os" in
2595  irix*)
2596    echo ""
2597    echo " Detected SGI IRIX. There are some hints regarding this platform"
2598    echo " in the file "
2599    echo ""
2600    echo "           ${srcdir}/README.UNIX"
2601    echo ""
2602    echo " Please take a look if this is your first time building on IRIX."
2603    echo ""
2604    ;;
2605  aix*)
2606    echo ""
2607    echo " Detected IBM AIX. There are some hints regarding this platform"
2608    echo " in the file "
2609    echo ""
2610    echo "           ${srcdir}/README.UNIX"
2611    echo ""
2612    echo " Please take a look if this is your first time building on AIX."
2613    echo ""
2614    ;;
2615  esac
2616fi
2617
2618# FIXME: these would be nice to show, but they puck up the configuration
2619# summary formatting. 20030509 mortene.
2620#
2621#SIM_AC_CONFIGURATION_SETTING([CPPFLAGS], [$CPPFLAGS])
2622#SIM_AC_CONFIGURATION_SETTING([CFLAGS], [$CFLAGS])
2623#SIM_AC_CONFIGURATION_SETTING([CXXFLAGS], [$CXXFLAGS])
2624#SIM_AC_CONFIGURATION_SETTING([LDFLAGS], [$LDFLAGS])
2625#SIM_AC_CONFIGURATION_SETTING([LIBS], [$LIBS])
2626
2627SIM_AC_CONFIGURATION_SUMMARY
2628
2629echo ""
2630
2631