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