Improve io-layer error logging.
[mono-project.git] / eglib / configure.ac
blobb011dbe3ad8a2e106e6ead04d18a92c835431e0b
1 AC_INIT(README)
2 AC_CANONICAL_SYSTEM
4 AM_CONFIG_HEADER(config.h)
5 AM_INIT_AUTOMAKE(eglib,0.3)
6 AM_MAINTAINER_MODE
8 AC_PROG_CC
9 AM_PROG_LIBTOOL
10 # Use dolt (http://dolt.freedesktop.org/) instead of libtool for building.
11 DOLT
12 CFLAGS="$CFLAGS -O0"
13 GNUC_PRETTY=
14 GNUC_UNUSED=
15 BREAKPOINT="G_STMT_START { raise (SIGTRAP); } G_STMT_END"
16 if test x$GCC = xyes; then
17    GNUC_UNUSED='__attribute__((__unused__))'
18    GNUC_NORETURN='__attribute__((__noreturn__))'
19    case $host_cpu in
20      i*86|x86_64) BREAKPOINT="G_STMT_START { __asm__ (\"int \$03\"); } G_STMT_END" ;;
21    esac
23 AC_SUBST(GNUC_PRETTY)
24 AC_SUBST(GNUC_UNUSED)
25 AC_SUBST(GNUC_NORETURN)
26 AC_SUBST(BREAKPOINT)
28 # We use a separate variable to pass down CPPFLAGS and CFLAGS from the main mono 
29 # configure, because of autoconf brokeness
30 if test "x$CPPFLAGS_FOR_EGLIB" != "x"; then
31    CPPFLAGS=$CPPFLAGS_FOR_EGLIB
33 if test "x$CFLAGS_FOR_EGLIB" != "x"; then
34    CFLAGS=$CFLAGS_FOR_EGLIB
37 CFLAGS="$CFLAGS -g -D_GNU_SOURCE"
39 AM_CONDITIONAL(CROSS_COMPILING, [test x$cross_compiling = xyes])
40 AC_C_BIGENDIAN([ORDER=G_BIG_ENDIAN],[ORDER=G_LITTLE_ENDIAN])
42 platform_darwin=no
43 platform_android=no
45 case $host in
46 *-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
47     PATHSEP='\\'
48     SEARCHSEP=';'
49     OS="WIN32"
50     PIDTYPE='void *'
51     ;;
52 *-*darwin*)
53     platform_darwin=yes
54     PATHSEP='/'
55     SEARCHSEP=':'
56     OS="UNIX"
57     PIDTYPE='int'
58     ;;
59 *-*-linux-android*)
60     platform_android=yes
61         AC_DEFINE(PLATFORM_ANDROID,1,[Targeting the Android platform])
62     PATHSEP='/'
63     SEARCHSEP=':'
64     OS="UNIX"
65     PIDTYPE='int'
66     ;;
68     PATHSEP='/'
69     SEARCHSEP=':'
70     OS="UNIX"
71     PIDTYPE='int'
72     ;;
73 esac
75 case $host in
76         *-*-solaris*)
77         CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS"
78         ;;
79 esac
81 case $target in
82 arm*-darwin*)
83     CFLAGS="$CFLAGS -U_FORTIFY_SOURCE"
84     ;;
85 i*86-*-darwin*)
86     ORDER=G_LITTLE_ENDIAN
87     ;;
88 *-*-openbsd*)
89     CFLAGS="$CFLAGS -pthread"
90     LDFLAGS="$LDFLAGS -pthread"
91     ;;
92 esac
94 AC_SUBST(ORDER)
95 AC_SUBST(CFLAGS)
96 AC_SUBST(PATHSEP)
97 AC_SUBST(SEARCHSEP)
98 AC_SUBST(OS)
99 AC_SUBST(PIDTYPE)
100 AM_CONDITIONAL(HOST_WIN32, test x$OS = xWIN32)
101 AM_CONDITIONAL(TARGET_WIN32, test x$OS = xWIN32)
102 AM_CONDITIONAL(PLATFORM_DARWIN, test x$platform_darwin = xyes)
103 AM_CONDITIONAL(PLATFORM_ANDROID, test x$platform_android = xyes)
105 AC_CHECK_SIZEOF(int)
106 AC_CHECK_SIZEOF(void *)
107 AC_CHECK_SIZEOF(long)
108 AC_CHECK_SIZEOF(long long)
109 AC_CHECK_FUNCS(strndup strlcpy getpwuid_r strtok_r rewinddir vasprintf)
110 AM_CONDITIONAL(NEED_VASPRINTF, test x$have_vasprintf = x )
111 AC_CHECK_LIB(iconv, iconv_open, LIBS="$LIBS -liconv")
112 AC_CHECK_LIB(iconv, libiconv_open, LIBS="$LIBS -liconv")
113 AC_CHECK_LIB(iconv, iconv_open, ICONV_LIBS="-liconv")
114 AC_CHECK_LIB(iconv, libiconv_open, ICONV_LIBS="-liconv")
115 AC_SUBST(ICONV_LIBS)
116 LIBS="$LIBS $ICONV_LIBS"
117 AC_SEARCH_LIBS(sqrtf, m)
119 # nanosleep may not be part of libc, also search it in other libraries
120 AC_SEARCH_LIBS(nanosleep, rt)
122 AC_SEARCH_LIBS(dlopen, dl)
123 old_ldflags="${LDFLAGS}"
124 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
125 AC_TRY_LINK(, [int i;], found_export_dynamic=yes, found_export_dynamic=no)
126 if test $found_export_dynamic = no; then
127         LDFLAGS="${old_ldflags}"
130 AC_MSG_CHECKING(for varargs macros)
131 AC_TRY_COMPILE([],[
132 int foo (int i, int j);
133 #define bar(...) foo (1, __VA_ARGS__)
134 void main () {
135          bar (2);
137 ],have_iso_varargs=yes,have_iso_varargs=no)
138 AC_MSG_RESULT($have_iso_varargs)
139 G_HAVE_ISO_VARARGS=0
140 if test "x$have_iso_varargs" = "xyes"; then
141    G_HAVE_ISO_VARARGS=1
143 AC_SUBST(G_HAVE_ISO_VARARGS)
145 AC_CHECK_HEADERS(getopt.h sys/time.h sys/wait.h pwd.h langinfo.h iconv.h localcharset.h sys/types.h)
146 AC_CHECK_HEADER(alloca.h, [HAVE_ALLOCA_H=1], [HAVE_ALLOCA_H=0])
147 AC_SUBST(HAVE_ALLOCA_H)
149 if test $ac_cv_sizeof_void_p = $ac_cv_sizeof_int; then
150    GPOINTER_TO_INT="((gint) (ptr))"
151    GPOINTER_TO_UINT="((guint) (ptr))"
152    GINT_TO_POINTER="((gpointer) (v))"
153    GUINT_TO_POINTER="((gpointer) (v))"
154    GSIZE="int"
155    GSIZE_FORMAT='"u"'
156    G_GUINT64_FORMAT='"llu"'
157    G_GINT64_FORMAT='"lld"'
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 elif test $ac_cv_sizeof_void_p = $ac_cv_sizeof_long_long; then
168    GPOINTER_TO_INT="((gint)(long long) (ptr))"
169    GPOINTER_TO_UINT="((guint)(unsigned long long) (ptr))"
170    GINT_TO_POINTER="((gpointer)(long long) (v))"
171    GUINT_TO_POINTER="((gpointer)(unsigned long long) (v))"
172    GSIZE="long long"
173    GSIZE_FORMAT='"I64u"'
174    G_GUINT64_FORMAT='"I64u"'
175    G_GINT64_FORMAT='"I64i"'
176 else
177    AC_MSG_ERROR([unsupported pointer size])
180 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
182 pkg_config_path=
183 AC_ARG_WITH(crosspkgdir, [  --with-crosspkgdir=/path/to/pkg-config/dir      Change pkg-config dir to custom dir],
184         if test x$with_crosspkgdir = "x"; then
185                 if test -s $PKG_CONFIG_PATH; then
186                         pkg_config_path=$PKG_CONFIG_PATH
187                 fi
188         else
189                 pkg_config_path=$with_crosspkgdir
190                 PKG_CONFIG_PATH=$pkg_config_path
191                 export PKG_CONFIG_PATH
192         fi
196 dnl No, you can not replace the call below with a pkg.m4 macro
198 have_glib=false
199 if test "x$PKG_CONFIG" != "xno"; then
200     if $PKG_CONFIG --atleast-version=$GLIB_REQUIRED_VERSION glib-2.0; then
201         have_glib=true;
202     else
203         have_glib=false;
204     fi
206 AM_CONDITIONAL(HAVE_GLIB, $have_glib)
208 AC_ARG_ENABLE(quiet-build, [  --enable-quiet-build  Enable quiet runtime build (on by default)], enable_quiet_build=$enableval, enable_quiet_build=yes)
209 AC_SUBST(GPOINTER_TO_INT)
210 AC_SUBST(GPOINTER_TO_UINT)
211 AC_SUBST(GINT_TO_POINTER)
212 AC_SUBST(GUINT_TO_POINTER)
213 AC_SUBST(GSIZE)
214 AC_SUBST(GSIZE_FORMAT)
215 AC_SUBST(G_GUINT64_FORMAT)
216 AC_SUBST(G_GINT64_FORMAT)
218 if test x$enable_quiet_build = xyes; then
219    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])
220    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])
223 AC_OUTPUT([
224 Makefile
225 src/Makefile
226 src/eglib-config.h
227 test/Makefile