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