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