]> git.mxchange.org Git - simgear.git/blob - configure.ac
cf1bfc27dece20689b8766863c0a4600998d260c
[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.5)
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
117 dnl Determine an extra directories to add to include/lib search paths
118 case "${host}" in
119 *-apple-darwin* | *-*-mingw32*)
120     echo no EXTRA_DIRS for $host
121     ;;
122
123 *)
124     if test -d /usr/X11R6 ; then
125         EXTRA_DIR1="/usr/X11R6"
126     fi
127     if test -d /opt/X11R6 ; then
128         EXTRA_DIR2="/opt/X11R6"
129     fi
130     EXTRA_DIRS="$EXTRA_DIR1 $EXTRA_DIR2"
131     ;;
132
133 esac
134 wi_EXTRA_DIRS(no, ${EXTRA_DIRS})
135
136
137 dnl Using AM_CONDITIONAL is a step out of the protected little 
138 dnl automake fold so it is potentially dangerous.  But, we are
139 dnl beginning to run into cases where the standard checks are not
140 dnl enough.  AM_CONDITIONALS are then referenced to conditionally
141 dnl build a Makefile.in from a Makefile.am which lets us define custom
142 dnl includes, compile alternative source files, etc.
143
144 dnl X11 might be installed on Mac OS X or cygwin/mingwin, we don't want
145 dnl to use it if it is.
146 case "${host}" in
147 *-apple-darwin* | *-*-cygwin* | *-*-mingw32*)
148     echo no fancy X11 check
149     ;;
150
151 *)
152     AC_PATH_XTRA
153     ;;
154
155 esac
156
157 dnl Checks for libraries.
158
159 dnl Thread related checks
160 AC_CHECK_HEADER(pthread.h)
161 AC_CHECK_LIB(pthread, pthread_exit)
162 if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
163     CXXFLAGS="$CXXFLAGS -D_REENTRANT"
164     CFLAGS="$CFLAGS -D_REENTRANT"
165 fi
166 if test "x$ac_cv_lib_pthread_pthread_exit" != "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
167     dnl FreeBSD: System has pthread.h, but -lpthread library check
168     dnl fails.  See if we need -pthread instead of -lpthread and look
169     dnl for the functions in libc_r.
170     save_CXXFLAGS="$CXXFLAGS"
171     save_CFLAGS="$CFLAGS"
172     CXXFLAGS="-pthread $CXXFLAGS"
173     CFLAGS="-pthread $FLAGS"
174     save_LIBS=$LIBS
175     AC_CHECK_LIB(c_r, pthread_exit)
176     if test "x$ac_cv_lib_c_r_pthread_exit" != "xyes"; then
177         CXXFLAGS=$save_CXXFLAGS
178         CFLAGS=$save_CFLAGS
179     else
180         dnl This is cheating a bit. pthread_exit comes with using -pthread, not
181 -lpthread
182         ac_cv_lib_pthread_pthread_exit="yes"
183     fi
184     LIBS=$save_LIBS
185 fi
186
187 AM_CONDITIONAL(HAVE_THREADS, test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes")
188
189 thread_LIBS="$LIBS"
190 LIBS=""
191
192 dnl search for network related libraries
193 AC_SEARCH_LIBS(inet_addr, xnet)
194 AC_SEARCH_LIBS(socket, socket)
195
196 network_LIBS="$LIBS"
197 LIBS=""
198
199 dnl check for some default libraries
200 AC_SEARCH_LIBS(cos, m)
201
202 base_LIBS="$LIBS"
203
204 dnl check for OpenGL related libraries
205 case "${host}" in
206 *-*-cygwin* | *-*-mingw32*)
207     dnl CygWin under Windoze.
208
209     echo Win32 specific hacks...
210     AC_DEFINE([WIN32], 1, [Define for Win32 platforms])
211     AC_DEFINE([NOMINMAX], 1, [Define for Win32 platforms])
212
213     LIBS="$LIBS -lglu32 -lopengl32"
214     LIBS="$LIBS -luser32 -lgdi32 -lwinmm"
215
216     dnl add -lwsock32 for mingwin
217     case "${host}" in
218     *-*-mingw32*)
219         base_LIBS="$base_LIBS -lws2_32"
220         ;;
221     esac
222
223     echo "Will link apps with $LIBS"
224     ;;
225
226 *-apple-darwin*)
227     dnl Mac OS X
228
229     LIBS="$LIBS -framework OpenGL -framework Carbon -lobjc"
230     ;;
231
232 *)
233     dnl X-Windows based machines
234
235     AC_SEARCH_LIBS(XCreateWindow, X11)
236     AC_SEARCH_LIBS(XShmCreateImage, Xext)
237     AC_SEARCH_LIBS(XGetExtensionVersion, Xi)
238     AC_SEARCH_LIBS(IceOpenConnection, ICE)
239     AC_SEARCH_LIBS(SmcOpenConnection, SM)
240     AC_SEARCH_LIBS(XtMalloc, Xt)
241     AC_SEARCH_LIBS(XmuLookupStandardColormap, Xmu)
242     
243     AC_SEARCH_LIBS(glNewList, [ GL GLcore MesaGL ])
244     if test "x$ac_cv_search_glNewList" = "x-lGLcore"; then
245         dnl if GLcore found, then also check for GL
246         AC_SEARCH_LIBS(glXCreateContext, GL)
247     fi
248
249     dnl if using mesa, check for xmesa.h
250     if test "x$ac_cv_search_glNewList" = "x-lMesaGL"; 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_SEARCH_LIBS(gluLookAt, [ GLU MesaGLU ])
259     ;;
260
261 esac
262
263 opengl_LIBS="$LIBS"
264 LIBS="$base_LIBS"
265
266 AC_SUBST(base_LIBS)
267 AC_SUBST(opengl_LIBS)
268 AC_SUBST(thread_LIBS)
269 AC_SUBST(network_LIBS)
270
271 dnl Check for MS Windows environment
272 AC_CHECK_HEADER(windows.h)
273 AM_CONDITIONAL(EXTGL_NEEDED, test "x$ac_cv_header_windows_h" = "xyes")
274
275 # The following are C++ items that need to be tested for with the c++
276 # compiler
277
278 AC_LANG_PUSH(C++)
279
280 dnl Check for "plib" without which we cannot go on
281 AC_CHECK_HEADER(plib/ul.h)
282 if test "x$ac_cv_header_plib_ul_h" != "xyes"; then
283     echo
284     echo "You *must* have the plib library installed on your system to build"
285     echo "SimGear!"
286     echo
287     echo "Please see README.plib for more details."
288     echo
289     echo "configure aborted."
290     exit
291 fi
292
293 AC_MSG_CHECKING([for plib 1.6.0 or newer])
294 AC_TRY_RUN([
295 #include <plib/ul.h>
296
297 #define MIN_PLIB_VERSION 160
298
299 int main() {
300     int major, minor, micro;
301
302     if ( PLIB_VERSION < MIN_PLIB_VERSION ) {
303          return -1;
304     }
305
306     return 0;
307 }
308
309 ],
310   AC_MSG_RESULT(yes),
311   [AC_MSG_RESULT(wrong version);
312    AC_MSG_ERROR([Install plib 1.6.0 or later first...])],
313   AC_MSG_RESULT(yes)
314 )
315
316 LIBS="$saved_LIBS"
317
318 AC_LANG_POP
319
320 dnl Check for system installed zlib
321 AC_CHECK_HEADER(zlib.h)
322 if test "x$ac_cv_header_zlib_h" != "xyes"; then
323     echo
324     echo "zlib library not found."
325     echo
326     echo "If your OS does not provide an installable package for zlib"
327     echo "you will have to compile and install it first yourself.  A copy"
328     echo "of zlib-1.1.4.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     echo
334 fi
335
336 dnl Checks for header files.
337 AC_HEADER_STDC
338 AC_CHECK_HEADERS( \
339         fcntl.h getopt.h malloc.h memory.h stdint.h stdlib.h sys/param.h \
340         sys/stat.h sys/time.h sys/timeb.h unistd.h values.h )
341
342 if test "x$ac_cv_header_stdint_h" = "xyes"; then
343     AC_DEFINE([HAVE_STDINT_H], 1, [Define if stdint.h exists])
344 fi
345
346 dnl Checks for typedefs, structures, and compiler characteristics.
347 AC_C_CONST
348 AC_TYPE_SIZE_T
349 AC_HEADER_TIME
350 AC_STRUCT_TM
351
352 dnl Checks for library functions.
353 old_LIBS=$LIBS
354 LIBS="$base_LIBS $network_LIBS $opengl_LIBS"
355 AC_TYPE_SIGNAL
356 AC_FUNC_VPRINTF
357 AC_CHECK_FUNCS( [ \
358         ftime gettimeofday timegm memcpy bcopy mktime strstr rand \
359         random drand48 setitimer getitimer signal GetLocalTime rint getrusage ] )
360 LIBS=$old_LIBS
361
362 AM_CONFIG_HEADER(simgear/simgear_config.h)
363
364 AC_CONFIG_FILES([ \
365         Makefile \
366         SimGear.spec \
367         src-libs/Makefile \
368         simgear/Makefile \
369         simgear/version.h \
370         simgear/compatibility/Makefile \
371         simgear/compatibility/MIPSpro721/Makefile \
372         simgear/compatibility/MIPSpro740/Makefile \
373         simgear/bucket/Makefile \
374         simgear/debug/Makefile \
375         simgear/ephemeris/Makefile \
376         simgear/io/Makefile \
377         simgear/magvar/Makefile \
378         simgear/math/Makefile \
379         simgear/metar/Makefile \
380         simgear/environment/Makefile \
381         simgear/misc/Makefile \
382         simgear/nasal/Makefile \
383         simgear/props/Makefile \
384         simgear/route/Makefile \
385         simgear/scene/Makefile \
386         simgear/scene/material/Makefile \
387         simgear/scene/model/Makefile \
388         simgear/scene/sky/Makefile \
389         simgear/scene/sky/clouds3d/Makefile \
390         simgear/scene/tgdb/Makefile \
391         simgear/screen/Makefile \
392         simgear/serial/Makefile \
393         simgear/sound/Makefile \
394         simgear/structure/Makefile \
395         simgear/threads/Makefile \
396         simgear/timing/Makefile \
397         simgear/xgl/Makefile \
398         simgear/xml/Makefile \
399 ])
400 AC_OUTPUT
401
402
403 echo ""
404 echo "Configure Summary"
405 echo "================="
406
407 echo "Prefix: $prefix"
408
409 if test "x$with_logging" != "x"; then
410     echo "Debug messages: $with_logging"
411 else
412     echo "Debug messages: yes"
413 fi
414
415 echo -n "Automake version: "
416 automake --version | head -1
417
418 if test "x$with_jpeg_factory" = "xyes"; then
419    echo "With JPEG Factory support"
420 else
421    echo "Without JPEG Factory support"
422 fi
423
424 if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
425    echo "Threads: pthread lib found."
426 else
427    echo "Threads: no threads (pthread lib not found.)"
428 fi
429