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