Merge branch 'master' of github.com:tgiphil/mono
[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 $target in
53 arm*-darwin*)
54     CFLAGS="$CFLAGS -U_FORTIFY_SOURCE"
55     ;;
56 i*86-*-darwin*)
57     ORDER=G_LITTLE_ENDIAN
58     ;;
59 *-*-openbsd*)
60     CFLAGS="$CFLAGS -pthread"
61     LDFLAGS="$LDFLAGS -pthread"
62     ;;
63 esac
64
65 AC_SUBST(ORDER)
66 AC_SUBST(CFLAGS)
67 AC_SUBST(PATHSEP)
68 AC_SUBST(SEARCHSEP)
69 AC_SUBST(OS)
70 AM_CONDITIONAL(HOST_WIN32, test x$OS = xWIN32)
71 AM_CONDITIONAL(TARGET_WIN32, test x$OS = xWIN32)
72
73 AC_CHECK_SIZEOF(int)
74 AC_CHECK_SIZEOF(void *)
75 AC_CHECK_FUNCS(strndup strlcpy getpwuid_r strtok_r rewinddir vasprintf)
76 AM_CONDITIONAL(NEED_VASPRINTF, test x$have_vasprintf = x )
77 AC_CHECK_LIB(iconv, iconv_open, LIBS="$LIBS -liconv")
78 AC_CHECK_LIB(iconv, libiconv_open, LIBS="$LIBS -liconv")
79 AC_SEARCH_LIBS(sqrtf, m)
80
81 # nanosleep may not be part of libc, also search it in other libraries
82 AC_SEARCH_LIBS(nanosleep, rt)
83
84 AC_SEARCH_LIBS(dlopen, dl)
85 old_ldflags="${LDFLAGS}"
86 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
87 AC_TRY_LINK(, [int i;], found_export_dynamic=yes, found_export_dynamic=no)
88 if test $found_export_dynamic = no; then
89         LDFLAGS="${old_ldflags}"
90 fi
91
92 AC_MSG_CHECKING(for varargs macros)
93 AC_TRY_COMPILE([],[
94 int foo (int i, int j);
95 #define bar(...) foo (1, __VA_ARGS__)
96 void main () {
97          bar (2);
98 }
99 ],have_iso_varargs=yes,have_iso_varargs=no)
100 AC_MSG_RESULT($have_iso_varargs)
101 G_HAVE_ISO_VARARGS=0
102 if test "x$have_iso_varargs" = "xyes"; then
103    G_HAVE_ISO_VARARGS=1
104 fi
105 AC_SUBST(G_HAVE_ISO_VARARGS)
106
107 AC_CHECK_HEADERS(getopt.h sys/time.h sys/wait.h pwd.h langinfo.h iconv.h)
108
109 if test $ac_cv_sizeof_void_p != $ac_cv_sizeof_int; then
110    GPOINTER_TO_INT="((gint)(long) (ptr))"
111    GPOINTER_TO_UINT="((guint)(long) (ptr))"
112    GINT_TO_POINTER="((gpointer)(glong) (v))"
113    GUINT_TO_POINTER="((gpointer)(gulong) (v))"
114    GSIZE="long"
115    GSIZE_FORMAT='"lu"'
116    G_GUINT64_FORMAT='"lu"'
117 else
118    GPOINTER_TO_INT="((gint) (ptr))"
119    GPOINTER_TO_UINT="((guint) (ptr))"
120    GINT_TO_POINTER="((gpointer) (v))"
121    GUINT_TO_POINTER="((gpointer) (v))"
122    GSIZE="int"
123    GSIZE_FORMAT='"u"'
124    G_GUINT64_FORMAT='"llu"'
125 fi
126
127 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
128 if test "x$PKG_CONFIG" = "xno"; then
129         AC_MSG_ERROR([You need to install pkg-config])
130 fi
131
132 pkg_config_path=
133 AC_ARG_WITH(crosspkgdir, [  --with-crosspkgdir=/path/to/pkg-config/dir      Change pkg-config dir to custom dir],
134         if test x$with_crosspkgdir = "x"; then
135                 if test -s $PKG_CONFIG_PATH; then
136                         pkg_config_path=$PKG_CONFIG_PATH
137                 fi
138         else
139                 pkg_config_path=$with_crosspkgdir
140                 PKG_CONFIG_PATH=$pkg_config_path
141                 export PKG_CONFIG_PATH
142         fi
143 )
144
145 dnl
146 dnl No, you can not replace the call below with a pkg.m4 macro
147 dnl
148 if $PKG_CONFIG --atleast-version=$GLIB_REQUIRED_VERSION glib-2.0; then
149     have_glib=true;
150 else
151     have_glib=false;
152 fi
153 AM_CONDITIONAL(HAVE_GLIB, $have_glib)
154
155 AC_SUBST(GPOINTER_TO_INT)
156 AC_SUBST(GPOINTER_TO_UINT)
157 AC_SUBST(GINT_TO_POINTER)
158 AC_SUBST(GUINT_TO_POINTER)
159 AC_SUBST(GSIZE)
160 AC_SUBST(GSIZE_FORMAT)
161 AC_SUBST(G_GUINT64_FORMAT)
162
163 AC_OUTPUT([
164 Makefile
165 src/Makefile
166 src/eglib-config.h
167 test/Makefile
168 ])