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