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