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