Don't unroll the loops unless told to
[mono.git] / eglib / configure.ac
1 AC_INIT(eglib, [0.3],
2         [http://bugzilla.novell.com/enter_bug.cgi?product=mono])
3
4 AC_CONFIG_SRCDIR([README])
5 AC_CONFIG_MACRO_DIR([m4])
6 AC_CANONICAL_SYSTEM
7 AC_CANONICAL_HOST
8
9 AM_INIT_AUTOMAKE([1.9 dist-bzip2 tar-ustar no-dist-gzip foreign])
10 AM_CONFIG_HEADER([config.h])
11 AM_MAINTAINER_MODE
12
13 AC_PROG_CC
14 AM_PROG_LIBTOOL
15 # Use dolt (http://dolt.freedesktop.org/) instead of libtool for building.
16 DOLT
17 GNUC_PRETTY=
18 GNUC_UNUSED=
19 BREAKPOINT="G_STMT_START { raise (SIGTRAP); } G_STMT_END"
20 if test x$GCC = xyes; then
21    GNUC_UNUSED='__attribute__((__unused__))'
22    GNUC_NORETURN='__attribute__((__noreturn__))'
23    case $host_cpu in
24      i*86|x86_64) BREAKPOINT="G_STMT_START { __asm__ (\"int \$03\"); } G_STMT_END" ;;
25    esac
26 fi
27 AC_SUBST(GNUC_PRETTY)
28 AC_SUBST(GNUC_UNUSED)
29 AC_SUBST(GNUC_NORETURN)
30 AC_SUBST(BREAKPOINT)
31
32 # We use a separate variable to pass down CPPFLAGS and CFLAGS from the main mono 
33 # configure, because of autoconf brokeness
34 if test "x$CPPFLAGS_FOR_EGLIB" != "x"; then
35    CPPFLAGS=$CPPFLAGS_FOR_EGLIB
36 fi
37 if test "x$CFLAGS_FOR_EGLIB" != "x"; then
38    CFLAGS=$CFLAGS_FOR_EGLIB
39 fi
40
41 CFLAGS="$CFLAGS -g -D_GNU_SOURCE"
42
43 AM_CONDITIONAL(CROSS_COMPILING, [test x$cross_compiling = xyes])
44 AC_C_BIGENDIAN([ORDER=G_BIG_ENDIAN],[ORDER=G_LITTLE_ENDIAN])
45
46 platform_darwin=no
47
48 case $host in
49 *-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
50     PATHSEP='\\'
51     SEARCHSEP=';'
52     OS="WIN32"
53     PIDTYPE='void *'
54     ;;
55 *-*darwin*)
56     platform_darwin=yes
57     PATHSEP='/'
58     SEARCHSEP=':'
59     OS="UNIX"
60     PIDTYPE='int'
61     ;;
62 *)
63     PATHSEP='/'
64     SEARCHSEP=':'
65     OS="UNIX"
66     PIDTYPE='int'
67     ;;
68 esac
69
70 case $host in
71         *-*-solaris*)
72         CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS"
73         ;;
74 esac
75
76 case $target in
77 arm*-darwin*)
78     CFLAGS="$CFLAGS -U_FORTIFY_SOURCE"
79     ;;
80 i*86-*-darwin*)
81     ORDER=G_LITTLE_ENDIAN
82     ;;
83 *-*-openbsd*)
84     CFLAGS="$CFLAGS -pthread"
85     LDFLAGS="$LDFLAGS -pthread"
86     ;;
87 esac
88
89 AC_SUBST(ORDER)
90 AC_SUBST(CFLAGS)
91 AC_SUBST(PATHSEP)
92 AC_SUBST(SEARCHSEP)
93 AC_SUBST(OS)
94 AC_SUBST(PIDTYPE)
95 AM_CONDITIONAL(HOST_WIN32, test x$OS = xWIN32)
96 AM_CONDITIONAL(TARGET_WIN32, test x$OS = xWIN32)
97 AM_CONDITIONAL(PLATFORM_DARWIN, test x$platform_darwin = xyes)
98
99 AC_CHECK_SIZEOF(int)
100 AC_CHECK_SIZEOF(void *)
101 AC_CHECK_SIZEOF(long)
102 AC_CHECK_SIZEOF(long long)
103 AC_CHECK_FUNCS(strndup strlcpy stpcpy getpwuid_r strtok_r rewinddir vasprintf)
104 AM_CONDITIONAL(NEED_VASPRINTF, test x$have_vasprintf = x )
105 AM_ICONV()
106 AC_SEARCH_LIBS(sqrtf, m)
107
108 # nanosleep may not be part of libc, also search it in other libraries
109 AC_SEARCH_LIBS(nanosleep, rt)
110
111 AC_SEARCH_LIBS(dlopen, dl)
112 old_ldflags="${LDFLAGS}"
113 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
114 AC_TRY_LINK(, [int i;], found_export_dynamic=yes, found_export_dynamic=no)
115 if test $found_export_dynamic = no; then
116         LDFLAGS="${old_ldflags}"
117 fi
118
119 AC_MSG_CHECKING(for varargs macros)
120 AC_TRY_COMPILE([],[
121 int foo (int i, int j);
122 #define bar(...) foo (1, __VA_ARGS__)
123 void main () {
124          bar (2);
125 }
126 ],have_iso_varargs=yes,have_iso_varargs=no)
127 AC_MSG_RESULT($have_iso_varargs)
128 G_HAVE_ISO_VARARGS=0
129 if test "x$have_iso_varargs" = "xyes"; then
130    G_HAVE_ISO_VARARGS=1
131 fi
132 AC_SUBST(G_HAVE_ISO_VARARGS)
133
134 AC_CHECK_HEADERS(getopt.h sys/time.h sys/wait.h pwd.h langinfo.h iconv.h localcharset.h sys/types.h)
135 AC_CHECK_HEADER(alloca.h, [HAVE_ALLOCA_H=1], [HAVE_ALLOCA_H=0])
136 AC_SUBST(HAVE_ALLOCA_H)
137
138 if test $ac_cv_sizeof_void_p = $ac_cv_sizeof_int; then
139    GPOINTER_TO_INT="((gint) (ptr))"
140    GPOINTER_TO_UINT="((guint) (ptr))"
141    GINT_TO_POINTER="((gpointer) (v))"
142    GUINT_TO_POINTER="((gpointer) (v))"
143    GSIZE="int"
144    GSIZE_FORMAT='"u"'
145    G_GUINT64_FORMAT='"llu"'
146    G_GINT64_FORMAT='"lld"'
147    G_GUINT32_FORMAT='"lu"'
148    G_GINT32_FORMAT='"ld"'
149 elif test $ac_cv_sizeof_void_p = $ac_cv_sizeof_long; then
150    GPOINTER_TO_INT="((gint)(long) (ptr))"
151    GPOINTER_TO_UINT="((guint)(long) (ptr))"
152    GINT_TO_POINTER="((gpointer)(glong) (v))"
153    GUINT_TO_POINTER="((gpointer)(gulong) (v))"
154    GSIZE="long"
155    GSIZE_FORMAT='"lu"'
156    G_GUINT64_FORMAT='"lu"'
157    G_GINT64_FORMAT='"ld"'
158    G_GUINT32_FORMAT='"u"'
159    G_GINT32_FORMAT='"d"'
160 elif test $ac_cv_sizeof_void_p = $ac_cv_sizeof_long_long; then
161    GPOINTER_TO_INT="((gint)(long long) (ptr))"
162    GPOINTER_TO_UINT="((guint)(unsigned long long) (ptr))"
163    GINT_TO_POINTER="((gpointer)(long long) (v))"
164    GUINT_TO_POINTER="((gpointer)(unsigned long long) (v))"
165    GSIZE="long long"
166    GSIZE_FORMAT='"I64u"'
167    G_GUINT64_FORMAT='"I64u"'
168    G_GINT64_FORMAT='"I64i"'
169    G_GUINT32_FORMAT='"I32u"'
170    G_GINT32_FORMAT='"I32i"'
171 else
172    AC_MSG_ERROR([unsupported pointer size])
173 fi
174
175 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
176
177 pkg_config_path=
178 AC_ARG_WITH(crosspkgdir, [  --with-crosspkgdir=/path/to/pkg-config/dir      Change pkg-config dir to custom dir],
179         if test x$with_crosspkgdir = "x"; then
180                 if test -s $PKG_CONFIG_PATH; then
181                         pkg_config_path=$PKG_CONFIG_PATH
182                 fi
183         else
184                 pkg_config_path=$with_crosspkgdir
185                 PKG_CONFIG_PATH=$pkg_config_path
186                 export PKG_CONFIG_PATH
187         fi
188 )
189
190 dnl
191 dnl No, you can not replace the call below with a pkg.m4 macro
192 dnl
193 have_glib=false
194 if test "x$PKG_CONFIG" != "xno"; then
195     if $PKG_CONFIG --atleast-version=$GLIB_REQUIRED_VERSION glib-2.0; then
196         have_glib=true;
197     else
198         have_glib=false;
199     fi
200 fi
201 AM_CONDITIONAL(HAVE_GLIB, $have_glib)
202
203 AC_ARG_ENABLE(quiet-build, [  --enable-quiet-build  Enable quiet runtime build (on by default)], enable_quiet_build=$enableval, enable_quiet_build=yes)
204 AC_SUBST(GPOINTER_TO_INT)
205 AC_SUBST(GPOINTER_TO_UINT)
206 AC_SUBST(GINT_TO_POINTER)
207 AC_SUBST(GUINT_TO_POINTER)
208 AC_SUBST(GSIZE)
209 AC_SUBST(GSIZE_FORMAT)
210 AC_SUBST(G_GUINT64_FORMAT)
211 AC_SUBST(G_GINT64_FORMAT)
212 AC_SUBST(G_GUINT32_FORMAT)
213 AC_SUBST(G_GINT32_FORMAT)
214
215 if test x$enable_quiet_build = xyes; then
216    AC_CONFIG_COMMANDS([quiet], [for i in `find src test -name Makefile.in | sed -e 's/Makefile.in/Makefile/g'`; do if test -f $i; then $srcdir/../scripts/patch-quiet.sh $i; fi; done], [shell=$SHELL])
217    AC_CONFIG_COMMANDS([quiet-libtool], [sed -e 's/$echo "copying selected/$show "copying selected/g' < libtool > libtool.tmp && mv libtool.tmp libtool && chmod a+x libtool; sed -e 's/$ECHO "copying selected/# "copying selected/g' < libtool > libtool.tmp && mv libtool.tmp libtool && chmod a+x libtool])
218 fi
219
220 AC_OUTPUT([
221 Makefile
222 m4/Makefile
223 src/Makefile
224 src/eglib-config.h
225 test/Makefile
226 ])