2009-05-25 Rodrigo Kumpera <rkumpera@novell.com>
[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='-g -O0 -D_GNU_SOURCE'
11 AC_SUBST(CFLAGS)
12 GNUC_PRETTY=
13 GNUC_UNUSED=
14 BREAKPOINT="G_STMT_START { raise (SIGTRAP); } G_STMT_END"
15 if test x$GCC = xyes; then
16    GNUC_UNUSED='__attribute__((__unused__))'
17    GNUC_NORETURN='__attribute__((__noreturn__))'
18    echo target_cpu=$target_cpu
19    case $target_cpu in
20      i*86) 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 AM_CONDITIONAL(CROSS_COMPILING, [test x$cross_compiling = xyes])
29 AC_C_BIGENDIAN([ORDER=G_BIG_ENDIAN],[ORDER=G_LITTLE_ENDIAN])
30 AC_SUBST(ORDER)
31
32 case $host in
33 *-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
34     PATHSEP='\\'
35     SEARCHSEP=';'
36     OS="WIN32"
37     ;;
38 *)
39     PATHSEP='/'
40     SEARCHSEP=':'
41     OS="UNIX"
42     ;;
43 esac
44
45 case $target in
46 arm*-darwin*)
47     CFLAGS="$CLAFGS -U_FORTIFY_SOURCE"
48     ;;
49 esac
50
51 AC_SUBST(PATHSEP)
52 AC_SUBST(SEARCHSEP)
53 AC_SUBST(OS)
54 AM_CONDITIONAL(PLATFORM_WIN32, test x$OS = xWIN32)
55
56 AC_CHECK_SIZEOF(int)
57 AC_CHECK_SIZEOF(void *)
58 AC_CHECK_FUNCS(strndup strlcpy getpwent_r strtok_r rewinddir)
59 AC_CHECK_LIB(iconv, libiconv_open, LIBS="$LIBS -liconv")
60 old_ldflags="${LDFLAGS}"
61 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
62 AC_TRY_LINK(, [int i;], found_export_dynamic=yes, found_export_dynamic=no)
63 if test $found_export_dynamic = no; then
64         LDFLAGS="${old_ldflags}"
65 fi
66
67 AC_CHECK_HEADERS(getopt.h sys/time.h sys/wait.h pwd.h langinfo.h iconv.h)
68
69 if test $ac_cv_sizeof_void_p != $ac_cv_sizeof_int; then
70    GPOINTER_TO_INT="((gint)(long) (ptr))"
71    GPOINTER_TO_UINT="((guint)(long) (ptr))"
72    GINT_TO_POINTER="((gpointer)(glong) (v))"
73    GUINT_TO_POINTER="((gpointer)(gulong) (v))"
74    GSIZE="long"
75    GSIZE_FORMAT='"lu"'
76    G_GUINT64_FORMAT='"lu"'
77 else
78    GPOINTER_TO_INT="((gint) (ptr))"
79    GPOINTER_TO_UINT="((guint) (ptr))"
80    GINT_TO_POINTER="((gpointer) (v))"
81    GUINT_TO_POINTER="((gpointer) (v))"
82    GSIZE="int"
83    GSIZE_FORMAT='"u"'
84    G_GUINT64_FORMAT='"llu"'
85 fi
86
87 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
88 if test "x$PKG_CONFIG" = "xno"; then
89         AC_MSG_ERROR([You need to install pkg-config])
90 fi
91
92 pkg_config_path=
93 AC_ARG_WITH(crosspkgdir, [  --with-crosspkgdir=/path/to/pkg-config/dir      Change pkg-config dir to custom dir],
94         if test x$with_crosspkgdir = "x"; then
95                 if test -s $PKG_CONFIG_PATH; then
96                         pkg_config_path=$PKG_CONFIG_PATH
97                 fi
98         else
99                 pkg_config_path=$with_crosspkgdir
100                 PKG_CONFIG_PATH=$pkg_config_path
101                 export PKG_CONFIG_PATH
102         fi
103 )
104
105 dnl
106 dnl No, you can not replace the call below with a pkg.m4 macro
107 dnl
108 if $PKG_CONFIG --atleast-version=$GLIB_REQUIRED_VERSION glib-2.0; then
109     have_glib=true;
110 else
111     have_glib=false;
112 fi
113 AM_CONDITIONAL(HAVE_GLIB, $have_glib)
114
115 AC_SUBST(GPOINTER_TO_INT)
116 AC_SUBST(GPOINTER_TO_UINT)
117 AC_SUBST(GINT_TO_POINTER)
118 AC_SUBST(GUINT_TO_POINTER)
119 AC_SUBST(GSIZE)
120 AC_SUBST(GSIZE_FORMAT)
121 AC_SUBST(G_GUINT64_FORMAT)
122
123 AC_OUTPUT([
124 Makefile
125 src/Makefile
126 src/eglib-config.h
127 test/Makefile
128 ])