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