]> git.mxchange.org Git - flightgear.git/blob - configure.ac
4b6a6ce0066a667a1524c40a95f26d7f455d6741
[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 -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
151 dnl add joystick support libraries
152 dnl search for FreeBSD library
153 AC_SEARCH_LIBS(hid_init, usbhid)
154 joystick_LIBS="$LIBS"
155 LIBS=""
156 AC_SUBST(joystick_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
231     dnl add -lwsock32 for mingwin
232     case "${host}" in
233     *-*-mingw32*)
234         echo "********** BUILDING FOR MINGW32 *************"
235         base_LIBS="$base_LIBS -lws2_32"
236         ;;
237     esac
238
239     echo "Will link apps with $LIBS"
240     ;;
241
242
243 *-apple-darwin*)
244     dnl Mac OS X
245
246     LIBS="$LIBS -framework GLUT -framework OpenGL -framework AGL -framework Carbon -lobjc"
247     ;;
248
249 *)
250     dnl X-Windows based machines
251
252     dnl Skip X11 library tests if requested.
253     if test "x$no_x" != "xyes"; then
254         AC_SEARCH_LIBS(XCreateWindow, X11)
255         AC_SEARCH_LIBS(XShmCreateImage, Xext)
256         AC_SEARCH_LIBS(XGetExtensionVersion, Xi)
257         AC_SEARCH_LIBS(IceOpenConnection, ICE)
258         AC_SEARCH_LIBS(SmcOpenConnection, SM)
259         AC_SEARCH_LIBS(XtMalloc, Xt)
260         AC_SEARCH_LIBS(XmuLookupStandardColormap, Xmu)
261     fi
262
263     AC_SEARCH_LIBS(glNewList, [ GL GLcore MesaGL ])
264     if test "x$ac_cv_search_glNewList" = "x-lGLcore"; then
265         dnl if GLcore found, then also check for GL
266         AC_SEARCH_LIBS(glXCreateContext, GL)
267     fi
268
269     dnl if using mesa, check for xmesa.h
270     if test "x$ac_cv_search_glNewList" = "x-lMesaGL"; then
271         AC_CHECK_HEADER(GL/fxmesa.h)
272         if test "x$ac_cv_header_GL_fxmesa_h" = "xyes"; then
273             AC_DEFINE([XMESA], 1, [Define for fxmesa])
274             AC_DEFINE([FX], 1, [Define for fxmesa])
275         fi
276     fi
277
278     AC_SEARCH_LIBS(gluLookAt, [ GLU MesaGLU ])
279     AC_SEARCH_LIBS(glutGetModifiers, [ glut freeglut ])
280     if test "x$enable_sdl" = "xyes"; then
281         AC_SEARCH_LIBS(SDL_Init, SDL)
282     fi
283     ;;
284
285 esac
286
287 opengl_LIBS="$LIBS"
288 LIBS="$base_LIBS $joystick_LIBS"
289
290 dnl check for OpenAL libraries
291 case "${host}" in
292 *-*-cygwin* | *-*-mingw32*)
293     dnl CygWin under Windoze.
294
295     AC_SEARCH_LIBS(alGenBuffers, openal32)
296     AC_SEARCH_LIBS(alutInit, [ openal32 ALut ] )
297     LIBS="$LIBS -lwinmm -ldsound -ldxguid -lole32"
298     openal_LIBS="$LIBS"
299     ;;
300
301 *-apple-darwin*)
302     dnl Mac OS X
303
304     LIBS="$LIBS -framework IOKit -framework OpenAL"
305     openal_LIBS="$LIBS"
306     ;;
307
308 *)
309     dnl default unix style machines
310
311     save_LIBS=$LIBS
312     LIBS="$LIBS $thread_LIBS"
313     AC_SEARCH_LIBS(alGenBuffers, 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
329 # The following are C++ items that need to be tested for with the c++
330 # compiler
331
332 AC_LANG_PUSH(C++)
333
334 # Check for "plib" without which we cannot go on
335 AC_CHECK_HEADER(plib/ul.h)
336 if test "x$ac_cv_header_plib_ul_h" != "xyes"; then
337     echo
338     echo "You *must* have the plib library installed on your system to build"
339     echo "the FGFS simulator!"
340     echo
341     echo "Please see README.plib for more details."
342     echo
343     echo "configure aborted."
344     exit
345 fi
346
347 AC_MSG_CHECKING([for plib 1.8.4 or newer])
348 AC_TRY_RUN([
349 #include <plib/ul.h>
350
351 #define MIN_PLIB_VERSION 184
352
353 int main() {
354     int major, minor, micro;
355
356     if ( PLIB_VERSION < MIN_PLIB_VERSION ) {
357          return -1;
358     }
359
360     return 0;
361 }
362
363 ],
364   AC_MSG_RESULT(yes),
365   [AC_MSG_RESULT(wrong version);
366    AC_MSG_ERROR([Install plib 1.8.0 or later first...])],
367   AC_MSG_RESULT(yes)
368 )
369
370 dnl If we get here then plib is available, so force use of plib
371 dnl joystick lib
372 AC_DEFINE([ENABLE_PLIB_JOYSTICK], 1, [Define to enable plib joystick support])
373
374
375 dnl Check for the presence of SimGear
376 AC_CHECK_HEADER(simgear/version.h)
377 if test "x$ac_cv_header_simgear_version_h" != "xyes"; then
378     echo
379     echo "You *must* have the SimGear support library installed on your system"
380     echo "to build the FGFS simulator!"
381     echo
382     echo "Please see README.SimGear for more details."
383     echo
384     echo "configure aborted."
385     exit
386 fi
387
388 AC_MSG_CHECKING([for simgear 0.3.8 or newer])
389 AC_TRY_RUN([
390 #include <stdio.h>
391
392 #include <simgear/version.h>
393
394 #define STRINGIFY(X) XSTRINGIFY(X)
395 #define XSTRINGIFY(X) #X
396
397 #define MIN_MAJOR 0
398 #define MIN_MINOR 3
399 #define MIN_MICRO 8
400
401 int main() {
402     int major, minor, micro;
403
404     /* printf("%d.%d.%d or greater, ", MIN_MAJOR, MIN_MINOR, MIN_MICRO); */
405     printf("[found %s] ... ", STRINGIFY(SIMGEAR_VERSION));
406
407     sscanf( STRINGIFY(SIMGEAR_VERSION), "%d.%d.%d", &major, &minor, &micro );
408
409     if ( (major < MIN_MAJOR) ||
410          (major == MIN_MAJOR && minor < MIN_MINOR) ||
411          (major == MIN_MAJOR && minor == MIN_MINOR && micro < MIN_MICRO) ) {
412          return -1;
413     }
414
415     return 0;
416 }
417
418 ],
419   AC_MSG_RESULT(yes),
420   [AC_MSG_RESULT(wrong version);
421    AC_MSG_ERROR([Install latest simgear first...])],
422   AC_MSG_RESULT(yes)
423 )
424
425 LIBS="$saved_LIBS"
426
427 dnl Check if SimGear was built with Norman's JPEG factory support
428 AC_CHECK_HEADER(simgear/screen/jpgfactory.hxx)
429 if test "x$ac_cv_header_simgear_screen_jpgfactory_hxx" = "xyes"; then
430     AC_CHECK_LIB(jpeg, jpeg_start_compress)
431     if test "x$ac_cv_lib_jpeg_jpeg_start_compress" != "xyes" ; then
432         echo
433         echo "The JPEG factory code was built and installed with SimGear."
434         echo "However it appears the libjpeg is no longer installed."
435         echo "You need to install libjpeg or remove jpgfactory support from"
436         echo "SimGear"
437         echo
438         echo "libjpeg is available at :"
439         echo "  ftp://ftp.uu.net in the directory graphics/jpeg"
440         exit 1
441     fi
442     AC_DEFINE([FG_JPEG_SERVER], 1,
443               [Define to build with jpeg screen shot server])
444 fi
445 AM_CONDITIONAL(ENABLE_JPEG_SERVER, test "x$ac_cv_header_simgear_screen_jpgfactory_hxx" = "xyes")
446
447 AC_LANG_POP
448
449 dnl Check for system installed zlib
450 AC_CHECK_HEADER(zlib.h)
451 if test "x$ac_cv_header_zlib_h" != "xyes"; then
452     echo
453     echo "zlib library not found."
454     echo
455     echo "If your OS does not provide an installable package for zlib"
456     echo "you will have to compile and install it first yourself.  A copy"
457     echo "of zlib-1.1.4.tar.gz is included with SimGear.  You will"
458     echo "have to untar this source code, and follow it's included instructions"
459     echo "to compile and install on your system."
460     echo
461     echo "configure aborted."
462     echo
463 fi
464
465 dnl Checks for header files.
466 AC_HEADER_STDC
467 AC_CHECK_HEADERS( \
468         fcntl.h getopt.h malloc.h memory.h stdlib.h sys/param.h sys/stat.h \
469         sys/time.h sys/timeb.h unistd.h windows.h values.h )
470
471 dnl Checks for typedefs, structures, and compiler characteristics.
472 AC_C_CONST
473 AC_TYPE_SIZE_T
474 AC_HEADER_TIME
475 AC_STRUCT_TM
476
477 dnl Checks for library functions.
478 old_LIBS=$LIBS
479 LIBS="$base_LIBS $network_LIBS $opengl_LIBS"
480 AC_TYPE_SIGNAL
481 AC_FUNC_VPRINTF
482 AC_CHECK_FUNCS( [ \
483         ftime gettimeofday timegm memcpy bcopy mktime strstr rand mkfifo \
484         random drand48 setitimer getitimer signal GetLocalTime rint getrusage \
485         truncf ] )
486 LIBS=$old_LIBS
487
488 AM_CONFIG_HEADER(src/Include/config.h)
489
490 AC_CONFIG_FILES([ \
491         Makefile \
492         man/Makefile \
493         man/est-epsilon.1 \
494         man/fgfs.1 \
495         man/fgjs.1 \
496         man/gl-info.1 \
497         man/js_demo.1 \
498         man/pstest.1 \
499         scripts/Makefile \
500         scripts/debug/Makefile \
501         scripts/perl/Makefile \
502         scripts/perl/examples/Makefile \
503         scripts/python/Makefile \
504         src/Makefile \
505         src/Include/Makefile \
506         src/Include/version.h \
507         src/Include/config.h-msvc6 \
508         src/Aircraft/Makefile \
509         src/Airports/Makefile \
510         src/ATC/Makefile \
511         src/Autopilot/Makefile \
512         src/Cockpit/Makefile \
513         src/Cockpit/built_in/Makefile \
514         src/Controls/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/Objects/Makefile \
538         src/Replay/Makefile \
539         src/Scenery/Makefile \
540         src/Scripting/Makefile \
541         src/Sound/Makefile \
542         src/Systems/Makefile \
543         src/Time/Makefile \
544         src/Traffic/Makefile \
545         tests/Makefile \
546         utils/Makefile \
547         utils/TerraSync/Makefile \
548         utils/Modeller/Makefile \
549         utils/js_server/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