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