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