a50c9ffaba5995ecfa191fe51781d1aa8507ff55
[mono.git] / configure.in
1 AC_INIT(README)
2 AM_CONFIG_HEADER(config.h)
3 AM_INIT_AUTOMAKE(mono, 0.7)
4 AM_MAINTAINER_MODE
5
6 AC_CANONICAL_HOST
7
8 AC_PROG_CC
9 AM_PROG_CC_STDC
10 AC_PROG_INSTALL
11
12 # Set STDC_HEADERS
13 AC_HEADER_STDC
14 AM_PROG_LIBTOOL
15
16 AC_CHECK_SIZEOF(void *)
17
18 CFLAGS='-g -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations'
19
20 dnl ***************************
21 dnl *** Checks for glib 1.2 ***
22 dnl ***************************
23 AM_PATH_GLIB(1.2.0,,
24              AC_MSG_ERROR([Cannot find GLIB: Is glib-config in path?]))
25
26 GLIB_CFLAGS=`glib-config --cflags glib`
27 GLIB_LIBS=`glib-config --libs glib`
28
29 AC_SUBST(GLIB_CFLAGS)
30 AC_SUBST(GLIB_LIBS)
31
32 GMODULE_CFLAGS=`glib-config --cflags gmodule`
33 GMODULE_LIBS=`glib-config --libs gmodule`
34
35 AC_SUBST(GMODULE_CFLAGS)
36 AC_SUBST(GMODULE_LIBS)
37
38 dnl *****************************
39 dnl *** Checks for libpthread ***
40 dnl *****************************
41 AC_CHECK_LIB(pthread, pthread_create, [
42                 THREAD_LIBS=-lpthread
43                 AM_CONDITIONAL(THREADS_PTHREAD, true)
44                 AC_DEFINE(HAVE_PTHREAD)
45
46                 # Need pthread_mutex_timedlock
47                 pthread_CFLAGS=""
48                 orig_CPPFLAGS=$CPPFLAGS
49                 # This is a gcc-specific error, but we already set gcc-specific
50                 # options in CFLAGS :)
51                 CPPFLAGS="$CPPFLAGS -Werror-implicit-function-declaration"
52                 AC_MSG_CHECKING(for pthread_mutex_timedlock)
53                 AC_TRY_COMPILE([ #include <pthread.h>], [
54                         pthread_mutex_t mut=PTHREAD_MUTEX_INITIALIZER;
55                         pthread_mutex_timedlock(&mut, NULL);
56                 ], [
57                         # Works!
58                         AC_MSG_RESULT(ok)
59                         AC_DEFINE(HAVE_PTHREAD_MUTEX_TIMEDLOCK)
60                 ], [
61                         AC_MSG_RESULT(no)
62
63                         # glibc requires -D_GNU_SOURCE before it will declare
64                         # this function
65                         AC_MSG_CHECKING(whether _GNU_SOURCE is needed for pthread_mutex_timedlock)
66                         CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
67                         AC_TRY_COMPILE([ #include <pthread.h>], [
68                                 pthread_mutex_t mut=PTHREAD_MUTEX_INITIALIZER;
69                                 pthread_mutex_timedlock(&mut, NULL);
70                         ], [
71                                 AC_MSG_RESULT(ok)
72                                 pthread_CFLAGS="-D_GNU_SOURCE"
73                                 AC_DEFINE(HAVE_PTHREAD_MUTEX_TIMEDLOCK)
74                         ], [
75                                 AC_MSG_RESULT(no)
76                                 dnl Add other variants here
77                                 AC_MSG_WARN(Working around pthread_mutex_timedlock)
78                         ])
79                 ])
80                 CPPFLAGS=$orig_CPPFLAGS
81                 CFLAGS="$CFLAGS $pthread_CFLAGS"
82         ], [
83                 AC_MSG_RESULT([Cannot find libpthread])
84                 # Check for other thread systems here, set THREAD_LIBS to
85                 # whatever is needed, and define
86                 # AM_CONDITIONAL(THREADS_foo, true), and add it to the
87                 # section in mono/metadata/Makefile.am, AC_DEFINE(HAVE_foo),
88                 # add that to acconfig.h, add the section for that in
89                 # mono/metadata/threads.h
90         ])
91 AC_SUBST(THREAD_LIBS)
92
93 TARGET="unknown"
94 ACCESS_UNALIGNED="yes"
95
96 case "$host" in
97 #mips-sgi-irix5.* | mips-sgi-irix6.*) TARGET=MIPS; ACCESS_UNALIGNED="no";;
98 i*86-*-*) TARGET=X86; arch_target=x86;;
99 sparc*-*-*) TARGET=SPARC; ACCESS_UNALIGNED="no";;
100 #alpha*-*-linux* | alpha*-*-osf*) TARGET=ALPHA; ACCESS_UNALIGNED="no";;
101 #m68k-*-linux*) TARGET=M68K;;
102 #powerpc-*-linux* | powerpc-*-sysv*) TARGET=POWERPC; ACCESS_UNALIGNED="no";;
103 #arm-*-linux-*) TARGET=ARM; ACCESS_UNALIGNED="no";;
104 esac
105
106 if test ${TARGET} = unknown; then
107         CFLAGS="$CFLAGS -DNO_PORT"
108         AC_MSG_WARN("mono has not been ported to $host: some things may not work.")
109 fi
110
111 if test ${ACCESS_UNALIGNED} = no; then
112         CPPFLAGS="$CPPFLAGS -DNO_UNALIGNED_ACCESS"
113 fi
114
115 AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
116 AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
117 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
118 AM_CONDITIONAL(X86, test x$TARGET = xX86)
119 AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
120 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
121 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
122 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
123
124 AC_SUBST(arch_target)
125 AC_SUBST(CFLAGS)
126
127 AC_OUTPUT([
128 Makefile
129 mono/Makefile
130 mono/metadata/Makefile
131 mono/dis/Makefile
132 mono/cil/Makefile
133 mono/arch/Makefile
134 mono/arch/x86/Makefile
135 mono/interpreter/Makefile
136 mono/tests/Makefile
137 mono/wrapper/Makefile
138 mono/monoburg/Makefile
139 mono/jit/Makefile
140 runtime/Makefile
141 doc/Makefile
142 ])