]> git.mxchange.org Git - flightgear.git/blob - configure.ac
dc57f2307dfd11a325cc35d5fc87724acec47fb9
[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 LIBS="-lplibsl -lplibsm"
154
155 dnl search for FreeBSD library
156 AC_SEARCH_LIBS(hid_init, usbhid)
157
158 case "${host}" in
159 *-*-cygwin* | *-*-mingw32*)
160     LIBS="$LIBS -lwinmm"
161     ;;
162 *-apple-darwin*)
163     LIBS="$LIBS -framework IOKit -framework CoreFoundation"
164     ;;
165 *-*-irix* )
166     LIBS="$LIBS -laudio"
167     ;;
168
169 esac
170 audio_LIBS="$LIBS"
171 LIBS=""
172 AC_SUBST(audio_LIBS)
173
174 dnl ENABLE_AUDIO_SUPPORT could be depricated at any time in favor of
175 dnl just assuming we have audio support on all platform.  We can
176 dnl depend on plib to hide the details.
177 AC_DEFINE([ENABLE_AUDIO_SUPPORT], 1, [Define for audio support])
178
179 dnl X11 might be installed on Mac OS X or cygwin/mingwin, we don't want
180 dnl to use it if it is.
181 case "${host}" in
182 *-apple-darwin* | *-*-cygwin* | *-*-mingw32*)
183     echo no fancy X11 check
184     ;;
185
186 *)
187     AC_PATH_XTRA
188     ;;
189
190 esac
191
192 dnl Checks for libraries.
193
194 dnl Thread related checks
195 AC_SEARCH_LIBS(pthread_cancel, [pthread c_r])
196 if test "x$ac_cv_header_pthread_h" = "xyes"; then
197   if test "x$ac_cv_search_pthread_exit" = "x-lc_r"; then
198     CXXFLAGS="-pthread $CXXFLAGS"
199     CFLAGS="-pthread $FLAGS"
200   fi
201 fi
202
203 thread_LIBS="$LIBS"
204 LIBS=""
205
206 dnl search for network related libraries
207 AC_SEARCH_LIBS(inet_addr, xnet)
208 AC_SEARCH_LIBS(socket, socket)
209 AC_SEARCH_LIBS(main, nsl)
210
211 network_LIBS="$LIBS"
212 LIBS=""
213
214 dnl check for some default libraries
215 AC_SEARCH_LIBS(cos, m)
216 AC_SEARCH_LIBS(dlclose, dl)
217
218 base_LIBS="$LIBS"
219
220 dnl Check for SDL if enabled.
221 AC_ARG_ENABLE(sdl, [  --enable-sdl                  Configure to use SDL instead of GLUT], [enable_sdl="$enableval"])
222 AM_CONDITIONAL(USE_SDL, test "x$enable_sdl" = "xyes")
223 if test "x$enable_sdl" = "xyes"; then
224     AC_DEFINE([PU_USE_SDL], 1, [Define to use SDL])
225 else
226     AC_DEFINE([PU_USE_GLUT], 1, [Define to use glut])
227 fi
228
229 dnl check for OpenGL related libraries
230 case "${host}" in
231 *-*-cygwin* | *-*-mingw32*)
232     dnl CygWin under Windoze.
233
234     echo Win32 specific hacks...
235     AC_DEFINE([WIN32], 1, [Define for Win32 platforms])
236     AC_DEFINE([NOMINMAX], 1, [Define for Win32 platforms])
237
238     if test "x$enable_sdl" = "xyes"; then
239         AC_SEARCH_LIBS(SDL_Init, SDL)
240     else
241         LIBS="$LIBS -lglut32"
242     fi
243
244     LIBS="$LIBS -lglu32 -lopengl32 -luser32 -lgdi32"
245
246     dnl add -lwsock32 for mingwin
247     case "${host}" in
248     *-*-mingw32*)
249         echo "********** BUILDING FOR MINGW32 *************"
250         base_LIBS="$base_LIBS -lws2_32"
251         ;;
252     esac
253
254     echo "Will link apps with $LIBS"
255     ;;
256
257
258 *-apple-darwin*)
259     dnl Mac OS X
260
261     LIBS="$LIBS -framework GLUT -framework OpenGL -framework AGL -framework Carbon -lobjc"
262     ;;
263
264 *)
265     dnl X-Windows based machines
266
267     dnl Skip X11 library tests if requested.
268     if test "x$no_x" != "xyes"; then
269         AC_SEARCH_LIBS(XCreateWindow, X11)
270         AC_SEARCH_LIBS(XShmCreateImage, Xext)
271         AC_SEARCH_LIBS(XGetExtensionVersion, Xi)
272         AC_SEARCH_LIBS(IceOpenConnection, ICE)
273         AC_SEARCH_LIBS(SmcOpenConnection, SM)
274         AC_SEARCH_LIBS(XtMalloc, Xt)
275         AC_SEARCH_LIBS(XmuLookupStandardColormap, Xmu)
276     fi
277
278     AC_SEARCH_LIBS(glNewList, [ GL GLcore MesaGL ])
279     if test "x$ac_cv_search_glNewList" = "x-lGLcore"; then
280         dnl if GLcore found, then also check for GL
281         AC_SEARCH_LIBS(glXCreateContext, GL)
282     fi
283
284     dnl if using mesa, check for xmesa.h
285     if test "x$ac_cv_search_glNewList" = "x-lMesaGL"; then
286         AC_CHECK_HEADER(GL/fxmesa.h)
287         if test "x$ac_cv_header_GL_fxmesa_h" = "xyes"; then
288             AC_DEFINE([XMESA], 1, [Define for fxmesa])
289             AC_DEFINE([FX], 1, [Define for fxmesa])
290         fi
291     fi
292
293     AC_SEARCH_LIBS(gluLookAt, [ GLU MesaGLU ])
294     AC_SEARCH_LIBS(glutGetModifiers, [ glut freeglut ])
295     if test "x$enable_sdl" = "xyes"; then
296         AC_SEARCH_LIBS(SDL_Init, SDL)
297     fi
298     ;;
299
300 esac
301
302 opengl_LIBS="$LIBS"
303 LIBS="$base_LIBS"
304
305 dnl search for FreeBSD library
306 AC_SEARCH_LIBS(hid_init, usbhid)
307
308 dnl check for OpenAL libraries
309 case "${host}" in
310 *-*-cygwin* | *-*-mingw32*)
311     dnl CygWin under Windoze.
312
313     AC_SEARCH_LIBS(alGenBuffers, openal32)
314     AC_SEARCH_LIBS(alutInit, [ openal32 ALut ] )
315     LIBS="$LIBS -lwinmm -ldsound -ldxguid -lole32"
316     openal_LIBS="$LIBS"
317     ;;
318
319 *-apple-darwin*)
320     dnl Mac OS X
321
322     LIBS="$LIBS -framework IOKit -framework OpenAL"
323     openal_LIBS="$LIBS"
324     ;;
325
326 *)
327     dnl default unix style machines
328
329     save_LIBS=$LIBS
330     LIBS="$LIBS $thread_LIBS"
331     AC_SEARCH_LIBS(alGenBuffers, openal)
332     OPENAL_OK="$ac_cv_search_alGenBuffers"
333     openal_LIBS="$LIBS"
334     LIBS=$save_LIBS
335     ;;
336
337 esac
338
339 LIBS="$base_LIBS"
340
341 AC_SUBST(base_LIBS)
342 AC_SUBST(openal_LIBS)
343 AC_SUBST(opengl_LIBS)
344 AC_SUBST(thread_LIBS)
345 AC_SUBST(network_LIBS)
346
347 # The following are C++ items that need to be tested for with the c++
348 # compiler
349
350 AC_LANG_PUSH(C++)
351
352 # Check for "plib" without which we cannot go on
353 AC_CHECK_HEADER(plib/ul.h)
354 if test "x$ac_cv_header_plib_ul_h" != "xyes"; then
355     echo
356     echo "You *must* have the plib library installed on your system to build"
357     echo "the FGFS simulator!"
358     echo
359     echo "Please see README.plib for more details."
360     echo
361     echo "configure aborted."
362     exit
363 fi
364
365 AC_MSG_CHECKING([for plib 1.8.0 or newer])
366 AC_TRY_RUN([
367 #include <plib/ul.h>
368
369 #define MIN_PLIB_VERSION 170
370
371 int main() {
372     int major, minor, micro;
373
374     if ( PLIB_VERSION < MIN_PLIB_VERSION ) {
375          return -1;
376     }
377
378     return 0;
379 }
380
381 ],
382   AC_MSG_RESULT(yes),
383   [AC_MSG_RESULT(wrong version);
384    AC_MSG_ERROR([Install plib 1.8.0 or later first...])],
385   AC_MSG_RESULT(yes)
386 )
387
388 dnl If we get here then plib is available, so force use of plib
389 dnl joystick lib
390 AC_DEFINE([ENABLE_PLIB_JOYSTICK], 1, [Define to enable plib joystick support])
391
392
393 dnl Check for the presence of SimGear
394 AC_CHECK_HEADER(simgear/version.h)
395 if test "x$ac_cv_header_simgear_version_h" != "xyes"; then
396     echo
397     echo "You *must* have the SimGear support library installed on your system"
398     echo "to build the FGFS simulator!"
399     echo
400     echo "Please see README.SimGear for more details."
401     echo
402     echo "configure aborted."
403     exit
404 fi
405
406 AC_MSG_CHECKING([for simgear 0.3.7 or newer])
407 AC_TRY_RUN([
408 #include <stdio.h>
409
410 #include <simgear/version.h>
411
412 #define STRINGIFY(X) XSTRINGIFY(X)
413 #define XSTRINGIFY(X) #X
414
415 #define MIN_MAJOR 0
416 #define MIN_MINOR 3
417 #define MIN_MICRO 7
418
419 int main() {
420     int major, minor, micro;
421
422     /* printf("%d.%d.%d or greater, ", MIN_MAJOR, MIN_MINOR, MIN_MICRO); */
423     printf("[found %s] ... ", STRINGIFY(SIMGEAR_VERSION));
424
425     sscanf( STRINGIFY(SIMGEAR_VERSION), "%d.%d.%d", &major, &minor, &micro );
426
427     if ( (major < MIN_MAJOR) ||
428          (major == MIN_MAJOR && minor < MIN_MINOR) ||
429          (major == MIN_MAJOR && minor == MIN_MINOR && micro < MIN_MICRO) ) {
430          return -1;
431     }
432
433     return 0;
434 }
435
436 ],
437   AC_MSG_RESULT(yes),
438   [AC_MSG_RESULT(wrong version);
439    AC_MSG_ERROR([Install latest simgear first...])],
440   AC_MSG_RESULT(yes)
441 )
442
443 LIBS="$saved_LIBS"
444
445 dnl Check if SimGear was built with Norman's JPEG factory support
446 AC_CHECK_HEADER(simgear/screen/jpgfactory.hxx)
447 if test "x$ac_cv_header_simgear_screen_jpgfactory_hxx" = "xyes"; then
448     AC_CHECK_LIB(jpeg, jpeg_start_compress)
449     if test "x$ac_cv_lib_jpeg_jpeg_start_compress" != "xyes" ; then
450         echo
451         echo "The JPEG factory code was built and installed with SimGear."
452         echo "However it appears the libjpeg is no longer installed."
453         echo "You need to install libjpeg or remove jpgfactory support from"
454         echo "SimGear"
455         echo
456         echo "libjpeg is available at :"
457         echo "  ftp://ftp.uu.net in the directory graphics/jpeg"
458         exit 1
459     fi
460     AC_DEFINE([FG_JPEG_SERVER], 1,
461               [Define to build with jpeg screen shot server])
462 fi
463 AM_CONDITIONAL(ENABLE_JPEG_SERVER, test "x$ac_cv_header_simgear_screen_jpgfactory_hxx" = "xyes")
464
465 AC_LANG_POP
466
467 dnl Check for system installed zlib
468 AC_CHECK_HEADER(zlib.h)
469 if test "x$ac_cv_header_zlib_h" != "xyes"; then
470     echo
471     echo "zlib library not found."
472     echo
473     echo "If your OS does not provide an installable package for zlib"
474     echo "you will have to compile and install it first yourself.  A copy"
475     echo "of zlib-1.1.4.tar.gz is included with SimGear.  You will"
476     echo "have to untar this source code, and follow it's included instructions"
477     echo "to compile and install on your system."
478     echo
479     echo "configure aborted."
480     echo
481 fi
482
483 dnl Checks for header files.
484 AC_HEADER_STDC
485 AC_CHECK_HEADERS( \
486         fcntl.h getopt.h malloc.h memory.h stdlib.h sys/param.h sys/stat.h \
487         sys/time.h sys/timeb.h unistd.h windows.h values.h )
488
489 dnl Checks for typedefs, structures, and compiler characteristics.
490 AC_C_CONST
491 AC_TYPE_SIZE_T
492 AC_HEADER_TIME
493 AC_STRUCT_TM
494
495 dnl Checks for library functions.
496 old_LIBS=$LIBS
497 LIBS="$base_LIBS $network_LIBS $opengl_LIBS"
498 AC_TYPE_SIGNAL
499 AC_FUNC_VPRINTF
500 AC_CHECK_FUNCS( [ \
501         ftime gettimeofday timegm memcpy bcopy mktime strstr rand mkfifo \
502         random drand48 setitimer getitimer signal GetLocalTime rint getrusage \
503         truncf ] )
504 LIBS=$old_LIBS
505
506 AM_CONFIG_HEADER(src/Include/config.h)
507
508 AC_CONFIG_FILES([ \
509         Makefile \
510         man/Makefile \
511         man/est-epsilon.1 \
512         man/fgfs.1 \
513         man/fgjs.1 \
514         man/gl-info.1 \
515         man/js_demo.1 \
516         man/pstest.1 \
517         scripts/Makefile \
518         scripts/debug/Makefile \
519         scripts/perl/Makefile \
520         scripts/perl/examples/Makefile \
521         scripts/python/Makefile \
522         src/Makefile \
523         src/Include/Makefile \
524         src/Include/version.h \
525         src/Include/config.h-msvc6 \
526         src/Aircraft/Makefile \
527         src/Airports/Makefile \
528         src/ATC/Makefile \
529         src/Autopilot/Makefile \
530         src/Cockpit/Makefile \
531         src/Cockpit/built_in/Makefile \
532         src/Controls/Makefile \
533         src/Environment/Makefile \
534         src/FDM/Balloon/Makefile \
535         src/FDM/ExternalNet/Makefile \
536         src/FDM/ExternalPipe/Makefile \
537         src/FDM/JSBSim/Makefile \
538         src/FDM/JSBSim/filtersjb/Makefile \
539         src/FDM/LaRCsim/Makefile \
540         src/FDM/SP/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/AIModel/Makefile \
552         src/MultiPlayer/Makefile \
553         src/Navaids/Makefile \
554         src/Network/Makefile \
555         src/Objects/Makefile \
556         src/Replay/Makefile \
557         src/Scenery/Makefile \
558         src/Scripting/Makefile \
559         src/Sound/Makefile \
560         src/Systems/Makefile \
561         src/Time/Makefile \
562         src/Traffic/Makefile \
563         tests/Makefile \
564         utils/Makefile \
565         utils/TerraSync/Makefile \
566         utils/Modeller/Makefile \
567         utils/js_server/Makefile \
568 ])
569 AC_OUTPUT
570
571 AC_OUTPUT_COMMANDS([chmod 755 src/Main/runfgfs])
572
573 echo ""
574 echo "Configure Summary"
575 echo "================="
576
577 echo "Prefix: $prefix"
578
579 if test "x$with_logging" != "x"; then
580     echo "Debug messages: $with_logging"
581 else
582     echo "Debug messages: yes"
583 fi
584
585 echo -n "Automake version: "
586 automake --version | head -1
587
588 if test "x$with_multiplayer" != "xno"; then
589     echo "Building with multiplayer support"
590 fi
591
592 if test "x$with_threads" = "xyes"; then
593     echo "threads: yes"
594 else
595     echo "threads: no"
596 fi
597
598 if test "x$enable_sp_fdms" != "xno"; then
599     echo "Include special purpose flight models: yes"
600 else
601     echo "Include special purpose flight models: no"
602 fi
603