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