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