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