ue May 21 15:51:17 2002 Owen Taylor <otaylor@redhat.com>
[platform/upstream/glib.git] / configure.in
index 8058c9a..00dd498 100644 (file)
@@ -264,11 +264,48 @@ else
 fi
 AC_SUBST(PERL_PATH)
 
+dnl ***********************
+dnl *** Tests for iconv ***
+dnl ***********************
+dnl
+dnl We do this before the gettext checks, to avoid distortion
+
+AC_ARG_WITH(libiconv, [  --with-libiconv=[no/gnu/native] use the libiconv library ],,with_libiconv=maybe)
+
+found_iconv=no
+case $with_libiconv in
+  maybe)
+    # Check in the C library first
+    AC_CHECK_FUNC(iconv_open, with_libiconv=no; found_iconv=yes)
+    # Check if we have GNU libiconv
+    if test $found_iconv = "no"; then
+      AC_CHECK_LIB(iconv, libiconv_open, with_libiconv=gnu; found_iconv=yes)
+    fi
+    # Check if we have a iconv in -liconv, possibly from vendor
+    if test $found_iconv = "no"; then
+      AC_CHECK_LIB(iconv, iconv_open, with_libiconv=native; found_iconv=yes)
+    fi
+    ;;
+  no)
+    AC_CHECK_FUNC(iconv_open, with_libiconv=no; found_iconv=yes)
+    ;;
+  gnu|yes)
+    AC_CHECK_LIB(iconv, libiconv_open, with_libiconv=gnu; found_iconv=yes)
+    ;;
+  native)
+    AC_CHECK_LIB(iconv, iconv_open, with_libiconv=native; found_iconv=yes)
+    ;;
+esac
+
+if test "x$found_iconv" = "xno" ; then
+   AC_MSG_ERROR([*** No iconv() implementation found in C library or libiconv])
+fi
+
 dnl
 dnl gettext support
 dnl
 
-ALL_LINGUAS="az ca cs de el es eu fr gl ja ko ms nl nn no pl pt ro ru sk sl sv ta tr uk zh_CN zh_TW"
+ALL_LINGUAS="az ca cs de el es eu fr gl hi ja ko ms nl nn no pl pt ro ru sk sl sv ta tr uk vi zh_CN zh_TW"
 AM_GLIB_GNU_GETTEXT
 
 if test "$gt_cv_func_dgettext_libc" = "yes" || test "$gt_cv_func_dgettext_libintl" = "yes"; then
@@ -293,6 +330,27 @@ AC_DEFINE_UNQUOTED(GLIB_LOCALE_DIR,"$GLIB_LOCALE_DIR")
 
 AC_CHECK_FUNCS(bind_textdomain_codeset)
 
+dnl
+dnl Now we are done with gettext checks, figure out ICONV_LIBS
+dnl
+
+if test x$with_libiconv != xno ; then
+  case " $INTLLIBS " in
+  *[[\ \       ]]-liconv[[\ \  ]]*) ;;
+  *) ICONV_LIBS="-liconv" ;;
+  esac
+fi
+AC_SUBST(ICONV_LIBS)
+
+case $with_libiconv in
+  gnu)
+    AC_DEFINE(USE_LIBICONV_GNU, [Using GNU libiconv])
+    ;;
+  native)
+    AC_DEFINE(USE_LIBICONV_NATIVE, [Using a native implementation of iconv in a separate library])
+    ;;
+esac
+
 dnl Initialize libtool
 AM_DISABLE_STATIC
 AC_LIBTOOL_WIN32_DLL
@@ -378,7 +436,7 @@ fi
 
 if test x$ac_cv_sizeof_long_long = x8; then
        # long long is a 64 bit integer.
