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