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