Simplify building with the Android NDK.
[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 platform_android=no
48
49 case $host in
50 *-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
51     PATHSEP='\\'
52     SEARCHSEP=';'
53     OS="WIN32"
54     PIDTYPE='void *'
55     ;;
56 *-*darwin*)
57     platform_darwin=yes
58     PATHSEP='/'
59     SEARCHSEP=':'
60     OS="UNIX"
61     PIDTYPE='int'
62     ;;
63 *-*-linux-android*)
64     platform_android=yes
65     PATHSEP='/'
66     SEARCHSEP=':'
67     OS="UNIX"
68     PIDTYPE='int'
69     ;;
70 *)
71     PATHSEP='/'
72     SEARCHSEP=':'
73     OS="UNIX"
74     PIDTYPE='int'
75     ;;
76 esac
77
78 case $host in
79         *-*-solaris*)
80         CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS"
81         ;;
82 esac
83
84 case $target in
85 arm*-darwin*)
86     CFLAGS="$CFLAGS -U_FORTIFY_SOURCE"
87     ;;
88 i*86-*-darwin*)
89     ORDER=G_LITTLE_ENDIAN
90     ;;
91 *-*-openbsd*)
92     CFLAGS="$CFLAGS -pthread"
93     LDFLAGS="$LDFLAGS -pthread"
94     ;;
95 esac
96
97 AC_SUBST(ORDER)
98 AC_SUBST(CFLAGS)
99 AC_SUBST(PATHSEP)
100 AC_SUBST(SEARCHSEP)
101 AC_SUBST(OS)
102 AC_SUBST(PIDTYPE)
103 AM_CONDITIONAL(HOST_WIN32, test x$OS = xWIN32)
104 AM_CONDITIONAL(TARGET_WIN32, test x$OS = xWIN32)
105 AM_CONDITIONAL(PLATFORM_DARWIN, test x$platform_darwin = xyes)
106 AM_CONDITIONAL(PLATFORM_ANDROID, test x$platform_android = xyes)
107
108 AC_CHECK_SIZEOF(int)
109 AC_CHECK_SIZEOF(void *)
110 AC_CHECK_SIZEOF(long)
111 AC_CHECK_SIZEOF(long long)
112 AC_CHECK_FUNCS(strndup strlcpy stpcpy getpwuid_r strtok_r rewinddir vasprintf)
113 AM_CONDITIONAL(NEED_VASPRINTF, test x$have_vasprintf = x )
114 AM_ICONV()
115 AC_SEARCH_LIBS(sqrtf, m)
116
117 # nanosleep may not be part of libc, also search it in other libraries
118 AC_SEARCH_LIBS(nanosleep, rt)
119
120 AC_SEARCH_LIBS(dlopen, dl)
121 old_ldflags="${LDFLAGS}"
122 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
123 AC_TRY_LINK(, [int i;], found_export_dynamic=yes, found_export_dynamic=no)
124 if test $found_export_dynamic = no; then
125         LDFLAGS="${old_ldflags}"
126 fi
127
128 AC_MSG_CHECKING(for varargs macros)
129 AC_TRY_COMPILE([],[
130 int foo (int i, int j);
131 #define bar(...) foo (1, __VA_ARGS__)
132 void main () {
133          bar (2);
134 }
135 ],have_iso_varargs=yes,have_iso_varargs=no)
136 AC_MSG_RESULT($have_iso_varargs)
137 G_HAVE_ISO_VARARGS=0
138 if test "x$have_iso_varargs" = "xyes"; then
139    G_HAVE_ISO_VARARGS=1
140 fi
141 AC_SUBST(G_HAVE_ISO_VARARGS)
142
143 AC_CHECK_HEADERS(getopt.h sys/time.h sys/wait.h pwd.h langinfo.h iconv.h localcharset.h sys/types.h)
144 AC_CHECK_HEADER(alloca.h, [HAVE_ALLOCA_H=1], [HAVE_ALLOCA_H=0])
145 AC_SUBST(HAVE_ALLOCA_H)
146
147 if test $ac_cv_sizeof_void_p = $ac_cv_sizeof_int; then
148    GPOINTER_TO_INT="((gint) (ptr))"
149    GPOINTER_TO_UINT="((guint) (ptr))"
150    GINT_TO_POINTER="((gpointer) (v))"
151    GUINT_TO_POINTER="((gpointer) (v))"
152    GSIZE="int"
153    GSIZE_FORMAT='"u"'
154    G_GUINT64_FORMAT='"llu"'
155    G_GINT64_FORMAT='"lld"'
156    G_GUINT32_FORMAT='"lu"'
157    G_GINT32_FORMAT='"ld"'
158 elif test $ac_cv_sizeof_void_p = $ac_cv_sizeof_long; then
159    GPOINTER_TO_INT="((gint)(long) (ptr))"
160    GPOINTER_TO_UINT="((guint)(long) (ptr))"
161    GINT_TO_POINTER="((gpointer)(glong) (v))"
162    GUINT_TO_POINTER="((gpointer)(gulong) (v))"
163    GSIZE="long"
164    GSIZE_FORMAT='"lu"'
165    G_GUINT64_FORMAT='"lu"'
166    G_GINT64_FORMAT='"ld"'
167    G_GUINT32_FORMAT='"u"'
168    G_GINT32_FORMAT='"d"'
169 elif test $ac_cv_sizeof_void_p = $ac_cv_sizeof_long_long; then
170    GPOINTER_TO_INT="((gint)(long long) (ptr))"
171    GPOINTER_TO_UINT="((guint)(unsigned long long) (ptr))"
172    GINT_TO_POINTER="((gpointer)(long long) (v))"
173    GUINT_TO_POINTER="((gpointer)(unsigned long long) (v))"
174    GSIZE="long long"
175    GSIZE_FORMAT='"I64u"'
176    G_GUINT64_FORMAT='"I64u"'
177    G_GINT64_FORMAT='"I64i"'
178    G_GUINT32_FORMAT='"I32u"'
179    G_GINT32_FORMAT='"I32i"'
180 else
181    AC_MSG_ERROR([unsupported pointer size])
182 fi
183
184 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
185
186 pkg_config_path=
187 AC_ARG_WITH(crosspkgdir, [  --with-crosspkgdir=/path/to/pkg-config/dir      Change pkg-config dir to custom dir],
188         if test x$with_crosspkgdir = "x"; then
189                 if test -s $PKG_CONFIG_PATH; then
190                         pkg_config_path=$PKG_CONFIG_PATH
191                 fi
192         else
193                 pkg_config_path=$with_crosspkgdir
194                 PKG_CONFIG_PATH=$pkg_config_path
195                 export PKG_CONFIG_PATH
196         fi
197 )
198
199 dnl
200 dnl No, you can not replace the call below with a pkg.m4 macro
201 dnl
202 have_glib=false
203 if test "x$PKG_CONFIG" != "xno"; then
204     if $PKG_CONFIG --atleast-version=$GLIB_REQUIRED_VERSION glib-2.0; then
205         have_glib=true;
206     else
207         have_glib=false;
208     fi
209 fi
210 AM_CONDITIONAL(HAVE_GLIB, $have_glib)
211
212 AC_ARG_ENABLE(quiet-build, [  --enable-quiet-build  Enable quiet runtime build (on by default)], enable_quiet_build=$enableval, enable_quiet_build=yes)
213 AC_SUBST(GPOINTER_TO_INT)
214 AC_SUBST(GPOINTER_TO_UINT)
215 AC_SUBST(GINT_TO_POINTER)
216 AC_SUBST(GUINT_TO_POINTER)
217 AC_SUBST(GSIZE)
218 AC_SUBST(GSIZE_FORMAT)
219 AC_SUBST(G_GUINT64_FORMAT)
220 AC_SUBST(G_GINT64_FORMAT)
221 AC_SUBST(G_GUINT32_FORMAT)
222 AC_SUBST(G_GINT32_FORMAT)
223
224 if test x$enable_quiet_build = xyes; then
225    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])
226    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])
227 fi
228
229 AC_OUTPUT([
230 Makefile
231 m4/Makefile
232 src/Makefile
233 src/eglib-config.h
234 test/Makefile
235 ])