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