Flush pending changes for 0.8
[mono.git] / configure.in
1
2 AC_INIT(README)
3 AC_CANONICAL_SYSTEM
4 AM_CONFIG_HEADER(config.h)
5 AM_INIT_AUTOMAKE(mono, 0.8)
6 AM_MAINTAINER_MODE
7
8 AC_CHECK_TOOL(CC, gcc, gcc)
9 AC_PROG_CC
10 AM_PROG_CC_STDC
11 AC_PROG_INSTALL
12
13 dnl may require a specific autoconf version
14 dnl AC_PROG_CC_FOR_BUILD
15 dnl CC_FOR_BUILD not automatically detected
16 CC_FOR_BUILD=$CC
17 BUILD_EXEEXT=
18 if test "x$cross_compiling" = "xyes"; then
19         CC_FOR_BUILD=cc
20         BUILD_EXEEXT=""
21 fi
22 AC_SUBST(CC_FOR_BUILD)
23 AC_SUBST(HOST_CC)
24 AC_SUBST(BUILD_EXEEXT)
25
26 # Set STDC_HEADERS
27 AC_HEADER_STDC
28 AC_LIBTOOL_WIN32_DLL
29 AM_PROG_LIBTOOL
30
31 # not 64 bit clean in cross-compile
32 AC_CHECK_SIZEOF(void *, 4)
33
34 CFLAGS='-g -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations'
35
36 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
37 if test "x$PKG_CONFIG" = "xno"; then
38         AC_MSG_ERROR([You need to install pkg-config])
39 fi
40
41 dnl for use on the build system
42 dnl pkg-config is stupid
43 BUILD_GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0`
44 BUILD_GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0`
45 AC_SUBST(BUILD_GLIB_CFLAGS)
46 AC_SUBST(BUILD_GLIB_LIBS)
47
48 PKG_PATH=
49 AC_ARG_WITH(crosspkgdir, [  --with-crosspkgdir=/path/to/pkg-config/dir],
50         if test x$with_crosspkgdir = "x"; then
51                 if test -s $PKG_CONFIG_PATH; then
52                         PKG_PATH=$PKG_CONFIG_PATH
53                 fi
54         else
55                 PKG_PATH=$with_crosspkgdir
56                 PKG_CONFIG_PATH=$PKG_PATH
57                 export PKG_CONFIG_PATH
58         fi
59 )
60
61 ## Versions of dependencies
62 GLIB_REQUIRED_VERSION=1.3.11
63
64 PKG_CHECK_MODULES(BASE_DEPENDENCIES, glib-2.0 >= $GLIB_REQUIRED_VERSION)
65
66 GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0`
67 GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0`
68 GMODULE_CFLAGS=`$PKG_CONFIG --cflags gmodule-2.0`
69 GMODULE_LIBS=`$PKG_CONFIG --libs gmodule-2.0`
70
71 AC_SUBST(GLIB_CFLAGS)
72 AC_SUBST(GLIB_LIBS)
73 AC_SUBST(GMODULE_CFLAGS)
74 AC_SUBST(GMODULE_LIBS)
75
76 dnl ****************************************
77 dnl *** Check if we're building on win32 ***
78 dnl ****************************************
79 AC_MSG_CHECKING([if building for some Win32 platform])
80 case "$host" in
81         *-*-mingw*|*-*-cygwin*)
82                 platform_win32=yes
83                 AC_DEFINE(PLATFORM_WIN32)
84                 ;;
85         *)
86                 platform_win32=no
87                 ;;
88 esac
89 AC_MSG_RESULT($platform_win32)
90 AM_CONDITIONAL(PLATFORM_WIN32, test x$platform_win32 = xyes)
91
92 if test x$platform_win32 = xyes; then
93         AC_MSG_CHECKING([if building for native Win32])
94         case "$host" in
95                 *-*-mingw*)
96                         platform_win32_native=yes
97                         AC_DEFINE(PLATFORM_WIN32_NATIVE)
98                         ;;
99                 *)
100                         platform_win32_native=no
101                         ;;
102         esac
103         AC_MSG_RESULT($platform_win32_native)
104         AM_CONDITIONAL(PLATFORM_WIN32_NATIVE,
105                        test x$platform_win32_native = xyes)
106 fi
107
108
109 if test x$platform_win32 = xno; then
110         dnl ******************************************************************
111         dnl *** Check for large file support                               ***
112         dnl *** (If we were using autoconf 2.50 we'd use AC_SYS_LARGEFILE) ***
113         dnl ******************************************************************
114         
115         # Check that off_t can represent 2**63 - 1 correctly, working around
116         # potential compiler bugs.  Defines LARGE_FILE_SUPPORT, adds $1 to
117         # CFLAGS and sets $large_offt to yes if the test succeeds
118         large_offt=no
119         AC_DEFUN(LARGE_FILES, [
120                 large_CPPFLAGS=$CPPFLAGS
121                 CPPFLAGS="$CPPFLAGS $1"
122                 AC_TRY_RUN([
123                         #include <sys/types.h>
124
125                         #define BIG_OFF_T (((off_t)1<<62)-1+((off_t)1<<62))
126
127                         int main(void) {
128                                 int big_off_t=((BIG_OFF_T%2147483629==721) &&
129                                                (BIG_OFF_T%2147483647==1));
130                                 if(big_off_t) {
131                                         exit(0);
132                                 } else {
133                                         exit(1);
134                                 }
135                         }
136                 ], [
137                         AC_MSG_RESULT(ok)
138                         AC_DEFINE(HAVE_LARGE_FILE_SUPPORT)
139                         CFLAGS="$CFLAGS $1"
140                         large_offt=yes
141                 ], [
142                         AC_MSG_RESULT(no)
143                 ], "")
144                 CPPFLAGS=$large_CPPFLAGS
145         ])
146
147         AC_MSG_CHECKING(if off_t is 64 bits wide)
148         LARGE_FILES("")
149         if test $large_offt = no; then
150                 AC_MSG_CHECKING(if _FILE_OFFSET_BITS=64 gives 64 bit off_t)
151                 LARGE_FILES("-D_FILE_OFFSET_BITS=64")
152         fi
153         if test $large_offt = no; then
154                 AC_MSG_WARN([No 64 bit file size support available])
155         fi
156
157
158         dnl *****************************
159         dnl *** Checks for libpthread ***
160         dnl *****************************
161         AC_SEARCH_LIBS(pthread_create, pthread, [
162                 AM_CONDITIONAL(THREADS_PTHREAD, true)
163                 AC_DEFINE(HAVE_PTHREAD)
164
165                 # Need pthread_mutex_timedlock
166                 pthread_CFLAGS=""
167                 orig_CPPFLAGS=$CPPFLAGS
168                 # This is a gcc-specific error, but we already set
169                 # gcc-specific options in CFLAGS
170                 CPPFLAGS="$CPPFLAGS -Werror-implicit-function-declaration"
171                 AC_MSG_CHECKING(for pthread_mutex_timedlock)
172                 AC_TRY_COMPILE([ #include <pthread.h>], [
173                         pthread_mutex_t mut=PTHREAD_MUTEX_INITIALIZER;
174                         pthread_mutex_timedlock(&mut, NULL);
175                 ], [
176                         # Works!
177                         AC_MSG_RESULT(ok)
178                         AC_DEFINE(HAVE_PTHREAD_MUTEX_TIMEDLOCK)
179                 ], [
180                         AC_MSG_RESULT(no)
181
182                         # glibc requires -D_GNU_SOURCE before it will declare
183                         # this function
184                         AC_MSG_CHECKING(whether _GNU_SOURCE is needed for pthread_mutex_timedlock)
185                         CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
186                         AC_TRY_COMPILE([ #include <pthread.h>], [
187                                 pthread_mutex_t mut=PTHREAD_MUTEX_INITIALIZER;
188                                 pthread_mutex_timedlock(&mut, NULL);
189                         ], [
190                                 AC_MSG_RESULT(ok)
191                                 pthread_CFLAGS="-D_GNU_SOURCE"
192                                 AC_DEFINE(HAVE_PTHREAD_MUTEX_TIMEDLOCK)
193                         ], [
194                                 AC_MSG_RESULT(no)
195                                 dnl Add other variants here
196                                 AC_MSG_WARN(Working around pthread_mutex_timedlock)
197                         ])
198                 ])
199                 CPPFLAGS=$orig_CPPFLAGS
200                 CFLAGS="$CFLAGS $pthread_CFLAGS"
201
202                 # Need PTHREAD_MUTEX_RECURSIVE
203                 pthread_CFLAGS=""
204                 orig_CPPFLAGS=$CPPFLAGS
205                 # This is a gcc-specific error, but we already set
206                 # gcc-specific options in CFLAGS
207                 CPPFLAGS="$CPPFLAGS -Werror-implicit-function-declaration"
208                 AC_MSG_CHECKING(for PTHREAD_MUTEX_RECURSIVE)
209                 AC_TRY_COMPILE([ #include <pthread.h>], [
210                         pthread_mutexattr_t attr;
211                         pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
212                 ], [
213                         # Works!
214                         AC_MSG_RESULT(ok)
215                 ], [
216                         AC_MSG_RESULT(no)
217
218                         # glibc requires -D_GNU_SOURCE before it will declare
219                         # this macro
220                         AC_MSG_CHECKING(whether _GNU_SOURCE is needed for PTHREAD_MUTEX_RECURSIVE)
221                         CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
222                         AC_TRY_COMPILE([ #include <pthread.h>], [
223                                 pthread_mutexattr_t attr;
224                                 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
225                         ], [
226                                 AC_MSG_RESULT(ok)
227                                 pthread_CFLAGS="-D_GNU_SOURCE"
228                         ], [
229                                 AC_MSG_RESULT(no)
230                                 dnl Add other variants here
231                                 AC_MSG_ERROR([PTHREAD_MUTEX_RECURSIVE not found])
232                         ])
233                 ])
234                 CPPFLAGS=$orig_CPPFLAGS
235                 CFLAGS="$CFLAGS $pthread_CFLAGS"
236         ], [
237                 AC_MSG_ERROR([libpthread is required on non-win32 hosts])
238         ])
239 fi
240
241 if test "x$cross_compiling" = "xno"; then
242 # check for new iconv version
243 AC_MSG_CHECKING(for new iconv)
244 AC_CACHE_VAL(new_iconv,[
245         AC_TRY_RUN([#include <stdio.h> 
246                 #include <iconv.h>
247  
248                 int main()
249                 {
250                   exit (iconv_open ("UTF-16le", "UTF-8") == (iconv_t)-1);
251                 }
252                 ],
253                 new_iconv=yes,new_iconv=)])
254 if test -n "$new_iconv"; then
255         AC_MSG_RESULT(yes)
256         AC_DEFINE(HAVE_NEW_ICONV)
257 else
258         AC_MSG_RESULT(no)
259 fi
260 fi
261
262 TARGET="unknown"
263 ACCESS_UNALIGNED="yes"
264
265 case "$host" in
266 #mips-sgi-irix5.* | mips-sgi-irix6.*) TARGET=MIPS; ACCESS_UNALIGNED="no";;
267 i*86-*-*) TARGET=X86; arch_target=x86;;
268 sparc*-*-*) TARGET=SPARC; ACCESS_UNALIGNED="no";;
269 #alpha*-*-linux* | alpha*-*-osf*) TARGET=ALPHA; ACCESS_UNALIGNED="no";;
270 #m68k-*-linux*) TARGET=M68K;;
271 powerpc-*-linux* | powerpc-*-sysv*) TARGET=POWERPC; arch_target=ppc;;
272 #arm-*-linux-*) TARGET=ARM; ACCESS_UNALIGNED="no";;
273 esac
274
275 if test ${TARGET} = unknown; then
276         CFLAGS="$CFLAGS -DNO_PORT"
277         AC_MSG_WARN("mono has not been ported to $host: some things may not work.")
278 fi
279
280 if test ${ACCESS_UNALIGNED} = no; then
281         CPPFLAGS="$CPPFLAGS -DNO_UNALIGNED_ACCESS"
282 fi
283
284 AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
285 AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
286 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
287 AM_CONDITIONAL(X86, test x$TARGET = xX86)
288 AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
289 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
290 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
291 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
292
293 AC_SUBST(arch_target)
294 AC_SUBST(CFLAGS)
295
296 AC_OUTPUT([
297 Makefile
298 mono/Makefile
299 mono/metadata/Makefile
300 mono/dis/Makefile
301 mono/cil/Makefile
302 mono/arch/Makefile
303 mono/arch/x86/Makefile
304 mono/arch/ppc/Makefile
305 mono/arch/sparc/Makefile
306 mono/interpreter/Makefile
307 mono/tests/Makefile
308 mono/wrapper/Makefile
309 mono/monoburg/Makefile
310 mono/jit/Makefile
311 mono/io-layer/Makefile
312 runtime/Makefile
313 scripts/Makefile
314 man/Makefile
315 doc/Makefile
316 ])