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