]> git.mxchange.org Git - simgear.git/blob - configure.ac
Additional build system tweaks, regenerated the .dsp/.dsw's.
[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.19pre1)
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/\-p[[0-9]]$//' | sed -e 's/\.//'`
60 AM_CONDITIONAL(ANCIENT_AUTOMAKE, test $AUTO_MAKE_VERSION -lt 14)
61 AM_CONDITIONAL(OLD_AUTOMAKE, test $AUTO_MAKE_VERSION -lt 15)
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/local /usr/local/plib /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 dnl X11 might be installed, but we don't want to use it for OSX -dw-
158 if test "x$HOSTTYPE" != "xmacintosh" ; then
159     AC_CHECK_LIB(X11, XCreateWindow)
160     AC_CHECK_LIB(Xext, XShmCreateImage)
161     AC_CHECK_LIB(Xi, XGetExtensionVersion)
162     AC_CHECK_LIB(ICE, IceOpenConnection)
163     AC_CHECK_LIB(SM, SmcOpenConnection)
164     AC_CHECK_LIB(Xt, XtMalloc)
165     AC_CHECK_LIB(Xmu, XmuLookupStandardColormap)
166 fi
167
168 dnl check for OpenGL related libraries
169
170 if test "x$HOSTTYPE" = "xmacintosh" ; then
171     dnl Macintosh OSX
172     LIBS="$LIBS -framework OpenGL -framework GLUT"
173 elif test "x$ac_cv_header_windows_h" != "xyes" ; then
174     dnl Reasonable stuff for X-Windows based machines
175
176     AC_CHECK_LIB(GLcore, glNewList)
177     if test "x$ac_cv_lib_GLcore_glNewList" = "xno" ; then
178         dnl if no GLcore, check for GL
179         AC_CHECK_LIB(GL, glNewList)
180         if test "x$ac_cv_lib_GL_glNewList" = "xno" ; then
181             dnl if no GL, check for MesaGL
182             AC_CHECK_LIB(MesaGL, glNewList)
183         fi
184     else
185         dnl if GLcore found, then also check for GL
186         AC_CHECK_LIB(GL, glXCreateContext)
187     fi
188
189     dnl if using mesa, check for xmesa.h
190     if test "x$ac_cv_lib_MesaGL_glNewList" = "xyes" ; then
191         AC_CHECK_HEADER(GL/fxmesa.h)
192         if test "x$ac_cv_header_GL_fxmesa_h" = "xyes"; then
193             AC_DEFINE([XMESA], 1, [Define for fxmesa])
194             AC_DEFINE([FX], 1, [Define for fxmesa])
195         fi
196     fi
197
198     AC_CHECK_LIB(GLU, gluLookAt)
199     if test "x$ac_cv_lib_GLU_gluLookAt" = "xno" ; then
200         dnl if no GLU, check for MesaGLU
201         AC_CHECK_LIB(MesaGLU, gluLookAt)
202     fi
203
204     dnl check for glut
205     AC_CHECK_LIB(glut, glutGetModifiers)
206
207     dnl test for glutGameModeString, but avoid adding glut a second time into
208     dnl the list of libraries
209     save_LIBS="$LIBS"
210     AC_CHECK_LIB(glut, glutGameModeString)
211     LIBS="$save_LIBS"
212 else
213     dnl Win32 libs
214
215     echo Win32 specific hacks...
216     AC_DEFINE([WIN32], 1, [Define for Win32 platforms])
217
218     dnl force a failed check since we will be building under windoze
219     AM_CONDITIONAL(ENABLE_XMESA_FX, test "no" = "yes")
220
221     dnl just define these to true and hope for the best
222     ac_cv_lib_glut_glutGetModifiers="yes"
223     ac_cv_lib_glut_glutGameModeString="yes"
224
225     if test "x$with_sgi_opengl" = "xyes" ; then
226         echo "Building with glut.dll, glu.dll, and opengl.dll"
227         WIN32_GLUT=glut
228         WIN32_GLU=glu
229         WIN32_OPENGL=opengl
230     else 
231         echo "Building with glut32.dll, glu32.dll, and opengl32.dll"
232         WIN32_GLUT=glut32
233         WIN32_GLU=glu32
234         WIN32_OPENGL=opengl32
235     fi
236
237     LIBS="$LIBS -l${WIN32_GLUT} -l${WIN32_GLU} -l${WIN32_OPENGL}"
238     LIBS="$LIBS -luser32 -lgdi32"
239     if test "x$is_mingw" = "xyes" ; then
240         EXTRA_DIRS="${EXTRA_DIRS}"
241     fi
242     echo "Will link apps with $LIBS"
243 fi
244
245 if test "x$ac_cv_lib_glut_glutGetModifiers" = "xno"; then
246     echo 
247     echo "Unable to find the necessary OpenGL or GLUT libraries."
248     echo "See config.log for automated test details and results ..."
249     exit 1
250 fi
251
252 if test "x$ac_cv_lib_glut_glutGameModeString" = "xno"; then
253     echo
254     echo "Your version of glut doesn't support game mode."
255     echo "You need to install the latest version of glut.  If your"
256     echo "distribution doesn't provide a newer version, you can get the source"
257     echo "code from:"
258     echo
259     echo "    http://reality.sgi.com/opengl/glut3/glut3.html"
260     exit 1
261 fi
262
263 opengl_LIBS="$LIBS"
264 LIBS="$base_LIBS"
265
266 AC_SUBST(base_LIBS)
267 AC_SUBST(opengl_LIBS)
268
269 AM_CONDITIONAL(HAVE_XWINDOWS, test "x$ac_cv_lib_X11_XCreateWindow" = "xyes" )
270
271 # The following are C++ items that need to be tested for with the c++
272 # compiler
273
274 AC_LANG_PUSH(C++)
275
276 dnl Check for "plib" without which we cannot go on
277 AC_CHECK_HEADER(plib/pu.h)
278 if test "x$ac_cv_header_plib_pu_h" != "xyes"; then
279     echo
280     echo "You *must* have the plib library installed on your system to build"
281     echo "the FGFS simulator!"
282     echo
283     echo "Please see README.plib for more details."
284     echo
285     echo "configure aborted."
286     exit
287 fi
288
289 AC_CHECK_HEADER(plib/ssgaLensFlare.h)
290 if test "x$ac_cv_header_plib_ssgaLensFlare_h" = "xyes"; then
291     AC_DEFINE([FG_CHEESY_LENS_FLARE], 1, [Define for cheesy lens flare effect])
292 fi
293
294 dnl Check for system installed metakit
295 AC_CHECK_HEADER(mk4.h)
296 if test "x$ac_cv_header_mk4_h" != "xyes"; then
297     echo 
298     echo "Metakit not found, you will need to install this first."
299     echo "Please read the README.metakit for more information."
300     exit
301 fi
302
303 AC_LANG_POP
304
305 dnl Specify if we want logging (testing build) or not (release build)
306
307 dnl Check for system installed zlib
308 AC_CHECK_HEADER(zlib.h)
309 if test "x$ac_cv_header_zlib_h" != "xyes"; then
310     echo 
311     echo "zlib not found, you will need to install this first."
312     echo "Please read the README.zlib for more information."
313     exit
314 fi
315
316 dnl Checks for header files.
317 AC_HEADER_STDC
318 AC_CHECK_HEADERS( \
319         fcntl.h getopt.h malloc.h memory.h stdint.h stdlib.h sys/param.h \
320         sys/stat.h sys/time.h sys/timeb.h unistd.h windows.h winbase.h values.h )
321
322 if test "x$ac_cv_header_stdint_h" = "xyes"; then
323     AC_DEFINE([HAVE_STDINT_H], 1, [Define if stdint.h exists])
324 fi
325
326 dnl Checks for typedefs, structures, and compiler characteristics.
327 AC_C_CONST
328 AC_TYPE_SIZE_T
329 AC_HEADER_TIME
330 AC_STRUCT_TM
331
332 dnl Checks for library functions.
333 AC_TYPE_SIGNAL
334 AC_FUNC_VPRINTF
335 AC_CHECK_FUNCS( ftime gettimeofday timegm memcpy bcopy mktime strstr rand \
336         random drand48 setitimer getitimer signal GetLocalTime rint getrusage )
337
338 AM_CONFIG_HEADER(simgear/simgear_config.h)
339
340 AC_CONFIG_FILES([ \
341         Makefile \
342         SimGear.spec \
343         src-libs/Makefile \
344         simgear/Makefile \
345         simgear/version.h \
346         simgear/bucket/Makefile \
347         simgear/debug/Makefile \
348         simgear/ephemeris/Makefile \
349         simgear/interpreter/Makefile \
350         simgear/io/Makefile \
351         simgear/magvar/Makefile \
352         simgear/math/Makefile \
353         simgear/metar/Makefile \
354         simgear/misc/Makefile \
355         simgear/route/Makefile \
356         simgear/screen/Makefile \
357         simgear/serial/Makefile \
358         simgear/sky/Makefile \
359         simgear/threads/Makefile \
360         simgear/timing/Makefile \
361         simgear/xgl/Makefile \
362         simgear/xml/Makefile \
363 ])
364 AC_OUTPUT
365
366
367 echo ""
368 echo "Configure Summary"
369 echo "================="
370
371 echo "Prefix: $prefix"
372
373 if test "x$with_logging" != "x"; then
374     echo "Debug messages: $with_logging"
375 else
376     echo "Debug messages: yes"
377 fi
378
379 echo -n "Automake version: ($AUTO_MAKE_VERSION) "
380 automake --version | head -1
381
382 if test "x$with_jpeg_factory" = "xyes"; then
383    echo "With JPEG Factory support"
384 else
385    echo "Without JPEG Factory support"
386 fi
387
388 if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
389    echo "Threads: pthread lib found."
390 else
391    echo "Threads: no threads (pthread lib not found.)"
392 fi