]> git.mxchange.org Git - simgear.git/blob - configure.ac
Fix a problem in loading models with paged LOD in some circunstances ( debug with...
[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, 0.3.10)
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
41 dnl set the $host variable based on local machine/os
42 AC_CANONICAL_HOST
43
44 dnl Used on the Irix platform
45 case "${host}" in
46 *-*-irix*)
47     if test "x$CXX" = "xCC" -o "x$CXX" = "xccache CC"; then
48         AR="$CXX -ar"
49         ARFLAGS="-o"
50         CXXFLAGS="$CXXFLAGS -I$(top_srcdir)/simgear/compatibility/MIPSpro740"
51         compatibility_DIR="compatibility"
52         MIPSpro_DIRS="MIPSpro740"
53         AC_MSG_CHECKING([for MIPSpro compiler version 7.4 or newer])
54         AC_TRY_RUN([
55            int main() {
56               if ( _COMPILER_VERSION < 740 ) {
57                  return -1;
58               }
59               return 0;
60            }
61
62         ], AC_MSG_RESULT(yes),
63         [  AC_MSG_RESULT(no)
64            CXXFLAGS="$CXXFLAGS -I$(top_srcdir)/simgear/compatibility/MIPSpro721"
65            MIPSpro_DIRS="$(MIPSpro_DIRS) MIPSpro721"
66            AC_MSG_WARN([Using our own subset of the STL headers])
67         ], AC_MSG_RESULT(yes))
68         AC_SUBST(MIPSpro_DIRS)
69     fi
70     ;;
71 *)
72     AR="ar"
73     ARFLAGS="cru"
74     compatibility_DIR=
75     ;;
76 esac
77 AC_SUBST(AR)
78 AC_SUBST(ARFLAGS)
79 AC_SUBST(compatibility_DIR)
80
81 if echo $includedir | egrep "simgear$" > /dev/null; then
82     echo "includedir is" $includedir "libdir is" $libdir
83 else
84     includedir="${includedir}/simgear"
85     echo "includedir changed to" $includedir "libdir is" $libdir
86 fi
87          
88 dnl set logging; default value of with_logging=yes
89 AC_ARG_WITH(logging, [  --with-logging          Include logging output (default)])
90 if test "x$with_logging" = "xno" ; then
91     AC_DEFINE([FG_NDEBUG], 1, [Define for no logging output])
92 fi
93
94 # Specify if we want to build with Norman's jpeg image server support.
95 # This requires libjpeg to be installed and available.
96 # Default to with_jpeg_server=no
97 JPEGLIB=''
98 AC_ARG_WITH(jpeg_factory, [  --with-jpeg-factory     Include Norman's jpeg image factory support code])
99 if test "x$with_jpeg_factory" = "xyes" ; then
100     echo "Building with Norman's jpeg image factory support"
101     AC_CHECK_LIB(jpeg, jpeg_start_compress)
102     if test "x$ac_cv_lib_jpeg_jpeg_start_compress" != "xyes" ; then
103         echo
104         echo "In order to build the jpeg factory code you need libjpeg installed."
105         echo "otherwise please configure with the --with-jpeg-sever=no option"
106         echo
107         echo "libjpeg is available at :"
108         echo "  ftp://ftp.uu.net in the directory graphics/jpeg"
109         exit 1
110     fi
111 else
112     echo "Building without Norman's jpeg image server support"
113 fi
114 AM_CONDITIONAL(ENABLE_JPEG_SERVER, test "x$with_jpeg_factory" = "xyes")
115
116 # specify the plib location
117 AC_ARG_WITH(plib, [  --with-plib=PREFIX      Specify the prefix path to plib])
118
119 if test "x$with_plib" != "x" ; then
120     echo "plib prefix is $with_plib"
121     EXTRA_DIRS="${EXTRA_DIRS} $with_plib"
122 fi
123
124 # specify the osg location
125 AC_ARG_WITH(osg, [  --with-osg=PREFIX       Specify the prefix path to osg])
126
127 if test "x$with_osg" != "x" ; then
128     echo "osg prefix is $with_osg"
129     EXTRA_DIRS="${EXTRA_DIRS} $with_osg"
130 fi
131
132 dnl Determine an extra directories to add to include/lib search paths
133 case "${host}" in
134 *-apple-darwin* | *-*-cygwin* | *-*-mingw32*)
135     echo no EXTRA_DIRS for $host
136     ;;
137
138 *)
139     if test -d /usr/X11R6 ; then
140         EXTRA_DIR1="/usr/X11R6"
141     fi
142     if test -d /opt/X11R6 ; then
143         EXTRA_DIR2="/opt/X11R6"
144     fi
145     EXTRA_DIRS="${EXTRA_DIRS} $EXTRA_DIR1 $EXTRA_DIR2"
146     ;;
147
148 esac
149 wi_EXTRA_DIRS(no, ${EXTRA_DIRS})
150
151
152 dnl Using AM_CONDITIONAL is a step out of the protected little 
153 dnl automake fold so it is potentially dangerous.  But, we are
154 dnl beginning to run into cases where the standard checks are not
155 dnl enough.  AM_CONDITIONALS are then referenced to conditionally
156 dnl build a Makefile.in from a Makefile.am which lets us define custom
157 dnl includes, compile alternative source files, etc.
158
159 dnl X11 might be installed on Mac OS X or cygwin/mingwin, we don't want
160 dnl to use it if it is.
161 case "${host}" in
162 *-apple-darwin* | *-*-cygwin* | *-*-mingw32*)
163     echo no fancy X11 check
164     ;;
165
166 *)
167     AC_PATH_XTRA
168     ;;
169
170 esac
171
172 dnl Checks for libraries.
173
174 dnl Thread related checks
175 AC_CHECK_HEADER(pthread.h)
176 AC_SEARCH_LIBS(pthread_exit, [pthread c_r])
177 if test "x$ac_cv_header_pthread_h" = "xyes"; then
178     CXXFLAGS="$CXXFLAGS -D_REENTRANT"
179     CFLAGS="$CFLAGS -D_REENTRANT"
180
181   if test "x$ac_cv_search_pthread_exit" = "x-lc_r"; then
182     CXXFLAGS="-pthread $CXXFLAGS"
183     CFLAGS="-pthread $CFLAGS"
184   fi
185 fi
186
187 AM_CONDITIONAL(HAVE_THREADS, test "x$ac_cv_header_pthread_h" = "xyes")
188
189 thread_LIBS="$LIBS"
190 LIBS=""
191
192 dnl search for network related libraries
193 AC_SEARCH_LIBS(inet_addr, xnet)
194 AC_SEARCH_LIBS(socket, socket)
195
196 network_LIBS="$LIBS"
197 LIBS=""
198
199 dnl check for some default libraries
200 AC_SEARCH_LIBS(cos, m)
201
202 base_LIBS="$LIBS"
203
204 dnl check for OpenGL related libraries
205 case "${host}" in
206 *-*-cygwin* | *-*-mingw32*)
207     dnl CygWin under Windoze.
208
209     echo Win32 specific hacks...
210     AC_DEFINE([WIN32], 1, [Define for Win32 platforms])
211     AC_DEFINE([NOMINMAX], 1, [Define for Win32 platforms])
212
213     LIBS="$LIBS -lglu32 -lopengl32"
214     LIBS="$LIBS -luser32 -lgdi32 -lwinmm"
215
216     dnl add -lwsock32 for mingwin
217     case "${host}" in
218     *-*-mingw32*)
219         base_LIBS="$base_LIBS -lws2_32"
220         ;;
221     esac
222
223     echo "Will link apps with $LIBS"
224     ;;
225
226 *-apple-darwin*)
227     dnl Mac OS X
228
229     LIBS="$LIBS -framework OpenGL -framework Carbon -lobjc"
230     ;;
231
232 *)
233     dnl X-Windows based machines
234
235     AC_SEARCH_LIBS(XCreateWindow, X11)
236     AC_SEARCH_LIBS(XShmCreateImage, Xext)
237     AC_SEARCH_LIBS(XGetExtensionVersion, Xi)
238     AC_SEARCH_LIBS(IceOpenConnection, ICE)
239     AC_SEARCH_LIBS(SmcOpenConnection, SM)
240     AC_SEARCH_LIBS(XtMalloc, Xt)
241     AC_SEARCH_LIBS(XmuLookupStandardColormap, Xmu)
242     
243     AC_SEARCH_LIBS(glNewList, [ GL GLcore MesaGL ])
244     if test "x$ac_cv_search_glNewList" = "x-lGLcore"; then
245         dnl if GLcore found, then also check for GL
246         AC_SEARCH_LIBS(glXCreateContext, GL)
247     fi
248
249     dnl if using mesa, check for xmesa.h
250     if test "x$ac_cv_search_glNewList" = "x-lMesaGL"; then
251         AC_CHECK_HEADER(GL/fxmesa.h)
252         if test "x$ac_cv_header_GL_fxmesa_h" = "xyes"; then
253             AC_DEFINE([XMESA], 1, [Define for fxmesa])
254             AC_DEFINE([FX], 1, [Define for fxmesa])
255         fi
256     fi
257
258     AC_SEARCH_LIBS(gluLookAt, [ GLU MesaGLU ])
259     ;;
260
261 esac
262
263 AC_SEARCH_LIBS(glutGetModifiers, [ glut glut32 freeglut ], have_glut=yes, have_glut=no)
264 AM_CONDITIONAL(HAVE_GLUT, test "x$have_glut" = "xyes")
265
266 opengl_LIBS="$LIBS"
267 LIBS="$base_LIBS"
268
269 dnl check for OpenAL libraries
270 OPENAL_OK="no"
271 ALUT_OK="no"
272 case "${host}" in
273 *-*-cygwin* | *-*-mingw32*)
274     dnl CygWin under Windoze.
275     INCLUDES="$INCLUDES -I/usr/local/include/"
276     LIBS="$LIBS -L/usr/local/lib"
277     AC_SEARCH_LIBS(alGenBuffers, [ openal32 openal ] )
278     AC_SEARCH_LIBS(alutInit, [ openal32 ALut alut ] )
279     LIBS="$LIBS -lwinmm -ldsound -ldxguid -lole32"
280     openal_LIBS="$LIBS"
281     OPENAL_OK="$ac_cv_search_alGenBuffers"
282     ALUT_OK="$ac_cv_search_alutInit"
283     ;;
284
285 *-apple-darwin*)
286     dnl Mac OS X
287
288     LIBS="$LIBS -framework IOKit -framework OpenAL"
289     openal_LIBS="$LIBS"
290     # not sure how to test if OpenAL exists on MacOS (does it come by default?)
291     OPENAL_OK="yes"
292     ALUT_OK="yes"
293     ;;
294
295 *)
296     dnl default unix style machines
297
298     save_LIBS=$LIBS
299     LIBS="$LIBS $thread_LIBS"
300     AC_SEARCH_LIBS(alGenBuffers, openal)
301     AC_SEARCH_LIBS(alutInit, [ alut openal ] )
302     OPENAL_OK="$ac_cv_search_alGenBuffers"
303     ALUT_OK="$ac_cv_search_alutInit"
304     openal_LIBS="$LIBS"
305     LIBS=$save_LIBS
306     ;;
307
308 esac
309
310 if test "$OPENAL_OK" == "no"; then
311     echo
312     echo "You *must* have the openal library installed on your system to build"
313     echo "SimGear!"
314     echo
315     echo "Please see README.OpenAL for more details."
316     echo
317     echo "configure aborted."
318     exit
319 fi
320
321 if test "$ALUT_OK" == "no"; then
322     echo
323     echo "You *must* have the alut library installed on your system to build"
324     echo "SimGear!"
325     echo
326     echo "Please see README.OpenAL for more details."
327     echo
328     echo "configure aborted."
329     exit
330 fi
331
332
333
334 LIBS="$base_LIBS"
335
336 AC_SUBST(base_LIBS)
337 AC_SUBST(openal_LIBS)
338 AC_SUBST(opengl_LIBS)
339 AC_SUBST(thread_LIBS)
340 AC_SUBST(network_LIBS)
341
342 dnl Check for MS Windows environment
343 AC_CHECK_HEADER(windows.h)
344 AM_CONDITIONAL(EXTGL_NEEDED, test "x$ac_cv_header_windows_h" = "xyes")
345
346 # The following are C++ items that need to be tested for with the c++
347 # compiler
348
349 AC_LANG_PUSH(C++)
350
351 dnl Check for "plib" without which we cannot go on
352 AC_CHECK_HEADER(plib/ul.h)
353 if test "x$ac_cv_header_plib_ul_h" != "xyes"; then
354     echo
355     echo "You *must* have the plib library installed on your system to build"
356     echo "SimGear!"
357     echo
358     echo "Please see README.plib for more details."
359     echo
360     echo "configure aborted."
361     exit
362 fi
363
364 AC_MSG_CHECKING([for plib 1.8.5 or newer])
365 AC_TRY_RUN([
366 #include <plib/ul.h>
367
368 #define MIN_PLIB_VERSION 185
369
370 int main() {
371     int major, minor, micro;
372
373     if ( PLIB_VERSION < MIN_PLIB_VERSION ) {
374          return -1;
375     }
376
377     return 0;
378 }
379
380 ],
381   AC_MSG_RESULT(yes),
382   [AC_MSG_RESULT(wrong version);
383    AC_MSG_ERROR([Install plib 1.8.5 or later first...])],
384   AC_MSG_RESULT(yes)
385 )
386
387 LIBS="$saved_LIBS"
388
389 AC_CHECK_HEADER(osg/Version)
390 if test "x$ac_cv_header_osg_Version" != "xyes"; then
391     echo
392     echo "You *must* have the OpenSceneGraph support library installed on your system"
393     echo "to build this version of SimGear!"
394     echo
395     echo "Please see README.OSG for more details."
396     echo
397     echo "configure aborted."
398     exit
399 fi
400
401 AC_LANG_POP
402
403 dnl Check for system installed zlib
404 AC_CHECK_HEADER(zlib.h)
405 if test "x$ac_cv_header_zlib_h" != "xyes"; then
406     echo
407     echo "zlib library not found."
408     echo
409     echo "If your OS does not provide an installable package for zlib"
410     echo "you will have to compile and install it first yourself.  A copy"
411     echo "of zlib-1.1.4.tar.gz is included with SimGear.  You will"
412     echo "have to untar this source code, and follow its included instructions"
413     echo "to compile and install on your system."
414     echo
415     echo "configure aborted."
416     echo
417 fi
418
419 dnl Checks for header files.
420 AC_HEADER_STDC
421 AC_CHECK_HEADERS( \
422         fcntl.h getopt.h malloc.h memory.h stdint.h stdlib.h sys/param.h \
423         sys/stat.h sys/time.h sys/timeb.h unistd.h values.h )
424
425 if test "x$ac_cv_header_stdint_h" = "xyes"; then
426     AC_DEFINE([HAVE_STDINT_H], 1, [Define if stdint.h exists])
427 fi
428
429 dnl Checks for typedefs, structures, and compiler characteristics.
430 AC_C_CONST
431 AC_TYPE_SIZE_T
432 AC_TYPE_MODE_T
433 AC_HEADER_TIME
434 AC_STRUCT_TM
435
436 dnl Checks for library functions.
437 old_LIBS=$LIBS
438 LIBS="$base_LIBS $network_LIBS $opengl_LIBS"
439 AC_TYPE_SIGNAL
440 AC_FUNC_VPRINTF
441 AC_CHECK_FUNCS( [ \
442         ftime gettimeofday timegm memcpy bcopy mktime strstr rand \
443         random drand48 setitimer getitimer signal GetLocalTime rint getrusage ] )
444 LIBS=$old_LIBS
445
446 AM_CONFIG_HEADER(simgear/simgear_config.h)
447
448 AC_CONFIG_FILES([ \
449         Makefile \
450         SimGear.spec \
451         simgear/Makefile \
452         simgear/version.h \
453         simgear/compatibility/Makefile \
454         simgear/compatibility/MIPSpro721/Makefile \
455         simgear/compatibility/MIPSpro740/Makefile \
456         simgear/bucket/Makefile \
457         simgear/debug/Makefile \
458         simgear/ephemeris/Makefile \
459         simgear/io/Makefile \
460         simgear/magvar/Makefile \
461         simgear/math/Makefile \
462         simgear/environment/Makefile \
463         simgear/misc/Makefile \
464         simgear/nasal/Makefile \
465         simgear/props/Makefile \
466         simgear/route/Makefile \
467         simgear/scene/Makefile \
468         simgear/scene/material/Makefile \
469         simgear/scene/model/Makefile \
470         simgear/scene/sky/Makefile \
471         simgear/scene/tgdb/Makefile \
472         simgear/scene/util/Makefile \
473         simgear/screen/Makefile \
474         simgear/serial/Makefile \
475         simgear/sound/Makefile \
476         simgear/structure/Makefile \
477         simgear/threads/Makefile \
478         simgear/timing/Makefile \
479         simgear/xml/Makefile \
480 ])
481 AC_OUTPUT
482
483
484 echo ""
485 echo "Configure Summary"
486 echo "================="
487
488 echo "Prefix: $prefix"
489
490 if test "x$with_logging" != "x"; then
491     echo "Debug messages: $with_logging"
492 else
493     echo "Debug messages: yes"
494 fi
495
496 echo -n "Automake version: "
497 automake --version | head -1
498
499 if test "x$with_jpeg_factory" = "xyes"; then
500    echo "With JPEG Factory support"
501 else
502    echo "Without JPEG Factory support"
503 fi
504
505 if test "x$ac_cv_header_pthread_h" = "xyes"; then
506    echo "Threads: pthread lib found."
507 else
508    echo "Threads: no threads (pthread lib not found.)"
509 fi
510