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