]> git.mxchange.org Git - simgear.git/blob - configure.ac
Don't check for OpenGL libraries without at least including -lm
[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 "x$CXX" = "xCC" -o "x$CXX" = "xccache CC"; then
50         AR="$CXX -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 dnl Thread related checks
138 AC_CHECK_HEADER(pthread.h)
139 AC_CHECK_LIB(pthread, pthread_exit)
140 if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
141     CXXFLAGS="$CXXFLAGS -D_REENTRANT"
142     CFLAGS="$CFLAGS -D_REENTRANT"
143 fi
144 if test "x$ac_cv_lib_pthread_pthread_exit" != "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
145     dnl FreeBSD: System has pthread.h, but -lpthread library check
146     dnl fails.  See if we need -pthread instead of -lpthread and look
147     dnl for the functions in libc_r.
148     save_CXXFLAGS="$CXXFLAGS"
149     save_CFLAGS="$CFLAGS"
150     CXXFLAGS="-pthread $CXXFLAGS"
151     CFLAGS="-pthread $FLAGS"
152     save_LIBS=$LIBS
153     AC_CHECK_LIB(c_r, pthread_exit)
154     if test "x$ac_cv_lib_c_r_pthread_exit" != "xyes"; then
155         CXXFLAGS=$save_CXXFLAGS
156         CFLAGS=$save_CFLAGS
157     else
158         dnl This is cheating a bit. pthread_exit comes with using -pthread, not
159 -lpthread
160         ac_cv_lib_pthread_pthread_exit="yes"
161     fi
162     LIBS=$save_LIBS
163 fi
164
165 AM_CONDITIONAL(HAVE_THREADS, test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes")
166
167 thread_LIBS="$LIBS"
168 LIBS=""
169
170 dnl search for network related libraries
171 AC_SEARCH_LIBS(inet_addr, xnet)
172 AC_SEARCH_LIBS(socket, socket)
173
174 network_LIBS="$LIBS"
175 LIBS=""
176
177 dnl check for some default libraries
178 AC_SEARCH_LIBS(cos, m)
179
180 base_LIBS="$LIBS"
181
182 dnl check for glut location
183 AC_CHECK_HEADER(GL/glut.h)
184 if test "x$ac_cv_header_GL_glut_h" = "xyes"; then
185     AC_DEFINE([GLUT_H], "GL/glut.h", [Define as glut.h include location])
186 else
187     AC_CHECK_HEADER(GLUT/glut.h)
188     if test "x$ac_cv_header_GLUT_glut_h" = "xyes"; then
189         AC_DEFINE([GLUT_H], "GLUT/glut.h", [Define as glut.h include location])
190     else
191         echo "Neither GL/glut.h nor GLUT/glut.h found.  Cannot continue"
192         exit
193     fi
194 fi
195
196 dnl check for OpenGL related libraries
197 case "${host}" in
198 *-*-cygwin* | *-*-mingw32*)
199     dnl CygWin under Windoze.
200
201     echo Win32 specific hacks...
202     AC_DEFINE([WIN32], 1, [Define for Win32 platforms])
203     AC_DEFINE([NOMINMAX], 1, [Define for Win32 platforms])
204
205     LIBS="$LIBS -lglut32 -lglu32 -lopengl32"
206     LIBS="$LIBS -luser32 -lgdi32 -lwinmm"
207
208     dnl add -lwsock32 for mingwin
209     case "${host}" in
210     *-*-mingw32*)
211         base_LIBS="$base_LIBS -lws2_32"
212         ;;
213     esac
214
215     echo "Will link apps with $LIBS"
216     ;;
217
218 *-apple-darwin*)
219     dnl Mac OS X
220
221     LIBS="$LIBS -framework GLUT -framework OpenGL -framework Carbon -lobjc"
222     ;;
223
224 *)
225     dnl X-Windows based machines
226
227     AC_SEARCH_LIBS(XCreateWindow, X11)
228     AC_SEARCH_LIBS(XShmCreateImage, Xext)
229     AC_SEARCH_LIBS(XGetExtensionVersion, Xi)
230     AC_SEARCH_LIBS(IceOpenConnection, ICE)
231     AC_SEARCH_LIBS(SmcOpenConnection, SM)
232     AC_SEARCH_LIBS(XtMalloc, Xt)
233     AC_SEARCH_LIBS(XmuLookupStandardColormap, Xmu)
234     
235     AC_SEARCH_LIBS(glNewList, [ GL GLcore MesaGL ])
236     if test "x$ac_cv_search_glNewList" = "x-lGLcore"; then
237         dnl if GLcore found, then also check for GL
238         AC_SEARCH_LIBS(glXCreateContext, GL)
239     fi
240
241     dnl if using mesa, check for xmesa.h
242     if test "x$ac_cv_search_glNewList" = "x-lMesaGL"; then
243         AC_CHECK_HEADER(GL/fxmesa.h)
244         if test "x$ac_cv_header_GL_fxmesa_h" = "xyes"; then
245             AC_DEFINE([XMESA], 1, [Define for fxmesa])
246             AC_DEFINE([FX], 1, [Define for fxmesa])
247         fi
248     fi
249
250     AC_SEARCH_LIBS(gluLookAt, [ GLU MesaGLU ])
251     AC_SEARCH_LIBS(glutGetModifiers, [ glut freeglut ])
252     ;;
253
254 esac
255
256 opengl_LIBS="$LIBS"
257 LIBS="$base_LIBS"
258
259 AC_SUBST(base_LIBS)
260 AC_SUBST(opengl_LIBS)
261 AC_SUBST(thread_LIBS)
262 AC_SUBST(network_LIBS)
263
264 dnl Check for MS Windows environment
265 AC_CHECK_HEADER(windows.h)
266 AM_CONDITIONAL(EXTGL_NEEDED, test "x$ac_cv_header_windows_h" = "xyes")
267
268 # The following are C++ items that need to be tested for with the c++
269 # compiler
270
271 AC_LANG_PUSH(C++)
272
273 dnl Check for "plib" without which we cannot go on
274 AC_CHECK_HEADER(plib/ul.h)
275 if test "x$ac_cv_header_plib_ul_h" != "xyes"; then
276     echo
277     echo "You *must* have the plib library installed on your system to build"
278     echo "SimGear!"
279     echo
280     echo "Please see README.plib for more details."
281     echo
282     echo "configure aborted."
283     exit
284 fi
285
286 AC_MSG_CHECKING([for plib 1.6.0 or newer])
287 AC_TRY_RUN([
288 #include <plib/ul.h>
289
290 #define MIN_PLIB_VERSION 160
291
292 int main() {
293     int major, minor, micro;
294
295     if ( PLIB_VERSION < MIN_PLIB_VERSION ) {
296          return -1;
297     }
298
299     return 0;
300 }
301
302 ],
303   AC_MSG_RESULT(yes),
304   [AC_MSG_RESULT(wrong version);
305    AC_MSG_ERROR([Install plib 1.6.0 or later first...])],
306   AC_MSG_RESULT(yes)
307 )
308
309 dnl Check for MetaKit
310 AC_CHECK_HEADER(mk4.h)
311 if test "x$ac_cv_header_mk4_h" != "xyes"; then
312     echo
313     echo "MetaKit library not found."
314     echo
315     echo "If your OS does not provide an installable package for MetaKit"
316     echo "you will have to compile and install it first yourself.  A copy"
317     echo "of metakit-$(VERSION).tar.gz is included with SimGear.  You will"
318     echo "have to untar this source code, and follow its included instructions"
319     echo "to compile and install on your system."
320     echo
321     echo "configure aborted."
322     exit
323 fi
324
325 AC_MSG_CHECKING([for metakit 2.4.3 or newer])
326 saved_LIBS="$LIBS"
327 LIBS="$saved_LIBS -lmk4"
328 AC_TRY_RUN([
329 #include <mk4.h>
330
331 #define MIN_MK4_VERSION 243
332
333 int main() {
334     int major, minor, micro;
335
336     if ( d4_MetaKitLibraryVersion < MIN_MK4_VERSION ) {
337          return -1;
338     }
339
340     return 0;
341 }
342
343 ],
344   AC_MSG_RESULT(yes),
345   [AC_MSG_RESULT(wrong version);
346    AC_MSG_ERROR([
347
348 Install metakit 2.4.3 or later first.
349
350 Or, the compiler may not be finding your libmk4.so library.
351 Please check the config.log file for specific details of the
352 failure if you believe you have the correct metakit version.
353 Also, look up this issue in the FlightGear FAQ.])],
354   AC_MSG_RESULT(yes)
355 )
356
357 LIBS="$saved_LIBS"
358
359 AC_LANG_POP
360
361 dnl Check for system installed zlib
362 AC_CHECK_HEADER(zlib.h)
363 if test "x$ac_cv_header_zlib_h" != "xyes"; then
364     echo
365     echo "zlib library not found."
366     echo
367     echo "If your OS does not provide an installable package for zlib"
368     echo "you will have to compile and install it first yourself.  A copy"
369     echo "of zlib-1.1.4.tar.gz is included with SimGear.  You will"
370     echo "have to untar this source code, and follow its included instructions"
371     echo "to compile and install on your system."
372     echo
373     echo "configure aborted."
374     echo
375 fi
376
377 dnl Checks for header files.
378 AC_HEADER_STDC
379 AC_CHECK_HEADERS( \
380         fcntl.h getopt.h malloc.h memory.h stdint.h stdlib.h sys/param.h \
381         sys/stat.h sys/time.h sys/timeb.h unistd.h values.h )
382
383 if test "x$ac_cv_header_stdint_h" = "xyes"; then
384     AC_DEFINE([HAVE_STDINT_H], 1, [Define if stdint.h exists])
385 fi
386
387 dnl Checks for typedefs, structures, and compiler characteristics.
388 AC_C_CONST
389 AC_TYPE_SIZE_T
390 AC_HEADER_TIME
391 AC_STRUCT_TM
392
393 dnl Checks for library functions.
394 AC_TYPE_SIGNAL
395 AC_FUNC_VPRINTF
396 AC_CHECK_FUNCS( \
397         ftime gettimeofday timegm memcpy bcopy mktime strstr rand \
398         random drand48 setitimer getitimer signal GetLocalTime rint getrusage )
399
400 AM_CONFIG_HEADER(simgear/simgear_config.h)
401
402 AC_CONFIG_FILES([ \
403         Makefile \
404         SimGear.spec \
405         src-libs/Makefile \
406         simgear/Makefile \
407         simgear/version.h \
408         simgear/compatibility/Makefile \
409         simgear/bucket/Makefile \
410         simgear/debug/Makefile \
411         simgear/ephemeris/Makefile \
412         simgear/io/Makefile \
413         simgear/magvar/Makefile \
414         simgear/math/Makefile \
415         simgear/metar/Makefile \
416         simgear/misc/Makefile \
417         simgear/props/Makefile \
418         simgear/route/Makefile \
419         simgear/scene/Makefile \
420         simgear/scene/material/Makefile \
421         simgear/scene/model/Makefile \
422         simgear/scene/sky/Makefile \
423         simgear/scene/tgdb/Makefile \
424         simgear/screen/Makefile \
425         simgear/serial/Makefile \
426         simgear/sound/Makefile \
427         simgear/threads/Makefile \
428         simgear/timing/Makefile \
429         simgear/xgl/Makefile \
430         simgear/xml/Makefile \
431 ])
432 AC_OUTPUT
433
434
435 echo ""
436 echo "Configure Summary"
437 echo "================="
438
439 echo "Prefix: $prefix"
440
441 if test "x$with_logging" != "x"; then
442     echo "Debug messages: $with_logging"
443 else
444     echo "Debug messages: yes"
445 fi
446
447 echo -n "Automake version: "
448 automake --version | head -1
449
450 if test "x$ac_cv_header_GL_glut_h" = "xyes"; then
451    echo "With GL/glut.h"
452 fi
453 if test "x$ac_cv_header_GLUT_glut_h" = "xyes"; then
454    echo "With GLUT/glut.h"
455 fi
456
457 if test "x$with_jpeg_factory" = "xyes"; then
458    echo "With JPEG Factory support"
459 else
460    echo "Without JPEG Factory support"
461 fi
462
463 if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
464    echo "Threads: pthread lib found."
465 else
466    echo "Threads: no threads (pthread lib not found.)"
467 fi
468