]> git.mxchange.org Git - simgear.git/blob - configure.ac
More tweaks to the configure script.
[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 case "${host}" in
154 *-*-cygwin* | *-*-mingw32*)
155     dnl CygWin under Windoze.
156
157     echo Win32 specific hacks...
158     AC_DEFINE([WIN32], 1, [Define for Win32 platforms])
159     AC_DEFINE([NOMINMAX], 1, [Define for Win32 platforms])
160
161     LIBS="$LIBS -lglut32 -lglu32 -lopengl32"
162     LIBS="$LIBS -luser32 -lgdi32 -lwinmm"
163
164     dnl add -lwsock32 for mingwin
165     case "${host}" in
166     *-*-mingw32*)
167         LIBS="$LIBS -lws2_32"
168         ;;
169     esac
170
171     echo "Will link apps with $LIBS"
172     ;;
173
174 *-apple-darwin*)
175     dnl Mac OS X
176
177     LIBS="$LIBS -framework GLUT -framework OpenGL -framework Carbon -lobjc"
178     ;;
179
180 *)
181     dnl X-Windows based machines
182
183     AC_CHECK_LIB(X11, XCreateWindow)
184     AC_CHECK_LIB(Xext, XShmCreateImage)
185     AC_CHECK_LIB(Xi, XGetExtensionVersion)
186     AC_CHECK_LIB(ICE, IceOpenConnection)
187     AC_CHECK_LIB(SM, SmcOpenConnection)
188     AC_CHECK_LIB(Xt, XtMalloc)
189     AC_CHECK_LIB(Xmu, XmuLookupStandardColormap)
190     
191     AC_CHECK_LIB(GLcore, glNewList)
192     if test "x$ac_cv_lib_GLcore_glNewList" = "xno" ; then
193         dnl if no GLcore, check for GL
194         AC_CHECK_LIB(GL, glNewList)
195         if test "x$ac_cv_lib_GL_glNewList" = "xno" ; then
196             dnl if no GL, check for MesaGL
197             AC_CHECK_LIB(MesaGL, glNewList)
198         fi
199     else
200         dnl if GLcore found, then also check for GL
201         AC_CHECK_LIB(GL, glXCreateContext)
202     fi
203
204     dnl if using mesa, check for xmesa.h
205     if test "x$ac_cv_lib_MesaGL_glNewList" = "xyes" ; then
206         AC_CHECK_HEADER(GL/fxmesa.h)
207         if test "x$ac_cv_header_GL_fxmesa_h" = "xyes"; then
208             AC_DEFINE([XMESA], 1, [Define for fxmesa])
209             AC_DEFINE([FX], 1, [Define for fxmesa])
210         fi
211     fi
212
213     AC_CHECK_LIB(GLU, gluLookAt)
214     if test "x$ac_cv_lib_GLU_gluLookAt" = "xno" ; then
215         dnl if no GLU, check for MesaGLU
216         AC_CHECK_LIB(MesaGLU, gluLookAt)
217     fi
218
219     LIBS="$LIBS -lglut"
220     ;;
221
222 esac
223
224 dnl check for glut location
225 AC_CHECK_HEADER(GL/glut.h)
226 if test "x$ac_cv_header_GL_glut_h" = "xyes"; then
227     AC_DEFINE([GLUT_H], "GL/glut.h", [Define as glut.h include location])
228 else
229     AC_CHECK_HEADER(GLUT/glut.h)
230     if test "x$ac_cv_header_GLUT_glut_h" = "xyes"; then
231         AC_DEFINE([GLUT_H], "GLUT/glut.h", [Define as glut.h include location])
232     else
233         echo "Neither GL/glut.h nor GLUT/glut.h found.  Cannot continue"
234         exit
235     fi
236 fi
237
238 opengl_LIBS="$LIBS"
239 LIBS="$base_LIBS"
240
241 AC_SUBST(base_LIBS)
242 AC_SUBST(opengl_LIBS)
243
244 dnl Check for MS Windows environment
245 AC_CHECK_HEADER(windows.h)
246 AM_CONDITIONAL(EXTGL_NEEDED, test "x$ac_cv_header_windows_h" = "xyes")
247
248 # The following are C++ items that need to be tested for with the c++
249 # compiler
250
251 AC_LANG_PUSH(C++)
252
253 dnl Check for "plib" without which we cannot go on
254 AC_CHECK_HEADER(plib/ul.h)
255 if test "x$ac_cv_header_plib_ul_h" != "xyes"; then
256     echo
257     echo "You *must* have the plib library installed on your system to build"
258     echo "SimGear!"
259     echo
260     echo "Please see README.plib for more details."
261     echo
262     echo "configure aborted."
263     exit
264 fi
265
266 AC_MSG_CHECKING([for plib 1.6.0 or newer])
267 AC_TRY_RUN([
268 #include <plib/ul.h>
269
270 #define MIN_PLIB_VERSION 160
271
272 int main() {
273     int major, minor, micro;
274
275     if ( PLIB_VERSION < MIN_PLIB_VERSION ) {
276          return -1;
277     }
278
279     return 0;
280 }
281
282 ],
283   AC_MSG_RESULT(yes),
284   [AC_MSG_RESULT(wrong version);
285    AC_MSG_ERROR([Install plib 1.6.0 or later first...])],
286   AC_MSG_RESULT(yes)
287 )
288
289 dnl Check for MetaKit
290 AC_CHECK_HEADER(mk4.h)
291 if test "x$ac_cv_header_mk4_h" != "xyes"; then
292     echo
293     echo "MetaKit library not found."
294     echo
295     echo "If your OS does not provide an installable package for MetaKit"
296     echo "you will have to compile and install it first yourself.  A copy"
297     echo "of metakit-$(VERSION).tar.gz is included with SimGear.  You will"
298     echo "have to untar this source code, and follow it's included instructions"
299     echo "to compile and install on your system."
300     echo
301     echo "configure aborted."
302     exit
303 fi
304
305 AC_MSG_CHECKING([for metakit 2.4.3 or newer])
306 saved_LIBS="$LIBS"
307 LIBS="$saved_LIBS -lmk4"
308 AC_TRY_RUN([
309 #include <mk4.h>
310
311 #define MIN_MK4_VERSION 243
312
313 int main() {
314     int major, minor, micro;
315
316     if ( d4_MetaKitLibraryVersion < MIN_MK4_VERSION ) {
317          return -1;
318     }
319
320     return 0;
321 }
322
323 ],
324   AC_MSG_RESULT(yes),
325   [AC_MSG_RESULT(wrong version);
326    AC_MSG_ERROR([
327
328 Install metakit 2.4.3 or later first.
329
330 Or, the compiler may not be finding your libmk4.so library.
331 Please check the config.log file for specific details of the
332 failure if you believe you have the correct metakit version.
333 Also, look up this issue in the FlightGear FAQ.])],
334   AC_MSG_RESULT(yes)
335 )
336
337 AC_LANG_POP
338
339 dnl Check for system installed zlib
340 AC_CHECK_HEADER(zlib.h)
341 if test "x$ac_cv_header_zlib_h" != "xyes"; then
342     echo
343     echo "zlib library not found."
344     echo
345     echo "If your OS does not provide an installable package for zlib"
346     echo "you will have to compile and install it first yourself.  A copy"
347     echo "of zlib-1.1.4.tar.gz is included with SimGear.  You will"
348     echo "have to untar this source code, and follow it's included instructions"
349     echo "to compile and install on your system."
350     echo
351     echo "configure aborted."
352     echo
353 fi
354
355 dnl Checks for header files.
356 AC_HEADER_STDC
357 AC_CHECK_HEADERS( \
358         fcntl.h getopt.h malloc.h memory.h stdint.h stdlib.h sys/param.h \
359         sys/stat.h sys/time.h sys/timeb.h unistd.h winbase.h values.h )
360
361 if test "x$ac_cv_header_stdint_h" = "xyes"; then
362     AC_DEFINE([HAVE_STDINT_H], 1, [Define if stdint.h exists])
363 fi
364
365 dnl Checks for typedefs, structures, and compiler characteristics.
366 AC_C_CONST
367 AC_TYPE_SIZE_T
368 AC_HEADER_TIME
369 AC_STRUCT_TM
370
371 dnl Checks for library functions.
372 AC_TYPE_SIGNAL
373 AC_FUNC_VPRINTF
374 AC_CHECK_FUNCS( \
375         ftime gettimeofday timegm memcpy bcopy mktime strstr rand \
376         random drand48 setitimer getitimer signal GetLocalTime rint getrusage )
377
378 AM_CONFIG_HEADER(simgear/simgear_config.h)
379
380 AC_CONFIG_FILES([ \
381         Makefile \
382         SimGear.spec \
383         src-libs/Makefile \
384         simgear/Makefile \
385         simgear/version.h \
386         simgear/bucket/Makefile \
387         simgear/debug/Makefile \
388         simgear/ephemeris/Makefile \
389         simgear/io/Makefile \
390         simgear/magvar/Makefile \
391         simgear/math/Makefile \
392         simgear/metar/Makefile \
393         simgear/misc/Makefile \
394         simgear/route/Makefile \
395         simgear/screen/Makefile \
396         simgear/serial/Makefile \
397         simgear/sky/Makefile \
398         simgear/sky/clouds3d/Makefile \
399         simgear/threads/Makefile \
400         simgear/timing/Makefile \
401         simgear/xgl/Makefile \
402         simgear/xml/Makefile \
403 ])
404 AC_OUTPUT
405
406
407 echo ""
408 echo "Configure Summary"
409 echo "================="
410
411 echo "Prefix: $prefix"
412
413 if test "x$with_logging" != "x"; then
414     echo "Debug messages: $with_logging"
415 else
416     echo "Debug messages: yes"
417 fi
418
419 echo -n "Automake version: "
420 automake --version | head -1
421
422 if test "x$ac_cv_header_GL_glut_h" = "xyes"; then
423    echo "With GL/glut.h"
424 fi
425 if test "x$ac_cv_header_GLUT_glut_h" = "xyes"; then
426    echo "With GLUT/glut.h"
427 fi
428
429 if test "x$with_jpeg_factory" = "xyes"; then
430    echo "With JPEG Factory support"
431 else
432    echo "Without JPEG Factory support"
433 fi
434
435 if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
436    echo "Threads: pthread lib found."
437 else
438    echo "Threads: no threads (pthread lib not found.)"
439 fi
440