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