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