]> git.mxchange.org Git - simgear.git/blob - configure.ac
70f33fdf69adf06ddcf6cc0dadcf04665af0bf28
[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.7)
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/MIPSpro740"
51         compatibility_DIR="compatibility"
52         MIPSpro_DIRS="MIPSpro740"
53         AC_MSG_CHECKING([for MIPSpro compiler version 7.4 or newer])
54         AC_TRY_RUN([
55            int main() {
56               if ( _COMPILER_VERSION < 740 ) {
57                  return -1;
58               }
59               return 0;
60            }
61
62         ], AC_MSG_RESULT(yes),
63         [  AC_MSG_RESULT(no)
64            CXXFLAGS="$CXXFLAGS -I$(top_srcdir)/simgear/compatibility/MIPSpro721"
65            MIPSpro_DIRS="$(MIPSpro_DIRS) MIPSpro721"
66            AC_MSG_WARN([Using our own subset of the STL headers])
67         ], AC_MSG_RESULT(yes))
68         AC_SUBST(MIPSpro_DIRS)
69     fi
70     ;;
71 *)
72     AR="ar"
73     ARFLAGS="cru"
74     compatibility_DIR=
75     ;;
76 esac
77 AC_SUBST(AR)
78 AC_SUBST(ARFLAGS)
79 AC_SUBST(compatibility_DIR)
80
81 if echo $includedir | egrep "simgear$" > /dev/null; then
82     echo "includedir is" $includedir "libdir is" $libdir
83 else
84     includedir="${includedir}/simgear"
85     echo "includedir changed to" $includedir "libdir is" $libdir
86 fi
87          
88 dnl set logging; default value of with_logging=yes
89 AC_ARG_WITH(logging, [  --with-logging          Include logging output (default)])
90 if test "x$with_logging" = "xno" ; then
91     AC_DEFINE([FG_NDEBUG], 1, [Define for no logging output])
92 fi
93
94 # Specify if we want to build with Norman's jpeg image server support.
95 # This requires libjpeg to be installed and available.
96 # Default to with_jpeg_server=no
97 JPEGLIB=''
98 AC_ARG_WITH(jpeg_factory, [  --with-jpeg-factory     Include Norman's jpeg image factory support code])
99 if test "x$with_jpeg_factory" = "xyes" ; then
100     echo "Building with Norman's jpeg image factory support"
101     AC_CHECK_LIB(jpeg, jpeg_start_compress)
102     if test "x$ac_cv_lib_jpeg_jpeg_start_compress" != "xyes" ; then
103         echo
104         echo "In order to build the jpeg factory code you need libjpeg installed."
105         echo "otherwise please configure with the --with-jpeg-sever=no option"
106         echo
107         echo "libjpeg is available at :"
108         echo "  ftp://ftp.uu.net in the directory graphics/jpeg"
109         exit 1
110     fi
111 else
112     echo "Building without Norman's jpeg image server support"
113 fi
114 AM_CONDITIONAL(ENABLE_JPEG_SERVER, test "x$with_jpeg_factory" = "xyes")
115
116 # specify the plib location
117 AC_ARG_WITH(plib, [  --with-plib=PREFIX      Specify the prefix path to plib])
118
119 if test "x$with_plib" != "x" ; then
120     echo "plib prefix is $with_plib"
121     EXTRA_DIRS="${EXTRA_DIRS} $with_plib"
122 fi
123
124 dnl Determine an extra directories to add to include/lib search paths
125 case "${host}" in
126 *-apple-darwin* | *-*-mingw32*)
127     echo no EXTRA_DIRS for $host
128     ;;
129
130 *)
131     if test -d /usr/X11R6 ; then
132         EXTRA_DIR1="/usr/X11R6"
133     fi
134     if test -d /opt/X11R6 ; then
135         EXTRA_DIR2="/opt/X11R6"
136     fi
137     EXTRA_DIRS="${EXTRA_DIRS} $EXTRA_DIR1 $EXTRA_DIR2"
138     ;;
139
140 esac
141 wi_EXTRA_DIRS(no, ${EXTRA_DIRS})
142
143
144 dnl Using AM_CONDITIONAL is a step out of the protected little 
145 dnl automake fold so it is potentially dangerous.  But, we are
146 dnl beginning to run into cases where the standard checks are not
147 dnl enough.  AM_CONDITIONALS are then referenced to conditionally
148 dnl build a Makefile.in from a Makefile.am which lets us define custom
149 dnl includes, compile alternative source files, etc.
150
151 dnl X11 might be installed on Mac OS X or cygwin/mingwin, we don't want
152 dnl to use it if it is.
153 case "${host}" in
154 *-apple-darwin* | *-*-cygwin* | *-*-mingw32*)
155     echo no fancy X11 check
156     ;;
157
158 *)
159     AC_PATH_XTRA
160     ;;
161
162 esac
163
164 dnl Checks for libraries.
165
166 dnl Thread related checks
167 AC_CHECK_HEADER(pthread.h)
168 AC_SEARCH_LIBS(pthread_exit, [pthread c_r])
169 if test "x$ac_cv_header_pthread_h" = "xyes"; then
170     CXXFLAGS="$CXXFLAGS -D_REENTRANT"
171     CFLAGS="$CFLAGS -D_REENTRANT"
172
173   if test "x$ac_cv_search_pthread_exit" = "x-lc_r"; then
174     CXXFLAGS="-pthread $CXXFLAGS"
175     CFLAGS="-pthread $FLAGS"
176   fi
177 fi
178
179 AM_CONDITIONAL(HAVE_THREADS, test "x$ac_cv_header_pthread_h" = "xyes")
180
181 thread_LIBS="$LIBS"
182 LIBS=""
183
184 dnl search for network related libraries
185 AC_SEARCH_LIBS(inet_addr, xnet)
186 AC_SEARCH_LIBS(socket, socket)
187
188 network_LIBS="$LIBS"
189 LIBS=""
190
191 dnl check for some default libraries
192 AC_SEARCH_LIBS(cos, m)
193
194 base_LIBS="$LIBS"
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 -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 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     ;;
252
253 esac
254
255 opengl_LIBS="$LIBS"
256 LIBS="$base_LIBS"
257
258 dnl check for OpenAL libraries
259 OPENAL_OK="no"
260 case "${host}" in
261 *-*-cygwin* | *-*-mingw32*)
262     dnl CygWin under Windoze.
263
264     AC_SEARCH_LIBS(alGenBuffers, openal32)
265     AC_SEARCH_LIBS(alutInit, [ openal32 ALut ] )
266     LIBS="$LIBS -lwinmm -ldsound -ldxguid -lole32"
267     openal_LIBS="$LIBS"
268     OPENAL_OK="$ac_cv_search_alGenBuffers"
269     ;;
270
271 *-apple-darwin*)
272     dnl Mac OS X
273
274     LIBS="$LIBS -framework IOKit -framework OpenAL"
275     openal_LIBS="$LIBS"
276     # not sure how to test if OpenAL exists on MacOS (does it come by default?)
277     OPENAL_OK="yes"
278     ;;
279
280 *)
281     dnl default unix style machines
282
283     save_LIBS=$LIBS
284     LIBS="$LIBS $thread_LIBS"
285     AC_SEARCH_LIBS(alGenBuffers, openal)
286     OPENAL_OK="$ac_cv_search_alGenBuffers"
287     openal_LIBS="$LIBS"
288     LIBS=$save_LIBS
289     ;;
290
291 esac
292
293 if test "$OPENAL_OK" == "no"; then
294     echo
295     echo "You *must* have the openal library installed on your system to build"
296     echo "SimGear!"
297     echo
298     echo "Please see README.OpenAL for more details."
299     echo
300     echo "configure aborted."
301     exit
302 fi
303
304 LIBS="$base_LIBS"
305
306 AC_SUBST(base_LIBS)
307 AC_SUBST(openal_LIBS)
308 AC_SUBST(opengl_LIBS)
309 AC_SUBST(thread_LIBS)
310 AC_SUBST(network_LIBS)
311
312 dnl Check for MS Windows environment
313 AC_CHECK_HEADER(windows.h)
314 AM_CONDITIONAL(EXTGL_NEEDED, test "x$ac_cv_header_windows_h" = "xyes")
315
316 # The following are C++ items that need to be tested for with the c++
317 # compiler
318
319 AC_LANG_PUSH(C++)
320
321 dnl Check for "plib" without which we cannot go on
322 AC_CHECK_HEADER(plib/ul.h)
323 if test "x$ac_cv_header_plib_ul_h" != "xyes"; then
324     echo
325     echo "You *must* have the plib library installed on your system to build"
326     echo "SimGear!"
327     echo
328     echo "Please see README.plib for more details."
329     echo
330     echo "configure aborted."
331     exit
332 fi
333
334 AC_MSG_CHECKING([for plib 1.6.0 or newer])
335 AC_TRY_RUN([
336 #include <plib/ul.h>
337
338 #define MIN_PLIB_VERSION 160
339
340 int main() {
341     int major, minor, micro;
342
343     if ( PLIB_VERSION < MIN_PLIB_VERSION ) {
344          return -1;
345     }
346
347     return 0;
348 }
349
350 ],
351   AC_MSG_RESULT(yes),
352   [AC_MSG_RESULT(wrong version);
353    AC_MSG_ERROR([Install plib 1.6.0 or later first...])],
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 old_LIBS=$LIBS
395 LIBS="$base_LIBS $network_LIBS $opengl_LIBS"
396 AC_TYPE_SIGNAL
397 AC_FUNC_VPRINTF
398 AC_CHECK_FUNCS( [ \
399         ftime gettimeofday timegm memcpy bcopy mktime strstr rand \
400         random drand48 setitimer getitimer signal GetLocalTime rint getrusage ] )
401 LIBS=$old_LIBS
402
403 AM_CONFIG_HEADER(simgear/simgear_config.h)
404
405 AC_CONFIG_FILES([ \
406         Makefile \
407         SimGear.spec \
408         src-libs/Makefile \
409         simgear/Makefile \
410         simgear/version.h \
411         simgear/compatibility/Makefile \
412         simgear/compatibility/MIPSpro721/Makefile \
413         simgear/compatibility/MIPSpro740/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/environment/Makefile \
421         simgear/misc/Makefile \
422         simgear/nasal/Makefile \
423         simgear/props/Makefile \
424         simgear/route/Makefile \
425         simgear/scene/Makefile \
426         simgear/scene/material/Makefile \
427         simgear/scene/model/Makefile \
428         simgear/scene/sky/Makefile \
429         simgear/scene/sky/clouds3d/Makefile \
430         simgear/scene/tgdb/Makefile \
431         simgear/screen/Makefile \
432         simgear/serial/Makefile \
433         simgear/sound/Makefile \
434         simgear/structure/Makefile \
435         simgear/threads/Makefile \
436         simgear/timing/Makefile \
437         simgear/xgl/Makefile \
438         simgear/xml/Makefile \
439 ])
440 AC_OUTPUT
441
442
443 echo ""
444 echo "Configure Summary"
445 echo "================="
446
447 echo "Prefix: $prefix"
448
449 if test "x$with_logging" != "x"; then
450     echo "Debug messages: $with_logging"
451 else
452     echo "Debug messages: yes"
453 fi
454
455 echo -n "Automake version: "
456 automake --version | head -1
457
458 if test "x$with_jpeg_factory" = "xyes"; then
459    echo "With JPEG Factory support"
460 else
461    echo "Without JPEG Factory support"
462 fi
463
464 if test "x$ac_cv_header_pthread_h" = "xyes"; then
465    echo "Threads: pthread lib found."
466 else
467    echo "Threads: no threads (pthread lib not found.)"
468 fi
469