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