-       AC_MSG_CHECKING(for format to printf and scanf a gint64)
+       AC_MSG_CHECKING(for format to printf and scanf a guint64)
        AC_CACHE_VAL(glib_cv_long_long_format,[
                for format in ll q I64; do
                  AC_TRY_RUN([#include <stdio.h>  
@@ -401,7 +459,7 @@ if test x$ac_cv_sizeof_long_long = x8; then
         fi
 elif test x$ac_cv_sizeof___int64 = x8; then
        # __int64 is a 64 bit integer.
-       AC_MSG_CHECKING(for format to printf and scanf a gint64)
+       AC_MSG_CHECKING(for format to printf and scanf a guint64)
        # We know this is MSVC, and what the formats are
        glib_cv_long_long_format=I64
        AC_MSG_RESULT(%${glib_cv_long_long_format}u)
@@ -578,8 +636,53 @@ GLIB_SIZEOF([$size_includes], size_t, size_t)
 GLIB_SIZEOF([$size_includes], ptrdiff_t, ptrdiff_t)
 GLIB_SIZEOF([$size_includes], intmax_t, intmax_t)
 
+dnl Try to figure out whether gsize, gssize should be long or int
+AC_MSG_CHECKING([for the appropriate definition for size_t])
+
+case $glib_cv_sizeof_size_t in
+  $ac_cv_sizeof_short) 
+      glib_size_type=short
+      ;;
+  $ac_cv_sizeof_int) 
+      glib_size_type=int
+      ;;
+  $ac_cv_sizeof_long) 
+      glib_size_type=long
+      ;;
+  *)  AC_MSG_ERROR([No type matching size_t in size])
+      ;;
+esac
+
+dnl If int/long are the same size, we see which one produces
+dnl warnings when used in the location as size_t. (This matters
+dnl on AIX with xlc)
+dnl
+if test $glib_cv_sizeof_size_t = $ac_cv_sizeof_int &&
+   test $glib_cv_sizeof_size_t = $ac_cv_sizeof_long ; then
+  GLIB_CHECK_COMPILE_WARNINGS([
+#include <stddef.h> 
+int main ()
+{
+  size_t s = 1;
+  unsigned int *size_int = &s;
+  return (int)*size_int;
+}
+    ],glib_size_type=int,
+      [GLIB_CHECK_COMPILE_WARNINGS([
+#include <stddef.h> 
+int main ()
+{
+   size_t s = 1;
+   unsigned long *size_long = &s;
+   return (int)*size_long;
+}
+        ],glib_size_type=long)])
+fi
+
+AC_MSG_RESULT(unsigned $glib_size_type)
+
 # Check for some functions
-AC_CHECK_FUNCS(lstat strerror strsignal memmove mkstemp vsnprintf stpcpy strcasecmp strncasecmp poll getcwd nanosleep vasprintf unsetenv)
+AC_CHECK_FUNCS(lstat strerror strsignal memmove mkstemp vsnprintf stpcpy strcasecmp strncasecmp poll getcwd nanosleep vasprintf unsetenv getc_unlocked)
 
 AC_FUNC_VSNPRINTF_C99
 
@@ -814,6 +917,13 @@ if test -z "$G_MODULE_IMPL" && test "x$glib_native_beos" = "xyes"; then
       G_MODULE_IMPL=G_MODULE_IMPL_BEOS],
       [])
 fi   
+dnl *** NSLinkModule (dyld) in system libraries (Darwin)
+if test -z "$G_MODULE_IMPL"; then
+       AC_CHECK_FUNC(NSLinkModule,
+                     [G_MODULE_IMPL=G_MODULE_IMPL_DYLD
+                      G_MODULE_NEED_USCORE=1],
+                     [])
+fi
 dnl *** dlopen() and dlsym() in libdl
 if test -z "$G_MODULE_IMPL"; then
        AC_CHECK_LIB(dl, dlopen,
@@ -822,13 +932,6 @@ if test -z "$G_MODULE_IMPL"; then
                                   G_MODULE_IMPL=G_MODULE_IMPL_DL],[])],
                     [])
 fi
