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