]> git.mxchange.org Git - simgear.git/blob - configure.ac
- Refactoring configure.ac a bit to use $host (please test on your platform)
[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 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
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 -lwsock32"
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 system installed metakit
290 AC_CHECK_HEADER(mk4.h)
291 if test "x$ac_cv_header_mk4_h" != "xyes"; then
292     echo 
293     echo "Metakit not found, you will need to install this first."
294     echo "Please read the README.metakit for more information."
295     exit
296 fi
297
298 AC_LANG_POP
299
300 dnl Check for system installed zlib
301 AC_CHECK_HEADER(zlib.h)
302 if test "x$ac_cv_header_zlib_h" != "xyes"; then
303     echo 
304     echo "zlib not found, you will need to install this first."
305     echo "Please read the README.zlib for more information."
306     exit
307 fi
308
309 dnl Checks for header files.
310 AC_HEADER_STDC
311 AC_CHECK_HEADERS( \
312         fcntl.h getopt.h malloc.h memory.h stdint.h stdlib.h sys/param.h \
313         sys/stat.h sys/time.h sys/timeb.h unistd.h winbase.h values.h )
314
315 if test "x$ac_cv_header_stdint_h" = "xyes"; then
316     AC_DEFINE([HAVE_STDINT_H], 1, [Define if stdint.h exists])
317 fi
318
319 dnl Checks for typedefs, structures, and compiler characteristics.
320 AC_C_CONST
321 AC_TYPE_SIZE_T
322 AC_HEADER_TIME
323 AC_STRUCT_TM
324
325 dnl Checks for library functions.
326 AC_TYPE_SIGNAL
327 AC_FUNC_VPRINTF
328 AC_CHECK_FUNCS( \
329         ftime gettimeofday timegm memcpy bcopy mktime strstr rand \
330         random drand48 setitimer getitimer signal GetLocalTime rint getrusage )
331
332 AM_CONFIG_HEADER(simgear/simgear_config.h)
333
334 AC_CONFIG_FILES([ \
335         Makefile \
336         SimGear.spec \
337         src-libs/Makefile \
338         simgear/Makefile \
339         simgear/version.h \
340         simgear/bucket/Makefile \
341         simgear/debug/Makefile \
342         simgear/ephemeris/Makefile \
343         simgear/io/Makefile \
344         simgear/magvar/Makefile \
345         simgear/math/Makefile \
346         simgear/metar/Makefile \
347         simgear/misc/Makefile \
348         simgear/route/Makefile \
349         simgear/screen/Makefile \
350         simgear/serial/Makefile \
351         simgear/sky/Makefile \
352         simgear/sky/clouds3d/Makefile \
353         simgear/threads/Makefile \
354         simgear/timing/Makefile \
355         simgear/xgl/Makefile \
356         simgear/xml/Makefile \
357 ])
358 AC_OUTPUT
359
360
361 echo ""
362 echo "Configure Summary"
363 echo "================="
364
365 echo "Prefix: $prefix"
366
367 if test "x$with_logging" != "x"; then
368     echo "Debug messages: $with_logging"
369 else
370     echo "Debug messages: yes"
371 fi
372
373 echo -n "Automake version: ($AUTO_MAKE_VERSION) "
374 automake --version | head -1
375
376 if test "x$ac_cv_header_GL_glut_h" = "xyes"; then
377    echo "With GL/glut.h"
378 fi
379 if test "x$ac_cv_header_GLUT_glut_h" = "xyes"; then
380    echo "With GLUT/glut.h"
381 fi
382
383 if test "x$with_jpeg_factory" = "xyes"; then
384    echo "With JPEG Factory support"
385 else
386    echo "Without JPEG Factory support"
387 fi
388
389 if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
390    echo "Threads: pthread lib found."
391 else
392    echo "Threads: no threads (pthread lib not found.)"
393 fi
394