-dnl *** NSLinkModule (dyld) in system libraries (Darwin)
-if test -z "$G_MODULE_IMPL"; then
-       AC_CHECK_FUNC(NSLinkModule,
-                     [G_MODULE_IMPL=G_MODULE_IMPL_DYLD
-                      G_MODULE_NEED_USCORE=1],
-                     [])
-fi
 dnl *** shl_load() in libdld (HP-UX)
 if test -z "$G_MODULE_IMPL"; then
        AC_CHECK_LIB(dld, shl_load,
@@ -1523,53 +1626,6 @@ case $host in
 esac
 AC_SUBST(G_LIBS_EXTRA)
 
-dnl ***********************
-dnl *** Tests for iconv ***
-dnl ***********************
-
-AC_ARG_WITH(libiconv, [  --with-libiconv=[no/gnu/native] use the libiconv library ],,with_libiconv=maybe)
-
-found_iconv=no
-case $with_libiconv in
-  maybe)
-    # Check in the C library first
-    AC_CHECK_FUNC(iconv_open, with_libiconv=no; found_iconv=yes)
-    # Check if we have GNU libiconv
-    if test $found_iconv = "no"; then
-      AC_CHECK_LIB(iconv, libiconv_open, with_libiconv=gnu; found_iconv=yes)
-    fi
-    # Check if we have a iconv in -liconv, possibly from vendor
-    if test $found_iconv = "no"; then
-      AC_CHECK_LIB(iconv, iconv_open, with_libiconv=native; found_iconv=yes)
-    fi
-    ;;
-  no)
-    AC_CHECK_FUNC(iconv_open, with_libiconv=no; found_iconv=yes)
-    ;;
-  gnu|yes)
-    AC_CHECK_LIB(iconv, libiconv_open, with_libiconv=gnu; found_iconv=yes)
-    ;;
-  native)
-    AC_CHECK_LIB(iconv, iconv_open, with_libiconv=native; found_iconv=yes)
-    ;;
-esac
-
-if test "x$found_iconv" = "xno" ; then
-   AC_MSG_ERROR([*** No iconv() implementation found in C library or libiconv])
-fi
-
-case $with_libiconv in
-  gnu)
-    ICONV_LIBS="-liconv"
-    AC_DEFINE(USE_LIBICONV_GNU, [Using GNU libiconv])
-    ;;
-  native)
-    ICONV_LIBS="-liconv"
-    AC_DEFINE(USE_LIBICONV_NATIVE, [Using a native implementation of iconv in a separate library])
-    ;;
-esac
-AC_SUBST(ICONV_LIBS)
-
 dnl If the system doesn't define EILSEQ, we should define EILSEQ ourselves
 dnl since we need it for g_iconv()
 
@@ -1582,6 +1638,19 @@ int error = EILSEQ;
 ], have_eilseq=yes, have_eilseq=no);
 AC_MSG_RESULT($have_eilseq)
 
+dnl ******************************************************************
+dnl *** Look for glib-genmarshal in PATH if we are cross-compiling ***
+dnl ******************************************************************
+
+AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes)
+
+if test $cross_compiling = yes; then
+  AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal, no)
+  if test x$GLIB_GENMARSHAL = xno; then
+    AC_MSG_ERROR(Could not find a glib-genmarshal in your PATH)
+  fi
+fi
+
 dnl **************************
 dnl *** Checks for gtk-doc ***
 dnl **************************
@@ -1767,19 +1836,8 @@ _______EOF
 
 _______EOF
 
-       case x$glib_size_t in
-        x2) echo "typedef gint16  gssize;" >> $outfile
-            echo "typedef guint16 gsize;"  >> $outfile
-            ;;
-        x4) echo "typedef gint32  gssize;" >> $outfile
-            echo "typedef guint32 gsize;"  >> $outfile
-            ;;
-        x8) echo "typedef gint64  gssize;" >> $outfile
-            echo "typedef guint64 gsize;"  >> $outfile
-            ;;
-       *)  echo "#error size of size_t is unknown" >> $outfile
-            ;;
-        esac
+echo "typedef signed $glib_size_type_define gssize;" >> $outfile
+echo "typedef unsigned $glib_size_type_define gsize;" >> $outfile
 
        if test -z "$glib_unknown_void_p"; then
          cat >>$outfile <<_______EOF
@@ -2061,6 +2119,7 @@ $ac_cv_sizeof___int64)
   ;;
 esac
 glib_size_t=$glib_cv_sizeof_size_t
+glib_size_type_define=$glib_size_type
 glib_void_p=$ac_cv_sizeof_long
 glib_long=$ac_cv_sizeof_void_p