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