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