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