]> git.mxchange.org Git - flightgear.git/blob - configure.ac
Merge branch 'maint'
[flightgear.git] / configure.ac
1 dnl Process this file with autogen.sh to produce a working configure
2 dnl script.
3
4 AC_INIT
5 AC_CONFIG_SRCDIR([src/Aircraft/aircraft.cxx])
6
7 dnl Require at least automake 2.52
8 AC_PREREQ(2.52)
9
10 dnl Initialize the automake stuff
11 dnl set the $host variable based on local machine/os
12 AC_CANONICAL_TARGET
13 AM_INIT_AUTOMAKE(FlightGear, 2.0.0)
14
15 dnl Checks for programs.
16 AC_PROG_MAKE_SET
17 AC_PROG_CC
18 AC_PROG_CPP
19 AC_PROG_CXX
20 AC_PROG_CXXCPP
21 AC_PROG_RANLIB
22 AC_PROG_INSTALL
23 AC_PROG_LN_S
24 AX_BOOST_BASE([1.37.0])
25
26 if test "x$BOOST_CPPFLAGS" != "x-I/usr/include" ; then
27    CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
28 fi
29
30 # specify the simgear location
31 AC_ARG_WITH(simgear, [  --with-simgear=PREFIX   Specify the prefix path to SimGear])
32
33 if test "x$with_simgear" != "x" ; then
34     echo "SimGear prefix path is $with_simgear"
35     EXTRA_DIRS="${EXTRA_DIRS} $with_simgear"
36     CXXFLAGS="$CXXFLAGS -I$with_simgear"
37 fi
38
39 # specify the plib location
40 AC_ARG_WITH(plib, [  --with-plib=PREFIX      Specify the prefix path to plib])
41
42 if test "x$with_plib" != "x" ; then
43     echo "plib prefix is $with_plib"
44     EXTRA_DIRS="${EXTRA_DIRS} $with_plib"
45 fi
46
47 # specify the osg location
48 AC_ARG_WITH(osg, [  --with-osg=PREFIX       Specify the prefix path to osg])
49
50 if test "x$with_osg" != "x" ; then
51     echo "osg prefix is $with_osg"
52     EXTRA_DIRS="${EXTRA_DIRS} $with_osg"
53 fi
54
55 # specify framework related locations for Mac OS X
56 case "${host}" in
57 *-apple-darwin*)
58
59     dnl Thank you Christian Bauer from SheepSaver
60     dnl Modified by Tatsuhiro Nishioka for accepting a given framework path
61     dnl AC_CHECK_FRAMEWORK($1=NAME, $2=INCLUDES, $3=FRAMEWORK_PATH) ; $3 is optional
62     AC_DEFUN([AC_CHECK_FRAMEWORK], [
63     AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1])dnl
64     AC_CACHE_CHECK([whether compiler supports framework $1],
65         ac_Framework, [
66         saved_LIBS="$LIBS"
67         FRAMEWORKS="$FRAMEWORKS -framework $1"
68         if test "$3" = ""; then
69             FRAMEWORKS="$FRAMEWORKS $ADD2LD"
70         elif test "`echo $FRAMEWORKS | grep -- -F$3`" = ""; then
71             FRAMEWORKS="$FRAMEWORKS -F$3"
72             CXXFLAGS="$CXXFLAGS -F$3"
73             CCFLAGS="$CCFLAGS -F$3"
74             dnl This is needed for AC_TRY_LINK when a framework path is specified
75             export DYLD_FRAMEWORK_PATH="${DYLD_FRAMEWORK_PATH}:$3"
76         fi
77         AC_TRY_LINK(
78         [$2], [],
79         [AS_VAR_SET(ac_Framework, yes)], [AS_VAR_SET(ac_Framework, no); LIBS="$saved_LIBS"]
80         )
81     ])
82     AS_IF([test AS_VAR_GET(ac_Framework) = yes],
83         [AC_DEFINE(AS_TR_CPP(HAVE_FRAMEWORK_$1), 1, [Define if framework $1 is available.])]
84     )
85     AS_VAR_POPDEF([ac_Framework])dnl
86     ])
87
88     # Mac OS X specific configure options
89     AC_ARG_WITH(cocoa_framework, [  --with-cocoa-framework       Use the Cocoa rather than Carbon]])
90     if test "x$with_cocoa_framework" != "x" ; then
91         macAPI=Cocoa
92         AC_MSG_NOTICE([Using Cocoa framework])
93     else
94         macAPI=Carbon
95         AC_MSG_NOTICE([Using Carbon framework])
96     fi
97
98     AC_ARG_WITH(osg_framework, [  --with-osg-framework=PREFIX       Specify the prefix path to osg frameworks [default=standard framework paths]])
99     if test "x$with_osg_framework" != "x" ; then
100         echo "osg prefix is $with_osg_framework"
101         export DYLD_FRAMEWORK_PATH="$DYLD_FRAMEWORK_PATH:$with_osg_framework"
102     fi
103
104     AC_ARG_WITH(plib_framework, [  --with-plib-framework=PREFIX       Specify the prefix path to PLIB framework [default=standard framework paths]])
105     if test "x$with_plib_framework" != "x" ; then
106         echo "plib prefix is $with_plib_framework"
107         export DYLD_FRAMEWORK_PATH="$DYLD_FRAMEWORK_PATH:$with_plib_framework"
108     fi
109
110     AC_ARG_WITH(openal_framework, [ --with-openal-framework=PREFIX    Speicfy the prefix path to OpenAL.framework ])
111     if test "x$with_openal_framework" != "x"; then
112         echo "OpenAL framework prefix is $with_openal_framework"
113     fi
114
115     ;;
116 esac
117
118 dnl Determine an extra directories to add to include/lib search paths
119 case "${host}" in
120 *-apple-darwin* | *-*-mingw32*)
121     echo no EXTRA_DIRS for $host
122     ;;
123
124 *-*-cygwin*)
125     if test -d /usr/local ; then
126         EXTRA_DIRS="${EXTRA_DIRS} /usr/local"
127     fi
128     ;;
129
130 *)
131     if test -d /usr/X11R6 ; then
132         EXTRA_DIR1="/usr/X11R6"
133     fi
134     if test -d /opt/X11R6 ; then
135         EXTRA_DIR2="/opt/X11R6"
136     fi
137     EXTRA_DIRS="${EXTRA_DIRS} $EXTRA_DIR1 $EXTRA_DIR2 /usr/local"
138     ;;
139
140 esac
141 wi_EXTRA_DIRS(no, ${EXTRA_DIRS})
142
143
144 case "${host}" in
145 *-*-irix*)
146     if test "$CXX" = "CC"; then
147         AR="CC -ar"
148         ARFLAGS="-o"
149         CXXFLAGS="$CXXFLAGS -c99 -I$with_simgear/include/simgear/compatibility"
150         CFLAGS="$CFLAGS -c99"
151     else
152         AR="ar"
153         ARFLAGS="cru"
154     fi
155     ;;
156 *)
157     AR="ar"
158     ARFLAGS="cru"
159     ;;
160 esac
161 AC_SUBST(AR)
162 AC_SUBST(ARFLAGS)
163
164 dnl set logging; default value of with_logging=yes
165 AC_ARG_WITH(logging, [  --with-logging          Include logging output (default)])
166 if test "x$with_logging" = "xno" ; then
167     AC_DEFINE([FG_NDEBUG], 1, [Define for no logging output])
168 fi
169
170 AC_ARG_ENABLE(sp_fdms, [  --enable-sp-fdms               Include special purpose Flight Models], [enable_sp_fdms="$enableval"] )
171 if test "x$enable_sp_fdms" != "xno"; then
172     AC_DEFINE([ENABLE_SP_FDM], 1, [Define to include special purpose FDMs])
173 else
174     AC_DEFINE([ENABLE_SP_FDM], 0, [Define to include special purpose FDMs])
175 fi
176 AM_CONDITIONAL(ENABLE_SP_FDM, test "x$enable_sp_fdms" != "xno")
177
178 # Specify whether we want to compile ATCDCL.
179 # default to with_atcdcl=yes
180 AC_ARG_ENABLE(atcdcl, [  --enable-atcdcl                Compile and link the depricated atc/ai module], [enable_atcdcl="$enableval"] )
181 if test "x$enable_atcdcl" != "xno"; then
182     AC_DEFINE([ENABLE_ATCDCL], 1, [Define to include old ATC/AI module])
183 else
184     AC_DEFINE([ENABLE_ATCDCL], 0, [Define to include old ATC/AI module])
185 fi
186 AM_CONDITIONAL(ENABLE_ATCDCL, test "x$enable_atcdcl" != "xno")
187
188
189
190 dnl EXPERIMENTAL generic event driven input device
191 # defaults to no
192 AC_ARG_WITH(eventinput, [  --with-eventinput       Include event driven input (EXPERIMENTAL) [default=no]], [], [with_eventinput=no])
193 if test "x$with_eventinput" = "xyes"; then
194     AC_DEFINE([WITH_EVENTINPUT], 1, [Define to enable generic event driven input device])
195     case "${host}" in
196     dnl OS specific sources for event driven input
197     dnl Linux and Mac OS X are supported at this moment
198     *-apple-darwin*)
199         eventinput_EXTRA_OBJS="FGMacOSXEventInput.o"
200         eventinput_INCUDES=""
201         eventinput_LIBS=""
202         ;;
203     *linux*)
204         dnl
205         dnl FIXME: include paths for dbus are hard-coded at this moment.
206         dnl FIXME: these must be found in configure
207         dnl
208         eventinput_EXTRA_OBJS="FGLinuxEventInput.o"
209         eventinput_INCLUDES="-I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/lib/dbus-1.0/include"
210         eventinput_LIBS="-ldbus-1 -lhal"
211         ;;
212     *)
213         echo "Event driven input is not supported on ${host}."
214         ;;
215     esac
216     AC_SUBST(eventinput_EXTRA_OBJS)
217     AC_SUBST(eventinput_INCLUDES)
218     AC_SUBST(eventinput_LIBS)
219 fi
220 AM_CONDITIONAL(WITH_EVENTINPUT, test "x$with_eventinput" = "xyes")
221
222 dnl Thread related checks
223 # defaults to yes
224 AC_ARG_WITH(threads, [  --with-threads          Include tile loading threads [default=yes]], [], [with_threads=yes])
225 if test "x$with_threads" = "xyes"; then
226     AC_DEFINE([ENABLE_THREADS], 1, [Define to enable threaded tile paging])
227     CXXFLAGS="$CXXFLAGS -D_REENTRANT"
228     CFLAGS="$CFLAGS -D_REENTRANT"
229 fi
230 AC_CHECK_HEADER(pthread.h)
231
232
233 dnl Used by JSBSim to conditionally compile in fgfs interface code
234 AC_DEFINE([FGFS], 1, [Define so that JSBSim compiles in 'library' mode])
235
236 # Check for MS Windows environment
237 AC_CHECK_HEADER(windows.h)
238
239 dnl Using AM_CONDITIONAL is a step out of the protected little 
240 dnl automake fold so it is potentially dangerous.  But, we are
241 dnl beginning to run into cases where the standard checks are not
242 dnl enough.  AM_CONDITIONALS are then referenced to conditionally
243 dnl build a Makefile.in from a Makefile.am which lets us define custom
244 dnl includes, compile alternative source files, etc.
245
246 dnl Check for external variables daylight and timezone.
247 AC_EXT_DAYLIGHT
248 if test "$have_daylight" = yes; then
249     AC_DEFINE([HAVE_DAYLIGHT], 1, [Define if system has daylight variable])
250 fi
251
252 AC_EXT_TIMEZONE
253 if test "$have_timezone" = yes; then
254     AC_DEFINE([HAVE_TIMEZONE], 1, [Define if system has timezone variable])
255 fi
256
257
258 dnl add joystick support libraries
259 dnl search for FreeBSD library
260 AC_SEARCH_LIBS(hid_init, usbhid)
261 joystick_LIBS="$LIBS"
262 LIBS=""
263
264
265 dnl ENABLE_AUDIO_SUPPORT could be depricated at any time in favor of
266 dnl just assuming we have audio support on all platform.  We can
267 dnl depend on plib to hide the details.
268 AC_DEFINE([ENABLE_AUDIO_SUPPORT], 1, [Define for audio support])
269
270 dnl X11 might be installed on Mac OS X or cygwin/mingwin, we don't want
271 dnl to use it if it is.
272 case "${host}" in
273 *-apple-darwin* | *-*-cygwin* | *-*-mingw32*)
274     echo no fancy X11 check
275     ;;
276
277 *)
278     AC_PATH_XTRA
279     ;;
280
281 esac
282
283 dnl Checks for libraries.
284
285 dnl Thread related checks
286 AC_SEARCH_LIBS(pthread_create, [pthread c_r])
287 if test "x$ac_cv_header_pthread_h" = "xyes"; then
288   if test "x$ac_cv_search_pthread_exit" = "x-lc_r"; then
289     CXXFLAGS="-pthread $CXXFLAGS"
290     CFLAGS="-pthread $CFLAGS"
291     LIBS="-lsgthreads $LIBS"
292   fi
293 fi
294
295 thread_LIBS="$LIBS"
296 LIBS=""
297
298 dnl search for network related libraries
299 AC_SEARCH_LIBS(inet_addr, xnet)
300 AC_SEARCH_LIBS(socket, socket)
301 AC_SEARCH_LIBS(main, nsl)
302
303 network_LIBS="$LIBS"
304 LIBS=""
305
306 dnl check for some default libraries
307 AC_SEARCH_LIBS(sqrt, [am ffm fm fastm m])
308 AC_SEARCH_LIBS(ceil, m)
309 AC_SEARCH_LIBS(dlclose, dl)
310 AC_SEARCH_LIBS(clock_gettime, rt)
311
312 base_LIBS="$LIBS"
313
314 dnl Check for SDL or glut if enabled.
315 AC_ARG_ENABLE(osgviewer, [  --enable-osgviewer             Configure to use osgViewer(default)], [enable_osgviewer="$enableval"])
316 AC_ARG_ENABLE(sdl,  [  --enable-sdl                   Configure to use SDL], [enable_sdl="$enableval"])
317 AC_ARG_ENABLE(glut, [  --enable-glut                  Configure to use GLUT], [enable_glut="$enableval"])
318 AM_CONDITIONAL(USE_SDL, test "x$enable_sdl" = "xyes")
319 AM_CONDITIONAL(USE_GLUT, test "x$enable_glut" = "xyes")
320 if test "x$enable_sdl" != "xyes" -a "x$enable_glut" != "xyes" -a "x$enable_osgviewer" != "xno"; then
321    enable_osgviewer="yes"
322 fi
323 if test \( "x$enable_osgviewer" = "xyes" \
324    -a \( "x$enable_sdl" = "xyes" -o "x$enable_glut" = "xyes" \) \) \
325    -o \( "x$enable_sdl" = "xyes" -a "x$enable_glut" = "xyes" \); then
326    echo " Only one of --enable-osgviewer, --enable-sdl, or --enable -glut may"
327    echo " be supplied."
328    exit
329 fi
330 AC_DEFINE([PU_USE_NONE], 1, [Define to use application's pu callbacks])
331
332 AC_ARG_ENABLE(osgdebug, [  --enable-osgdebug              Use OSG debug libraries], [enable_osgdebug="$enableval"])
333
334 dnl check for OpenGL related libraries
335 case "${host}" in
336 *-*-cygwin* | *-*-mingw32*)
337     dnl CygWin under Windoze.
338
339     echo Win32 specific hacks...
340     AC_DEFINE([WIN32], 1, [Define for Win32 platforms])
341     AC_DEFINE([NOMINMAX], 1, [Define for Win32 platforms])
342
343     if test "x$enable_sdl" = "xyes"; then
344         AC_SEARCH_LIBS(SDL_Init, SDL)
345     else
346         LIBS="$LIBS -lglut32"
347     fi
348
349     LIBS="$LIBS -lglu32 -lopengl32 -luser32 -lgdi32"
350     joystick_LIBS="$joystick_LIBS -lwinmm"
351
352     dnl add -lwsock32 for mingwin
353     case "${host}" in
354     *-*-mingw32*)
355         echo "********** BUILDING FOR MINGW32 *************"
356         network_LIBS="$network_LIBS -lws2_32"
357         ;;
358     esac
359
360     echo "Will link apps with $LIBS"
361     ;;
362
363
364 *-apple-darwin*)
365     dnl Mac OS X
366
367     LIBS="$LIBS -framework GLUT -framework OpenGL -framework AGL -framework $macAPI -lobjc"
368     joystick_LIBS="$joystick_LIBS -framework IOKit -framework CoreFoundation"
369     ;;
370
371 *)
372     dnl X-Windows based machines
373
374     dnl Skip X11 library tests if requested.
375     if test "x$no_x" != "xyes"; then
376         AC_SEARCH_LIBS(XCreateWindow, X11)
377         AC_SEARCH_LIBS(XShmCreateImage, Xext)
378         AC_SEARCH_LIBS(XGetExtensionVersion, Xi)
379         AC_SEARCH_LIBS(IceOpenConnection, ICE)
380         AC_SEARCH_LIBS(SmcOpenConnection, SM)
381         AC_SEARCH_LIBS(XtMalloc, Xt)
382         AC_SEARCH_LIBS(XmuLookupStandardColormap, Xmu)
383     fi
384
385     AC_SEARCH_LIBS(glNewList, [ GL GLcore MesaGL ])
386     if test "x$ac_cv_search_glNewList" = "x-lGLcore"; then
387         dnl if GLcore found, then also check for GL
388         AC_SEARCH_LIBS(glXCreateContext, GL)
389     fi
390
391     dnl if using mesa, check for xmesa.h
392     if test "x$ac_cv_search_glNewList" = "x-lMesaGL"; then
393         AC_CHECK_HEADER(GL/fxmesa.h)
394         if test "x$ac_cv_header_GL_fxmesa_h" = "xyes"; then
395             AC_DEFINE([XMESA], 1, [Define for fxmesa])
396             AC_DEFINE([FX], 1, [Define for fxmesa])
397         fi
398     fi
399
400     AC_SEARCH_LIBS(gluLookAt, [ GLU MesaGLU ])
401     AC_SEARCH_LIBS(glutGetModifiers, [ glut freeglut ])
402     if test "x$enable_sdl" = "xyes"; then
403         AC_SEARCH_LIBS(SDL_Init, SDL)
404     fi
405     ;;
406
407 esac
408
409 opengl_LIBS="$LIBS"
410 LIBS="$base_LIBS $joystick_LIBS"
411
412 dnl check for OpenAL libraries
413 OPENAL_OK="no"
414 ALUT_OK="no"
415 case "${host}" in
416 *-*-cygwin* | *-*-mingw32*)
417     dnl CygWin under Windoze.
418     INCLUDES="$INCLUDES -I/usr/local/include/"
419     LIBS="$LIBS -L/usr/local/lib"
420     AC_SEARCH_LIBS(alGenBuffers, [ openal32 openal 'openal -ldsound -lwinmm' ] )
421     AC_SEARCH_LIBS(alutInit, [ openal32 ALut alut ] )
422     LIBS="$LIBS -lwinmm -ldsound -ldxguid -lole32"
423     openal_LIBS="$LIBS"
424     OPENAL_OK="$ac_cv_search_alGenBuffers"
425     ALUT_OK="$ac_cv_search_alutInit"
426     ;;
427
428 *-apple-darwin*)
429     dnl Mac OS X
430
431     # Mac OS X has OpenAL.framework with ALUT by default
432     # so we can use it without checking it.
433     # Note: SimGear needs to check the existance of alut.h since it includes the header.
434     LIBS="$LIBS -framework IOKit -framework OpenAL"
435     openal_LIBS="$LIBS"
436     OPENAL_OK="yes"
437     ALUT_OK="yes"
438     
439     dnl Check for OpenAL.framework when --with-openal-framework is specified
440     if test "x$with_openal_framework" != "x"; then
441       AC_CHECK_FRAMEWORK(OpenAL, [#include <OpenAL/alut.h>], $with_openal_framework)
442     fi
443
444     ;;
445
446 *)
447     dnl default unix style machines
448
449     save_LIBS=$LIBS
450     LIBS="$LIBS $thread_LIBS"
451     AC_SEARCH_LIBS(alGenBuffers, openal)
452     AC_SEARCH_LIBS(alutInit, [ alut openal ] )
453     OPENAL_OK="$ac_cv_search_alGenBuffers"
454     ALUT_OK="$ac_cv_search_alutInit"
455     openal_LIBS="$LIBS"
456     LIBS=$save_LIBS
457     ;;
458
459 esac
460
461 if test "$OPENAL_OK" == "no"; then
462     echo
463     echo "You *must* have the openal library installed on your system to build"
464     echo "SimGear!"
465     echo
466     echo "Please see README.OpenAL for more details."
467     echo
468     echo "configure aborted."
469     exit
470 fi
471
472 if test "$ALUT_OK" == "no"; then
473     echo
474     echo "You *must* have the alut library installed on your system to build"
475     echo "SimGear!"
476     echo
477     echo "Please see README.OpenAL for more details."
478     echo
479     echo "configure aborted."
480     exit
481 fi
482
483
484 LIBS="$base_LIBS"
485
486 AC_SUBST(base_LIBS)
487 AC_SUBST(openal_LIBS)
488 AC_SUBST(opengl_LIBS)
489 AC_SUBST(thread_LIBS)
490 AC_SUBST(network_LIBS)
491 AC_SUBST(joystick_LIBS)
492
493 # The following are C++ items that need to be tested for with the c++
494 # compiler
495
496 AC_LANG_PUSH(C++)
497
498 dnl Check for the presence of SimGear
499 if test "x$with_simgear" != "x"; then
500 AC_CHECK_HEADER($with_simgear/include/simgear/version.h, [ac_cv_header_simgear_version_h=yes], [ac_cv_header_simgear_version_h=no])
501 else
502 AC_CHECK_HEADER(simgear/version.h)
503 fi
504 if test "x$ac_cv_header_simgear_version_h" != "xyes"; then
505     echo
506     echo "You *must* have the SimGear support library installed on your system"
507     echo "to build the FGFS simulator!"
508     echo
509     echo "Please see README.SimGear for more details."
510     echo
511     echo "configure aborted."
512     exit
513 fi
514
515 AC_MSG_CHECKING([for SimGear 1.9.0 or newer])
516 AC_TRY_RUN([
517 #include <stdio.h>
518
519 #include <simgear/version.h>
520
521 #define STRINGIFY(X) XSTRINGIFY(X)
522 #define XSTRINGIFY(X) #X
523
524 #define MIN_MAJOR 1
525 #define MIN_MINOR 9
526 #define MIN_MICRO 0
527
528 int main() {
529     int major, minor, micro;
530
531     /* printf("%d.%d.%d or greater, ", MIN_MAJOR, MIN_MINOR, MIN_MICRO); */
532     printf("[found %s] ... ", STRINGIFY(SIMGEAR_VERSION));
533
534     sscanf( STRINGIFY(SIMGEAR_VERSION), "%d.%d.%d", &major, &minor, &micro );
535
536     if ( (major < MIN_MAJOR) ||
537          (major == MIN_MAJOR && minor < MIN_MINOR) ||
538          (major == MIN_MAJOR && minor == MIN_MINOR && micro < MIN_MICRO) ) {
539          return -1;
540     }
541
542     return 0;
543 }
544
545 ],
546   AC_MSG_RESULT(yes),
547   [AC_MSG_RESULT(wrong version);
548    AC_MSG_ERROR([Install latest SimGear first...])],
549   AC_MSG_RESULT(yes)
550 )
551
552 LIBS="$saved_LIBS"
553
554 dnl Check if SimGear was built with Norman's JPEG factory support
555 if test "x$with_simgear" != "x"; then
556 AC_CHECK_HEADER($with_simgear/include/simgear/screen/jpgfactory.hxx,[ac_cv_header_simgear_screen_jpgfactory_hxx=yes],[ac_cv_header_simgear_screen_jpgfactory_hxx=no])
557 else
558 AC_CHECK_HEADER(simgear/screen/jpgfactory.hxx)
559 fi
560 if test "x$ac_cv_header_simgear_screen_jpgfactory_hxx" = "xyes"; then
561     AC_CHECK_LIB(jpeg, jpeg_start_compress)
562     if test "x$ac_cv_lib_jpeg_jpeg_start_compress" != "xyes" ; then
563         echo
564         echo "The JPEG factory code was built and installed with SimGear."
565         echo "However it appears the libjpeg is no longer installed."
566         echo "You need to install libjpeg or remove jpgfactory support from"
567         echo "SimGear"
568         echo
569         echo "libjpeg is available at :"
570         echo "  ftp://ftp.uu.net in the directory graphics/jpeg"
571         exit 1
572     fi
573     AC_DEFINE([FG_JPEG_SERVER], 1,
574               [Define to build with jpeg screen shot server])
575 fi
576 AM_CONDITIONAL(ENABLE_JPEG_SERVER, test "x$ac_cv_header_simgear_screen_jpgfactory_hxx" = "xyes")
577
578 # Check for "plib" without which we cannot go on
579 case "${host}" in
580 *-apple-darwin*)
581     if test "x$with_plib_framework" != "x"; then
582         AC_CHECK_FRAMEWORK(PLIB, [#include <plib/ul.h>], $with_plib_framework, no)
583         plib_FRAMEWORK="$FRAMEWORKS"
584         AC_SUBST(plib_FRAMEWORK)
585         FRAMEWORKS=""
586     fi
587     ;;
588 esac
589 AM_CONDITIONAL(HAVE_FRAMEWORK_PLIB, test "x$ac_cv_framework_PLIB" != "x")
590
591 AC_CHECK_HEADER(plib/ul.h)
592 if test "x$ac_cv_header_plib_ul_h" != "xyes"; then
593     echo
594     echo "You *must* have the plib library installed on your system to build"
595     echo "the FGFS simulator!"
596     echo
597     echo "Please see README.plib for more details."
598     echo
599     echo "configure aborted."
600     exit
601 fi
602
603 echo "$DYLD_FRAMEWORK_PATH"
604 AC_MSG_CHECKING([for plib 1.8.5 or newer])
605 AC_TRY_RUN([
606 #include <plib/ul.h>
607
608 #define MIN_PLIB_VERSION 185
609
610 int main() {
611     if ( PLIB_VERSION < MIN_PLIB_VERSION ) {
612          return -1;
613     }
614
615     return 0;
616 }
617
618 ],
619   AC_MSG_RESULT(yes),
620   [AC_MSG_RESULT(wrong version);
621    AC_MSG_ERROR([Install plib 1.8.5 or later first...])],
622   AC_MSG_RESULT(yes)
623 )
624
625 dnl If we get here then plib is available, so force use of plib
626 dnl joystick lib
627 AC_DEFINE([ENABLE_PLIB_JOYSTICK], 1, [Define to enable plib joystick support])
628
629 # Find the OSG libraries.  Note special handling for OS X frameworks
630 case "${host}" in
631 *-apple-darwin*)
632     if test "x$with_osg_framework" = "x"; then
633         if test "x$enable_osgdebug" = "xyes"; then
634             # debug version of osg libs
635             AC_CHECK_LIB(OpenThreadsd,OpenThreadsGetVersion)
636             openthreads_LIBS="$LIBS"
637             LIBS=""
638             AC_CHECK_LIB(osgd,osgGetVersion)
639             AC_CHECK_LIB(osgUtild,osgUtilGetVersion)
640             AC_CHECK_LIB(osgDBd,osgDBGetVersion)
641             AC_CHECK_LIB(osgTextd,osgTextGetVersion)
642             AC_CHECK_LIB(osgGAd,osgGAGetVersion)
643             AC_CHECK_LIB(osgViewerd,osgViewerGetVersion)
644             AC_CHECK_LIB(osgSimd,osgSimGetVersion)
645             AC_CHECK_LIB(osgParticled,osgParticleGetVersion)
646             OSG_LIBS="$LIBS -losgFXd $openthreads_LIBS"
647             LIBS=""
648         else
649             # release version of osg libs
650             AC_CHECK_LIB(OpenThreads,OpenThreadsGetVersion)
651             openthreads_LIBS="$LIBS"
652             LIBS=""
653             AC_CHECK_LIB(osg,osgGetVersion)
654             AC_CHECK_LIB(osgUtil,osgUtilGetVersion)
655             AC_CHECK_LIB(osgDB,osgDBGetVersion)
656             AC_CHECK_LIB(osgText,osgTextGetVersion)
657             AC_CHECK_LIB(osgGA,osgGAGetVersion)
658             AC_CHECK_LIB(osgViewer,osgViewerGetVersion)
659             AC_CHECK_LIB(osgSim,osgSimGetVersion)
660             AC_CHECK_LIB(osgParticle,osgParticleGetVersion)
661             OSG_LIBS="$LIBS -losgFX $openthreads_LIBS"
662             LIBS=""
663             # echo $LIBS
664         fi
665         AC_SUBST(openthreads_LIBS)
666         AC_SUBST(OSG_LIBS)
667     else
668         # Checking osg frameworks.
669         AC_CHECK_FRAMEWORK(osgViewer, [#include <osgViewer/Version>], $with_osg_framework)
670         AC_CHECK_FRAMEWORK(osgGA, [#include <osgGA/Version>], $with_osg_framework)
671         AC_CHECK_FRAMEWORK(osgText, [#include <osgText/Version>], $with_osg_framework)
672         AC_CHECK_FRAMEWORK(osgFX, [#include <osgFX/AnisotropicLighting>], $with_osg_framework)
673         AC_CHECK_FRAMEWORK(osgUtil, [#include <osgUtil/Version>], $with_osg_framework)
674         AC_CHECK_FRAMEWORK(osgDB, [#include <osgDB/Version>], $with_osg_framework)
675         AC_CHECK_FRAMEWORK(osgSim, [#include <osgSim/Version>], $with_osg_framework)
676         AC_CHECK_FRAMEWORK(osgParticle, [#include <osgParticle/Version>], $with_osg_framework)
677         AC_CHECK_FRAMEWORK(osg, [#include <osg/Version>], $with_osg_framework)
678         osg_FRAMEWORKS="$FRAMEWORKS"
679         FRAMEWORKS=""
680         AC_CHECK_FRAMEWORK(OpenThreads, [#include <OpenThreads/Version>], $with_osg_framework)
681         openthreads_FRAMEWORK="$FRAMEWORKS"
682         AC_SUBST(osg_FRAMEWORKS)
683         AC_SUBST(openthreads_FRAMEWORK)
684     fi
685     ;;
686 *)
687     if test "x$enable_osgdebug" = "xyes"; then
688         AC_CHECK_LIB(OpenThreadsd,OpenThreadsGetVersion)
689         AC_CHECK_LIB(osgd,osgGetVersion)
690         AC_CHECK_LIB(osgUtild,osgUtilGetVersion)
691         AC_CHECK_LIB(osgDBd,osgDBGetVersion)
692         AC_CHECK_LIB(osgTextd,osgTextGetVersion)
693         AC_CHECK_LIB(osgGAd,osgGAGetVersion)
694         AC_CHECK_LIB(osgViewerd,osgViewerGetVersion)
695         AC_CHECK_LIB(osgSimd,osgSimGetVersion)
696         AC_CHECK_LIB(osgParticled,osgParticleGetVersion)
697         LIBS="$LIBS -losgFXd $opengl_LIBS"
698     else
699         AC_CHECK_LIB(OpenThreads,OpenThreadsGetVersion)
700         AC_CHECK_LIB(osg,osgGetVersion)
701         AC_CHECK_LIB(osgUtil,osgUtilGetVersion)
702         AC_CHECK_LIB(osgDB,osgDBGetVersion)
703         AC_CHECK_LIB(osgText,osgTextGetVersion)
704         AC_CHECK_LIB(osgGA,osgGAGetVersion)
705         AC_CHECK_LIB(osgViewer,osgViewerGetVersion)
706         AC_CHECK_LIB(osgSim,osgSimGetVersion)
707         AC_CHECK_LIB(osgParticle,osgParticleGetVersion)
708         LIBS="$LIBS -losgFX $opengl_LIBS"
709     fi
710     ;;
711 esac
712 AM_CONDITIONAL(HAVE_FRAMEWORK_OSG, test "x$ac_cv_framework_osg" != "x")
713
714 AC_CHECK_HEADER(osg/Version)
715 if test "x$ac_cv_header_osg_Version" != "xyes"; then
716     echo
717     echo "You *must* have the OpenSceneGraph support library installed on your system"
718     echo "to build the FGFS simulator!"
719     echo
720     echo "Please see README.OSG for more details."
721     echo
722     echo "configure aborted."
723     exit
724 fi
725
726
727 AC_MSG_CHECKING([checking for osg::CullSettings::CLEAR_MASK])
728 AC_COMPILE_IFELSE(
729   [AC_LANG_PROGRAM([[#include <osg/CullSettings>]],
730     [[osg::CullSettings::VariablesMask mask = osg::CullSettings::CLEAR_MASK;]])],
731   [AC_DEFINE([HAVE_CULLSETTINGS_CLEAR_MASK],1,[define if OSG has CullSettings::CLEAR_MASK])
732    AC_MSG_RESULT([yes])],
733   [AC_MSG_RESULT([no])])
734
735 # Special handling for static version of OSG
736 if test -n "`echo "$CPPFLAGS" "$CXXFLAGS" "$CFLAGS" | grep "\-DOSG_LIBRARY_STATIC" 2>/dev/null`" ; then
737     saved_LIBS="$LIBS"
738     LIBS=""
739     #***** Check image support (needed for static build) *****
740     AC_SEARCH_LIBS([jpeg_read_header], [jpeg], [CPPFLAGS="$CPPFLAGS -DOSG_JPEG_ENABLED"])
741     AC_SEARCH_LIBS([png_read_image], [png 'png -lz'], [CPPFLAGS="$CPPFLAGS -DOSG_PNG_ENABLED"])
742     AC_SEARCH_LIBS([TIFFOpen], [tiff], [CPPFLAGS="$CPPFLAGS -DOSG_TIFF_ENABLED"])
743     img_LIBS="$LIBS"
744     LIBS="$saved_LIBS"
745
746     if test "x$with_osg" != "x" ; then
747         osg_prefix="$with_osg"
748     else
749         osg_prefix="/usr"
750     fi
751     PKG_CHECK_EXISTS([openscenegraph], [osg_version="`$PKG_CONFIG --modversion openscenegraph 2>/dev/null`"])
752     LIBS="-L$osg_prefix/lib/osgPlugins-$osg_version -losgdb_bmp -losgdb_dds -losgdb_hdr -losgdb_pic -losgdb_pnm -losgdb_rgb -losgdb_tga \
753                                                           -losgdb_3ds -losgdb_ac -losgdb_ive -losgdb_osg -losgdb_txf \
754                                                           -losgVolume -losgTerrain $LIBS -losgUtil"
755
756     if test -n "`echo "$CPPFLAGS" "$CXXFLAGS" "$CFLAGS" | grep "\-DOSG_JPEG_ENABLED" 2>/dev/null`" ; then
757       LIBS="$LIBS -losgdb_jpeg"
758     fi
759     if test -n "`echo "$CPPFLAGS" "$CXXFLAGS" "$CFLAGS" | grep "\-DOSG_PNG_ENABLED" 2>/dev/null`" ; then
760       LIBS="$LIBS -losgdb_png"
761     fi
762     if test -n "`echo "$CPPFLAGS" "$CXXFLAGS" "$CFLAGS" | grep "\-DOSG_TIFF_ENABLED" 2>/dev/null`" ; then
763       LIBS="$LIBS -losgdb_tiff"
764     fi
765
766     LIBS="$LIBS $img_LIBS"
767 fi
768
769 AC_LANG_POP
770
771 dnl Check for system installed zlib
772 AC_CHECK_HEADER(zlib.h)
773 if test "x$ac_cv_header_zlib_h" != "xyes"; then
774     echo
775     echo "zlib library not found."
776     echo
777     echo "If your OS does not provide an installable package for zlib"
778     echo "you will have to compile and install it first yourself.  A copy"
779     echo "of zlib-1.1.4.tar.gz is included with SimGear.  You will"
780     echo "have to untar this source code, and follow it's included instructions"
781     echo "to compile and install on your system."
782     echo
783     echo "configure aborted."
784     echo
785 fi
786
787 dnl Check for Subversion library support
788 save_LIBS=$LIBS
789 save_CPPFLAGS=$CPPFLAGS
790 LIBS=""
791 CPPFLAGS="-I/usr/include/subversion-1 `apr-1-config --includes`"
792 AC_CHECK_LIB(svn_client-1, svn_client_checkout3)
793 AC_CHECK_HEADERS([svn_client.h glut.h])
794 if test "x$ac_cv_header_svn_client_h" != "xyes"; then
795   echo "TerraSync will shell out for command line subversion"
796   svn_LIBS=""
797   svn_CPPFLAGS=""
798 else
799   echo "TerraSync will use integrated subversion library"
800   AC_SEARCH_LIBS(svn_client_checkout, svn_client-1)
801   svn_LIBS=$LIBS
802   svn_CPPFLAGS=$CPPFLAGS
803   AC_SUBST(svn_LIBS)
804   AC_SUBST(svn_CPPFLAGS)
805 fi
806 LIBS=$save_LIBS
807 CPPFLAGS=$save_CPPFLAGS
808
809 AC_MSG_CHECKING([for feenableexcept])
810 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define _GNU_SOURCE
811 #include <fenv.h>]], [[feenableexcept(FE_DIVBYZERO)]])],
812 [AC_DEFINE([HAVE_FEENABLEEXCEPT], 1, [define if system has fenableexcept])],
813 AC_MSG_RESULT([yes]),
814 AC_MSG_RESULT([no]))
815
816 dnl Checks for header files.
817 AC_HEADER_STDC
818 AC_CHECK_HEADERS( \
819         fcntl.h getopt.h malloc.h memory.h stdlib.h sys/param.h sys/stat.h \
820         sys/time.h sys/timeb.h unistd.h windows.h values.h )
821
822 dnl Checks for typedefs, structures, and compiler characteristics.
823 AC_C_CONST
824 AC_TYPE_SIZE_T
825 AC_HEADER_TIME
826 AC_STRUCT_TM
827
828 dnl Checks for library functions.
829 old_LIBS=$LIBS
830 LIBS="$base_LIBS $network_LIBS $opengl_LIBS"
831 AC_TYPE_SIGNAL
832 AC_FUNC_VPRINTF
833 AC_CHECK_FUNCS( [ \
834         ftime gettimeofday timegm memcpy bcopy mktime strstr rand mkfifo \
835         random drand48 setitimer getitimer signal GetLocalTime rint getrusage \
836         truncf ] )
837 LIBS=$old_LIBS
838
839 AM_CONFIG_HEADER(src/Include/config.h)
840
841 AC_CONFIG_FILES([ \
842         Makefile \
843         man/Makefile \
844         man/est-epsilon.1 \
845         man/fgfs.1 \
846         man/fgjs.1 \
847         man/gl-info.1 \
848         man/js_demo.1 \
849         man/pstest.1 \
850         scripts/Makefile \
851         scripts/debug/Makefile \
852         scripts/perl/Makefile \
853         scripts/perl/examples/Makefile \
854         scripts/python/Makefile \
855         src/Makefile \
856         src/Include/Makefile \
857         src/Include/version.h \
858         src/Include/config.h-msvc6 \
859         src/Include/config.h-msvc71 \
860         src/Include/config.h-msvc8 \
861         src/Include/config.h-msvc90 \
862         src/Aircraft/Makefile \
863         src/Airports/Makefile \
864         src/ATC/Makefile \
865         src/ATCDCL/Makefile \
866         src/Autopilot/Makefile \
867         src/Cockpit/Makefile \
868         src/Cockpit/built_in/Makefile \
869         src/Environment/Makefile \
870         src/FDM/ExternalNet/Makefile \
871         src/FDM/ExternalPipe/Makefile \
872         src/FDM/JSBSim/Makefile \
873         src/FDM/JSBSim/initialization/Makefile \
874         src/FDM/JSBSim/input_output/Makefile \
875         src/FDM/JSBSim/math/Makefile \
876         src/FDM/JSBSim/models/Makefile \
877         src/FDM/JSBSim/models/flight_control/Makefile \
878         src/FDM/JSBSim/models/atmosphere/Makefile \
879         src/FDM/JSBSim/models/propulsion/Makefile \
880         src/FDM/LaRCsim/Makefile \
881         src/FDM/SP/Makefile \
882         src/FDM/UIUCModel/Makefile \
883         src/FDM/YASim/Makefile \
884         src/FDM/Makefile \
885         src/GUI/Makefile \
886         src/Input/Makefile \
887         src/Instrumentation/Makefile \
888         src/Instrumentation/KLN89/Makefile \
889         src/Instrumentation/HUD/Makefile \
890         src/Main/Makefile \
891         src/Main/runfgfs \
892         src/Main/runfgfs.bat \
893         src/Model/Makefile \
894         src/AIModel/Makefile \
895         src/MultiPlayer/Makefile \
896         src/Navaids/Makefile \
897         src/Network/Makefile \
898         src/Scenery/Makefile \
899         src/Scripting/Makefile \
900         src/Sound/Makefile \
901         src/Systems/Makefile \
902         src/Time/Makefile \
903         src/Traffic/Makefile \
904         tests/Makefile \
905         utils/Makefile \
906         utils/GPSsmooth/Makefile \
907         utils/fgadmin/Makefile
908         utils/fgadmin/src/Makefile \
909         utils/js_server/Makefile \
910         utils/Modeller/Makefile \
911         utils/propmerge/Makefile \
912         utils/TerraSync/Makefile \
913         utils/xmlgrep/Makefile \
914         utils/fgviewer/Makefile
915 ])
916 AC_OUTPUT
917
918 AC_OUTPUT_COMMANDS([chmod 755 src/Main/runfgfs])
919
920 echo ""
921 echo "Configure Summary"
922 echo "================="
923
924 echo "Prefix: $prefix"
925
926 if test "x$with_logging" != "x"; then
927     echo "Debug messages: $with_logging"
928 else
929     echo "Debug messages: yes"
930 fi
931
932 echo -n "Automake version: "
933 automake --version | head -n 1
934
935 if test "x$with_multiplayer" != "xno"; then
936     echo "Building with multiplayer support"
937 fi
938
939 if test "x$with_threads" = "xyes"; then
940     echo "threads: yes"
941 else
942     echo "threads: no"
943 fi
944
945 if test "x$with_eventinput" = "xyes"; then
946     echo "event input: yes"
947 else
948     echo "event input: no"
949 fi
950
951 if test "x$enable_sp_fdms" != "xno"; then
952     echo "Include special purpose flight models: yes"
953 else
954     echo "Include special purpose flight models: no"
955 fi
956
957 if test "x$enable_atcdcl" != "xno"; then
958     echo "Build depricated ATC/AI module: yes"
959 else
960     echo "Build depricated ATC/AI module: no"
961 fi