]> git.mxchange.org Git - flightgear.git/blob - configure.ac
Turn the __timers garbage collector cache into a more generic "gcsave"
[flightgear.git] / configure.ac
1 dnl Process this file with autoget.sh to produce a working configure
2 dnl script.
3 dnl
4 dnl $Id$
5
6 AC_INIT
7 AC_CONFIG_SRCDIR([src/Aircraft/aircraft.cxx])
8
9 dnl Require at least automake 2.52
10 AC_PREREQ(2.52)
11
12 dnl Initialize the automake stuff
13 AM_INIT_AUTOMAKE(FlightGear, 0.9.3)
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
24 # specify the simgear location
25 AC_ARG_WITH(simgear, [  --with-simgear=PREFIX   Specify the prefix path to simgear])
26
27 if test "x$with_simgear" != "x" ; then
28     echo "SimGear prefix path is $with_simgear"
29     EXTRA_DIRS="${EXTRA_DIRS} $with_simgear"
30 fi
31
32 dnl set the $host variable based on local machine/os
33 AC_CANONICAL_HOST
34
35 case "${host}" in
36 *-*-irix*)
37     if test "$CXX" = "CC"; then
38         AR="CC -ar"
39         ARFLAGS="-o"
40         CXXFLAGS="$CXXFLAGS -I$with_simgear/include/simgear/compatibility"
41     else
42         AR="ar"
43         ARFLAGS="cru"
44     fi
45     ;;
46 *)
47     AR="ar"
48     ARFLAGS="cru"
49     ;;
50 esac
51 AC_SUBST(AR)
52 AC_SUBST(ARFLAGS)
53
54 dnl set logging; default value of with_logging=yes
55 AC_ARG_WITH(logging, [  --with-logging          Include logging output (default)])
56 if test "x$with_logging" = "xno" ; then
57     AC_DEFINE([FG_NDEBUG], 1, [Define for no logging output])
58 fi
59
60 # Specify if we want to build with Multiplayer support
61 # default to with_network=yes
62 AC_ARG_WITH(multiplayer, [  --with-multiplayer      Include multiplayer support [default=yes]])
63
64 if test "x$with_multiplayer" = "xno"; then
65   echo "Building without any kind of multiplayer support"
66 else
67   echo "Building with multiplayer support"
68   AC_DEFINE([FG_MPLAYER_AS], 1, [Define to build with multiplayer support])
69 fi
70 AM_CONDITIONAL(ENABLE_MPLAYER_AS, test "x$with_multiplayer" != "xno")
71
72
73 # Specify if we want to use WeatherCM instead of FGEnvironment.
74 # default to with_weathercm=no
75 AC_ARG_WITH(weathercm, [  --with-weathercm        Use WeatherCM instead of FGEnvironment])
76 if test "x$with_weathercm" = "xyes" ; then
77     echo "Building with WeatherCM"
78     AC_DEFINE([FG_WEATHERCM], 1,
79               [Define to build with Christian Mayer's weather code])
80 else
81     echo "Building with FGEnvironment"
82 fi
83 AM_CONDITIONAL(ENABLE_WEATHERCM, test "x$with_weathercm" = "xyes")
84
85 dnl Thread related checks
86 AC_ARG_WITH(threads, [  --with-threads          Include tile loading threads [default=no]])
87 if test "x$with_threads" = "xyes"; then
88     AC_DEFINE([ENABLE_THREADS], 1, [Define to enable threaded tile paging])
89     CXXFLAGS="$CXXFLAGS -D_REENTRANT"
90     CFLAGS="$CFLAGS -D_REENTRANT"
91 fi
92 AC_CHECK_HEADER(pthread.h)
93 AM_CONDITIONAL(WITH_THREADS, test "x$with_threads" = "xyes")
94
95 # specify the plib location
96 AC_ARG_WITH(plib, [  --with-plib=PREFIX      Specify the prefix path to plib])
97
98 if test "x$with_plib" != "x" ; then
99     echo "plib prefix is $with_plib"
100     EXTRA_DIRS="${EXTRA_DIRS} $with_plib"
101 fi
102
103 dnl Used by JSBSim to conditionally compile in fgfs interface code
104 AC_DEFINE([FGFS], 1, [Define so that JSBSim compiles in 'library' mode])
105
106 dnl Used to controll whether clouds3d should be compiled in or not
107 AC_DEFINE([FG_USE_CLOUDS_3D], 1, [Define to use 3D cloud support])
108 AM_CONDITIONAL(FG_USE_CLOUDS_3D, test "x" = "x")
109
110 # Check for MS Windows environment
111 AC_CHECK_HEADER(windows.h)
112
113 dnl Determine an extra directories to add to include/lib search paths
114 case "${host}" in
115 *-apple-darwin* | *-*-mingw32*)
116     echo no EXTRA_DIRS for $host
117     ;;
118
119 *)
120     if test -d /usr/X11R6 ; then
121         EXTRA_DIR1="/usr/X11R6"
122     fi
123     if test -d /opt/X11R6 ; then
124         EXTRA_DIR2="/opt/X11R6"
125     fi
126     EXTRA_DIRS="${EXTRA_DIRS} $EXTRA_DIR1 $EXTRA_DIR2"
127     ;;
128
129 esac
130 wi_EXTRA_DIRS(no, ${EXTRA_DIRS})
131
132
133 dnl Using AM_CONDITIONAL is a step out of the protected little 
134 dnl automake fold so it is potentially dangerous.  But, we are
135 dnl beginning to run into cases where the standard checks are not
136 dnl enough.  AM_CONDITIONALS are then referenced to conditionally
137 dnl build a Makefile.in from a Makefile.am which lets us define custom
138 dnl includes, compile alternative source files, etc.
139
140 dnl Check for external variables daylight and timezone.
141 AC_EXT_DAYLIGHT
142 if test "$have_daylight" = yes; then
143     AC_DEFINE([HAVE_DAYLIGHT], 1, [Define if system has daylight variable])
144 fi
145
146 AC_EXT_TIMEZONE
147 if test "$have_timezone" = yes; then
148     AC_DEFINE([HAVE_TIMEZONE], 1, [Define if system has timezone variable])
149 fi
150
151 dnl add correct audio libs and configure for audio support
152 audio_LIBS="-lplibsl -lplibsm"
153 case "${host}" in
154 *-*-cygwin* | *-*-mingw32*)
155     audio_LIBS="$audio_LIBS -lwinmm"
156     ;;
157 *-apple-darwin*)
158     audio_LIBS="$audio_LIBS -framework IOKit -framework CoreFoundation"
159     ;;
160 *-*-irix* )
161     audio_LIBS="$audio_LIBS -laudio"
162     ;;
163
164 esac
165 AC_SUBST(audio_LIBS)
166
167 dnl ENABLE_AUDIO_SUPPORT could be depricated at any time in favor of
168 dnl just assuming we have audio support on all platform.  We can
169 dnl depend on plib to hide the details.
170 AC_DEFINE([ENABLE_AUDIO_SUPPORT], 1, [Define for audio support])
171
172 dnl X11 might be installed on Mac OS X or cygwin/mingwin, we don't want
173 dnl to use it if it is.
174 case "${host}" in
175 *-apple-darwin* | *-*-cygwin* | *-*-mingw32*)
176     echo no fancy X11 check
177     ;;
178
179 *)
180     AC_PATH_XTRA
181     ;;
182
183 esac
184
185 dnl Checks for libraries.
186
187 dnl Thread related checks
188 AC_CHECK_LIB(pthread, pthread_exit)
189 if test "x$ac_cv_lib_pthread_pthread_exit" != "xyes" \
190    -a "x$ac_cv_header_pthread_h" = "xyes"; then
191     dnl FreeBSD: System has pthread.h, but -lpthread library check
192     dnl fails.  See if we need -pthread instead of -lpthread and look
193     dnl for the functions in libc_r.
194     save_CXXFLAGS="$CXXFLAGS"
195     save_CFLAGS="$CFLAGS"
196     CXXFLAGS="-pthread $CXXFLAGS"
197     CFLAGS="-pthread $CFLAGS"
198     save_LIBS=$LIBS
199     AC_CHECK_LIB(c_r, pthread_exit)
200     if test "x$ac_cv_lib_c_r_pthread_exit" != "xyes"; then
201         CXXFLAGS=$save_CXXFLAGS
202         CFLAGS=$save_CFLAGS
203     fi
204     LIBS=$save_LIBS
205 fi
206
207 thread_LIBS="$LIBS"
208 LIBS=""
209
210 dnl search for network related libraries
211 AC_SEARCH_LIBS(inet_addr, xnet)
212 AC_SEARCH_LIBS(socket, socket)
213 AC_SEARCH_LIBS(main, nsl)
214
215 network_LIBS="$LIBS"
216 LIBS=""
217
218 dnl check for some default libraries
219 AC_SEARCH_LIBS(cos, m)
220 AC_SEARCH_LIBS(dlclose, dl)
221
222 base_LIBS="$LIBS"
223
224 dnl check for glut location
225 AC_CHECK_HEADER(GL/glut.h)
226 if test "x$ac_cv_header_GL_glut_h" = "xyes"; then
227     AC_DEFINE([FG_GLUT_H], <GL/glut.h>, [Define as glut.h include location])
228 else
229     AC_CHECK_HEADER(GLUT/glut.h)
230     if test "x$ac_cv_header_GLUT_glut_h" = "xyes"; then
231         AC_DEFINE([FG_GLUT_H], <GLUT/glut.h>, [Define as glut.h include location])
232     else
233         echo "Neither GL/glut.h nor GLUT/glut.h found.  Cannot continue"
234         exit
235     fi
236 fi
237
238 dnl check for OpenGL related libraries
239 case "${host}" in
240 *-*-cygwin* | *-*-mingw32*)
241     dnl CygWin under Windoze.
242
243     echo Win32 specific hacks...
244     AC_DEFINE([WIN32], 1, [Define for Win32 platforms])
245     AC_DEFINE([NOMINMAX], 1, [Define for Win32 platforms])
246
247     LIBS="$LIBS -lglut32 -lglu32 -lopengl32"
248     LIBS="$LIBS -luser32 -lgdi32"
249
250     dnl add -lwsock32 for mingwin
251     case "${host}" in
252     *-*-mingw32*)
253         echo "********** BUILDING FOR MINGW32 *************"
254         base_LIBS="$base_LIBS -lws2_32"
255         ;;
256     esac
257
258     echo "Will link apps with $LIBS"
259     ;;
260
261
262 *-apple-darwin*)
263     dnl Mac OS X
264
265     LIBS="$LIBS -framework GLUT -framework OpenGL -framework Carbon -lobjc"
266     ;;
267
268 *)
269     dnl X-Windows based machines
270
271     dnl Skip X11 library tests if requested.
272     if test "x$no_x" != "xyes"; then
273         AC_SEARCH_LIBS(XCreateWindow, X11)
274         AC_SEARCH_LIBS(XShmCreateImage, Xext)
275         AC_SEARCH_LIBS(XGetExtensionVersion, Xi)
276         AC_SEARCH_LIBS(IceOpenConnection, ICE)
277         AC_SEARCH_LIBS(SmcOpenConnection, SM)
278         AC_SEARCH_LIBS(XtMalloc, Xt)
279         AC_SEARCH_LIBS(XmuLookupStandardColormap, Xmu)
280     fi
281
282     AC_SEARCH_LIBS(glNewList, [ GL GLcore MesaGL ])
283     if test "x$ac_cv_search_glNewList" = "x-lGLcore"; then
284         dnl if GLcore found, then also check for GL
285         AC_SEARCH_LIBS(glXCreateContext, GL)
286     fi
287
288     dnl if using mesa, check for xmesa.h
289     if test "x$ac_cv_search_glNewList" = "x-lMesaGL"; then
290         AC_CHECK_HEADER(GL/fxmesa.h)
291         if test "x$ac_cv_header_GL_fxmesa_h" = "xyes"; then
292             AC_DEFINE([XMESA], 1, [Define for fxmesa])
293             AC_DEFINE([FX], 1, [Define for fxmesa])
294         fi
295     fi
296
297     AC_SEARCH_LIBS(gluLookAt, [ GLU MesaGLU ])
298     AC_SEARCH_LIBS(glutGetModifiers, [ glut freeglut ])
299     ;;
300
301 esac
302
303 opengl_LIBS="$LIBS"
304 LIBS="$base_LIBS"
305
306 AC_SUBST(base_LIBS)
307 AC_SUBST(opengl_LIBS)
308 AC_SUBST(thread_LIBS)
309 AC_SUBST(network_LIBS)
310
311 # The following are C++ items that need to be tested for with the c++
312 # compiler
313
314 AC_LANG_PUSH(C++)
315
316 # Check for "plib" without which we cannot go on
317 AC_CHECK_HEADER(plib/ul.h)
318 if test "x$ac_cv_header_plib_ul_h" != "xyes"; then
319     echo
320     echo "You *must* have the plib library installed on your system to build"
321     echo "the FGFS simulator!"
322     echo
323     echo "Please see README.plib for more details."
324     echo
325     echo "configure aborted."
326     exit
327 fi
328
329 AC_MSG_CHECKING([for plib 1.6.0 or newer])
330 AC_TRY_RUN([
331 #include <plib/ul.h>
332
333 #define MIN_PLIB_VERSION 160
334
335 int main() {
336     int major, minor, micro;
337
338     if ( PLIB_VERSION < MIN_PLIB_VERSION ) {
339          return -1;
340     }
341
342     return 0;
343 }
344
345 ],
346   AC_MSG_RESULT(yes),
347   [AC_MSG_RESULT(wrong version);
348    AC_MSG_ERROR([Install plib 1.6.0 or later first...])],
349   AC_MSG_RESULT(yes)
350 )
351
352 dnl If we get here then plib is available, so force use of plib
353 dnl joystick lib
354 AC_DEFINE([ENABLE_PLIB_JOYSTICK], 1, [Define to enable plib joystick support])
355
356
357 dnl Check for the presence of SimGear
358 AC_CHECK_HEADER(simgear/version.h)
359 if test "x$ac_cv_header_simgear_version_h" != "xyes"; then
360     echo
361     echo "You *must* have the SimGear support library installed on your system"
362     echo "to build the FGFS simulator!"
363     echo
364     echo "Please see README.SimGear for more details."
365     echo
366     echo "configure aborted."
367     exit
368 fi
369
370 AC_MSG_CHECKING([for simgear 0.3.4 or newer])
371 AC_TRY_RUN([
372 #include <stdio.h>
373
374 #include <simgear/version.h>
375
376 #define STRINGIFY(X) XSTRINGIFY(X)
377 #define XSTRINGIFY(X) #X
378
379 #define MIN_MAJOR 0
380 #define MIN_MINOR 3
381 #define MIN_MICRO 4
382
383 int main() {
384     int major, minor, micro;
385
386     printf("%d.%d.%d or greater... ", MIN_MAJOR, MIN_MINOR, MIN_MICRO);
387
388     sscanf( STRINGIFY(SIMGEAR_VERSION), "%d.%d.%d", &major, &minor, &micro );
389
390     if ( major < MIN_MAJOR ) {
391          return -1;
392     } else if ( major == MIN_MAJOR && minor < MIN_MINOR ) {
393          return -1;
394     } else if ( major == MIN_MAJOR && minor == MIN_MINOR && micro < MIN_MICRO ){
395          return -1;
396     }
397
398     return 0;
399 }
400
401 ],
402   AC_MSG_RESULT(yes),
403   [AC_MSG_RESULT(wrong version);
404    AC_MSG_ERROR([Install latest simgear first...])],
405   AC_MSG_RESULT(yes)
406 )
407
408 LIBS="$saved_LIBS"
409
410 dnl Check if SimGear was built with Norman JPEG factory support
411 AC_CHECK_HEADER(simgear/screen/jpgfactory.hxx)
412 if test "x$ac_cv_header_simgear_screen_jpgfactory_hxx" = "xyes"; then
413     AC_CHECK_LIB(jpeg, jpeg_start_compress)
414     if test "x$ac_cv_lib_jpeg_jpeg_start_compress" != "xyes" ; then
415         echo
416         echo "The JPEG factory code was built and installed with SimGear."
417         echo "However it appears the libjpeg is no longer installed."
418         echo "You need to install libjpeg or remove jpgfactory support from"
419         echo "SimGear"
420         echo
421         echo "libjpeg is available at :"
422         echo "  ftp://ftp.uu.net in the directory graphics/jpeg"
423         exit 1
424     fi
425     AC_DEFINE([FG_JPEG_SERVER], 1,
426               [Define to build with jpeg screen shot server])
427 fi
428 AM_CONDITIONAL(ENABLE_JPEG_SERVER, test "x$ac_cv_header_simgear_screen_jpgfactory_hxx" = "xyes")
429
430 AC_LANG_POP
431
432 dnl Check for system installed zlib
433 AC_CHECK_HEADER(zlib.h)
434 if test "x$ac_cv_header_zlib_h" != "xyes"; then
435     echo
436     echo "zlib library not found."
437     echo
438     echo "If your OS does not provide an installable package for zlib"
439     echo "you will have to compile and install it first yourself.  A copy"
440     echo "of zlib-1.1.4.tar.gz is included with SimGear.  You will"
441     echo "have to untar this source code, and follow it's included instructions"
442     echo "to compile and install on your system."
443     echo
444     echo "configure aborted."
445     echo
446 fi
447
448 dnl Checks for header files.
449 AC_HEADER_STDC
450 AC_CHECK_HEADERS( \
451         fcntl.h getopt.h malloc.h memory.h stdlib.h sys/param.h sys/stat.h \
452         sys/time.h sys/timeb.h unistd.h windows.h values.h )
453
454 dnl Checks for typedefs, structures, and compiler characteristics.
455 AC_C_CONST
456 AC_TYPE_SIZE_T
457 AC_HEADER_TIME
458 AC_STRUCT_TM
459
460 dnl Checks for library functions.
461 AC_TYPE_SIGNAL
462 AC_FUNC_VPRINTF
463 AC_CHECK_FUNCS( \
464         ftime gettimeofday timegm memcpy bcopy mktime strstr rand mkfifo \
465         random drand48 setitimer getitimer signal GetLocalTime rint getrusage )
466
467 AM_CONFIG_HEADER(src/Include/config.h)
468
469 AC_CONFIG_FILES([ \
470         Makefile \
471         man/Makefile \
472         man/est-epsilon.1 \
473         man/fgfs.1 \
474         man/fgjs.1 \
475         man/gl-info.1 \
476         man/js_demo.1 \
477         man/pstest.1 \
478         scripts/Makefile \
479         scripts/debug/Makefile \
480         scripts/python/Makefile \
481         src/Makefile \
482         src/Include/Makefile \
483         src/Include/version.h \
484         src/Aircraft/Makefile \
485         src/Airports/Makefile \
486         src/ATC/Makefile \
487         src/Autopilot/Makefile \
488         src/Cockpit/Makefile \
489         src/Cockpit/built_in/Makefile \
490         src/Controls/Makefile \
491         src/Environment/Makefile \
492         src/FDM/Balloon/Makefile \
493         src/FDM/ExternalNet/Makefile \
494         src/FDM/ExternalPipe/Makefile \
495         src/FDM/JSBSim/Makefile \
496         src/FDM/JSBSim/filtersjb/Makefile \
497         src/FDM/LaRCsim/Makefile \
498         src/FDM/UIUCModel/Makefile \
499         src/FDM/YASim/Makefile \
500         src/FDM/Makefile \
501         src/GUI/Makefile \
502         src/Input/Makefile \
503         src/Instrumentation/Makefile \
504         src/Main/Makefile \
505         src/Main/runfgfs \
506         src/Main/runfgfs.bat \
507         src/Model/Makefile \
508         src/AIModel/Makefile \
509         src/MultiPlayer/Makefile \
510         src/Navaids/Makefile \
511         src/Network/Makefile \
512         src/Objects/Makefile \
513         src/Replay/Makefile \
514         src/Scenery/Makefile \
515         src/Scripting/Makefile \
516         src/Sound/Makefile \
517         src/Systems/Makefile \
518         src/Time/Makefile \
519         src/WeatherCM/Makefile \
520         tests/Makefile \
521         utils/Makefile \
522         utils/TerraSync/Makefile \
523         utils/js_server/Makefile \
524         utils/3dconvert/Makefile \
525 ])
526 AC_OUTPUT
527
528 AC_OUTPUT_COMMANDS([chmod 755 src/Main/runfgfs])
529
530 echo ""
531 echo "Configure Summary"
532 echo "================="
533
534 echo "Prefix: $prefix"
535
536 if test "x$with_logging" != "x"; then
537     echo "Debug messages: $with_logging"
538 else
539     echo "Debug messages: yes"
540 fi
541
542 echo -n "Automake version: "
543 automake --version | head -1
544
545 if test "x$with_weathercm" != "x"; then
546     echo "WeatherCM instead of FGEnvironment: $with_weathercm"
547 else
548     echo "Using FGEnvironment"
549 fi
550
551 if test "x$with_multiplayer" != "xno"; then
552     echo "Building with multiplayer support"
553 fi
554
555 if test "x$with_threads" = "xyes"; then
556     echo "threads: yes"
557 else
558     echo "threads: no"
559 fi