Temporary kludge to work around older linuxthreads implementations that
[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_ERROR(Need pthread_mutex_timedlock)
78                                 AC_MSG_WARN(Working around pthread_mutex_timedlock)
79                         ])
80                 ])
81                 CPPFLAGS=$orig_CPPFLAGS
82                 CFLAGS="$CFLAGS $pthread_CFLAGS"
83         ], [
84                 AC_MSG_RESULT([Cannot find libpthread])
85                 # Check for other thread systems here, set THREAD_LIBS to
86                 # whatever is needed, and define
87                 # AM_CONDITIONAL(THREADS_foo, true), and add it to the
88                 # section in mono/metadata/Makefile.am, AC_DEFINE(HAVE_foo),
89                 # add that to acconfig.h, add the section for that in
90                 # mono/metadata/threads.h
91         ])
92 AC_SUBST(THREAD_LIBS)
93
94 TARGET="unknown"
95
96 case "$host" in
97 #mips-sgi-irix5.* | mips-sgi-irix6.*) TARGET=MIPS;;
98 i*86-*-*) TARGET=X86; arch_target=x86;;
99 #sparc-sun-4*) TARGET=SPARC;;
100 #sparc-sun-*) TARGET=SPARC;;
101 #sparc*-*-linux*) TARGET=SPARC;;
102 #alpha*-*-linux* | alpha*-*-osf*) TARGET=ALPHA;;
103 #m68k-*-linux*) TARGET=M68K;;
104 #powerpc-*-linux* | powerpc-*-sysv*) TARGET=POWERPC;;
105 #arm-*-linux-*) TARGET=ARM;;
106 esac
107
108 if test ${TARGET} = unknown; then
109         CFLAGS="$CFLAGS -DNO_PORT"
110         AC_MSG_WARN("mono has not been ported to $host: some things may not work.")
111 fi
112
113 AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
114 AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
115 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
116 AM_CONDITIONAL(X86, test x$TARGET = xX86)
117 AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
118 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
119 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
120 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
121
122 AC_SUBST(arch_target)
123 AC_SUBST(CFLAGS)
124
125 AC_OUTPUT([
126 Makefile
127 mono/Makefile
128 mono/metadata/Makefile
129 mono/dis/Makefile
130 mono/cil/Makefile
131 mono/arch/Makefile
132 mono/arch/x86/Makefile
133 mono/interpreter/Makefile
134 mono/tests/Makefile
135 mono/wrapper/Makefile
136 mono/monoburg/Makefile
137 mono/jit/Makefile
138 runtime/Makefile
139 doc/Makefile
140 ])