]> git.mxchange.org Git - simgear.git/blob - configure.ac
Geoff McLane:
[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.34.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 # specify the osg location
130 AC_ARG_WITH(osg, [  --with-osg=PREFIX       Specify the prefix path to osg])
131
132 if test "x$with_osg" != "x" ; then
133     echo "osg prefix is $with_osg"
134     EXTRA_DIRS="${EXTRA_DIRS} $with_osg"
135 fi
136
137 dnl Determine an extra directories to add to include/lib search paths
138 case "${host}" in
139 *-apple-darwin* | *-*-cygwin* | *-*-mingw32*)
140     echo no EXTRA_DIRS for $host
141     ;;
142
143 *)
144     if test -d /usr/X11R6 ; then
145         EXTRA_DIR1="/usr/X11R6"
146     fi
147     if test -d /opt/X11R6 ; then
148         EXTRA_DIR2="/opt/X11R6"
149     fi
150     EXTRA_DIRS="${EXTRA_DIRS} $EXTRA_DIR1 $EXTRA_DIR2"
151     ;;
152
153 esac
154 wi_EXTRA_DIRS(no, ${EXTRA_DIRS})
155
156
157 dnl Using AM_CONDITIONAL is a step out of the protected little 
158 dnl automake fold so it is potentially dangerous.  But, we are
159 dnl beginning to run into cases where the standard checks are not
160 dnl enough.  AM_CONDITIONALS are then referenced to conditionally
161 dnl build a Makefile.in from a Makefile.am which lets us define custom
162 dnl includes, compile alternative source files, etc.
163
164 dnl X11 might be installed on Mac OS X or cygwin/mingwin, we don't want
165 dnl to use it if it is.
166 case "${host}" in
167 *-apple-darwin* | *-*-cygwin* | *-*-mingw32*)
168     echo no fancy X11 check
169     ;;
170
171 *)
172     AC_PATH_XTRA
173     ;;
174
175 esac
176
177 dnl Checks for libraries.
178
179 dnl Thread related checks
180 AC_CHECK_HEADER(pthread.h)
181 AC_SEARCH_LIBS(pthread_exit, [pthread c_r])
182 if test "x$ac_cv_header_pthread_h" = "xyes"; then
183     CXXFLAGS="$CXXFLAGS -D_REENTRANT"
184     CFLAGS="$CFLAGS -D_REENTRANT"
185
186   if test "x$ac_cv_search_pthread_exit" = "x-lc_r"; then
187     CXXFLAGS="-pthread $CXXFLAGS"
188     CFLAGS="-pthread $CFLAGS"
189   fi
190 fi
191
192 AM_CONDITIONAL(HAVE_THREADS, test "x$ac_cv_header_pthread_h" = "xyes")
193
194 thread_LIBS="$LIBS"
195 LIBS=""
196
197 dnl search for network related libraries
198 AC_SEARCH_LIBS(inet_addr, xnet)
199 AC_SEARCH_LIBS(socket, socket)
200
201 network_LIBS="$LIBS"
202 LIBS=""
203
204 dnl check for some default libraries
205 AC_SEARCH_LIBS(cos, m)
206
207 base_LIBS="$LIBS"
208
209 dnl check for OpenGL related libraries
210 case "${host}" in
211 *-*-cygwin* | *-*-mingw32*)
212     dnl CygWin under Windoze.
213
214     echo Win32 specific hacks...
215     AC_DEFINE([WIN32], 1, [Define for Win32 platforms])
216     AC_DEFINE([NOMINMAX], 1, [Define for Win32 platforms])
217
218     LIBS="$LIBS -lglu32 -lopengl32"
219     LIBS="$LIBS -luser32 -lgdi32 -lwinmm"
220
221     dnl add -lwsock32 for mingwin
222     case "${host}" in
223     *-*-mingw32*)
224         base_LIBS="$base_LIBS -lws2_32"
225         ;;
226     esac
227
228     echo "Will link apps with $LIBS"
229     ;;
230
231 *-apple-darwin*)
232     dnl Mac OS X
233
234     LIBS="$LIBS -framework OpenGL -framework Carbon -lobjc"
235     ;;
236
237 *)
238     dnl X-Windows based machines
239
240     AC_SEARCH_LIBS(XCreateWindow, X11)
241     AC_SEARCH_LIBS(XShmCreateImage, Xext)
242     AC_SEARCH_LIBS(XGetExtensionVersion, Xi)
243     AC_SEARCH_LIBS(IceOpenConnection, ICE)
244     AC_SEARCH_LIBS(SmcOpenConnection, SM)
245     AC_SEARCH_LIBS(XtMalloc, Xt)
246     AC_SEARCH_LIBS(XmuLookupStandardColormap, Xmu)
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     ;;
265
266 esac
267
268 AC_SEARCH_LIBS(glutGetModifiers, [ glut glut32 freeglut ], have_glut=yes, have_glut=no)
269 AM_CONDITIONAL(HAVE_GLUT, test "x$have_glut" = "xyes")
270
271 opengl_LIBS="$LIBS"
272 LIBS="$base_LIBS"
273
274 dnl check for OpenAL libraries
275 OPENAL_OK="no"
276 ALUT_OK="no"
277 case "${host}" in
278 *-*-cygwin* | *-*-mingw32*)
279     dnl CygWin under Windoze.
280     INCLUDES="$INCLUDES -I/usr/local/include/"
281     LIBS="$LIBS -L/usr/local/lib"
282     AC_SEARCH_LIBS(alGenBuffers, [ openal32 openal ] )
283     AC_SEARCH_LIBS(alutInit, [ openal32 ALut alut ] )
284     LIBS="$LIBS -lwinmm -ldsound -ldxguid -lole32"
285     openal_LIBS="$LIBS"
286     OPENAL_OK="$ac_cv_search_alGenBuffers"
287     ALUT_OK="$ac_cv_search_alutInit"
288     ;;
289
290 *-apple-darwin*)
291     dnl Mac OS X
292
293     LIBS="$LIBS -framework IOKit -framework OpenAL"
294     openal_LIBS="$LIBS"
295     # not sure how to test if OpenAL exists on MacOS (does it come by default?)
296     OPENAL_OK="yes"
297     ALUT_OK="yes"
298     ;;
299
300 *)
301     dnl default unix style machines
302
303     save_LIBS=$LIBS
304     LIBS="$LIBS $thread_LIBS"
305     AC_SEARCH_LIBS(alGenBuffers, openal)
306     AC_SEARCH_LIBS(alutInit, [ alut openal ] )
307     OPENAL_OK="$ac_cv_search_alGenBuffers"
308     ALUT_OK="$ac_cv_search_alutInit"
309     openal_LIBS="$LIBS"
310     LIBS=$save_LIBS
311     ;;
312
313 esac
314
315 if test "$OPENAL_OK" == "no"; then
316     echo
317     echo "You *must* have the openal library installed on your system to build"
318     echo "SimGear!"
319     echo
320     echo "Please see README.OpenAL for more details."
321     echo
322     echo "configure aborted."
323     exit
324 fi
325
326 if test "$ALUT_OK" == "no"; then
327     echo
328     echo "You *must* have the alut library installed on your system to build"
329     echo "SimGear!"
330     echo
331     echo "Please see README.OpenAL for more details."
332     echo
333     echo "configure aborted."
334     exit
335 fi
336
337
338
339 LIBS="$base_LIBS"
340
341 AC_SUBST(base_LIBS)
342 AC_SUBST(openal_LIBS)
343 AC_SUBST(opengl_LIBS)
344 AC_SUBST(thread_LIBS)
345 AC_SUBST(network_LIBS)
346
347 dnl Check for MS Windows environment
348 AC_CHECK_HEADER(windows.h)
349 AM_CONDITIONAL(EXTGL_NEEDED, test "x$ac_cv_header_windows_h" = "xyes")
350
351 # The following are C++ items that need to be tested for with the c++
352 # compiler
353
354 AC_LANG_PUSH(C++)
355
356 dnl Check for "plib" without which we cannot go on
357 AC_CHECK_HEADER(plib/ul.h)
358 if test "x$ac_cv_header_plib_ul_h" != "xyes"; then
359     echo
360     echo "You *must* have the plib library installed on your system to build"
361     echo "SimGear!"
362     echo
363     echo "Please see README.plib for more details."
364     echo
365     echo "configure aborted."
366     exit
367 fi
368
369 AC_MSG_CHECKING([for plib 1.8.5 or newer])
370 AC_TRY_RUN([
371 #include <plib/ul.h>
372
373 #define MIN_PLIB_VERSION 185
374
375 int main() {
376     int major, minor, micro;
377
378     if ( PLIB_VERSION < MIN_PLIB_VERSION ) {
379          return -1;
380     }
381
382     return 0;
383 }
384
385 ],
386   AC_MSG_RESULT(yes),
387   [AC_MSG_RESULT(wrong version);
388    AC_MSG_ERROR([Install plib 1.8.5 or later first...])],
389   AC_MSG_RESULT(yes)
390 )
391
392 LIBS="$saved_LIBS"
393
394 AC_CHECK_HEADER(osg/Version)
395 if test "x$ac_cv_header_osg_Version" != "xyes"; then
396     echo
397     echo "You *must* have the OpenSceneGraph support library installed on your system"
398     echo "to build this version of SimGear!"
399     echo
400     echo "Please see README.OSG for more details."
401     echo
402     echo "configure aborted."
403     exit
404 fi
405
406 AC_CHECK_HEADER(boost/version.hpp)
407 if test "x$ac_cv_header_boost_version_hpp" != "xyes"; then
408     echo
409     echo "You *must* have the Boost library installed on your system"
410     echo "to build this version of SimGear!"
411     echo
412     echo "configure aborted."
413     exit
414 fi
415
416 AC_LANG_POP
417
418 dnl Check for system installed zlib
419 AC_CHECK_HEADER(zlib.h)
420 if test "x$ac_cv_header_zlib_h" != "xyes"; then
421     echo
422     echo "zlib library not found."
423     echo
424     echo "If your OS does not provide an installable package for zlib"
425     echo "you will have to compile and install it first yourself.  A copy"
426     echo "of zlib-1.1.4.tar.gz is included with SimGear.  You will"
427     echo "have to untar this source code, and follow its included instructions"
428     echo "to compile and install on your system."
429     echo
430     echo "configure aborted."
431     echo
432 fi
433
434 dnl Checks for header files.
435 AC_HEADER_STDC
436 AC_CHECK_HEADERS( \
437         fcntl.h getopt.h malloc.h memory.h stdint.h stdlib.h sys/param.h \
438         sys/stat.h sys/time.h sys/timeb.h unistd.h values.h )
439
440 if test "x$ac_cv_header_stdint_h" = "xyes"; then
441     AC_DEFINE([HAVE_STDINT_H], 1, [Define if stdint.h exists])
442 fi
443
444 dnl Checks for typedefs, structures, and compiler characteristics.
445 AC_C_CONST
446 AC_TYPE_SIZE_T
447 AC_TYPE_MODE_T
448 AC_HEADER_TIME
449 AC_STRUCT_TM
450
451 dnl Checks for library functions.
452 old_LIBS=$LIBS
453 LIBS="$base_LIBS $network_LIBS $opengl_LIBS"
454 AC_TYPE_SIGNAL
455 AC_FUNC_VPRINTF
456 AC_CHECK_FUNCS( [ \
457         ftime gettimeofday timegm memcpy bcopy mktime strstr rand \
458         random drand48 setitimer getitimer signal GetLocalTime rint getrusage ] )
459 LIBS=$old_LIBS
460
461 AM_CONFIG_HEADER(simgear/simgear_config.h)
462
463 AC_CONFIG_FILES([ \
464         Makefile \
465         SimGear.spec \
466         simgear/Makefile \
467         simgear/version.h \
468         simgear/compatibility/Makefile \
469         simgear/compatibility/MIPSpro721/Makefile \
470         simgear/compatibility/MIPSpro740/Makefile \
471         simgear/bucket/Makefile \
472         simgear/debug/Makefile \
473         simgear/ephemeris/Makefile \
474         simgear/io/Makefile \
475         simgear/magvar/Makefile \
476         simgear/math/Makefile \
477         simgear/environment/Makefile \
478         simgear/misc/Makefile \
479         simgear/nasal/Makefile \
480         simgear/props/Makefile \
481         simgear/route/Makefile \
482         simgear/scene/Makefile \
483         simgear/scene/bvh/Makefile \
484         simgear/scene/material/Makefile \
485         simgear/scene/model/Makefile \
486         simgear/scene/sky/Makefile \
487         simgear/scene/tgdb/Makefile \
488         simgear/scene/util/Makefile \
489         simgear/screen/Makefile \
490         simgear/serial/Makefile \
491         simgear/sound/Makefile \
492         simgear/structure/Makefile \
493         simgear/threads/Makefile \
494         simgear/timing/Makefile \
495         simgear/xml/Makefile \
496 ])
497 AC_OUTPUT
498
499
500 echo ""
501 echo "Configure Summary"
502 echo "================="
503
504 echo "Prefix: $prefix"
505
506 if test "x$with_logging" != "x"; then
507     echo "Debug messages: $with_logging"
508 else
509     echo "Debug messages: yes"
510 fi
511
512 echo -n "Automake version: "
513 automake --version | head -1
514
515 if test "x$with_jpeg_factory" = "xyes"; then
516    echo "With JPEG Factory support"
517 else
518    echo "Without JPEG Factory support"
519 fi
520
521 if test "x$ac_cv_header_pthread_h" = "xyes"; then
522    echo "Threads: pthread lib found."
523 else
524    echo "Threads: no threads (pthread lib not found.)"
525 fi
526