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