]> git.mxchange.org Git - simgear.git/blob - configure.ac
3e18ea0a179d8610f784d5a0d01cb4fac1473aa9
[simgear.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([simgear/bucket/newbucket.cxx])
6
7 dnl Require at least automake 2.52
8 AC_PREREQ(2.52)
9
10 dnl Initialize the automake stuff
11 AM_INIT_AUTOMAKE(SimGear, 1.9.1)
12
13 dnl Specify KAI C++ compiler and flags.
14 dnl Borrowed with slight modification from blitz distribution.
15 AC_ARG_WITH(cxx,
16   [  --with-cxx=COMPILER[:name-flags] set options for COMPILER (KCC)],
17   [case "$withval" in
18     KCC*)    # KAI C++ http://www.kai.com/
19       echo "Configuring for KAI C++"
20       AC_SG_SET_COMPILER($withval,"KCC","--restrict --strict_warnings")
21       CXX_OPTIMIZE_FLAGS=="+K3 -O3"
22       CXX_DEBUG_FLAGS="-g +K0"
23     ;;
24   esac
25 ])
26
27 AC_MSG_CHECKING([CXX])
28 AC_MSG_RESULT([$CXX])
29 AC_MSG_CHECKING([CC])
30 AC_MSG_RESULT([$CC])
31
32 dnl Checks for programs.
33 AC_PROG_MAKE_SET
34 AC_PROG_CC
35 AC_PROG_CPP
36 AC_PROG_CXX
37 AC_PROG_RANLIB
38 AC_PROG_INSTALL
39 AC_PROG_LN_S
40 AX_BOOST_BASE([1.37.0])
41
42 if test "x$BOOST_CPPFLAGS" != "x-I/usr/include" ; then
43    CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
44 fi
45
46 dnl set the $host variable based on local machine/os
47 AC_CANONICAL_HOST
48
49 dnl Used on the Irix platform
50 case "${host}" in
51 *-*-irix*)
52     if test "x$CXX" = "xCC" -o "x$CXX" = "xccache CC"; then
53         AR="$CXX -ar"
54         ARFLAGS="-o"
55         CXXFLAGS="$CXXFLAGS -I$(top_srcdir)/simgear/compatibility/MIPSpro740"
56         compatibility_DIR="compatibility"
57         MIPSpro_DIRS="MIPSpro740"
58         AC_MSG_CHECKING([for MIPSpro compiler version 7.4 or newer])
59         AC_TRY_RUN([
60            int main() {
61               if ( _COMPILER_VERSION < 740 ) {
62                  return -1;
63               }
64               return 0;
65            }
66
67         ], AC_MSG_RESULT(yes),
68         [  AC_MSG_RESULT(no)
69            CXXFLAGS="$CXXFLAGS -I$(top_srcdir)/simgear/compatibility/MIPSpro721"
70            MIPSpro_DIRS="$(MIPSpro_DIRS) MIPSpro721"
71            AC_MSG_WARN([Using our own subset of the STL headers])
72         ], AC_MSG_RESULT(yes))
73         AC_SUBST(MIPSpro_DIRS)
74     fi
75     ;;
76 *)
77     AR="ar"
78     ARFLAGS="cru"
79     compatibility_DIR=
80     ;;
81 esac
82 AC_SUBST(AR)
83 AC_SUBST(ARFLAGS)
84 AC_SUBST(compatibility_DIR)
85
86 if echo $includedir | egrep "simgear$" > /dev/null; then
87     echo "includedir is" $includedir "libdir is" $libdir
88 else
89     includedir="${includedir}/simgear"
90     echo "includedir changed to" $includedir "libdir is" $libdir
91 fi
92          
93 dnl set logging; default value of with_logging=yes
94 AC_ARG_WITH(logging, [  --with-logging          Include logging output (default)])
95 if test "x$with_logging" = "xno" ; then
96     AC_DEFINE([FG_NDEBUG], 1, [Define for no logging output])
97 fi
98
99 # Specify if we want to build with Norman's jpeg image server support.
100 # This requires libjpeg to be installed and available.
101 # Default to with_jpeg_server=no
102 JPEGLIB=''
103 AC_ARG_WITH(jpeg_factory, [  --with-jpeg-factory     Include Norman's jpeg image factory support code])
104 if test "x$with_jpeg_factory" = "xyes" ; then
105     echo "Building with Norman's jpeg image factory support"
106     AC_CHECK_LIB(jpeg, jpeg_start_compress)
107     if test "x$ac_cv_lib_jpeg_jpeg_start_compress" != "xyes" ; then
108         echo
109         echo "In order to build the jpeg factory code you need libjpeg installed."
110         echo "otherwise please configure with the --with-jpeg-sever=no option"
111         echo
112         echo "libjpeg is available at :"
113         echo "  ftp://ftp.uu.net in the directory graphics/jpeg"
114         exit 1
115     fi
116 else
117     echo "Building without Norman's jpeg image server support"
118 fi
119 AM_CONDITIONAL(ENABLE_JPEG_SERVER, test "x$with_jpeg_factory" = "xyes")
120
121 # specify the plib location
122 AC_ARG_WITH(plib, [  --with-plib=PREFIX      Specify the prefix path to plib])
123
124 if test "x$with_plib" != "x" ; then
125     echo "plib prefix is $with_plib"
126     EXTRA_DIRS="${EXTRA_DIRS} $with_plib"
127 fi
128
129 AC_ARG_WITH(plib_framework, [ --with-plib-framework=PREFIX      Specify the prefix path to PLIB.framework ])
130
131 if test "x$with_plib_framework" != "x"; then
132     echo "plib framework prefix is $with_plib_framework"
133 fi
134
135 # specify the osg location
136 AC_ARG_WITH(osg, [  --with-osg=PREFIX       Specify the prefix path to osg])
137
138 if test "x$with_osg" != "x" ; then
139     echo "osg prefix is $with_osg"
140     EXTRA_DIRS="${EXTRA_DIRS} $with_osg"
141 fi
142
143 AC_ARG_WITH(osg_framework, [ --with-osg-framework=PREFIX      Specify the prefix path to OSG.framework ])
144
145 if test "x$with_osg_framework" != "x"; then
146     echo "osg framework prefix is $with_osg_framework"
147 fi
148
149 dnl Determine an extra directories to add to include/lib search paths
150 case "${host}" in
151 *-apple-darwin* | *-*-cygwin* | *-*-mingw32*)
152     echo no EXTRA_DIRS for $host
153     ;;
154
155 *)
156     if test -d /usr/X11R6 ; then
157         EXTRA_DIR1="/usr/X11R6"
158     fi
159     if test -d /opt/X11R6 ; then
160         EXTRA_DIR2="/opt/X11R6"
161     fi
162     EXTRA_DIRS="${EXTRA_DIRS} $EXTRA_DIR1 $EXTRA_DIR2"
163     ;;
164
165 esac
166 wi_EXTRA_DIRS(no, ${EXTRA_DIRS})
167
168
169 dnl Using AM_CONDITIONAL is a step out of the protected little 
170 dnl automake fold so it is potentially dangerous.  But, we are
171 dnl beginning to run into cases where the standard checks are not
172 dnl enough.  AM_CONDITIONALS are then referenced to conditionally
173 dnl build a Makefile.in from a Makefile.am which lets us define custom
174 dnl includes, compile alternative source files, etc.
175
176 dnl X11 might be installed on Mac OS X or cygwin/mingwin, we don't want
177 dnl to use it if it is.
178 case "${host}" in
179 *-apple-darwin* | *-*-cygwin* | *-*-mingw32*)
180     echo no fancy X11 check
181     ;;
182
183 *)
184     AC_PATH_XTRA
185     ;;
186
187 esac
188
189 dnl Checks for libraries.
190
191 dnl Thread related checks
192 AC_CHECK_HEADER(pthread.h)
193 AC_SEARCH_LIBS(pthread_exit, [pthread c_r])
194 if test "x$ac_cv_header_pthread_h" = "xyes"; then
195     CXXFLAGS="$CXXFLAGS -D_REENTRANT"
196     CFLAGS="$CFLAGS -D_REENTRANT"
197
198   if test "x$ac_cv_search_pthread_exit" = "x-lc_r"; then
199     CXXFLAGS="-pthread $CXXFLAGS"
200     CFLAGS="-pthread $CFLAGS"
201   fi
202 fi
203
204 AM_CONDITIONAL(HAVE_THREADS, test "x$ac_cv_header_pthread_h" = "xyes")
205
206 thread_LIBS="$LIBS"
207 LIBS=""
208
209 dnl search for network related libraries
210 AC_SEARCH_LIBS(inet_addr, xnet)
211 AC_SEARCH_LIBS(socket, socket)
212
213 network_LIBS="$LIBS"
214 LIBS=""
215
216 dnl check for some default libraries
217 AC_SEARCH_LIBS(cos, m)
218
219 base_LIBS="$LIBS"
220
221 dnl check for OpenGL related libraries
222 case "${host}" in
223 *-*-cygwin* | *-*-mingw32*)
224     dnl CygWin under Windoze.
225
226     echo Win32 specific hacks...
227     AC_DEFINE([WIN32], 1, [Define for Win32 platforms])
228     AC_DEFINE([NOMINMAX], 1, [Define for Win32 platforms])
229
230     LIBS="$LIBS -lglu32 -lopengl32"
231     LIBS="$LIBS -luser32 -lgdi32 -lwinmm"
232
233     dnl add -lwsock32 for mingwin
234     case "${host}" in
235     *-*-mingw32*)
236         base_LIBS="$base_LIBS -lws2_32"
237         ;;
238     esac
239
240     echo "Will link apps with $LIBS"
241     ;;
242
243 *-apple-darwin*)
244     dnl Mac OS X
245
246     LIBS="$LIBS -framework OpenGL -framework Carbon -lobjc"
247     ;;
248
249 *)
250     dnl X-Windows based machines
251
252     AC_SEARCH_LIBS(XCreateWindow, X11)
253     AC_SEARCH_LIBS(XShmCreateImage, Xext)
254     AC_SEARCH_LIBS(XGetExtensionVersion, Xi)
255     AC_SEARCH_LIBS(IceOpenConnection, ICE)
256     AC_SEARCH_LIBS(SmcOpenConnection, SM)
257     AC_SEARCH_LIBS(XtMalloc, Xt)
258     AC_SEARCH_LIBS(XmuLookupStandardColormap, Xmu)
259     
260     AC_SEARCH_LIBS(glNewList, [ GL GLcore MesaGL ])
261     if test "x$ac_cv_search_glNewList" = "x-lGLcore"; then
262         dnl if GLcore found, then also check for GL
263         AC_SEARCH_LIBS(glXCreateContext, GL)
264     fi
265
266     dnl if using mesa, check for xmesa.h
267     if test "x$ac_cv_search_glNewList" = "x-lMesaGL"; then
268         AC_CHECK_HEADER(GL/fxmesa.h)
269         if test "x$ac_cv_header_GL_fxmesa_h" = "xyes"; then
270             AC_DEFINE([XMESA], 1, [Define for fxmesa])
271             AC_DEFINE([FX], 1, [Define for fxmesa])
272         fi
273     fi
274
275     AC_SEARCH_LIBS(gluLookAt, [ GLU MesaGLU ])
276     ;;
277
278 esac
279
280 AC_SEARCH_LIBS(glutGetModifiers, [ glut glut32 freeglut ], have_glut=yes, have_glut=no)
281 AM_CONDITIONAL(HAVE_GLUT, test "x$have_glut" = "xyes")
282
283 opengl_LIBS="$LIBS"
284 LIBS="$base_LIBS"
285
286 dnl check for OpenAL libraries
287 OPENAL_OK="no"
288 ALUT_OK="no"
289 case "${host}" in
290 *-*-cygwin* | *-*-mingw32*)
291     dnl CygWin under Windoze.
292     INCLUDES="$INCLUDES -I/usr/local/include/"
293     LIBS="$LIBS -L/usr/local/lib"
294     AC_SEARCH_LIBS(alGenBuffers, [ openal32 openal ] )
295     AC_SEARCH_LIBS(alutInit, [ openal32 ALut alut ] )
296     LIBS="$LIBS -lwinmm -ldsound -ldxguid -lole32"
297     openal_LIBS="$LIBS"
298     OPENAL_OK="$ac_cv_search_alGenBuffers"
299     ALUT_OK="$ac_cv_search_alutInit"
300     ;;
301
302 *-apple-darwin*)
303     dnl Mac OS X
304
305     LIBS="$LIBS -framework IOKit -framework OpenAL"
306     openal_LIBS="$LIBS"
307     # not sure how to test if OpenAL exists on MacOS (does it come by default?)
308     OPENAL_OK="yes"
309     ALUT_OK="yes"
310
311     dnl Thank you Christian Bauer from SheepSaver
312     dnl Modified by Tatsuhiro Nishioka for accepting a given framework path
313     dnl AC_CHECK_FRAMEWORK($1=NAME, $2=INCLUDES, $3=FRAMEWORK_PATH) ; $3 is optional
314     AC_DEFUN([AC_CHECK_FRAMEWORK], [
315     AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1])dnl
316     AC_CACHE_CHECK([whether compiler supports framework $1],
317         ac_Framework, [
318         saved_LIBS="$LIBS"
319         FRAMEWORKS="$FRAMEWORKS -framework $1"
320         if test "$3" = ""; then
321             FRAMEWORKS="$FRAMEWORKS $ADD2LD"
322         elif test "`echo $FRAMEWORKS | grep -- -F$3`" = ""; then
323             FRAMEWORKS="$FRAMEWORKS -F$3"
324             CXXFLAGS="$CXXFLAGS -F$3"
325             CCFLAGS="$CCFLAGS -F$3"
326             dnl This is needed for AC_TRY_LINK when a framework path is specified
327             export DYLD_FRAMEWORK_PATH="${DYLD_FRAMEWORK_PATH}:$3"
328         fi
329         AC_TRY_LINK(
330         [$2], [],
331         [AS_VAR_SET(ac_Framework, yes)], [AS_VAR_SET(ac_Framework, no); LIBS="$saved_LIBS"]
332         )
333     ])
334     AS_IF([test AS_VAR_GET(ac_Framework) = yes],
335         [AC_DEFINE(AS_TR_CPP(HAVE_FRAMEWORK_$1), 1, [Define if framework $1 is available.])]
336     )
337     AS_VAR_POPDEF([ac_Framework])dnl
338     ])
339
340     ;;
341
342 *)
343     dnl default unix style machines
344
345     save_LIBS=$LIBS
346     LIBS="$LIBS $thread_LIBS"
347     AC_SEARCH_LIBS(alGenBuffers, openal)
348     AC_SEARCH_LIBS(alutInit, [ alut openal ] )
349     OPENAL_OK="$ac_cv_search_alGenBuffers"
350     ALUT_OK="$ac_cv_search_alutInit"
351     openal_LIBS="$LIBS"
352     LIBS=$save_LIBS
353     ;;
354
355 esac
356
357 if test "$OPENAL_OK" == "no"; then
358     echo
359     echo "You *must* have the openal library installed on your system to build"
360     echo "SimGear!"
361     echo
362     echo "Please see README.OpenAL for more details."
363     echo
364     echo "configure aborted."
365     exit
366 fi
367
368 if test "$ALUT_OK" == "no"; then
369     echo
370     echo "You *must* have the alut library installed on your system to build"
371     echo "SimGear!"
372     echo
373     echo "Please see README.OpenAL for more details."
374     echo
375     echo "configure aborted."
376     exit
377 fi
378
379
380
381 LIBS="$base_LIBS"
382
383 AC_SUBST(base_LIBS)
384 AC_SUBST(openal_LIBS)
385 AC_SUBST(opengl_LIBS)
386 AC_SUBST(thread_LIBS)
387 AC_SUBST(network_LIBS)
388
389 dnl Check for MS Windows environment
390 AC_CHECK_HEADER(windows.h)
391 AM_CONDITIONAL(EXTGL_NEEDED, test "x$ac_cv_header_windows_h" = "xyes")
392
393 # The following are C++ items that need to be tested for with the c++
394 # compiler
395
396 CXXCPP="g++ -E"
397 AC_LANG_PUSH(C++)
398
399 dnl Check for "plib" without which we cannot go on
400 case ${host} in 
401 *-apple-darwin*)
402     # Check PLIB framework availability when with-plib-framework is specified 
403     if test "x$with_plib_framework" != "x"; then
404         AC_CHECK_FRAMEWORK(PLIB, [#include <plib/ul.h>], $with_plib_framework)
405         plib_FRAMEWORK="$FRAMEWORKS"
406         FRAMEWORKS=""
407         AC_SUBST(plib_FRAMEWORK)
408     fi
409     ;;
410 esac
411 AM_CONDITIONAL(HAVE_FRAMEWORK_PLIB, test "x$ac_cv_framework_PLIB" != "x")
412
413 AC_CHECK_HEADER(plib/ul.h)
414 if test "x$ac_cv_header_plib_ul_h" != "xyes"; then
415     echo
416     echo "You *must* have the plib library installed on your system to build"
417     echo "SimGear!"
418     echo
419     echo "Please see README.plib for more details."
420     echo
421     echo "configure aborted."
422     exit
423 fi
424
425 AC_MSG_CHECKING([for plib 1.8.5 or newer])
426 AC_TRY_RUN([
427 #include <plib/ul.h>
428
429 #define MIN_PLIB_VERSION 185
430
431 int main() {
432     int major, minor, micro;
433
434     if ( PLIB_VERSION < MIN_PLIB_VERSION ) {
435          return -1;
436     }
437
438     return 0;
439 }
440
441 ],
442   AC_MSG_RESULT(yes),
443   [AC_MSG_RESULT(wrong version);
444    AC_MSG_ERROR([Install plib 1.8.5 or later first...])],
445   AC_MSG_RESULT(yes)
446 )
447
448 LIBS="$saved_LIBS"
449
450 # OpenSceneGraph
451 case "${host}" in
452 *-apple-darwin*)
453     if test "x$with_osg_framework" != "x"; then
454         AC_CHECK_FRAMEWORK(osgViewer, [#include <osgViewer/Version>], $with_osg_framework)
455         AC_CHECK_FRAMEWORK(osgGA, [#include <osgGA/Version>], $with_osg_framework)
456         AC_CHECK_FRAMEWORK(osgText, [#include <osgText/Version>], $with_osg_framework)
457         AC_CHECK_FRAMEWORK(osgFX, [#include <osgFX/AnisotropicLighting>], $with_osg_framework)
458         AC_CHECK_FRAMEWORK(osgUtil, [#include <osgUtil/Version>], $with_osg_framework)
459         AC_CHECK_FRAMEWORK(osgDB, [#include <osgDB/Version>], $with_osg_framework)
460         AC_CHECK_FRAMEWORK(osgSim, [#include <osgSim/Version>], $with_osg_framework)
461         AC_CHECK_FRAMEWORK(osgParticle, [#include <osgParticle/Version>], $with_osg_framework)
462         AC_CHECK_FRAMEWORK(osg, [#include <osg/Version>], $with_osg_framework)
463         osg_FRAMEWORKS="$FRAMEWORKS"
464         FRAMEWORKS=""
465         AC_SUBST(osg_FRAMEWORKS)
466         AC_CHECK_FRAMEWORK(OpenThreads, [#include <OpenThreads/Version>], $with_osg_framework)
467         openthreads_FRAMEWORK="$FRAMEWORKS"
468         FRAMEWORKS=""
469         AC_SUBST(openthreads_FRAMEWORK)
470     else
471         dnl
472         dnl This is needed when osg dynamic libs are specified 
473         dnl instead of OSG frameworks on Mac OS X
474         dnl
475         LDFLAGS="$LDFLAGS -L$with_osg"
476     fi
477     ;;
478 esac
479 AM_CONDITIONAL(HAVE_FRAMEWORK_OSG, test "x$ac_cv_framework_osg" != "x")
480
481 AC_CHECK_HEADER(osg/Version)
482 if test "x$ac_cv_header_osg_Version" != "xyes"; then
483   if test "x$ac_cv_framework_osg" != "xyes"; then
484     echo
485     echo "You *must* have the OpenSceneGraph support library installed on your system"
486     echo "to build this version of SimGear!"
487     echo
488     echo "Please see README.OSG for more details."
489     echo
490     echo "configure aborted."
491     exit
492   fi
493 fi
494
495 AC_CHECK_HEADER(boost/version.hpp)
496 if test "x$ac_cv_header_boost_version_hpp" != "xyes"; then
497     echo
498     echo "You *must* have the Boost library installed on your system"
499     echo "to build this version of SimGear!"
500     echo
501     echo "configure aborted."
502     exit
503 fi
504
505 AC_LANG_POP
506
507 dnl Check for system installed zlib
508 AC_CHECK_HEADER(zlib.h)
509 if test "x$ac_cv_header_zlib_h" != "xyes"; then
510     echo
511     echo "zlib library not found."
512     echo
513     echo "If your OS does not provide an installable package for zlib"
514     echo "you will have to compile and install it first yourself.  A copy"
515     echo "of zlib-1.1.4.tar.gz is included with SimGear.  You will"
516     echo "have to untar this source code, and follow its included instructions"
517     echo "to compile and install on your system."
518     echo
519     echo "configure aborted."
520     echo
521 fi
522
523 dnl Checks for header files.
524 AC_HEADER_STDC
525 AC_CHECK_HEADERS( \
526         fcntl.h getopt.h malloc.h memory.h stdint.h stdlib.h sys/param.h \
527         sys/stat.h sys/time.h sys/timeb.h unistd.h values.h )
528
529 if test "x$ac_cv_header_stdint_h" = "xyes"; then
530     AC_DEFINE([HAVE_STDINT_H], 1, [Define if stdint.h exists])
531 fi
532
533 dnl Checks for typedefs, structures, and compiler characteristics.
534 AC_C_CONST
535 AC_TYPE_SIZE_T
536 AC_TYPE_MODE_T
537 AC_HEADER_TIME
538 AC_STRUCT_TM
539
540 dnl Checks for library functions.
541 old_LIBS=$LIBS
542 LIBS="$base_LIBS $network_LIBS $opengl_LIBS"
543 AC_TYPE_SIGNAL
544 AC_FUNC_VPRINTF
545 AC_CHECK_FUNCS( [ \
546         ftime gettimeofday timegm memcpy bcopy mktime strstr rand \
547         random drand48 setitimer getitimer signal GetLocalTime rint getrusage ] )
548 LIBS=$old_LIBS
549
550 AM_CONFIG_HEADER(simgear/simgear_config.h)
551
552 AC_CONFIG_FILES([ \
553         Makefile \
554         SimGear.spec \
555         simgear/Makefile \
556         simgear/version.h \
557         simgear/compatibility/Makefile \
558         simgear/compatibility/MIPSpro721/Makefile \
559         simgear/compatibility/MIPSpro740/Makefile \
560         simgear/bucket/Makefile \
561         simgear/debug/Makefile \
562         simgear/ephemeris/Makefile \
563         simgear/io/Makefile \
564         simgear/magvar/Makefile \
565         simgear/math/Makefile \
566         simgear/environment/Makefile \
567         simgear/misc/Makefile \
568         simgear/nasal/Makefile \
569         simgear/props/Makefile \
570         simgear/route/Makefile \
571         simgear/scene/Makefile \
572         simgear/scene/bvh/Makefile \
573         simgear/scene/material/Makefile \
574         simgear/scene/model/Makefile \
575         simgear/scene/sky/Makefile \
576         simgear/scene/tgdb/Makefile \
577         simgear/scene/util/Makefile \
578         simgear/screen/Makefile \
579         simgear/serial/Makefile \
580         simgear/sound/Makefile \
581         simgear/structure/Makefile \
582         simgear/threads/Makefile \
583         simgear/timing/Makefile \
584         simgear/xml/Makefile \
585 ])
586 AC_OUTPUT
587
588
589 echo ""
590 echo "Configure Summary"
591 echo "================="
592
593 echo "Prefix: $prefix"
594
595 if test "x$with_logging" != "x"; then
596     echo "Debug messages: $with_logging"
597 else
598     echo "Debug messages: yes"
599 fi
600
601 echo -n "Automake version: "
602 automake --version | head -1
603
604 if test "x$with_jpeg_factory" = "xyes"; then
605    echo "With JPEG Factory support"
606 else
607    echo "Without JPEG Factory support"
608 fi
609
610 if test "x$ac_cv_header_pthread_h" = "xyes"; then
611    echo "Threads: pthread lib found."
612 else
613    echo "Threads: no threads (pthread lib not found.)"
614 fi
615