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