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