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