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