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