]> git.mxchange.org Git - simgear.git/blob - configure.ac
d3f68ffd228f091a48de17f46cc4e710f1b43fc6
[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 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"
51         compatibility_DIR="compatibility"
52     fi
53     ;;
54 *)
55     AR="ar"
56     ARFLAGS="cru"
57     compatibility_DIR=
58     ;;
59 esac
60 AC_SUBST(AR)
61 AC_SUBST(ARFLAGS)
62 AC_SUBST(compatibility_DIR)
63
64 if echo $includedir | egrep "simgear$" > /dev/null; then
65     echo "includedir is" $includedir "libdir is" $libdir
66 else
67     includedir="${includedir}/simgear"
68     echo "includedir changed to" $includedir "libdir is" $libdir
69 fi
70          
71 dnl set logging; default value of with_logging=yes
72 AC_ARG_WITH(logging, [  --with-logging          Include logging output (default)])
73 if test "x$with_logging" = "xno" ; then
74     AC_DEFINE([FG_NDEBUG], 1, [Define for no logging output])
75 fi
76
77 # Specify if we want to build with Norman's jpeg image server support.
78 # This requires libjpeg to be installed and available.
79 # Default to with_jpeg_server=no
80 JPEGLIB=''
81 AC_ARG_WITH(jpeg_factory, [  --with-jpeg-factory     Include Norman's jpeg image factory support code])
82 if test "x$with_jpeg_factory" = "xyes" ; then
83     echo "Building with Norman's jpeg image factory support"
84     AC_CHECK_LIB(jpeg, jpeg_start_compress)
85     if test "x$ac_cv_lib_jpeg_jpeg_start_compress" != "xyes" ; then
86         echo
87         echo "In order to build the jpeg factory code you need libjpeg installed."
88         echo "otherwise please configure with the --with-jpeg-sever=no option"
89         echo
90         echo "libjpeg is available at :"
91         echo "  ftp://ftp.uu.net in the directory graphics/jpeg"
92         exit 1
93     fi
94 else
95     echo "Building without Norman's jpeg image server support"
96 fi
97 AM_CONDITIONAL(ENABLE_JPEG_SERVER, test "x$with_jpeg_factory" = "xyes")
98
99
100 dnl Determine an extra directories to add to include/lib search paths
101 case "${host}" in
102 *-apple-darwin* | *-*-mingw32*)
103     echo no EXTRA_DIRS for $host
104     ;;
105
106 *)
107     if test -d /usr/X11R6 ; then
108         EXTRA_DIR1="/usr/X11R6"
109     fi
110     if test -d /opt/X11R6 ; then
111         EXTRA_DIR2="/opt/X11R6"
112     fi
113     EXTRA_DIRS="$EXTRA_DIR1 $EXTRA_DIR2"
114     ;;
115
116 esac
117 wi_EXTRA_DIRS(no, ${EXTRA_DIRS})
118
119
120 dnl Using AM_CONDITIONAL is a step out of the protected little 
121 dnl automake fold so it is potentially dangerous.  But, we are
122 dnl beginning to run into cases where the standard checks are not
123 dnl enough.  AM_CONDITIONALS are then referenced to conditionally
124 dnl build a Makefile.in from a Makefile.am which lets us define custom
125 dnl includes, compile alternative source files, etc.
126
127 dnl X11 might be installed on Mac OS X or cygwin/mingwin, we don't want
128 dnl to use it if it is.
129 case "${host}" in
130 *-apple-darwin* | *-*-cygwin* | *-*-mingw32*)
131     echo no fancy X11 check
132     ;;
133
134 *)
135     AC_PATH_XTRA
136     ;;
137
138 esac
139
140 dnl Checks for libraries.
141
142 dnl Thread related checks
143 AC_CHECK_HEADER(pthread.h)
144 AC_CHECK_LIB(pthread, pthread_exit)
145 if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
146     CXXFLAGS="$CXXFLAGS -D_REENTRANT"
147     CFLAGS="$CFLAGS -D_REENTRANT"
148 fi
149 if test "x$ac_cv_lib_pthread_pthread_exit" != "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
150     dnl FreeBSD: System has pthread.h, but -lpthread library check
151     dnl fails.  See if we need -pthread instead of -lpthread and look
152     dnl for the functions in libc_r.
153     save_CXXFLAGS="$CXXFLAGS"
154     save_CFLAGS="$CFLAGS"
155     CXXFLAGS="-pthread $CXXFLAGS"
156     CFLAGS="-pthread $FLAGS"
157     save_LIBS=$LIBS
158     AC_CHECK_LIB(c_r, pthread_exit)
159     if test "x$ac_cv_lib_c_r_pthread_exit" != "xyes"; then
160         CXXFLAGS=$save_CXXFLAGS
161         CFLAGS=$save_CFLAGS
162     else
163         dnl This is cheating a bit. pthread_exit comes with using -pthread, not
164 -lpthread
165         ac_cv_lib_pthread_pthread_exit="yes"
166     fi
167     LIBS=$save_LIBS
168 fi
169
170 AM_CONDITIONAL(HAVE_THREADS, test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes")
171
172 thread_LIBS="$LIBS"
173 LIBS=""
174
175 dnl search for network related libraries
176 AC_SEARCH_LIBS(inet_addr, xnet)
177 AC_SEARCH_LIBS(socket, socket)
178
179 network_LIBS="$LIBS"
180 LIBS=""
181
182 dnl check for some default libraries
183 AC_SEARCH_LIBS(cos, m)
184
185 base_LIBS="$LIBS"
186
187 dnl check for OpenGL related libraries
188 case "${host}" in
189 *-*-cygwin* | *-*-mingw32*)
190     dnl CygWin under Windoze.
191
192     echo Win32 specific hacks...
193     AC_DEFINE([WIN32], 1, [Define for Win32 platforms])
194     AC_DEFINE([NOMINMAX], 1, [Define for Win32 platforms])
195
196     LIBS="$LIBS -lglu32 -lopengl32"
197     LIBS="$LIBS -luser32 -lgdi32 -lwinmm"
198
199     dnl add -lwsock32 for mingwin
200     case "${host}" in
201     *-*-mingw32*)
202         base_LIBS="$base_LIBS -lws2_32"
203         ;;
204     esac
205
206     echo "Will link apps with $LIBS"
207     ;;
208
209 *-apple-darwin*)
210     dnl Mac OS X
211
212     LIBS="$LIBS -framework OpenGL -framework Carbon -lobjc"
213     ;;
214
215 *)
216     dnl X-Windows based machines
217
218     AC_SEARCH_LIBS(XCreateWindow, X11)
219     AC_SEARCH_LIBS(XShmCreateImage, Xext)
220     AC_SEARCH_LIBS(XGetExtensionVersion, Xi)
221     AC_SEARCH_LIBS(IceOpenConnection, ICE)
222     AC_SEARCH_LIBS(SmcOpenConnection, SM)
223     AC_SEARCH_LIBS(XtMalloc, Xt)
224     AC_SEARCH_LIBS(XmuLookupStandardColormap, Xmu)
225     
226     AC_SEARCH_LIBS(glNewList, [ GL GLcore MesaGL ])
227     if test "x$ac_cv_search_glNewList" = "x-lGLcore"; then
228         dnl if GLcore found, then also check for GL
229         AC_SEARCH_LIBS(glXCreateContext, GL)
230     fi
231
232     dnl if using mesa, check for xmesa.h
233     if test "x$ac_cv_search_glNewList" = "x-lMesaGL"; then
234         AC_CHECK_HEADER(GL/fxmesa.h)
235         if test "x$ac_cv_header_GL_fxmesa_h" = "xyes"; then
236             AC_DEFINE([XMESA], 1, [Define for fxmesa])
237             AC_DEFINE([FX], 1, [Define for fxmesa])
238         fi
239     fi
240
241     AC_SEARCH_LIBS(gluLookAt, [ GLU MesaGLU ])
242     ;;
243
244 esac
245
246 opengl_LIBS="$LIBS"
247 LIBS="$base_LIBS"
248
249 AC_SUBST(base_LIBS)
250 AC_SUBST(opengl_LIBS)
251 AC_SUBST(thread_LIBS)
252 AC_SUBST(network_LIBS)
253
254 dnl Check for MS Windows environment
255 AC_CHECK_HEADER(windows.h)
256 AM_CONDITIONAL(EXTGL_NEEDED, test "x$ac_cv_header_windows_h" = "xyes")
257
258 # The following are C++ items that need to be tested for with the c++
259 # compiler
260
261 AC_LANG_PUSH(C++)
262
263 dnl Check for "plib" without which we cannot go on
264 AC_CHECK_HEADER(plib/ul.h)
265 if test "x$ac_cv_header_plib_ul_h" != "xyes"; then
266     echo
267     echo "You *must* have the plib library installed on your system to build"
268     echo "SimGear!"
269     echo
270     echo "Please see README.plib for more details."
271     echo
272     echo "configure aborted."
273     exit
274 fi
275
276 AC_MSG_CHECKING([for plib 1.6.0 or newer])
277 AC_TRY_RUN([
278 #include <plib/ul.h>
279
280 #define MIN_PLIB_VERSION 160
281
282 int main() {
283     int major, minor, micro;
284
285     if ( PLIB_VERSION < MIN_PLIB_VERSION ) {
286          return -1;
287     }
288
289     return 0;
290 }
291
292 ],
293   AC_MSG_RESULT(yes),
294   [AC_MSG_RESULT(wrong version);
295    AC_MSG_ERROR([Install plib 1.6.0 or later first...])],
296   AC_MSG_RESULT(yes)
297 )
298
299 LIBS="$saved_LIBS"
300
301 AC_LANG_POP
302
303 dnl Check for system installed zlib
304 AC_CHECK_HEADER(zlib.h)
305 if test "x$ac_cv_header_zlib_h" != "xyes"; then
306     echo
307     echo "zlib library not found."
308     echo
309     echo "If your OS does not provide an installable package for zlib"
310     echo "you will have to compile and install it first yourself.  A copy"
311     echo "of zlib-1.1.4.tar.gz is included with SimGear.  You will"
312     echo "have to untar this source code, and follow its included instructions"
313     echo "to compile and install on your system."
314     echo
315     echo "configure aborted."
316     echo
317 fi
318
319 dnl Checks for header files.
320 AC_HEADER_STDC
321 AC_CHECK_HEADERS( \
322         fcntl.h getopt.h malloc.h memory.h stdint.h stdlib.h sys/param.h \
323         sys/stat.h sys/time.h sys/timeb.h unistd.h values.h )
324
325 if test "x$ac_cv_header_stdint_h" = "xyes"; then
326     AC_DEFINE([HAVE_STDINT_H], 1, [Define if stdint.h exists])
327 fi
328
329 dnl Checks for typedefs, structures, and compiler characteristics.
330 AC_C_CONST
331 AC_TYPE_SIZE_T
332 AC_HEADER_TIME
333 AC_STRUCT_TM
334
335 dnl Checks for library functions.
336 AC_TYPE_SIGNAL
337 AC_FUNC_VPRINTF
338 AC_CHECK_FUNCS( \
339         ftime gettimeofday timegm memcpy bcopy mktime strstr rand \
340         random drand48 setitimer getitimer signal GetLocalTime rint getrusage )
341
342 AM_CONFIG_HEADER(simgear/simgear_config.h)
343
344 AC_CONFIG_FILES([ \
345         Makefile \
346         SimGear.spec \
347         src-libs/Makefile \
348         simgear/Makefile \
349         simgear/version.h \
350         simgear/compatibility/Makefile \
351         simgear/bucket/Makefile \
352         simgear/debug/Makefile \
353         simgear/ephemeris/Makefile \
354         simgear/io/Makefile \
355         simgear/magvar/Makefile \
356         simgear/math/Makefile \
357         simgear/metar/Makefile \
358         simgear/misc/Makefile \
359         simgear/props/Makefile \
360         simgear/route/Makefile \
361         simgear/scene/Makefile \
362         simgear/scene/material/Makefile \
363         simgear/scene/model/Makefile \
364         simgear/scene/sky/Makefile \
365         simgear/scene/sky/clouds3d/Makefile \
366         simgear/scene/tgdb/Makefile \
367         simgear/screen/Makefile \
368         simgear/serial/Makefile \
369         simgear/sound/Makefile \
370         simgear/threads/Makefile \
371         simgear/timing/Makefile \
372         simgear/xgl/Makefile \
373         simgear/xml/Makefile \
374 ])
375 AC_OUTPUT
376
377
378 echo ""
379 echo "Configure Summary"
380 echo "================="
381
382 echo "Prefix: $prefix"
383
384 if test "x$with_logging" != "x"; then
385     echo "Debug messages: $with_logging"
386 else
387     echo "Debug messages: yes"
388 fi
389
390 echo -n "Automake version: "
391 automake --version | head -1
392
393 if test "x$with_jpeg_factory" = "xyes"; then
394    echo "With JPEG Factory support"
395 else
396    echo "Without JPEG Factory support"
397 fi
398
399 if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
400    echo "Threads: pthread lib found."
401 else
402    echo "Threads: no threads (pthread lib not found.)"
403 fi
404