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