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