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