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