]> git.mxchange.org Git - flightgear.git/blob - configure.ac
48aed5347486c6e3a0760f14eac132dd1b457d5c
[flightgear.git] / configure.ac
1 dnl Process this file with aclocal ; automake -a ; autoconf to produce a 
2 dnl working configure script.
3
4 #
5 # $Id$
6 #
7
8 AC_INIT
9 AC_CONFIG_SRCDIR([src/Aircraft/aircraft.cxx])
10
11 # Require at least automake 2.52
12 AC_PREREQ(2.52)
13
14 # Initialize the automake stuff
15 AM_INIT_AUTOMAKE(FlightGear, 0.7.11pre1)
16
17 # Checks for programs.
18 AC_PROG_MAKE_SET
19 AC_PROG_CC
20 AC_PROG_CPP
21 AC_PROG_CXX
22 AC_PROG_RANLIB
23 AC_PROG_INSTALL
24 AC_PROG_LN_S
25
26 # Initialize libtool
27 # AM_PROG_LIBTOOL
28
29 # Initialize maintainer mode
30 # AM_MAINTAINER_MODE
31
32 # This is needed for AC_TRY_COMPILE later
33 # AC_ISC_POSIX
34
35 # Check to see if this `configure' is being run in the `Cygwin32' environment
36 AC_EGREP_CPP(yes,
37 [#ifdef __MINGW32__
38  yes
39  #endif
40 ],is_mingw=yes, is_mingw=no)
41
42 echo "IS_MINGW = $is_mingw"
43 AM_CONDITIONAL(IS_MINGW, test "x$is_mingw" = "xyes")
44
45 AC_EGREP_CPP(yes,
46 [#ifdef __CYGWIN__
47  yes
48  #endif
49 ],is_cygwin=yes, is_cygwin=no)
50
51 echo "IS_CYGWIN = $is_cygwin"
52 AM_CONDITIONAL(IS_CYGWIN, test "x$is_cygwin" = "xyes")
53
54 # Determine version of automake ... important becuase of
55 # incompatibilities between versions
56 AUTO_MAKE_VERSION=`automake --version | head -1 | awk '{print $4}' | sed -e 's/\-p[[0-9]]$//' | sed -e 's/\.//g'`
57 if test $AUTO_MAKE_VERSION -lt 15; then
58     echo "You need to upgrade your automake to version 1.5 or newer"
59     exit 1
60 fi
61
62 # Used by JSBSim
63 AC_DEFINE([FGFS], 1, [Define so that JSBSim compiles in 'library' mode])
64
65 # Used on the Irix platform
66 AR="ar"
67 OS=`uname -s`
68 if test "$OS" = "IRIX" -o "$OS" = "IRIX64"; then
69     if test "$CXX" = "CC"; then
70         AR="CC -ar"
71         AC_SUBST(AR)
72     fi
73 fi
74
75
76 # Specify if we want logging (testing build) or not (release build)
77 # set logging default value
78 # with_logging=yes
79 AC_ARG_WITH(logging, [  --with-logging          Include logging output (default)])
80 if test "x$with_logging" = "xno" ; then
81     AC_DEFINE([FG_NDEBUG], 1, [Define for no logging output])
82 fi
83
84 # Specify if we want to build with Oliver's networking support
85 # default to with_network=yes
86 AC_ARG_WITH(network_olk, [  --with-network-olk      Include Oliver's multi-pilot networking support])
87 if test "x$with_network_olk" = "xno" ; then
88     echo "Building without Oliver's multi-pilot network support"
89 else
90     echo "Building with Oliver's multi-pilot network support"
91     AC_DEFINE([FG_NETWORK_OLK], 1, [Define to build with Oliver's networking])
92 fi
93 AM_CONDITIONAL(ENABLE_NETWORK_OLK, test "x$with_network_olk" != "xno")
94
95
96 # Check if SimGear was built with Norman JPEG factory support
97 AC_CHECK_HEADER(simgear/screen/jpgfactory.hxx)
98 if test "x$ac_cv_header_simgear_screen_jpgfactory_hxx" = "xyes"; then
99     AC_CHECK_LIB(jpeg, jpeg_start_compress)
100     if test "x$ac_cv_lib_jpeg_jpeg_start_compress" != "xyes" ; then
101         echo
102         echo "The JPEG factory code was built and installed with SimGear."
103         echo "However it appears the libjpeg is no longer installed."
104         echo "You need to install libjpeg or remove jpgfactory support from"
105         echo "SimGear"
106         echo
107         echo "libjpeg is available at :"
108         echo "  ftp://ftp.uu.net in the directory graphics/jpeg"
109         exit 1
110     fi
111     AC_DEFINE([FG_JPEG_SERVER], 1,
112               [Define to build with jpeg screen shot server])
113 fi
114 AM_CONDITIONAL(ENABLE_JPEG_SERVER, test "x$ac_cv_header_simgear_screen_jpgfactory_hxx" = "xyes")
115
116 # Specify if we want to use WeatherCM instead of FGEnvironment.
117 # default to with_weathercm=no
118 AC_ARG_WITH(new-environment, [  --with-weathercm        Use WeatherCM instead of FGEnvironment])
119 if test "x$with_weathercm" = "xyes" ; then
120     echo "Building with WeatherCM"
121     AC_DEFINE([FG_WEATHERCM], 1,
122               [Define to build with Christian Mayer's weather code])
123 else
124     echo "Building with FGEnvironment"
125 fi
126 AM_CONDITIONAL(ENABLE_WEATHERCM, test "x$with_weathercm" = "xyes")
127
128 # Let the Win32 user specify if they want to build with the SGI
129 # opengl.dll as opposed to the more standard openg32.dll
130 AC_ARG_WITH(sgi-opengl, [  --with-sgi-opengl       Build against SGI's opengl.dll glu.dll and glut.dll])
131
132 dnl Thread related checks
133 AC_ARG_WITH(threads, [  --with-threads          Include tile loading threads [default=no]])
134 if test "x$with_threads" = "xyes"; then
135     AC_DEFINE([ENABLE_THREADS], 1, [Define to enable threaded tile paging])
136     CXXFLAGS="$CXXFLAGS -D_REENTRANT"
137     CFLAGS="$CFLAGS -D_REENTRANT"
138     AC_CHECK_HEADER(pthread.h)
139 fi
140 AM_CONDITIONAL(WITH_THREADS, test "x$with_threads" = "xyes")
141
142 # specify the plib location
143 AC_ARG_WITH(plib, [  --with-plib=PREFIX      Specify the prefix path to plib])
144
145 if test "x$with_plib" != "x" ; then
146     echo "plib prefix is $with_plib"
147     EXTRA_DIRS="${EXTRA_DIRS} $with_plib"
148 fi
149
150 # specify the metakit location
151 AC_ARG_WITH(metakit, [  --with-metakit=PREFIX   Specify the prefix path to metakit])
152
153 if test "x$with_metakit" != "x" ; then
154     echo "metakit prefix is $with_metakit"
155     EXTRA_DIRS="${EXTRA_DIRS} $with_metakit"
156 fi
157
158 # specify the simgear location
159 AC_ARG_WITH(simgear, [  --with-simgear=PREFIX   Specify the prefix path to simgear])
160
161 if test "x$with_simgear" != "x" ; then
162     echo "SimGear prefix path is $with_simgear"
163     EXTRA_DIRS="${EXTRA_DIRS} $with_simgear"
164 fi
165
166 # Check for MS Windows environment
167 AC_CHECK_HEADER(windows.h)
168
169 # extra library and include directories
170 if test "x$ac_cv_header_windows_h" != "xyes" ; then
171     EXTRA_DIRS="${EXTRA_DIRS} /usr/local /usr/X11R6"
172
173     if test -d /opt/X11R6 ; then
174         EXTRA_DIRS="${EXTRA_DIRS} /opt/X11R6"
175     fi
176 else
177     if test  "x$is_cygwin" = "xyes" ; then
178         EXTRA_DIRS="${EXTRA_DIRS} /usr/local"
179     fi
180 fi
181
182 wi_EXTRA_DIRS(no, ${EXTRA_DIRS})
183
184 # Using AM_CONDITIONAL is a step out of the protected little 
185 # automake fold so it is potentially dangerous.  But, we are
186 # beginning to run into cases where the standard checks are not
187 # enough.  AM_CONDITIONALS are then referenced to conditionally
188 # build a Makefile.in from a Makefile.am which lets us define custom
189 # includes, compile alternative source files, etc.
190
191 # Check for external variables daylight and timezone.
192 AC_EXT_DAYLIGHT
193 if test "$have_daylight" = yes; then
194     AC_DEFINE([HAVE_DAYLIGHT], 1, [Define if system has daylight variable])
195 fi
196 # AM_CONDITIONAL(HAVE_DAYLIGHT, test "$have_daylight" = yes )
197
198 AC_EXT_TIMEZONE
199 if test "$have_timezone" = yes; then
200     AC_DEFINE([HAVE_TIMEZONE], 1, [Define if system has timezone variable])
201 fi
202 # AM_CONDITIONAL(HAVE_TIMEZONE, test "$have_timezone" = yes )
203
204 # Check for audio support
205 AC_MSG_CHECKING(for audio support)
206 audio_LIBS=""
207 if test -r /usr/include/soundcard.h \
208         -o -r /usr/include/linux/soundcard.h \
209         -o -r /usr/include/machine/soundcard.h \
210         -o -r /usr/include/audio.h \
211         -o "x$ac_cv_header_windows_h" = "xyes" \
212         -o "$HOSTTYPE" = "macintosh"; then
213
214     AC_DEFINE([ENABLE_AUDIO_SUPPORT], 1, [Define for audio support])
215     audio_LIBS="-lplibsl -lplibsm"
216     AC_MSG_RESULT(yes)
217     if test -r /usr/include/audio.h; then
218         audio_LIBS="$audio_LIBS -laudio"
219     fi
220
221     if test "x$ac_cv_header_windows_h" = "xyes"; then
222         audio_LIBS="$audio_LIBS -lwinmm"
223     fi
224
225     if test "$HOSTTYPE" = "macintosh"; then
226         audio_LIBS="$audio_LIBS -framework Carbon"
227     fi
228 else
229     AC_MSG_RESULT(no)
230 fi
231 AC_SUBST(audio_LIBS)
232
233 # Check for X11 (fancy)
234 if test "x$no_x" != "xyes"; then
235     AC_PATH_XTRA
236 fi
237
238 # Checks for libraries.
239
240 null_LIBS="$LIBS"
241
242 AC_CHECK_LIB(m, cos)
243
244 dnl MINGW requires libwsock32
245 if test  "x$is_mingw" = "xyes" ; then
246     LIBS="$LIBS -lws2_32"
247 fi
248
249 base_LIBS="$LIBS"
250
251 dnl Mesa >= 3.2 requires pthreads
252 AC_CHECK_LIB(pthread, pthread_exit)
253 AC_CHECK_LIB(socket, socket)
254
255 dnl Skip X library tests.
256 if test "x$no_x" != "xyes"; then
257     AC_CHECK_LIB(X11, XCreateWindow)
258     AC_CHECK_LIB(Xext, XShmCreateImage)
259     AC_CHECK_LIB(Xi, XGetExtensionVersion)
260     AC_CHECK_LIB(ICE, IceOpenConnection)
261     AC_CHECK_LIB(SM, SmcOpenConnection)
262     AC_CHECK_LIB(Xt, XtMalloc)
263     AC_CHECK_LIB(Xmu, XmuLookupStandardColormap)
264 fi
265
266 # check for OpenGL related libraries
267
268 if test "$HOSTTYPE" = "macintosh"; then
269     LIBS="$LIBS -framework OpenGL -framework GLUT -lobjc"
270 elif test "x$ac_cv_header_windows_h" != "xyes" ; then
271     # Reasonable stuff for non-windoze variants ... :-)
272
273     AC_CHECK_LIB(GLcore, glNewList)
274     if test "x$ac_cv_lib_GLcore_glNewList" = "xno" ; then
275         # if no GLcore, check for GL
276         AC_CHECK_LIB(GL, glNewList)
277         if test "x$ac_cv_lib_GL_glNewList" = "xno" ; then
278             # if no GL, check for MesaGL
279             AC_CHECK_LIB(MesaGL, glNewList)
280         fi
281     else
282         # if GLcore found, then also check for GL
283         AC_CHECK_LIB(GL, glXCreateContext)
284     fi
285
286     # check for xmesa.h and if found enable XMESA / FX
287     AC_CHECK_HEADER(GL/fxmesa.h)
288     if test "x$ac_cv_header_GL_fxmesa_h" = "xyes"; then
289         save_LIBS="$LIBS"
290         AC_CHECK_LIB(GL, XMesaSetFXmode)
291         if test "x$ac_cv_lib_GL_XMesaSetFXmode" = "xyes" ; then
292             AC_DEFINE([XMESA], 1, [Define for Mesa FX mode])
293             AC_DEFINE([FX], 1, [Define for Mesa FX mode])
294         else
295             AC_CHECK_LIB(MesaGL, XMesaSetFXmode)
296             if test "x$ac_cv_lib_MesaGL_XMesaSetFXmode" = "xyes" ; then
297                 AC_DEFINE([XMESA], 1, [Define for Mesa FX mode])
298                 AC_DEFINE([FX], 1, [Define for Mesa FX mode])
299             fi
300         fi
301         LIBS="$save_LIBS"
302     fi
303
304     AC_CHECK_LIB(GLU, gluLookAt)
305     if test "x$ac_cv_lib_GLU_gluLookAt" = "xno" ; then
306         # if no GLU, check for MesaGLU
307         AC_CHECK_LIB(MesaGLU, gluLookAt)
308     fi
309
310     # check for glut
311     AC_CHECK_LIB(glut, glutGetModifiers)
312
313     # test for glutGameModeString, but avoid adding glut a second time into
314     # the list of libraries
315     save_LIBS="$LIBS"
316     AC_CHECK_LIB(glut, glutGameModeString)
317     LIBS="$save_LIBS"
318 else
319     # Win32 is a little wierd because it has to try to handle the various
320     # winbloze-isms.  We'll just do this manually for now.
321
322     echo Win32 specific hacks...
323     AC_DEFINE([WIN32], 1, [Define if building on a Win32 platform])
324
325     # just define these to true and hope for the best
326     ac_cv_lib_glut_glutGetModifiers="yes"
327     ac_cv_lib_glut_glutGameModeString="yes"
328
329     if test "x$with_sgi_opengl" = "xyes" ; then
330         echo "Building with glut.dll, glu.dll, and opengl.dll"
331         WIN32_GLUT=glut
332         WIN32_GLU=glu
333         WIN32_OPENGL=opengl
334     else 
335         echo "Building with glut32.dll, glu32.dll, and opengl32.dll"
336         WIN32_GLUT=glut32
337         WIN32_GLU=glu32
338         WIN32_OPENGL=opengl32
339     fi
340
341     LIBS="$LIBS -l${WIN32_GLUT} -l${WIN32_GLU} -l${WIN32_OPENGL}"
342     LIBS="$LIBS -luser32 -lgdi32"
343     echo "Will link apps with $LIBS"
344 fi
345
346 if test "x$ac_cv_lib_glut_glutGetModifiers" = "xno"; then
347     echo 
348     echo "Unable to find the necessary OpenGL or GLUT libraries."
349     echo "See config.log for automated test details and results ..."
350     exit 1
351 fi
352
353 if test "x$ac_cv_lib_glut_glutGameModeString" = "xno"; then
354     echo
355     echo "Your version of glut doesn't support game mode."
356     echo "You need to install the latest version.  If your distribution doesn't"
357     echo "provide a newer version, you can get the latest source code from:"
358     echo
359     echo "    http://reality.sgi.com/opengl/glut3/glut3.html"
360     exit 1
361 fi
362
363 opengl_LIBS="$LIBS"
364 LIBS="$base_LIBS"
365
366 AC_SUBST(base_LIBS)
367 AC_SUBST(opengl_LIBS)
368
369 AM_CONDITIONAL(HAVE_XWINDOWS, test "x$ac_cv_lib_X11_XCreateWindow" = "xyes" )
370
371 # The following are C++ items that need to be tested for with the c++
372 # compiler
373
374 AC_LANG_PUSH(C++)
375
376 # Check for "plib" without which we cannot go on
377 AC_CHECK_HEADER(plib/pu.h)
378 if test "x$ac_cv_header_plib_pu_h" != "xyes"; then
379     echo
380     echo "You *must* have the plib library installed on your system to build"
381     echo "the FGFS simulator!"
382     echo
383     echo "Please see README.plib for more details."
384     echo
385     echo "configure aborted."
386     exit
387 fi
388
389 # needed for plib 1.3.x and later
390 AC_CHECK_LIB(plibul, ulInit,,,)
391
392 if test "x$ac_cv_lib_plibul_ulInit" != "xyes"; then
393     echo
394     echo "You have an old version of plib, you need to upgrade to at least"
395     echo "plib-1.4.2"
396     exit
397 fi
398
399 # If we get here then plib is available, so force use of plib joystick lib
400 AC_DEFINE([ENABLE_PLIB_JOYSTICK], 1, [Define to enable plib joystick support])
401
402 # Do we have a new CVS plib version with jsJoystick::getName?
403 echo -n "Testing for Plib joystick getName support: "
404 AC_EGREP_HEADER( getName, plib/js.h,
405                  plib_js_has_getname=yes, plib_js_has_getname=no )
406 echo $plib_js_has_getname
407 if test $plib_js_has_getname = 'yes'; then
408     AC_DEFINE([FG_PLIB_JOYSTICK_GETNAME], 1,
409               [Define to enable plib joystick name support])
410 fi
411
412 # Check for the presence of SimGear
413 AC_CHECK_HEADER(simgear/version.h)
414 if test "x$ac_cv_header_simgear_version_h" != "xyes"; then
415     echo
416     echo "You *must* have the SimGear support library installed on your system"
417     echo "to build the FGFS simulator!"
418     echo
419     echo "Please see README.SimGear for more details."
420     echo
421     echo "configure aborted."
422     exit
423 fi
424
425 AC_MSG_CHECKING([for proper simgear version])
426 AC_TRY_RUN([
427 #include <stdio.h>
428
429 #include <simgear/version.h>
430
431 #define STRINGIFY(X) XSTRINGIFY(X)
432 #define XSTRINGIFY(X) #X
433
434 #define MIN_MAJOR 0
435 #define MIN_MINOR 0
436 #define MIN_MICRO 19
437
438 int main() {
439     int major, minor, micro;
440
441     printf("%d.%d.%d or greater... ", MIN_MAJOR, MIN_MINOR, MIN_MICRO);
442
443     sscanf( STRINGIFY(SIMGEAR_VERSION), "%d.%d.%d", &major, &minor, &micro );
444
445     if ( major < MIN_MAJOR ) {
446          return -1;
447     } else if ( major == MIN_MAJOR && minor < MIN_MINOR ) {
448          return -1;
449     } else if ( major == MIN_MAJOR && minor == MIN_MINOR && micro < MIN_MICRO ){
450          return -1;
451     }
452
453     return 0;
454 }
455
456 ],
457   AC_MSG_RESULT(yes),
458   [AC_MSG_RESULT(wrong version);
459    AC_MSG_ERROR([Install latest simgear first...])],
460   AC_MSG_RESULT(yes)
461 )
462
463 # Check for MetaKit
464 AC_CHECK_HEADER(mk4.h)
465 if test "x$ac_cv_header_mk4_h" != "xyes"; then
466     echo
467     echo "MetaKit library not found."
468     echo
469     echo "If your OS does not provide an installable package for MetaKit"
470     echo "you will have to compile and install it first yourself.  A copy"
471     echo "of metakit-$(VERSION).tar.gz is included with SimGear.  You will"
472     echo "have to untar this source code, and follow it's included instructions"
473     echo "to compile and install on your system."
474     echo
475     echo "configure aborted."
476     exit
477 fi
478
479 AC_MSG_CHECKING([for proper metakit version])
480 AC_TRY_RUN([
481 #include <mk4.h>
482
483 #define MIN_MK4_VERSION 243
484
485 int main() {
486     int major, minor, micro;
487
488     if ( d4_MetaKitLibraryVersion < MIN_MK4_VERSION ) {
489          return -1;
490     }
491
492     return 0;
493 }
494
495 ],
496   AC_MSG_RESULT(yes),
497   [AC_MSG_RESULT(wrong version);
498    AC_MSG_ERROR([Install metakit 2.4.3 or later first...])],
499   AC_MSG_RESULT(yes)
500 )
501
502 AC_LANG_POP
503
504 # Check for system installed zlib
505 AC_CHECK_HEADER(zlib.h)
506 if test "x$ac_cv_header_zlib_h" != "xyes"; then
507     echo
508     echo "zlib library not found."
509     echo
510     echo "If your OS does not provide an installable package for zlib"
511     echo "you will have to compile and install it first yourself.  A copy"
512     echo "of zlib-1.1.4.tar.gz is included with SimGear.  You will"
513     echo "have to untar this source code, and follow it's included instructions"
514     echo "to compile and install on your system."
515     echo
516     echo "configure aborted."
517     echo
518 fi
519
520 # Checks for header files.
521 AC_HEADER_STDC
522 AC_CHECK_HEADERS( \
523         fcntl.h getopt.h malloc.h memory.h stdlib.h sys/param.h sys/stat.h \
524         sys/time.h sys/timeb.h unistd.h windows.h winbase.h values.h )
525
526 # Checks for typedefs, structures, and compiler characteristics.
527 AC_C_CONST
528 AC_TYPE_SIZE_T
529 AC_HEADER_TIME
530 AC_STRUCT_TM
531
532 # Checks for library functions.
533 AC_TYPE_SIGNAL
534 AC_FUNC_VPRINTF
535 AC_CHECK_FUNCS( ftime gettimeofday timegm memcpy bcopy mktime strstr rand \
536         random setitimer getitimer signal GetLocalTime rint getrusage )
537
538 AM_CONFIG_HEADER(src/Include/config.h)
539
540 AC_CONFIG_FILES([ \
541         Makefile \
542         man/Makefile \
543         man/est-epsilon.1 \
544         man/fgfs.1 \
545         man/fgjs.1 \
546         man/gl-info.1 \
547         man/js_demo.1 \
548         man/pstest.1 \
549         scripts/Makefile \
550         scripts/debug/Makefile \
551         scripts/python/Makefile \
552         src/Makefile \
553         src/Include/Makefile \
554         src/Include/version.h \
555         src/Aircraft/Makefile \
556         src/Airports/Makefile \
557         src/ATC/Makefile \
558         src/Autopilot/Makefile \
559         src/Cockpit/Makefile \
560         src/Cockpit/built_in/Makefile \
561         src/Controls/Makefile \
562         src/Environment/Makefile \
563         src/FDM/Balloon/Makefile \
564         src/FDM/JSBSim/Makefile \
565         src/FDM/JSBSim/filtersjb/Makefile \
566         src/FDM/LaRCsim/Makefile \
567         src/FDM/UIUCModel/Makefile \
568         src/FDM/YASim/Makefile \
569         src/FDM/Makefile \
570         src/GUI/Makefile \
571         src/Input/Makefile \
572         src/Main/Makefile \
573         src/Main/runfgfs \
574         src/Main/runfgfs.bat \
575         src/Model/Makefile \
576         src/Navaids/Makefile \
577         src/Network/Makefile \
578         src/NetworkOLK/Makefile \
579         src/Objects/Makefile \
580         src/Scenery/Makefile \
581         src/Sound/Makefile \
582         src/Time/Makefile \
583         src/WeatherCM/Makefile \
584         tests/Makefile \
585 ])
586 AC_OUTPUT
587
588 AC_OUTPUT_COMMANDS([chmod 755 src/Main/runfgfs])
589
590 echo ""
591 echo "Configure Summary"
592 echo "================="
593
594 echo "Prefix: $prefix"
595
596 if test "x$with_logging" != "x"; then
597     echo "Debug messages: $with_logging"
598 else
599     echo "Debug messages: yes"
600 fi
601
602 echo -n "Automake version: ($AUTO_MAKE_VERSION) "
603 automake --version | head -1
604
605 echo "New plib joystick name support: $plib_js_has_getname"
606
607 if test "x$with_weathercm" != "x"; then
608     echo "WeatherCM instead of FGEnvironment: $with_weathercm"
609 else
610     echo "Using FGEnvironment"
611 fi
612
613 if test "x$with_threads" = "xyes"; then
614     echo "threads: yes"
615 else
616     echo "threads: no"
617 fi