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