]> git.mxchange.org Git - flightgear.git/blob - configure.ac
Add a gl-info equivalent for OpenAL.
[flightgear.git] / configure.ac
1 dnl Process this file with autoget.sh to produce a working configure
2 dnl script.
3
4 AC_INIT
5 AC_CONFIG_SRCDIR([src/Aircraft/aircraft.cxx])
6
7 dnl Require at least automake 2.52
8 AC_PREREQ(2.52)
9
10 dnl Initialize the automake stuff
11 dnl set the $host variable based on local machine/os
12 AC_CANONICAL_TARGET
13 AM_INIT_AUTOMAKE(FlightGear, 0.9.9)
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     CXXFLAGS="$CXXFLAGS -I$with_simgear"
31 fi
32
33 # specify the plib location
34 AC_ARG_WITH(plib, [  --with-plib=PREFIX      Specify the prefix path to plib])
35
36 if test "x$with_plib" != "x" ; then
37     echo "plib prefix is $with_plib"
38     EXTRA_DIRS="${EXTRA_DIRS} $with_plib"
39 fi
40
41 dnl Determine an extra directories to add to include/lib search paths
42 case "${host}" in
43 *-apple-darwin* | *-*-mingw32*)
44     echo no EXTRA_DIRS for $host
45     ;;
46
47 *-*-cygwin*)
48     if test -d /usr/local ; then
49         EXTRA_DIRS="${EXTRA_DIRS} /usr/local"
50     fi
51     ;;
52
53 *)
54     if test -d /usr/X11R6 ; then
55         EXTRA_DIR1="/usr/X11R6"
56     fi
57     if test -d /opt/X11R6 ; then
58         EXTRA_DIR2="/opt/X11R6"
59     fi
60     EXTRA_DIRS="${EXTRA_DIRS} $EXTRA_DIR1 $EXTRA_DIR2 /usr/local"
61     ;;
62
63 esac
64 wi_EXTRA_DIRS(no, ${EXTRA_DIRS})
65
66
67 case "${host}" in
68 *-*-irix*)
69     if test "$CXX" = "CC"; then
70         AR="CC -ar"
71         ARFLAGS="-o"
72         CXXFLAGS="$CXXFLAGS -c99 -I$with_simgear/include/simgear/compatibility"
73         CFLAGS="$CFLAGS -c99"
74     else
75         AR="ar"
76         ARFLAGS="cru"
77     fi
78     ;;
79 *)
80     AR="ar"
81     ARFLAGS="cru"
82     ;;
83 esac
84 AC_SUBST(AR)
85 AC_SUBST(ARFLAGS)
86
87 dnl set logging; default value of with_logging=yes
88 AC_ARG_WITH(logging, [  --with-logging          Include logging output (default)])
89 if test "x$with_logging" = "xno" ; then
90     AC_DEFINE([FG_NDEBUG], 1, [Define for no logging output])
91 fi
92
93 # Specify if we want to build with Multiplayer support
94 # default to with_network=yes
95 AC_ARG_WITH(multiplayer, [  --with-multiplayer      Include multiplayer support [default=yes]])
96
97 if test "x$with_multiplayer" = "xno"; then
98   echo "Building without any kind of multiplayer support"
99 else
100   echo "Building with multiplayer support"
101   AC_DEFINE([FG_MPLAYER_AS], 1, [Define to build with multiplayer support])
102 fi
103 AM_CONDITIONAL(ENABLE_MPLAYER_AS, test "x$with_multiplayer" != "xno")
104
105 AC_ARG_ENABLE(sp_fdms, [  --enable-sp-fdms              Include special purpose Flight Models], [enable_sp_fdms="$enableval"] )
106 AC_DEFINE([ENABLE_SP_FMDS], test "x$enable_sp_fdms" = "xyes", [Define to include special purpose FDMs])
107 AM_CONDITIONAL(ENABLE_SP_FDM, test "x$enable_sp_fdms" != "xno")
108
109
110 dnl Thread related checks
111 # defaults to yes
112 AC_ARG_WITH(threads, [  --with-threads          Include tile loading threads [default=yes]], [], [with_threads=yes])
113 if test "x$with_threads" = "xyes"; then
114     AC_DEFINE([ENABLE_THREADS], 1, [Define to enable threaded tile paging])
115     CXXFLAGS="$CXXFLAGS -D_REENTRANT"
116     CFLAGS="$CFLAGS -D_REENTRANT"
117 fi
118 AC_CHECK_HEADER(pthread.h)
119 AM_CONDITIONAL(WITH_THREADS, test "x$with_threads" = "xyes")
120
121 dnl Festival related checks
122 # defaults to yes
123 AC_ARG_WITH(festival, [  --with-festival         Use festival speech software [default=no]], [], [with_festival=no])
124 if test "x$with_festival" = "xyes"; then
125     AC_DEFINE([USE_FESTIVAL], 1, [Define to enable festival speech software])
126 fi
127 AM_CONDITIONAL(USE_FESTIVAL, test "x$with_festival" = "xyes")
128
129 dnl Used by JSBSim to conditionally compile in fgfs interface code
130 AC_DEFINE([FGFS], 1, [Define so that JSBSim compiles in 'library' mode])
131
132 # Check for MS Windows environment
133 AC_CHECK_HEADER(windows.h)
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
154 dnl add joystick support libraries
155 dnl search for FreeBSD library
156 AC_SEARCH_LIBS(hid_init, usbhid)
157 joystick_LIBS="$LIBS"
158 LIBS=""
159
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_SEARCH_LIBS(pthread_cancel, [pthread c_r])
183 if test "x$ac_cv_header_pthread_h" = "xyes"; then
184   if test "x$ac_cv_search_pthread_exit" = "x-lc_r"; then
185     CXXFLAGS="-pthread $CXXFLAGS"
186     CFLAGS="-pthread $CFLAGS"
187   fi
188 fi
189
190 thread_LIBS="$LIBS"
191 LIBS=""
192
193 dnl search for network related libraries
194 AC_SEARCH_LIBS(inet_addr, xnet)
195 AC_SEARCH_LIBS(socket, socket)
196 AC_SEARCH_LIBS(main, nsl)
197
198 network_LIBS="$LIBS"
199 LIBS=""
200
201 dnl check for some default libraries
202 AC_SEARCH_LIBS(sqrt, [am ffm fm fastm m])
203 AC_SEARCH_LIBS(ceil, m)
204 AC_SEARCH_LIBS(dlclose, dl)
205
206 base_LIBS="$LIBS"
207
208 dnl Check for SDL if enabled.
209 AC_ARG_ENABLE(sdl, [  --enable-sdl                  Configure to use SDL instead of GLUT], [enable_sdl="$enableval"])
210 AM_CONDITIONAL(USE_SDL, test "x$enable_sdl" = "xyes")
211 if test "x$enable_sdl" = "xyes"; then
212     AC_DEFINE([PU_USE_SDL], 1, [Define to use SDL])
213 else
214     AC_DEFINE([PU_USE_GLUT], 1, [Define to use glut])
215 fi
216
217 dnl check for OpenGL related libraries
218 case "${host}" in
219 *-*-cygwin* | *-*-mingw32*)
220     dnl CygWin under Windoze.
221
222     echo Win32 specific hacks...
223     AC_DEFINE([WIN32], 1, [Define for Win32 platforms])
224     AC_DEFINE([NOMINMAX], 1, [Define for Win32 platforms])
225
226     if test "x$enable_sdl" = "xyes"; then
227         AC_SEARCH_LIBS(SDL_Init, SDL)
228     else
229         LIBS="$LIBS -lglut32"
230     fi
231
232     LIBS="$LIBS -lglu32 -lopengl32 -luser32 -lgdi32"
233     joystick_LIBS="$joystick_LIBS -lwinmm"
234
235     dnl add -lwsock32 for mingwin
236     case "${host}" in
237     *-*-mingw32*)
238         echo "********** BUILDING FOR MINGW32 *************"
239         network_LIBS="$network_LIBS -lws2_32"
240         ;;
241     esac
242
243     echo "Will link apps with $LIBS"
244     ;;
245
246
247 *-apple-darwin*)
248     dnl Mac OS X
249
250     LIBS="$LIBS -framework GLUT -framework OpenGL -framework AGL -framework Carbon -lobjc"
251     joystick_LIBS="$joystick_LIBS -framework IOKit -framework CoreFoundation"
252     ;;
253
254 *)
255     dnl X-Windows based machines
256
257     dnl Skip X11 library tests if requested.
258     if test "x$no_x" != "xyes"; then
259         AC_SEARCH_LIBS(XCreateWindow, X11)
260         AC_SEARCH_LIBS(XShmCreateImage, Xext)
261         AC_SEARCH_LIBS(XGetExtensionVersion, Xi)
262         AC_SEARCH_LIBS(IceOpenConnection, ICE)
263         AC_SEARCH_LIBS(SmcOpenConnection, SM)
264         AC_SEARCH_LIBS(XtMalloc, Xt)
265         AC_SEARCH_LIBS(XmuLookupStandardColormap, Xmu)
266     fi
267
268     AC_SEARCH_LIBS(glNewList, [ GL GLcore MesaGL ])
269     if test "x$ac_cv_search_glNewList" = "x-lGLcore"; then
270         dnl if GLcore found, then also check for GL
271         AC_SEARCH_LIBS(glXCreateContext, GL)
272     fi
273
274     dnl if using mesa, check for xmesa.h
275     if test "x$ac_cv_search_glNewList" = "x-lMesaGL"; then
276         AC_CHECK_HEADER(GL/fxmesa.h)
277         if test "x$ac_cv_header_GL_fxmesa_h" = "xyes"; then
278             AC_DEFINE([XMESA], 1, [Define for fxmesa])
279             AC_DEFINE([FX], 1, [Define for fxmesa])
280         fi
281     fi
282
283     AC_SEARCH_LIBS(gluLookAt, [ GLU MesaGLU ])
284     AC_SEARCH_LIBS(glutGetModifiers, [ glut freeglut ])
285     if test "x$enable_sdl" = "xyes"; then
286         AC_SEARCH_LIBS(SDL_Init, SDL)
287     fi
288     ;;
289
290 esac
291
292 opengl_LIBS="$LIBS"
293 LIBS="$base_LIBS $joystick_LIBS"
294
295 dnl check for OpenAL libraries
296 case "${host}" in
297 *-*-cygwin* | *-*-mingw32*)
298     dnl CygWin under Windoze.
299
300     AC_SEARCH_LIBS(alGenBuffers, openal32)
301     AC_SEARCH_LIBS(alutInit, [ openal32 ALut ] )
302     LIBS="$LIBS -ldsound -ldxguid -lole32"
303     openal_LIBS="$LIBS"
304     ;;
305
306 *-apple-darwin*)
307     dnl Mac OS X
308
309     LIBS="$LIBS -framework IOKit -framework OpenAL"
310     openal_LIBS="$LIBS"
311     ;;
312
313 *)
314     dnl default unix style machines
315
316     save_LIBS=$LIBS
317     LIBS="$LIBS $thread_LIBS"
318     AC_SEARCH_LIBS(alGenBuffers, openal)
319     AC_SEARCH_LIBS(alutInit, [ alut openal ] )
320     OPENAL_OK="$ac_cv_search_alGenBuffers"
321     openal_LIBS="$LIBS"
322     LIBS=$save_LIBS
323     ;;
324
325 esac
326
327 LIBS="$base_LIBS"
328
329 AC_SUBST(base_LIBS)
330 AC_SUBST(openal_LIBS)
331 AC_SUBST(opengl_LIBS)
332 AC_SUBST(thread_LIBS)
333 AC_SUBST(network_LIBS)
334 AC_SUBST(joystick_LIBS)
335
336 # The following are C++ items that need to be tested for with the c++
337 # compiler
338
339 AC_LANG_PUSH(C++)
340
341 # Check for "plib" without which we cannot go on
342 AC_CHECK_HEADER(plib/ul.h)
343 if test "x$ac_cv_header_plib_ul_h" != "xyes"; then
344     echo
345     echo "You *must* have the plib library installed on your system to build"
346     echo "the FGFS simulator!"
347     echo
348     echo "Please see README.plib for more details."
349     echo
350     echo "configure aborted."
351     exit
352 fi
353
354 AC_MSG_CHECKING([for plib 1.8.4 or newer])
355 AC_TRY_RUN([
356 #include <plib/ul.h>
357
358 #define MIN_PLIB_VERSION 184
359
360 int main() {
361     int major, minor, micro;
362
363     if ( PLIB_VERSION < MIN_PLIB_VERSION ) {
364          return -1;
365     }
366
367     return 0;
368 }
369
370 ],
371   AC_MSG_RESULT(yes),
372   [AC_MSG_RESULT(wrong version);
373    AC_MSG_ERROR([Install plib 1.8.4 or later first...])],
374   AC_MSG_RESULT(yes)
375 )
376
377 dnl If we get here then plib is available, so force use of plib
378 dnl joystick lib
379 AC_DEFINE([ENABLE_PLIB_JOYSTICK], 1, [Define to enable plib joystick support])
380
381
382 dnl Check for the presence of SimGear
383 if test "x$with_simgear" != "x"; then
384 AC_CHECK_HEADER($with_simgear/include/simgear/version.h, [ac_cv_header_simgear_version_h=yes], [ac_cv_header_simgear_version_h=no])
385 else
386 AC_CHECK_HEADER(simgear/version.h)
387 fi
388 if test "x$ac_cv_header_simgear_version_h" != "xyes"; then
389     echo
390     echo "You *must* have the SimGear support library installed on your system"
391     echo "to build the FGFS simulator!"
392     echo
393     echo "Please see README.SimGear for more details."
394     echo
395     echo "configure aborted."
396     exit
397 fi
398
399 AC_MSG_CHECKING([for simgear 0.3.9 or newer])
400 AC_TRY_RUN([
401 #include <stdio.h>
402
403 #include <simgear/version.h>
404
405 #define STRINGIFY(X) XSTRINGIFY(X)
406 #define XSTRINGIFY(X) #X
407
408 #define MIN_MAJOR 0
409 #define MIN_MINOR 3
410 #define MIN_MICRO 9
411
412 int main() {
413     int major, minor, micro;
414
415     /* printf("%d.%d.%d or greater, ", MIN_MAJOR, MIN_MINOR, MIN_MICRO); */
416     printf("[found %s] ... ", STRINGIFY(SIMGEAR_VERSION));
417
418     sscanf( STRINGIFY(SIMGEAR_VERSION), "%d.%d.%d", &major, &minor, &micro );
419
420     if ( (major < MIN_MAJOR) ||
421          (major == MIN_MAJOR && minor < MIN_MINOR) ||
422          (major == MIN_MAJOR && minor == MIN_MINOR && micro < MIN_MICRO) ) {
423          return -1;
424     }
425
426     return 0;
427 }
428
429 ],
430   AC_MSG_RESULT(yes),
431   [AC_MSG_RESULT(wrong version);
432    AC_MSG_ERROR([Install latest simgear first...])],
433   AC_MSG_RESULT(yes)
434 )
435
436 LIBS="$saved_LIBS"
437
438 dnl Check if SimGear was built with Norman's JPEG factory support
439 if test "x$with_simgear" != "x"; then
440 AC_CHECK_HEADER($with_simgear/include/simgear/screen/jpgfactory.hxx,[ac_cv_header_simgear_screen_jpgfactory_hxx=yes],[ac_cv_header_simgear_screen_jpgfactory_hxx=no])
441 else
442 AC_CHECK_HEADER(simgear/screen/jpgfactory.hxx)
443 fi
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 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 old_LIBS=$LIBS
494 LIBS="$base_LIBS $network_LIBS $opengl_LIBS"
495 AC_TYPE_SIGNAL
496 AC_FUNC_VPRINTF
497 AC_CHECK_FUNCS( [ \
498         ftime gettimeofday timegm memcpy bcopy mktime strstr rand mkfifo \
499         random drand48 setitimer getitimer signal GetLocalTime rint getrusage \
500         truncf ] )
501 LIBS=$old_LIBS
502
503 AM_CONFIG_HEADER(src/Include/config.h)
504
505 AC_CONFIG_FILES([ \
506         Makefile \
507         man/Makefile \
508         man/est-epsilon.1 \
509         man/fgfs.1 \
510         man/fgjs.1 \
511         man/gl-info.1 \
512         man/js_demo.1 \
513         man/pstest.1 \
514         scripts/Makefile \
515         scripts/debug/Makefile \
516         scripts/perl/Makefile \
517         scripts/perl/examples/Makefile \
518         scripts/python/Makefile \
519         src/Makefile \
520         src/Include/Makefile \
521         src/Include/version.h \
522         src/Include/config.h-msvc6 \
523         src/Aircraft/Makefile \
524         src/Airports/Makefile \
525         src/ATC/Makefile \
526         src/Autopilot/Makefile \
527         src/Cockpit/Makefile \
528         src/Cockpit/built_in/Makefile \
529         src/Environment/Makefile \
530         src/FDM/Balloon/Makefile \
531         src/FDM/ExternalNet/Makefile \
532         src/FDM/ExternalPipe/Makefile \
533         src/FDM/JSBSim/Makefile \
534         src/FDM/JSBSim/initialization/Makefile \
535         src/FDM/JSBSim/input_output/Makefile \
536         src/FDM/JSBSim/math/Makefile \
537         src/FDM/JSBSim/models/Makefile \
538         src/FDM/JSBSim/models/flight_control/Makefile \
539         src/FDM/JSBSim/models/atmosphere/Makefile \
540         src/FDM/JSBSim/models/propulsion/Makefile \
541         src/FDM/LaRCsim/Makefile \
542         src/FDM/SP/Makefile \
543         src/FDM/UIUCModel/Makefile \
544         src/FDM/YASim/Makefile \
545         src/FDM/Makefile \
546         src/GUI/Makefile \
547         src/Input/Makefile \
548         src/Instrumentation/Makefile \
549         src/Instrumentation/KLN89/Makefile \
550         src/Main/Makefile \
551         src/Main/runfgfs \
552         src/Main/runfgfs.bat \
553         src/Model/Makefile \
554         src/AIModel/Makefile \
555         src/MultiPlayer/Makefile \
556         src/Navaids/Makefile \
557         src/Network/Makefile \
558         src/Scenery/Makefile \
559         src/Scripting/Makefile \
560         src/Sound/Makefile \
561         src/Systems/Makefile \
562         src/Time/Makefile \
563         src/Traffic/Makefile \
564         tests/Makefile \
565         utils/Makefile \
566         utils/GPSsmooth/Makefile \
567         utils/js_server/Makefile \
568         utils/Modeller/Makefile \
569         utils/TerraSync/Makefile \
570         utils/xmlgrep/Makefile \
571 ])
572 AC_OUTPUT
573
574 AC_OUTPUT_COMMANDS([chmod 755 src/Main/runfgfs])
575
576 echo ""
577 echo "Configure Summary"
578 echo "================="
579
580 echo "Prefix: $prefix"
581
582 if test "x$with_logging" != "x"; then
583     echo "Debug messages: $with_logging"
584 else
585     echo "Debug messages: yes"
586 fi
587
588 echo -n "Automake version: "
589 automake --version | head -n 1
590
591 if test "x$with_multiplayer" != "xno"; then
592     echo "Building with multiplayer support"
593 fi
594
595 if test "x$with_threads" = "xyes"; then
596     echo "threads: yes"
597 else
598     echo "threads: no"
599 fi
600
601 if test "x$enable_sp_fdms" != "xno"; then
602     echo "Include special purpose flight models: yes"
603 else
604     echo "Include special purpose flight models: no"
605 fi
606