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