eglib build is now 'quiet' by default
[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 CFLAGS="$CFLAGS -g -O0 -D_GNU_SOURCE"
11 GNUC_PRETTY=
12 GNUC_UNUSED=
13 BREAKPOINT="G_STMT_START { raise (SIGTRAP); } G_STMT_END"
14 if test x$GCC = xyes; then
15    GNUC_UNUSED='__attribute__((__unused__))'
16    GNUC_NORETURN='__attribute__((__noreturn__))'
17    echo target_cpu=$target_cpu
18    case $target_cpu in
19      i*86) BREAKPOINT="G_STMT_START { __asm__ (\"int \$03\"); } G_STMT_END" ;;
20    esac
21 fi
22 AC_SUBST(GNUC_PRETTY)
23 AC_SUBST(GNUC_UNUSED)
24 AC_SUBST(GNUC_NORETURN)
25 AC_SUBST(BREAKPOINT)
26
27 # We use a separate variable to pass down CPPFLAGS and CFLAGS from the main mono 
28 # configure, because of autoconf brokeness
29 if test "x$CPPFLAGS_FOR_EGLIB" != "x"; then
30    CPPFLAGS=$CPPFLAGS_FOR_EGLIB
31 fi
32 if test "x$CFLAGS_FOR_EGLIB" != "x"; then
33    CFLAGS=$CFLAGS_FOR_EGLIB
34 fi
35
36 AM_CONDITIONAL(CROSS_COMPILING, [test x$cross_compiling = xyes])
37 AC_C_BIGENDIAN([ORDER=G_BIG_ENDIAN],[ORDER=G_LITTLE_ENDIAN])
38
39 case $host in
40 *-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
41     PATHSEP='\\'
42     SEARCHSEP=';'
43     OS="WIN32"
44     ;;
45 *)
46     PATHSEP='/'
47     SEARCHSEP=':'
48     OS="UNIX"
49     ;;
50 esac
51
52 case $host in
53         *-*-solaris*)
54         CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS"
55         ;;
56 esac
57
58 case $target in
59 arm*-darwin*)
60     CFLAGS="$CFLAGS -U_FORTIFY_SOURCE"
61     ;;
62 i*86-*-darwin*)
63     ORDER=G_LITTLE_ENDIAN
64     ;;
65 *-*-openbsd*)
66     CFLAGS="$CFLAGS -pthread"
67     LDFLAGS="$LDFLAGS -pthread"
68     ;;
69 esac
70
71 AC_SUBST(ORDER)
72 AC_SUBST(CFLAGS)
73 AC_SUBST(PATHSEP)
74 AC_SUBST(SEARCHSEP)
75 AC_SUBST(OS)
76 AM_CONDITIONAL(HOST_WIN32, test x$OS = xWIN32)
77 AM_CONDITIONAL(TARGET_WIN32, test x$OS = xWIN32)
78
79 AC_CHECK_SIZEOF(int)
80 AC_CHECK_SIZEOF(void *)
81 AC_CHECK_FUNCS(strndup strlcpy getpwuid_r strtok_r rewinddir vasprintf)
82 AM_CONDITIONAL(NEED_VASPRINTF, test x$have_vasprintf = x )
83 AC_CHECK_LIB(iconv, iconv_open, LIBS="$LIBS -liconv")
84 AC_CHECK_LIB(iconv, libiconv_open, LIBS="$LIBS -liconv")
85 AC_SEARCH_LIBS(sqrtf, m)
86
87 # nanosleep may not be part of libc, also search it in other libraries
88 AC_SEARCH_LIBS(nanosleep, rt)
89
90 AC_SEARCH_LIBS(dlopen, dl)
91 old_ldflags="${LDFLAGS}"
92 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
93 AC_TRY_LINK(, [int i;], found_export_dynamic=yes, found_export_dynamic=no)
94 if test $found_export_dynamic = no; then
95         LDFLAGS="${old_ldflags}"
96 fi
97
98 AC_MSG_CHECKING(for varargs macros)
99 AC_TRY_COMPILE([],[
100 int foo (int i, int j);
101 #define bar(...) foo (1, __VA_ARGS__)
102 void main () {
103          bar (2);
104 }
105 ],have_iso_varargs=yes,have_iso_varargs=no)
106 AC_MSG_RESULT($have_iso_varargs)
107 G_HAVE_ISO_VARARGS=0
108 if test "x$have_iso_varargs" = "xyes"; then
109    G_HAVE_ISO_VARARGS=1
110 fi
111 AC_SUBST(G_HAVE_ISO_VARARGS)
112
113 AC_CHECK_HEADERS(getopt.h sys/time.h sys/wait.h pwd.h langinfo.h iconv.h)
114
115 if test $ac_cv_sizeof_void_p != $ac_cv_sizeof_int; then
116    GPOINTER_TO_INT="((gint)(long) (ptr))"
117    GPOINTER_TO_UINT="((guint)(long) (ptr))"
118    GINT_TO_POINTER="((gpointer)(glong) (v))"
119    GUINT_TO_POINTER="((gpointer)(gulong) (v))"
120    GSIZE="long"
121    GSIZE_FORMAT='"lu"'
122    G_GUINT64_FORMAT='"lu"'
123    G_GINT64_FORMAT='"ld"'
124 else
125    GPOINTER_TO_INT="((gint) (ptr))"
126    GPOINTER_TO_UINT="((guint) (ptr))"
127    GINT_TO_POINTER="((gpointer) (v))"
128    GUINT_TO_POINTER="((gpointer) (v))"
129    GSIZE="int"
130    GSIZE_FORMAT='"u"'
131    G_GUINT64_FORMAT='"llu"'
132    G_GINT64_FORMAT='"lld"'
133 fi
134
135 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
136
137 pkg_config_path=
138 AC_ARG_WITH(crosspkgdir, [  --with-crosspkgdir=/path/to/pkg-config/dir      Change pkg-config dir to custom dir],
139         if test x$with_crosspkgdir = "x"; then
140                 if test -s $PKG_CONFIG_PATH; then
141                         pkg_config_path=$PKG_CONFIG_PATH
142                 fi
143         else
144                 pkg_config_path=$with_crosspkgdir
145                 PKG_CONFIG_PATH=$pkg_config_path
146                 export PKG_CONFIG_PATH
147         fi
148 )
149
150 dnl
151 dnl No, you can not replace the call below with a pkg.m4 macro
152 dnl
153 have_glib=false
154 if test "x$PKG_CONFIG" != "xno"; then
155     if $PKG_CONFIG --atleast-version=$GLIB_REQUIRED_VERSION glib-2.0; then
156         have_glib=true;
157     else
158         have_glib=false;
159     fi
160 fi
161 AM_CONDITIONAL(HAVE_GLIB, $have_glib)
162
163 AC_ARG_ENABLE(quiet-build, [  --enable-quiet-build  Enable quiet runtime build (on by default)], enable_quiet_build=$enableval, enable_quiet_build=yes)
164 AC_SUBST(GPOINTER_TO_INT)
165 AC_SUBST(GPOINTER_TO_UINT)
166 AC_SUBST(GINT_TO_POINTER)
167 AC_SUBST(GUINT_TO_POINTER)
168 AC_SUBST(GSIZE)
169 AC_SUBST(GSIZE_FORMAT)
170 AC_SUBST(G_GUINT64_FORMAT)
171 AC_SUBST(G_GINT64_FORMAT)
172
173 if test x$enable_quiet_build = xyes; then
174    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])
175    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])
176 fi
177
178 AC_OUTPUT([
179 Makefile
180 src/Makefile
181 src/eglib-config.h
182 test/Makefile
183 ])