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