]> git.mxchange.org Git - simgear.git/blob - configure.ac
810e9cff26c4218220ba08884c301907bc1aba1d
[simgear.git] / configure.ac
1 dnl Process this file with autoget.sh to produce a working configure
2 dnl script.
3 dnl
4 dnl $Id$
5
6 AC_INIT
7 AC_CONFIG_SRCDIR([simgear/bucket/newbucket.cxx])
8
9 dnl Require at least automake 2.52
10 AC_PREREQ(2.52)
11
12 dnl Initialize the automake stuff
13 AM_INIT_AUTOMAKE(SimGear, 0.3.7)
14
15 dnl Specify KAI C++ compiler and flags.
16 dnl Borrowed with slight modification from blitz distribution.
17 AC_ARG_WITH(cxx,
18   [  --with-cxx=COMPILER[:name-flags] set options for COMPILER (KCC)],
19   [case "$withval" in
20     KCC*)    # KAI C++ http://www.kai.com/
21       echo "Configuring for KAI C++"
22       AC_SG_SET_COMPILER($withval,"KCC","--restrict --strict_warnings")
23       CXX_OPTIMIZE_FLAGS=="+K3 -O3"
24       CXX_DEBUG_FLAGS="-g +K0"
25     ;;
26   esac
27 ])
28
29 echo CXX = $CXX
30 echo CC = $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 dnl Determine an extra directories to add to include/lib search paths
125 case "${host}" in
126 *-apple-darwin* | *-*-mingw32*)
127     echo no EXTRA_DIRS for $host
128     ;;
129
130 *)
131     if test -d /usr/X11R6 ; then
132         EXTRA_DIR1="/usr/X11R6"
133     fi
134     if test -d /opt/X11R6 ; then
135         EXTRA_DIR2="/opt/X11R6"
136     fi
137     EXTRA_DIRS="${EXTRA_DIRS} $EXTRA_DIR1 $EXTRA_DIR2"
138     ;;
139
140 esac
141 wi_EXTRA_DIRS(no, ${EXTRA_DIRS})
142
143
144 dnl Using AM_CONDITIONAL is a step out of the protected little 
145 dnl automake fold so it is potentially dangerous.  But, we are
146 dnl beginning to run into cases where the standard checks are not
147 dnl enough.  AM_CONDITIONALS are then referenced to conditionally
148 dnl build a Makefile.in from a Makefile.am which lets us define custom
149 dnl includes, compile alternative source files, etc.
150
151 dnl X11 might be installed on Mac OS X or cygwin/mingwin, we don't want
152 dnl to use it if it is.
153 case "${host}" in
154 *-apple-darwin* | *-*-cygwin* | *-*-mingw32*)
155     echo no fancy X11 check
156     ;;
157
158 *)
159     AC_PATH_XTRA
160     ;;
161
162 esac
163
164 dnl Checks for libraries.
165
166 dnl Thread related checks
167 AC_CHECK_HEADER(pthread.h)
168 AC_CHECK_LIB(pthread, pthread_exit)
169 AC_SEARCH_LIBS(pthread_exit, pthread)
170 if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
171     CXXFLAGS="$CXXFLAGS -D_REENTRANT"
172     CFLAGS="$CFLAGS -D_REENTRANT"
173 fi
174 if test "x$ac_cv_lib_pthread_pthread_exit" != "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
175     dnl FreeBSD: System has pthread.h, but -lpthread library check
176     dnl fails.  See if we need -pthread instead of -lpthread and look
177     dnl for the functions in libc_r.
178     save_CXXFLAGS="$CXXFLAGS"
179     save_CFLAGS="$CFLAGS"
180     CXXFLAGS="-pthread $CXXFLAGS"
181     CFLAGS="-pthread $FLAGS"
182     save_LIBS=$LIBS
183     AC_CHECK_LIB(c_r, pthread_exit)
184     if test "x$ac_cv_lib_c_r_pthread_exit" != "xyes"; then
185         CXXFLAGS=$save_CXXFLAGS
186         CFLAGS=$save_CFLAGS
187     else
188         dnl This is cheating a bit. pthread_exit comes with using -pthread, not
189         dnl -lpthread
190         ac_cv_lib_pthread_pthread_exit="yes"
191     fi
192     LIBS=$save_LIBS
193 fi
194
195 AM_CONDITIONAL(HAVE_THREADS, test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes")
196
197 thread_LIBS="$LIBS"
198 LIBS=""
199
200 dnl search for network related libraries
201 AC_SEARCH_LIBS(inet_addr, xnet)
202 AC_SEARCH_LIBS(socket, socket)
203
204 network_LIBS="$LIBS"
205 LIBS=""
206
207 dnl check for some default libraries
208 AC_SEARCH_LIBS(cos, m)
209
210 base_LIBS="$LIBS"
211
212 dnl check for OpenGL related libraries
213 case "${host}" in
214 *-*-cygwin* | *-*-mingw32*)
215     dnl CygWin under Windoze.
216
217     echo Win32 specific hacks...
218     AC_DEFINE([WIN32], 1, [Define for Win32 platforms])
219     AC_DEFINE([NOMINMAX], 1, [Define for Win32 platforms])
220
221     LIBS="$LIBS -lglu32 -lopengl32"
222     LIBS="$LIBS -luser32 -lgdi32 -lwinmm"
223
224     dnl add -lwsock32 for mingwin
225     case "${host}" in
226     *-*-mingw32*)
227         base_LIBS="$base_LIBS -lws2_32"
228         ;;
229     esac
230
231     echo "Will link apps with $LIBS"
232     ;;
233
234 *-apple-darwin*)
235     dnl Mac OS X
236
237     LIBS="$LIBS -framework OpenGL -framework Carbon -lobjc"
238     ;;
239
240 *)
241     dnl X-Windows based machines
242
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     
251     AC_SEARCH_LIBS(glNewList, [ GL GLcore MesaGL ])
252     if test "x$ac_cv_search_glNewList" = "x-lGLcore"; then
253         dnl if GLcore found, then also check for GL
254         AC_SEARCH_LIBS(glXCreateContext, GL)
255     fi
256
257     dnl if using mesa, check for xmesa.h
258     if test "x$ac_cv_search_glNewList" = "x-lMesaGL"; then
259         AC_CHECK_HEADER(GL/fxmesa.h)
260         if test "x$ac_cv_header_GL_fxmesa_h" = "xyes"; then
261             AC_DEFINE([XMESA], 1, [Define for fxmesa])
262             AC_DEFINE([FX], 1, [Define for fxmesa])
263         fi
264     fi
265
266     AC_SEARCH_LIBS(gluLookAt, [ GLU MesaGLU ])
267     ;;
268
269 esac
270
271 opengl_LIBS="$LIBS"
272 LIBS="$base_LIBS"
273
274 dnl check for OpenAL libraries
275 OPENAL_OK="no"
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 -lwinmm -ldsound -ldxguid -lole32"
283     OPENAL_OK="$ac_cv_search_alGenBuffers"
284     ;;
285
286 *-apple-darwin*)
287     dnl Mac OS X
288
289     LIBS="$LIBS -framework IOKit -framework OpenAL"
290     # not sure how to test if OpenAL exists on MacOS (does it come by default?)
291     OPENAL_OK="yes"
292     ;;
293
294 *)
295     dnl default unix style machines
296
297     AC_SEARCH_LIBS(alGenBuffers, openal)
298     OPENAL_OK="$ac_cv_search_alGenBuffers"
299     ;;
300
301 esac
302
303 if test "$OPENAL_OK" == "no"; then
304     echo
305     echo "You *must* have the openal library installed on your system to build"
306     echo "SimGear!"
307     echo
308     echo "Please see README.OpenAL for more details."
309     echo
310     echo "configure aborted."
311     exit
312 fi
313
314 openal_LIBS="$LIBS"
315 LIBS="$base_LIBS"
316
317 AC_SUBST(base_LIBS)
318 AC_SUBST(openal_LIBS)
319 AC_SUBST(opengl_LIBS)
320 AC_SUBST(thread_LIBS)
321 AC_SUBST(network_LIBS)
322
323 dnl Check for MS Windows environment
324 AC_CHECK_HEADER(windows.h)
325 AM_CONDITIONAL(EXTGL_NEEDED, test "x$ac_cv_header_windows_h" = "xyes")
326
327 # The following are C++ items that need to be tested for with the c++
328 # compiler
329
330 AC_LANG_PUSH(C++)
331
332 dnl Check for "plib" without which we cannot go on
333 AC_CHECK_HEADER(plib/ul.h)
334 if test "x$ac_cv_header_plib_ul_h" != "xyes"; then
335     echo
336     echo "You *must* have the plib library installed on your system to build"
337     echo "SimGear!"
338     echo
339     echo "Please see README.plib for more details."
340     echo
341     echo "configure aborted."
342     exit
343 fi
344
345 AC_MSG_CHECKING([for plib 1.6.0 or newer])
346 AC_TRY_RUN([
347 #include <plib/ul.h>
348
349 #define MIN_PLIB_VERSION 160
350
351 int main() {
352     int major, minor, micro;
353
354     if ( PLIB_VERSION < MIN_PLIB_VERSION ) {
355          return -1;
356     }
357
358     return 0;
359 }
360
361 ],
362   AC_MSG_RESULT(yes),
363   [AC_MSG_RESULT(wrong version);
364    AC_MSG_ERROR([Install plib 1.6.0 or later first...])],
365   AC_MSG_RESULT(yes)
366 )
367
368 LIBS="$saved_LIBS"
369
370 AC_LANG_POP
371
372 dnl Check for system installed zlib
373 AC_CHECK_HEADER(zlib.h)
374 if test "x$ac_cv_header_zlib_h" != "xyes"; then
375     echo
376     echo "zlib library not found."
377     echo
378     echo "If your OS does not provide an installable package for zlib"
379     echo "you will have to compile and install it first yourself.  A copy"
380     echo "of zlib-1.1.4.tar.gz is included with SimGear.  You will"
381     echo "have to untar this source code, and follow its included instructions"
382     echo "to compile and install on your system."
383     echo
384     echo "configure aborted."
385     echo
386 fi
387
388 dnl Checks for header files.
389 AC_HEADER_STDC
390 AC_CHECK_HEADERS( \
391         fcntl.h getopt.h malloc.h memory.h stdint.h stdlib.h sys/param.h \
392         sys/stat.h sys/time.h sys/timeb.h unistd.h values.h )
393
394 if test "x$ac_cv_header_stdint_h" = "xyes"; then
395     AC_DEFINE([HAVE_STDINT_H], 1, [Define if stdint.h exists])
396 fi
397
398 dnl Checks for typedefs, structures, and compiler characteristics.
399 AC_C_CONST
400 AC_TYPE_SIZE_T
401 AC_HEADER_TIME
402 AC_STRUCT_TM
403
404 dnl Checks for library functions.
405 old_LIBS=$LIBS
406 LIBS="$base_LIBS $network_LIBS $opengl_LIBS"
407 AC_TYPE_SIGNAL
408 AC_FUNC_VPRINTF
409 AC_CHECK_FUNCS( [ \
410         ftime gettimeofday timegm memcpy bcopy mktime strstr rand \
411         random drand48 setitimer getitimer signal GetLocalTime rint getrusage ] )
412 LIBS=$old_LIBS
413
414 AM_CONFIG_HEADER(simgear/simgear_config.h)
415
416 AC_CONFIG_FILES([ \
417         Makefile \
418         SimGear.spec \
419         src-libs/Makefile \
420         simgear/Makefile \
421         simgear/version.h \
422         simgear/compatibility/Makefile \
423         simgear/compatibility/MIPSpro721/Makefile \
424         simgear/compatibility/MIPSpro740/Makefile \
425         simgear/bucket/Makefile \
426         simgear/debug/Makefile \
427         simgear/ephemeris/Makefile \
428         simgear/io/Makefile \
429         simgear/magvar/Makefile \
430         simgear/math/Makefile \
431         simgear/environment/Makefile \
432         simgear/misc/Makefile \
433         simgear/nasal/Makefile \
434         simgear/props/Makefile \
435         simgear/route/Makefile \
436         simgear/scene/Makefile \
437         simgear/scene/material/Makefile \
438         simgear/scene/model/Makefile \
439         simgear/scene/sky/Makefile \
440         simgear/scene/sky/clouds3d/Makefile \
441         simgear/scene/tgdb/Makefile \
442         simgear/screen/Makefile \
443         simgear/serial/Makefile \
444         simgear/sound/Makefile \
445         simgear/structure/Makefile \
446         simgear/threads/Makefile \
447         simgear/timing/Makefile \
448         simgear/xgl/Makefile \
449         simgear/xml/Makefile \
450 ])
451 AC_OUTPUT
452
453
454 echo ""
455 echo "Configure Summary"
456 echo "================="
457
458 echo "Prefix: $prefix"
459
460 if test "x$with_logging" != "x"; then
461     echo "Debug messages: $with_logging"
462 else
463     echo "Debug messages: yes"
464 fi
465
466 echo -n "Automake version: "
467 automake --version | head -1
468
469 if test "x$with_jpeg_factory" = "xyes"; then
470    echo "With JPEG Factory support"
471 else
472    echo "Without JPEG Factory support"
473 fi
474
475 if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
476    echo "Threads: pthread lib found."
477 else
478    echo "Threads: no threads (pthread lib not found.)"
479 fi
480