2 # Copyright 2012 Xamarin Inc
5 [http://bugzilla.xamarin.com/enter_bug.cgi?classification=Mono])
7 AC_CONFIG_SRCDIR([README])
8 AC_CONFIG_MACRO_DIR([m4])
12 AM_INIT_AUTOMAKE([1.9 dist-bzip2 tar-ustar no-dist-gzip foreign])
13 AC_CONFIG_HEADERS([config.h])
16 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
20 # Use dolt (http://dolt.freedesktop.org/) instead of libtool for building.
24 BREAKPOINT="G_STMT_START { raise (SIGTRAP); } G_STMT_END"
25 if test x$GCC = xyes; then
26 GNUC_UNUSED='__attribute__((__unused__))'
27 GNUC_NORETURN='__attribute__((__noreturn__))'
29 i*86|x86_64) BREAKPOINT="G_STMT_START { __asm__ (\"int \$03\"); } G_STMT_END" ;;
34 AC_SUBST(GNUC_NORETURN)
37 # We use a separate variable to pass down CPPFLAGS and CFLAGS from the main mono
38 # configure, because of autoconf brokeness
39 if test "x$CPPFLAGS_FOR_EGLIB" != "x"; then
40 CPPFLAGS=$CPPFLAGS_FOR_EGLIB
42 if test "x$CFLAGS_FOR_EGLIB" != "x"; then
43 CFLAGS=$CFLAGS_FOR_EGLIB
46 CFLAGS="$CFLAGS -g -D_GNU_SOURCE"
48 AM_CONDITIONAL(CROSS_COMPILING, [test x$cross_compiling = xyes])
49 AC_C_BIGENDIAN([ORDER=G_BIG_ENDIAN],[ORDER=G_LITTLE_ENDIAN])
55 *-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
70 AC_DEFINE(PLATFORM_ANDROID,1,[Targeting the Android platform])
86 CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS"
91 arm*-darwin*|aarch64*-*)
92 CFLAGS="$CFLAGS -U_FORTIFY_SOURCE"
98 CFLAGS="$CFLAGS -pthread"
99 LDFLAGS="$LDFLAGS -pthread"
106 if test "x$platform_darwin" = "xyes"; then
107 AC_TRY_COMPILE([#include "TargetConditionals.h"],[
108 #if TARGET_IPHONE_SIMULATOR == 1 || TARGET_OS_IPHONE == 1
109 #error fail this for ios
113 AC_DEFINE(TARGET_OSX,1,[The JIT/AOT targets OSX])
116 AC_DEFINE(TARGET_IOS,1,[The JIT/AOT targets iOS])
119 AC_DEFINE(TARGET_MACH,1,[The JIT/AOT targets Apple platforms])
128 AM_CONDITIONAL(HOST_WIN32, test x$OS = xWIN32)
129 AM_CONDITIONAL(TARGET_WIN32, test x$OS = xWIN32)
130 AM_CONDITIONAL(PLATFORM_DARWIN, test x$platform_darwin = xyes)
131 AM_CONDITIONAL(PLATFORM_ANDROID, test x$platform_android = xyes)
133 # Defined for all targets/platforms using classic Windows API support.
134 AC_DEFINE(HAVE_CLASSIC_WINAPI_SUPPORT, 1, [Use classic Windows API support])
135 AC_DEFINE(HAVE_UWP_WINAPI_SUPPORT, 0, [Don't use UWP Windows API support])
138 AC_CHECK_SIZEOF(void *)
139 AC_CHECK_SIZEOF(long)
140 AC_CHECK_SIZEOF(long long)
141 AC_CHECK_FUNCS(strlcpy stpcpy strtok_r rewinddir vasprintf)
142 AC_CHECK_FUNCS(getrlimit)
143 AC_CHECK_FUNCS(fork execv execve)
145 AC_ARG_WITH([overridable-allocators], [ --with-overridable-allocators allow g_*alloc/g_free to call custom allocators set via g_mem_set_vtable])
147 if test x$with_overridable_allocators = xyes; then
148 AC_DEFINE(ENABLE_OVERRIDABLE_ALLOCATORS,1,[Overridable allocator support enabled])
149 AC_MSG_NOTICE([Overridable allocator support enabled])
151 AC_MSG_NOTICE([Overridable allocator support disabled])
155 # Mono currently supports 10.6, but strndup is not available prior to 10.7; avoiding
156 # the detection of strndup on OS X so Mono built on 10.7+ still runs on 10.6. This can be
157 # removed once support for 10.6 is dropped.
159 # iOS detection of strndup and getpwuid_r is faulty for some reason so let's simply avoid it
161 if test x$target_osx = xyes; then
162 AC_CHECK_FUNCS(getpwuid_r)
163 elif test x$target_ios = xno; then
164 AC_CHECK_FUNCS(strndup getpwuid_r)
167 AM_CONDITIONAL(NEED_VASPRINTF, test x$ac_cv_func_vasprintf = xno || test x$with_overridable_allocators = xyes)
169 AC_SEARCH_LIBS(sqrtf, m)
171 # nanosleep may not be part of libc, also search it in other libraries
172 AC_SEARCH_LIBS(nanosleep, rt)
174 AC_SEARCH_LIBS(dlopen, dl)
175 old_ldflags="${LDFLAGS}"
176 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
177 AC_TRY_LINK(, [int i;], found_export_dynamic=yes, found_export_dynamic=no)
178 if test $found_export_dynamic = no; then
179 LDFLAGS="${old_ldflags}"
182 AC_MSG_CHECKING(for varargs macros)
184 int foo (int i, int j);
185 #define bar(...) foo (1, __VA_ARGS__)
189 ],have_iso_varargs=yes,have_iso_varargs=no)
190 AC_MSG_RESULT($have_iso_varargs)
192 if test "x$have_iso_varargs" = "xyes"; then
195 AC_SUBST(G_HAVE_ISO_VARARGS)
197 AC_CHECK_HEADERS(getopt.h sys/select.h sys/time.h sys/wait.h pwd.h iconv.h localcharset.h sys/types.h sys/resource.h)
198 AC_CHECK_LIB([iconv], [locale_charset],[],[AC_CHECK_LIB([charset], [locale_charset],[LIBS+="-liconv -lcharset"])])
199 AC_CHECK_HEADER(alloca.h, [HAVE_ALLOCA_H=1], [HAVE_ALLOCA_H=0])
200 AC_SUBST(HAVE_ALLOCA_H)
202 if test $ac_cv_sizeof_void_p = $ac_cv_sizeof_int; then
203 GPOINTER_TO_INT="((gint) (ptr))"
204 GPOINTER_TO_UINT="((guint) (ptr))"
205 GINT_TO_POINTER="((gpointer) (v))"
206 GUINT_TO_POINTER="((gpointer) (v))"
209 elif test $ac_cv_sizeof_void_p = $ac_cv_sizeof_long; then
210 GPOINTER_TO_INT="((gint)(long) (ptr))"
211 GPOINTER_TO_UINT="((guint)(long) (ptr))"
212 GINT_TO_POINTER="((gpointer)(glong) (v))"
213 GUINT_TO_POINTER="((gpointer)(gulong) (v))"
216 elif test $ac_cv_sizeof_void_p = $ac_cv_sizeof_long_long; then
217 GPOINTER_TO_INT="((gint)(long long) (ptr))"
218 GPOINTER_TO_UINT="((guint)(unsigned long long) (ptr))"
219 GINT_TO_POINTER="((gpointer)(long long) (v))"
220 GUINT_TO_POINTER="((gpointer)(unsigned long long) (v))"
222 GSIZE_FORMAT='"I64u"'
224 AC_MSG_ERROR([unsupported pointer size])
227 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
230 AC_ARG_WITH(crosspkgdir, [ --with-crosspkgdir=/path/to/pkg-config/dir Change pkg-config dir to custom dir],
231 if test x$with_crosspkgdir = "x"; then
232 if test -s $PKG_CONFIG_PATH; then
233 pkg_config_path=$PKG_CONFIG_PATH
236 pkg_config_path=$with_crosspkgdir
237 PKG_CONFIG_PATH=$pkg_config_path
238 export PKG_CONFIG_PATH
242 AC_ARG_ENABLE(werror, [ --enable-werror Pass -Werror to the C compiler], werror_flag=$enableval, werror_flag=no)
243 if test x$werror_flag = xyes; then
244 WERROR_CFLAGS="-Werror"
246 AC_SUBST([WERROR_CFLAGS])
248 AC_SUBST(GPOINTER_TO_INT)
249 AC_SUBST(GPOINTER_TO_UINT)
250 AC_SUBST(GINT_TO_POINTER)
251 AC_SUBST(GUINT_TO_POINTER)
253 AC_SUBST(GSIZE_FORMAT)
254 AC_SUBST(G_GUINT64_FORMAT)
255 AC_SUBST(G_GINT64_FORMAT)
256 AC_SUBST(G_GUINT32_FORMAT)
257 AC_SUBST(G_GINT32_FORMAT)