]> git.mxchange.org Git - simgear.git/blob - configure.in
Updates to build system to better support automake-1.5
[simgear.git] / configure.in
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(simgear/bucket/newbucket.cxx)
7
8 dnl Initialize the automake stuff
9 AM_INIT_AUTOMAKE(SimGear, 0.0.17)
10
11 dnl Specify KAI C++ compiler and flags.
12 dnl Borrowed with slight modification from blitz distribution.
13 AC_ARG_WITH(cxx,
14   [  --with-cxx=COMPILER[:name-flags] set options for COMPILER (KCC)],
15   [case "$withval" in
16     KCC*)    # KAI C++ http://www.kai.com/
17       echo "Configuring for KAI C++"
18       AC_SG_SET_COMPILER($withval,"KCC","--restrict --strict_warnings")
19       CXX_OPTIMIZE_FLAGS=="+K3 -O3"
20       CXX_DEBUG_FLAGS="-g +K0"
21     ;;
22   esac
23 ])
24
25 echo CXX = $CXX
26 echo CC = $CC
27
28 dnl Checks for programs.
29 AC_PROG_MAKE_SET
30 AC_PROG_CC
31 AC_PROG_CPP
32 AC_PROG_CXX
33 AC_PROG_RANLIB
34 AC_PROG_INSTALL
35 AC_PROG_LN_S
36
37 AR="ar"
38 OS=`uname -s`
39 if test "$OS" = "IRIX" -o "$OS" = "IRIX64"; then
40     if test "$CXX" = "CC"; then
41         AR="CC -ar"
42         AC_SUBST(AR)
43     fi
44 fi
45
46 if echo $includedir | egrep "simgear$" > /dev/null; then
47     echo "includedir is" $includedir "libdir is" $libdir
48 else
49     includedir="${includedir}/simgear"
50     echo "includedir changed to" $includedir "libdir is" $libdir
51 fi
52          
53 # Determine version of automake ... important becuase of
54 # incompatibilities between versions
55 AUTO_MAKE_VERSION=`automake --version | head -1 | awk '{print $4}' | sed -e 's/\-p[[0-9]]$//' | sed -e 's/\.//'`
56 AM_CONDITIONAL(ANCIENT_AUTOMAKE, test $AUTO_MAKE_VERSION -lt 14)
57 AM_CONDITIONAL(OLD_AUTOMAKE, test $AUTO_MAKE_VERSION -lt 15)
58
59 # set logging default value
60 # with_logging=yes
61 AC_ARG_WITH(logging, [  --with-logging          Include logging output (default)])
62 if test "x$with_logging" = "xno" ; then
63     AC_DEFINE(FG_NDEBUG)
64 fi
65
66 dnl specify if we are building with "checker"
67 AC_ARG_WITH(efence, [  --with-efence           Specify if we are building with "electric-fence"])
68
69 if test "x$with_efence" = "xyes" ; then
70     echo "Building with efence"
71     LIBS="$LIBS -lefence"
72 fi
73
74 dnl Check for MS Windows environment
75 AC_CHECK_HEADER(windows.h)
76
77 if test "$HOSTTYPE" != "macintosh" ; then
78     dnl extra library and include directories
79     EXTRA_DIRS="/usr/local /usr/local/plib /usr/X11R6"
80
81     if test -d /opt/X11R6 ; then
82         EXTRA_DIRS="$EXTRA_DIRS /opt/X11R6"
83     fi
84
85     if test "x$ac_cv_header_windows_h" = "xyes" ; then
86         if test -d /usr/mingw/usr ; then
87             EXTRA_DIRS="$EXTRA_DIRS /usr/mingw/usr"
88         fi
89         EXTRA_DIRS="${EXTRA_DIRS} `pwd`/Win32"
90     fi
91 fi
92
93 wi_EXTRA_DIRS(no, ${EXTRA_DIRS})
94
95 dnl Using AM_CONDITIONAL is a step out of the protected little 
96 dnl automake fold so it is potentially dangerous.  But, we are
97 dnl beginning to run into cases where the standard checks are not
98 dnl enough.  AM_CONDITIONALS are then referenced to conditionally
99 dnl build a Makefile.in from a Makefile.am which lets us define custom
100 dnl includes, compile alternative source files, etc.
101
102 dnl Enable serial support on Unix type systems
103 AM_CONDITIONAL(ENABLE_UNIX_SERIAL, true)
104
105 dnl X11 might be installed on Mac OS X, don't want to use it if it is.
106 if test "$HOSTTYPE" != "macintosh" ; then
107     dnl Check for X11 (fancy)
108     AC_PATH_XTRA
109 fi
110
111 dnl Checks for libraries.
112
113 null_LIBS="$LIBS"
114
115 AC_CHECK_LIB(m, cos)
116
117 base_LIBS="$LIBS"
118
119 dnl Thread related checks
120 AC_CHECK_LIB(pthread, pthread_exit)
121 AC_CHECK_HEADER(pthread.h)
122 if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
123     CXXFLAGS="$CXXFLAGS -D_REENTRANT"
124     CFLAGS="$CFLAGS -D_REENTRANT"
125 fi
126 AM_CONDITIONAL(HAVE_THREADS, test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes")
127
128 AC_CHECK_LIB(socket, socket)
129
130 dnl X11 might be installed, but we don't want to use it for OSX -dw-
131 if test "$HOSTTYPE" != "macintosh" ; then
132     AC_CHECK_LIB(X11, XCreateWindow)
133     AC_CHECK_LIB(Xext, XShmCreateImage)
134     AC_CHECK_LIB(Xi, XGetExtensionVersion)
135     AC_CHECK_LIB(ICE, IceOpenConnection)
136     AC_CHECK_LIB(SM, SmcOpenConnection)
137     AC_CHECK_LIB(Xt, XtMalloc)
138     AC_CHECK_LIB(Xmu, XmuLookupStandardColormap)
139 fi
140
141 dnl check for OpenGL related libraries
142
143 if test "$HOSTTYPE" = "macintosh" ; then
144     dnl Macintosh OSX
145     LIBS="$LIBS -framework OpenGL -framework GLUT"
146 elif test "x$ac_cv_header_windows_h" != "xyes" ; then
147     dnl Reasonable stuff for non-windoze variants ... :-)
148
149     AC_CHECK_LIB(GLcore, glNewList)
150     if test "x$ac_cv_lib_GLcore_glNewList" = "xno" ; then
151         dnl if no GLcore, check for GL
152         AC_CHECK_LIB(GL, glNewList)
153         if test "x$ac_cv_lib_GL_glNewList" = "xno" ; then
154             dnl if no GL, check for MesaGL
155             AC_CHECK_LIB(MesaGL, glNewList)
156         fi
157     else
158         dnl if GLcore found, then also check for GL
159         AC_CHECK_LIB(GL, glXCreateContext)
160     fi
161
162     dnl if using mesa, check for xmesa.h
163     if test "x$ac_cv_lib_MesaGL_glNewList" = "xyes" ; then
164         AC_CHECK_HEADER(GL/xmesa.h)
165         if test "x$ac_cv_header_GL_xmesa_h" = "xyes"; then
166             AC_DEFINE( XMESA )
167             AC_DEFINE( FX )
168         fi
169     fi
170
171     AC_CHECK_LIB(GLU, gluLookAt)
172     if test "x$ac_cv_lib_GLU_gluLookAt" = "xno" ; then
173         dnl if no GLU, check for MesaGLU
174         AC_CHECK_LIB(MesaGLU, gluLookAt)
175     fi
176
177     dnl check for glut
178     AC_CHECK_LIB(glut, glutGetModifiers)
179
180     dnl test for glutGameModeString, but avoid adding glut a second time into
181     dnl the list of libraries
182     save_LIBS="$LIBS"
183     AC_CHECK_LIB(glut, glutGameModeString)
184     LIBS="$save_LIBS"
185 else
186     dnl Win32 is a little wierd because it has to try to handle the various
187     dnl winbloze-isms.  We'll just do this manually for now.
188
189     echo Win32 specific hacks...
190     AC_DEFINE(WIN32)
191
192     dnl force a failed check since we will be building under windoze
193     AM_CONDITIONAL(ENABLE_XMESA_FX, test "no" = "yes")
194
195     dnl just define these to true and hope for the best
196     ac_cv_lib_glut_glutGetModifiers="yes"
197     ac_cv_lib_glut_glutGameModeString="yes"
198
199     if test "x$with_sgi_opengl" = "xyes" ; then
200         echo "Building with glut.dll, glu.dll, and opengl.dll"
201         WIN32_GLUT=glut
202         WIN32_GLU=glu
203         WIN32_OPENGL=opengl
204     else 
205         echo "Building with glut32.dll, glu32.dll, and opengl32.dll"
206         WIN32_GLUT=glut32
207         WIN32_GLU=glu32
208         WIN32_OPENGL=opengl32
209     fi
210
211     LIBS="$LIBS -l${WIN32_GLUT} -l${WIN32_GLU} -l${WIN32_OPENGL}"
212     LIBS="$LIBS -luser32 -lgdi32"
213     echo "Will link apps with $LIBS"
214 fi
215
216 if test "x$ac_cv_lib_glut_glutGetModifiers" = "xno"; then
217     echo 
218     echo "Unable to find the necessary OpenGL or GLUT libraries."
219     echo "See config.log for automated test details and results ..."
220     exit 1
221 fi
222
223 if test "x$ac_cv_lib_glut_glutGameModeString" = "xno"; then
224     echo
225     echo "Your version of glut doesn't support game mode."
226     echo "You need to fetch and install the latest version of glut from:"
227     echo
228     echo "    http://reality.sgi.com/opengl/glut3/glut3.html"
229     exit 1
230 fi
231
232 opengl_LIBS="$LIBS"
233 LIBS="$base_LIBS"
234
235 AC_SUBST(base_LIBS)
236 AC_SUBST(opengl_LIBS)
237
238 AM_CONDITIONAL(HAVE_XWINDOWS, test "x$ac_cv_lib_X11_XCreateWindow" = "xyes" )
239
240 dnl Check for "plib" without which we cannot go on
241 AC_CHECK_HEADER(plib/pu.h)
242 if test "x$ac_cv_header_plib_pu_h" != "xyes"; then
243     echo
244     echo "You *must* have the plib library installed on your system to build"
245     echo "the FGFS simulator!"
246     echo
247     echo "Please see README.plib for more details."
248     echo
249     echo "configure aborted."
250     exit
251 fi
252
253 # dnl Check for system installed gdbm
254 # AC_CHECK_HEADER(gdbm.h)
255 # if test "x$ac_cv_header_gdbm_h" = "xyes"; then
256 #     AC_DEFINE( HAVE_GDBM )
257 # else
258 #     echo "no gdbm found, configuring and building."
259 # fi
260 # AM_CONDITIONAL(HAVE_GDBM, test "x$ac_cv_header_gdbm_h" = "xyes" )
261
262 dnl Check for system installed metakit
263 AC_CHECK_HEADER(mk4.h)
264 if test "x$ac_cv_header_mk4_h" != "xyes"; then
265     echo "no metakit found, configuring and building."
266     # Run configure in the metakit subdir
267     AC_CONFIG_SUBDIRS( simgear/metakit/unix )
268 fi
269 AM_CONDITIONAL(HAVE_METAKIT, test "x$ac_cv_header_mk4_h" = "xyes" )
270
271
272 dnl Specify if we want logging (testing build) or not (release build)
273
274 dnl Check for system installed zlib
275 AC_CHECK_HEADER(zlib.h)
276 if test "x$ac_cv_header_zlib_h" = "xyes"; then
277     AC_DEFINE( HAVE_ZLIB )
278 else
279     echo "no zlib found, building."
280 fi
281 AM_CONDITIONAL(HAVE_ZLIB, test "x$ac_cv_header_zlib_h" = "xyes" )
282
283 dnl Checks for header files.
284 AC_HEADER_STDC
285 AC_CHECK_HEADERS( \
286         fcntl.h getopt.h malloc.h memory.h stdint.h stdlib.h sys/param.h \
287         sys/stat.h sys/time.h sys/timeb.h unistd.h windows.h winbase.h values.h )
288
289 if test "x$ac_cv_header_stdint_h" = "xyes"; then
290     AC_DEFINE( HAVE_STDINT_H )
291 fi
292
293 dnl Checks for typedefs, structures, and compiler characteristics.
294 AC_C_CONST
295 AC_TYPE_SIZE_T
296 AC_HEADER_TIME
297 AC_STRUCT_TM
298
299 dnl Checks for library functions.
300 AC_TYPE_SIGNAL
301 AC_FUNC_VPRINTF
302 AC_CHECK_FUNCS( ftime gettimeofday timegm memcpy bcopy mktime strstr rand \
303         random setitimer getitimer signal GetLocalTime rint getrusage )
304
305 AM_CONFIG_HEADER(simgear/simgear_config.h)
306
307 AC_OUTPUT( \
308         Makefile \
309         SimGear.spec \
310         simgear/Makefile \
311         simgear/version.h \
312         simgear/bucket/Makefile \
313         simgear/debug/Makefile \
314         simgear/ephemeris/Makefile \
315         simgear/io/Makefile \
316         simgear/magvar/Makefile \
317         simgear/math/Makefile \
318         simgear/metar/Makefile \
319         simgear/misc/Makefile \
320         simgear/route/Makefile \
321         simgear/screen/Makefile \
322         simgear/serial/Makefile \
323         simgear/sky/Makefile \
324         simgear/threads/Makefile \
325         simgear/timing/Makefile \
326         simgear/xgl/Makefile \
327         simgear/xml/Makefile \
328         simgear/zlib/Makefile \
329 )
330
331 AC_OUTPUT_COMMANDS([
332 #       if test "x$ac_cv_header_windows_h" = "xyes" ; then
333 #               cp simgear/gdbm/autoconf.h.cygwin32 simgear/gdbm/autoconf.h
334 #       fi
335 ])
336
337 echo ""
338 echo "Configure Summary"
339 echo "================="
340
341 echo "Prefix: $prefix"
342
343 if test "x$with_logging" != "x"; then
344     echo "Debug messages: $with_logging"
345 else
346     echo "Debug messages: yes"
347 fi
348
349 if test "x$with_efence" != "x"; then
350     echo "Electric fence: $with_efence"
351 else
352     echo "Electric fence: no"
353 fi
354
355 echo -n "Automake version: ($AUTO_MAKE_VERSION) "
356 automake --version | head -1
357
358 if test "x$ac_cv_header_mk4_h" != "xyes"; then
359    echo "Building metakit"
360 fi
361
362 if test "x$ac_cv_header_zlib_h" != "xyes"; then
363    echo "Building zlib"
364 fi
365
366 if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
367    echo "Threads: pthread lib found."
368 else
369    echo "Threads: no threads (pthread lib not found.)"
370 fi
371
372 if test "$OS" = "IRIX" -o "$OS" = "IRIX64"; then
373     if test "$CXX" = "CC"; then
374         echo "\nRemember to run: sh ../FlightGear/irix-hack.sh!\07\n"
375     fi
376 fi