]> git.mxchange.org Git - simgear.git/blob - configure.ac
Melchior FRANZ:
[simgear.git] / configure.ac
1 dnl Process this file with autoget.sh to produce a working configure
2 dnl script.
3
4 AC_INIT
5 AC_CONFIG_SRCDIR([simgear/bucket/newbucket.cxx])
6
7 dnl Require at least automake 2.52
8 AC_PREREQ(2.52)
9
10 dnl Initialize the automake stuff
11 AM_INIT_AUTOMAKE(SimGear, 0.3.8)
12
13 dnl Specify KAI C++ compiler and flags.
14 dnl Borrowed with slight modification from blitz distribution.
15 AC_ARG_WITH(cxx,
16   [  --with-cxx=COMPILER[:name-flags] set options for COMPILER (KCC)],
17   [case "$withval" in
18     KCC*)    # KAI C++ http://www.kai.com/
19       echo "Configuring for KAI C++"
20       AC_SG_SET_COMPILER($withval,"KCC","--restrict --strict_warnings")
21       CXX_OPTIMIZE_FLAGS=="+K3 -O3"
22       CXX_DEBUG_FLAGS="-g +K0"
23     ;;
24   esac
25 ])
26
27 echo CXX = $CXX
28 echo CC = $CC
29
30 dnl Checks for programs.
31 AC_PROG_MAKE_SET
32 AC_PROG_CC
33 AC_PROG_CPP
34 AC_PROG_CXX
35 AC_PROG_RANLIB
36 AC_PROG_INSTALL
37 AC_PROG_LN_S
38
39 dnl set the $host variable based on local machine/os
40 AC_CANONICAL_HOST
41
42 dnl Used on the Irix platform
43 case "${host}" in
44 *-*-irix*)
45     if test "x$CXX" = "xCC" -o "x$CXX" = "xccache CC"; then
46         AR="$CXX -ar"
47         ARFLAGS="-o"
48         CXXFLAGS="$CXXFLAGS -I$(top_srcdir)/simgear/compatibility/MIPSpro740"
49         compatibility_DIR="compatibility"
50         MIPSpro_DIRS="MIPSpro740"
51         AC_MSG_CHECKING([for MIPSpro compiler version 7.4 or newer])
52         AC_TRY_RUN([
53            int main() {
54               if ( _COMPILER_VERSION < 740 ) {
55                  return -1;
56               }
57               return 0;
58            }
59
60         ], AC_MSG_RESULT(yes),
61         [  AC_MSG_RESULT(no)
62            CXXFLAGS="$CXXFLAGS -I$(top_srcdir)/simgear/compatibility/MIPSpro721"
63            MIPSpro_DIRS="$(MIPSpro_DIRS) MIPSpro721"
64            AC_MSG_WARN([Using our own subset of the STL headers])
65         ], AC_MSG_RESULT(yes))
66         AC_SUBST(MIPSpro_DIRS)
67     fi
68     ;;
69 *)
70     AR="ar"
71     ARFLAGS="cru"
72     compatibility_DIR=
73     ;;
74 esac
75 AC_SUBST(AR)
76 AC_SUBST(ARFLAGS)
77 AC_SUBST(compatibility_DIR)
78
79 if echo $includedir | egrep "simgear$" > /dev/null; then
80     echo "includedir is" $includedir "libdir is" $libdir
81 else
82     includedir="${includedir}/simgear"
83     echo "includedir changed to" $includedir "libdir is" $libdir
84 fi
85          
86 dnl set logging; default value of with_logging=yes
87 AC_ARG_WITH(logging, [  --with-logging          Include logging output (default)])
88 if test "x$with_logging" = "xno" ; then
89     AC_DEFINE([FG_NDEBUG], 1, [Define for no logging output])
90 fi
91
92 # Specify if we want to build with Norman's jpeg image server support.
93 # This requires libjpeg to be installed and available.
94 # Default to with_jpeg_server=no
95 JPEGLIB=''
96 AC_ARG_WITH(jpeg_factory, [  --with-jpeg-factory     Include Norman's jpeg image factory support code])
97 if test "x$with_jpeg_factory" = "xyes" ; then
98     echo "Building with Norman's jpeg image factory support"
99     AC_CHECK_LIB(jpeg, jpeg_start_compress)
100     if test "x$ac_cv_lib_jpeg_jpeg_start_compress" != "xyes" ; then
101         echo
102         echo "In order to build the jpeg factory code you need libjpeg installed."
103         echo "otherwise please configure with the --with-jpeg-sever=no option"
104         echo
105         echo "libjpeg is available at :"
106         echo "  ftp://ftp.uu.net in the directory graphics/jpeg"
107         exit 1
108     fi
109 else
110     echo "Building without Norman's jpeg image server support"
111 fi
112 AM_CONDITIONAL(ENABLE_JPEG_SERVER, test "x$with_jpeg_factory" = "xyes")
113
114 # specify the plib location
115 AC_ARG_WITH(plib, [  --with-plib=PREFIX      Specify the prefix path to plib])
116
117 if test "x$with_plib" != "x" ; then
118     echo "plib prefix is $with_plib"
119     EXTRA_DIRS="${EXTRA_DIRS} $with_plib"
120 fi
121
122 dnl Determine an extra directories to add to include/lib search paths
123 case "${host}" in
124 *-apple-darwin* | *-*-mingw32*)
125     echo no EXTRA_DIRS for $host
126     ;;
127
128 *)
129     if test -d /usr/X11R6 ; then
130         EXTRA_DIR1="/usr/X11R6"
131     fi
132     if test -d /opt/X11R6 ; then
133         EXTRA_DIR2="/opt/X11R6"
134     fi
135     EXTRA_DIRS="${EXTRA_DIRS} $EXTRA_DIR1 $EXTRA_DIR2"
136     ;;
137
138 esac
139 wi_EXTRA_DIRS(no, ${EXTRA_DIRS})
140
141
142 dnl Using AM_CONDITIONAL is a step out of the protected little 
143 dnl automake fold so it is potentially dangerous.  But, we are
144 dnl beginning to run into cases where the standard checks are not
145 dnl enough.  AM_CONDITIONALS are then referenced to conditionally
146 dnl build a Makefile.in from a Makefile.am which lets us define custom
147 dnl includes, compile alternative source files, etc.
148
149 dnl X11 might be installed on Mac OS X or cygwin/mingwin, we don't want
150 dnl to use it if it is.
151 case "${host}" in
152 *-apple-darwin* | *-*-cygwin* | *-*-mingw32*)
153     echo no fancy X11 check
154     ;;
155
156 *)
157     AC_PATH_XTRA
158     ;;
159
160 esac
161
162 dnl Checks for libraries.
163
164 dnl Thread related checks
165 AC_CHECK_HEADER(pthread.h)
166 AC_SEARCH_LIBS(pthread_exit, [pthread c_r])
167 if test "x$ac_cv_header_pthread_h" = "xyes"; then
168     CXXFLAGS="$CXXFLAGS -D_REENTRANT"
169     CFLAGS="$CFLAGS -D_REENTRANT"
170
171   if test "x$ac_cv_search_pthread_exit" = "x-lc_r"; then
172     CXXFLAGS="-pthread $CXXFLAGS"
173     CFLAGS="-pthread $FLAGS"
174   fi
175 fi
176
177 AM_CONDITIONAL(HAVE_THREADS, test "x$ac_cv_header_pthread_h" = "xyes")
178
179 thread_LIBS="$LIBS"
180 LIBS=""
181
182 dnl search for network related libraries
183 AC_SEARCH_LIBS(inet_addr, xnet)
184 AC_SEARCH_LIBS(socket, socket)
185
186 network_LIBS="$LIBS"
187 LIBS=""
188
189 dnl check for some default libraries
190 AC_SEARCH_LIBS(cos, m)
191
192 base_LIBS="$LIBS"
193
194 dnl check for OpenGL related libraries
195 case "${host}" in
196 *-*-cygwin* | *-*-mingw32*)
197     dnl CygWin under Windoze.
198
199     echo Win32 specific hacks...
200     AC_DEFINE([WIN32], 1, [Define for Win32 platforms])
201     AC_DEFINE([NOMINMAX], 1, [Define for Win32 platforms])
202
203     LIBS="$LIBS -lglu32 -lopengl32"
204     LIBS="$LIBS -luser32 -lgdi32 -lwinmm"
205
206     dnl add -lwsock32 for mingwin
207     case "${host}" in
208     *-*-mingw32*)
209         base_LIBS="$base_LIBS -lws2_32"
210         ;;
211     esac
212
213     echo "Will link apps with $LIBS"
214     ;;
215
216 *-apple-darwin*)
217     dnl Mac OS X
218
219     LIBS="$LIBS -framework OpenGL -framework Carbon -lobjc"
220     ;;
221
222 *)
223     dnl X-Windows based machines
224
225     AC_SEARCH_LIBS(XCreateWindow, X11)
226     AC_SEARCH_LIBS(XShmCreateImage, Xext)
227     AC_SEARCH_LIBS(XGetExtensionVersion, Xi)
228     AC_SEARCH_LIBS(IceOpenConnection, ICE)
229     AC_SEARCH_LIBS(SmcOpenConnection, SM)
230     AC_SEARCH_LIBS(XtMalloc, Xt)
231     AC_SEARCH_LIBS(XmuLookupStandardColormap, Xmu)
232     
233     AC_SEARCH_LIBS(glNewList, [ GL GLcore MesaGL ])
234     if test "x$ac_cv_search_glNewList" = "x-lGLcore"; then
235         dnl if GLcore found, then also check for GL
236         AC_SEARCH_LIBS(glXCreateContext, GL)
237     fi
238
239     dnl if using mesa, check for xmesa.h
240     if test "x$ac_cv_search_glNewList" = "x-lMesaGL"; then
241         AC_CHECK_HEADER(GL/fxmesa.h)
242         if test "x$ac_cv_header_GL_fxmesa_h" = "xyes"; then
243             AC_DEFINE([XMESA], 1, [Define for fxmesa])
244             AC_DEFINE([FX], 1, [Define for fxmesa])
245         fi
246     fi
247
248     AC_SEARCH_LIBS(gluLookAt, [ GLU MesaGLU ])
249     ;;
250
251 esac
252
253 opengl_LIBS="$LIBS"
254 LIBS="$base_LIBS"
255
256 dnl check for OpenAL libraries
257 OPENAL_OK="no"
258 case "${host}" in
259 *-*-cygwin* | *-*-mingw32*)
260     dnl CygWin under Windoze.
261
262     AC_SEARCH_LIBS(alGenBuffers, openal32)
263     AC_SEARCH_LIBS(alutInit, [ openal32 ALut ] )
264     LIBS="$LIBS -lwinmm -ldsound -ldxguid -lole32"
265     openal_LIBS="$LIBS"
266     OPENAL_OK="$ac_cv_search_alGenBuffers"
267     ;;
268
269 *-apple-darwin*)
270     dnl Mac OS X
271
272     LIBS="$LIBS -framework IOKit -framework OpenAL"
273     openal_LIBS="$LIBS"
274     # not sure how to test if OpenAL exists on MacOS (does it come by default?)
275     OPENAL_OK="yes"
276     ;;
277
278 *)
279     dnl default unix style machines
280
281     save_LIBS=$LIBS
282     LIBS="$LIBS $thread_LIBS"
283     AC_SEARCH_LIBS(alGenBuffers, openal)
284     OPENAL_OK="$ac_cv_search_alGenBuffers"
285     openal_LIBS="$LIBS"
286     LIBS=$save_LIBS
287     ;;
288
289 esac
290
291 if test "$OPENAL_OK" == "no"; then
292     echo
293     echo "You *must* have the openal library installed on your system to build"
294     echo "SimGear!"
295     echo
296     echo "Please see README.OpenAL for more details."
297     echo
298     echo "configure aborted."
299     exit
300 fi
301
302 LIBS="$base_LIBS"
303
304 AC_SUBST(base_LIBS)
305 AC_SUBST(openal_LIBS)
306 AC_SUBST(opengl_LIBS)
307 AC_SUBST(thread_LIBS)
308 AC_SUBST(network_LIBS)
309
310 dnl Check for MS Windows environment
311 AC_CHECK_HEADER(windows.h)
312 AM_CONDITIONAL(EXTGL_NEEDED, test "x$ac_cv_header_windows_h" = "xyes")
313
314 # The following are C++ items that need to be tested for with the c++
315 # compiler
316
317 AC_LANG_PUSH(C++)
318
319 dnl Check for "plib" without which we cannot go on
320 AC_CHECK_HEADER(plib/ul.h)
321 if test "x$ac_cv_header_plib_ul_h" != "xyes"; then
322     echo
323     echo "You *must* have the plib library installed on your system to build"
324     echo "SimGear!"
325     echo
326     echo "Please see README.plib for more details."
327     echo
328     echo "configure aborted."
329     exit
330 fi
331
332 AC_MSG_CHECKING([for plib 1.8.4 or newer])
333 AC_TRY_RUN([
334 #include <plib/ul.h>
335
336 #define MIN_PLIB_VERSION 184
337
338 int main() {
339     int major, minor, micro;
340
341     if ( PLIB_VERSION < MIN_PLIB_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([Install plib 1.8.4 or later first...])],
352   AC_MSG_RESULT(yes)
353 )
354
355 LIBS="$saved_LIBS"
356
357 AC_LANG_POP
358
359 dnl Check for system installed zlib
360 AC_CHECK_HEADER(zlib.h)
361 if test "x$ac_cv_header_zlib_h" != "xyes"; then
362     echo
363     echo "zlib library not found."
364     echo
365     echo "If your OS does not provide an installable package for zlib"
366     echo "you will have to compile and install it first yourself.  A copy"
367     echo "of zlib-1.1.4.tar.gz is included with SimGear.  You will"
368     echo "have to untar this source code, and follow its included instructions"
369     echo "to compile and install on your system."
370     echo
371     echo "configure aborted."
372     echo
373 fi
374
375 dnl Checks for header files.
376 AC_HEADER_STDC
377 AC_CHECK_HEADERS( \
378         fcntl.h getopt.h malloc.h memory.h stdint.h stdlib.h sys/param.h \
379         sys/stat.h sys/time.h sys/timeb.h unistd.h values.h )
380
381 if test "x$ac_cv_header_stdint_h" = "xyes"; then
382     AC_DEFINE([HAVE_STDINT_H], 1, [Define if stdint.h exists])
383 fi
384
385 dnl Checks for typedefs, structures, and compiler characteristics.
386 AC_C_CONST
387 AC_TYPE_SIZE_T
388 AC_HEADER_TIME
389 AC_STRUCT_TM
390
391 dnl Checks for library functions.
392 old_LIBS=$LIBS
393 LIBS="$base_LIBS $network_LIBS $opengl_LIBS"
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 LIBS=$old_LIBS
400
401 AM_CONFIG_HEADER(simgear/simgear_config.h)
402
403 AC_CONFIG_FILES([ \
404         Makefile \
405         SimGear.spec \
406         src-libs/Makefile \
407         simgear/Makefile \
408         simgear/version.h \
409         simgear/compatibility/Makefile \
410         simgear/compatibility/MIPSpro721/Makefile \
411         simgear/compatibility/MIPSpro740/Makefile \
412         simgear/bucket/Makefile \
413         simgear/debug/Makefile \
414         simgear/ephemeris/Makefile \
415         simgear/io/Makefile \
416         simgear/magvar/Makefile \
417         simgear/math/Makefile \
418         simgear/environment/Makefile \
419         simgear/misc/Makefile \
420         simgear/nasal/Makefile \
421         simgear/props/Makefile \
422         simgear/route/Makefile \
423         simgear/scene/Makefile \
424         simgear/scene/material/Makefile \
425         simgear/scene/model/Makefile \
426         simgear/scene/sky/Makefile \
427         simgear/scene/sky/clouds3d/Makefile \
428         simgear/scene/tgdb/Makefile \
429         simgear/screen/Makefile \
430         simgear/serial/Makefile \
431         simgear/sound/Makefile \
432         simgear/structure/Makefile \
433         simgear/threads/Makefile \
434         simgear/timing/Makefile \
435         simgear/xgl/Makefile \
436         simgear/xml/Makefile \
437 ])
438 AC_OUTPUT
439
440
441 echo ""
442 echo "Configure Summary"
443 echo "================="
444
445 echo "Prefix: $prefix"
446
447 if test "x$with_logging" != "x"; then
448     echo "Debug messages: $with_logging"
449 else
450     echo "Debug messages: yes"
451 fi
452
453 echo -n "Automake version: "
454 automake --version | head -1
455
456 if test "x$with_jpeg_factory" = "xyes"; then
457    echo "With JPEG Factory support"
458 else
459    echo "Without JPEG Factory support"
460 fi
461
462 if test "x$ac_cv_header_pthread_h" = "xyes"; then
463    echo "Threads: pthread lib found."
464 else
465    echo "Threads: no threads (pthread lib not found.)"
466 fi
467