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