]> git.mxchange.org Git - simgear.git/blob - configure.ac
Make some adjustment to low level serial port configuration flags for unix.
[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* | *-*-cygwin* | *-*-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     INCLUDES="$INCLUDES -I/usr/local/include"
262     LIBS="$LIBS -L/usr/local/lib"
263     AC_SEARCH_LIBS(alGenBuffers, openal32)
264     AC_SEARCH_LIBS(alutInit, [ openal32 ALut ] )
265     LIBS="$LIBS -lwinmm -ldsound -ldxguid -lole32"
266     openal_LIBS="$LIBS"
267     OPENAL_OK="$ac_cv_search_alGenBuffers"
268     ;;
269
270 *-apple-darwin*)
271     dnl Mac OS X
272
273     LIBS="$LIBS -framework IOKit -framework OpenAL"
274     openal_LIBS="$LIBS"
275     # not sure how to test if OpenAL exists on MacOS (does it come by default?)
276     OPENAL_OK="yes"
277     ;;
278
279 *)
280     dnl default unix style machines
281
282     save_LIBS=$LIBS
283     LIBS="$LIBS $thread_LIBS"
284     AC_SEARCH_LIBS(alGenBuffers, openal)
285     AC_SEARCH_LIBS(alutInit, [ alut 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.8.4 or newer])
335 AC_TRY_RUN([
336 #include <plib/ul.h>
337
338 #define MIN_PLIB_VERSION 184
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.8.4 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/tgdb/Makefile \
430         simgear/screen/Makefile \
431         simgear/serial/Makefile \
432         simgear/sound/Makefile \
433         simgear/structure/Makefile \
434         simgear/threads/Makefile \
435         simgear/timing/Makefile \
436         simgear/xgl/Makefile \
437         simgear/xml/Makefile \
438 ])
439 AC_OUTPUT
440
441
442 echo ""
443 echo "Configure Summary"
444 echo "================="
445
446 echo "Prefix: $prefix"
447
448 if test "x$with_logging" != "x"; then
449     echo "Debug messages: $with_logging"
450 else
451     echo "Debug messages: yes"
452 fi
453
454 echo -n "Automake version: "
455 automake --version | head -1
456
457 if test "x$with_jpeg_factory" = "xyes"; then
458    echo "With JPEG Factory support"
459 else
460    echo "Without JPEG Factory support"
461 fi
462
463 if test "x$ac_cv_header_pthread_h" = "xyes"; then
464    echo "Threads: pthread lib found."
465 else
466    echo "Threads: no threads (pthread lib not found.)"
467 fi
468