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