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