Rename from GLIB_DIVERT_BEFORE_HELP. Update to track autoconf 2.49b.
[platform/upstream/glib.git] / configure.in
index c558d4b..6fd14ac 100644 (file)
@@ -15,10 +15,10 @@ cflags_set=${CFLAGS+set}
 # we rewrite this file
 rm -f glibconfig-sysdefs.h
 
-GLIB_DIVERT_BEFORE_HELP([
+GLIB_AC_DIVERT_BEFORE_HELP([
 #
-# The following version number definitions apply to GLib, GModule, GObject and GThread
-# as a whole, so if changes occoured in any of them, they are all
+# The following version number definitions apply to GLib, GModule, GObject 
+# and GThread as a whole, so if changes occoured in any of them, they are all
 # treated with the same interface and binary age.
 #
 # Making releases:
@@ -31,7 +31,7 @@ GLIB_DIVERT_BEFORE_HELP([
 #
 GLIB_MAJOR_VERSION=1
 GLIB_MINOR_VERSION=3
-GLIB_MICRO_VERSION=1
+GLIB_MICRO_VERSION=2
 GLIB_INTERFACE_AGE=0
 GLIB_BINARY_AGE=0
 GLIB_VERSION=$GLIB_MAJOR_VERSION.$GLIB_MINOR_VERSION.$GLIB_MICRO_VERSION
@@ -91,13 +91,12 @@ AC_MSG_RESULT([$glib_native_beos])
 
 dnl
 
-GLIB_DIVERT_BEFORE_HELP([
+GLIB_AC_DIVERT_BEFORE_HELP([
 # figure debugging default, prior to $ac_help setup
-if test `expr $GLIB_MINOR_VERSION \% 2` = 1 ; then
-  debug_default=yes
-else
-  debug_default=minimum
-fi[]dnl
+case $GLIB_MINOR_VERSION in
+*[[13579]]) debug_default=yes ;;
+*)          debug_default=minimum ;;
+esac[]dnl
 ])
 
 dnl declare --enable-* args and collect ac_help strings
@@ -312,7 +311,7 @@ AC_C_BIGENDIAN
 
 # check for header files
 AC_CHECK_HEADERS([float.h limits.h pwd.h sys/param.h sys/poll.h sys/select.h])
-AC_CHECK_HEADERS([sys/time.h sys/times.h unistd.h values.h stdint.h])
+AC_CHECK_HEADERS([sys/time.h sys/times.h unistd.h values.h stdint.h sched.h])
 
 AC_MSG_CHECKING(whether make is GNU Make)
 STRIP_BEGIN=
@@ -351,7 +350,7 @@ GLIB_SIZEOF([$size_includes], ptrdiff_t, ptrdiff_t)
 GLIB_SIZEOF([$size_includes], intmax_t, intmax_t)
 
 # Check for some functions
-AC_CHECK_FUNCS(lstat strerror strsignal memmove vsnprintf strcasecmp strncasecmp poll getcwd)
+AC_CHECK_FUNCS(lstat strerror strsignal memmove mkstemp vsnprintf strcasecmp strncasecmp poll getcwd)
 
 # Check if bcopy can be used for overlapping copies, if memmove isn't found.
 # The check is borrowed from the PERL Configure script.
@@ -373,7 +372,7 @@ if test "$ac_cv_func_memmove" != "yes"; then
         }
         return(0);
       }],glib_cv_working_bcopy=yes,glib_cv_working_bcopy=no)])
-  if test "$glib_cv_working_bcopy" == "yes"; then
+  if test "$glib_cv_working_bcopy" = "yes"; then
     AC_DEFINE(HAVE_WORKING_BCOPY,1,[Have a working bcopy])
   fi
 fi
@@ -418,7 +417,7 @@ AC_TRY_COMPILE([#include <sys/types.h>],
 if test $gtk_ok = yes; then
     AC_MSG_RESULT([yes, found in sys/types.h])
 else
-    AC_HEADER_EGREP(fd_set, sys/select.h, gtk_ok=yes)
+    AC_EGREP_HEADER(fd_set, sys/select.h, gtk_ok=yes)
     if test $gtk_ok = yes; then
        # *** FIXME: give it a different name
         AC_DEFINE(HAVE_SYS_SELECT_H,1,[found fd_set in sys/select.h])
@@ -732,20 +731,20 @@ if test "x$want_threads" = xyes || test "x$want_threads" = xsolaris; then
 fi
 if test "x$want_threads" = xyes || test "x$want_threads" = xposix \
                                || test "x$want_threads" = xdce; then
-       # -D_POSIX4A_DRAFT10_SOURCE is for DG/UX
+       # -D_POSIX4_DRAFT_SOURCE -D_POSIX4A_DRAFT10_SOURCE is for DG/UX
        # -U_OSF_SOURCE is for Digital UNIX 4.0d
-       GTHREAD_COMPILE_IMPL_DEFINES="-D_POSIX4A_DRAFT10_SOURCE -U_OSF_SOURCE"
+       GTHREAD_COMPILE_IMPL_DEFINES="-D_POSIX4_DRAFT_SOURCE -D_POSIX4A_DRAFT10_SOURCE -U_OSF_SOURCE"
        glib_save_CPPFLAGS="$CPPFLAGS"
        CPPFLAGS="$CPPFLAGS $GTHREAD_COMPILE_IMPL_DEFINES"
         if test "x$have_threads" = xnone; then
-                AC_EGREP_HEADER([(^|[^a-zA-Z_])pthread_attr_init[^a-zA-Z_]],
-                       pthread.h,
+                AC_TRY_COMPILE([#include <pthread.h>],
+                       [pthread_attr_t attr; pthread_attr_init(&attr);],
                        have_threads=posix)
         fi
         if test "x$have_threads" = xnone; then
-                AC_EGREP_HEADER([(^|[^a-zA-Z_])pthread_attr_create[^a-zA-Z_]],
-                       pthread.h,
-                       have_threads=dce)
+                AC_TRY_COMPILE([#include <pthread.h>],
+                       [pthread_attr_t attr; pthread_attr_create(&attr);],
+                       have_threads=posix)
         fi
        CPPFLAGS="$glib_save_CPPFLAGS"
 fi
@@ -791,6 +790,8 @@ if test x"$have_threads" != xnone; then
                        G_THREAD_CFLAGS="$G_THREAD_CFLAGS -pthread"
                fi      
                ;;
+       *-dg-dgux*)  # DG/UX
+               G_THREAD_CFLAGS="$G_THREAD_CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
     esac
 
     # if we are not finding the ctime_r function, then we probably are
@@ -799,9 +800,11 @@ if test x"$have_threads" != xnone; then
     glib_save_CPPFLAGS="$CPPFLAGS"
     CPPFLAGS="$CPPFLAGS $G_THREAD_CFLAGS"
 
-    # Note: Digital UNIX 4.0d #defines ctime_r to _Pctime_r for gcc.
-    AC_EGREP_HEADER([[^a-zA-Z_](_P)?ctime_r[^a-zA-Z_]], time.h, ,
-       AC_MSG_WARN($FLAG_DOES_NOT_WORK))
+    AC_TRY_COMPILE([#include <time.h>],
+       [time_t t; char b[30]; ctime_r (&t, b);], ,
+           [AC_TRY_COMPILE([#include <time.h>],
+               [time_t t; char b[30]; ctime_r (&t, b, 30);], ,
+                       AC_MSG_WARN($FLAG_DOES_NOT_WORK))])
 
     CPPFLAGS="$glib_save_CPPFLAGS"
 
@@ -816,7 +819,9 @@ dnl ******************************
 mutex_has_default=no
 case $have_threads in
         posix|dce)
-          G_THREAD_LIBS=error
+          glib_save_CPPFLAGS="$CPPFLAGS"
+          CPPFLAGS="$CPPFLAGS $GTHREAD_COMPILE_IMPL_DEFINES"
+           G_THREAD_LIBS=error
           glib_save_LIBS="$LIBS"
           case $host in
             *-sysv5uw7*) # UnixWare 7 
@@ -836,7 +841,7 @@ case $have_threads in
                                IN=" in -l$thread_lib"
                        fi
                        if test x"$have_threads" = xposix; then
-                               defattr=NULL
+                               defattr=0
                        else
                                defattr=pthread_attr_default
                        fi
@@ -850,7 +855,7 @@ case $have_threads in
                                 main()
                                { pthread_t t; 
                                  void *ret;
-                                 pthread_create (&t, $defattr, func, NULL);
+                                 pthread_create (&t, $defattr, func, 0);
                                  pthread_join (t, &ret);
                                  exit (check_me != 42);
                                }],
@@ -862,7 +867,7 @@ case $have_threads in
                if test "x$G_THREAD_LIBS" = xerror; then
                  AC_MSG_ERROR($LIBS_NOT_FOUND_1$have_threads$LIBS_NOT_FOUND_2)
                fi
-               for thread_lib in "" rt; do
+               for thread_lib in "" rt rte; do
                        if test x"$thread_lib" = x; then
                                add_thread_lib=""
                                IN=""
@@ -901,6 +906,7 @@ case $have_threads in
             have_threads="posix"
           fi
           AC_SUBST(GTHREAD_COMPILE_IMPL_DEFINES)
+           CPPFLAGS="$glib_save_CPPFLAGS"
            ;;
         solaris)
           G_THREAD_LIBS=error
@@ -946,33 +952,37 @@ if test x"$have_threads" != xnone; then
        # LIBS="$LIBS $G_THREAD_LIBS"
        AC_CHECK_FUNCS(localtime_r)
        if test "$ac_cv_header_pwd_h" = "yes"; then
-               AC_CACHE_CHECK([for getpwuid_r],ac_cv_func_getpwuid_r,
+               AC_CACHE_CHECK([for posix getpwuid_r],
+                       ac_cv_func_posix_getpwuid_r,
                        [AC_TRY_RUN([#include <errno.h>
-                               int main () { char buffer[10000], *pointer; 
-                               char getpwuid_r (long, void*, void*,
-                                       int, void*);
-                               int error;
-                               errno = 0;
-                               error = getpwuid_r (0, &buffer, &buffer, 
-                                       sizeof (buffer), &pointer);
-                               return errno == ENOSYS || error == ENOSYS;}],
-                               [ac_cv_func_getpwuid_r=yes],
-                               [ac_cv_func_getpwuid_r=no])])
-               if test "$ac_cv_func_getpwuid_r" = yes; then
-                       AC_DEFINE(HAVE_GETPWUID_R,1,[Have function getpwuid_r])
-               fi
-               if test "$ac_cv_func_getpwuid_r" = "yes"; then
-                       AC_MSG_CHECKING(whether getpwuid_r is posix like)
-                       # The signature for the POSIX version is:
-                       # int getpwuid_r(uid_t, struct passwd *, char *, size_t, struct passwd **)
-                       AC_TRY_COMPILE([#include <pwd.h>
-                               #include <sys/types.h>
-                               #include <stdlib.h>],
-                               [getpwuid_r((uid_t)0, NULL, NULL, (size_t)0, NULL);],
-                               [AC_DEFINE(HAVE_GETPWUID_R_POSIX,1,
-                                [Function getpwuid_r has the POSIX signature])
-                               AC_MSG_RESULT(yes)],
-                               [AC_MSG_RESULT(no)])
+                                #include <pwd.h>
+                                int main () { char buffer[10000];
+                                struct passwd pwd, *pwptr = &pwd;
+                                int error;
+                                errno = 0;
+                                error = getpwuid_r (0, &pwd, buffer, 
+                                        sizeof (buffer), &pwptr);
+                                return (error < 0 && errno == ENOSYS) 
+                                       || error == ENOSYS; }],
+                               [ac_cv_func_posix_getpwuid_r=yes],
+                               [ac_cv_func_posix_getpwuid_r=no])])
+               if test "$ac_cv_func_posix_getpwuid_r" = yes; then
+                       AC_DEFINE(HAVE_POSIX_GETPWUID_R,1,
+                               [Have POSIX function getpwuid_r])
+               else
+                       AC_CACHE_CHECK([for nonposix getpwuid_r],
+                               ac_cv_func_nonposix_getpwuid_r,
+                               [AC_TRY_COMPILE([#include <pwd.h>],
+                                       [char buffer[10000];
+                                       struct passwd pwd;
+                                       getpwuid_r (0, &pwd, buffer, 
+                                                       sizeof (buffer));],
+                                       [ac_cv_func_nonposix_getpwuid_r=yes],
+                                       [ac_cv_func_nonposix_getpwuid_r=no])])
+                       if test "$ac_cv_func_nonposix_getpwuid_r" = yes; then
+                               AC_DEFINE(HAVE_NONPOSIX_GETPWUID_R,1,
+                                       [Have non-POSIX function getpwuid_r])
+                       fi
                fi
        fi
        LIBS="$LIBS $G_THREAD_LIBS"
@@ -1033,6 +1043,29 @@ if test x"$have_threads" != xnone; then
                fi
                AC_DEFINE_UNQUOTED(POSIX_YIELD_FUNC,$posix_yield_func,[The POSIX RT yield function])
                CPPFLAGS="$glib_save_CPPFLAGS"
+
+               AC_MSG_CHECKING(whether to use the PID niceness surrogate for thread priorities)
+               AC_TRY_RUN([#include <pthread.h> 
+                       #include <sys/types.h>
+                       #include <unistd.h>
+                       pid_t other_pid = 0;
+
+                       void* func(void* data) {other_pid = getpid();}
+                       main()
+                       { pthread_t t; 
+                         void *ret;
+                         pthread_create (&t, $defattr, func, NULL);
+                         pthread_join (t, &ret);
+                         exit (getpid()==other_pid || 
+                               $posix_priority_min != $posix_priority_max);
+                       }],
+                       [AC_MSG_RESULT(yes),
+                        AC_DEFINE(G_THREAD_USE_PID_SURROGATE, 1,
+                               [whether to use the PID niceness surrogate for thread priorities])
+
+                        glib_cv_sizeof_system_thread=`expr $glib_cv_sizeof_system_thread + $ac_cv_sizeof_long`],
+                       [AC_MSG_RESULT(no)])
+          
        else # solaris threads
                GLIB_SIZEOF([#include <thread.h>],
                        thread_t,
@@ -1042,7 +1075,8 @@ if test x"$have_threads" != xnone; then
        LIBS="$glib_save_LIBS"
 
        # now spit out all the warnings.
-       if test "$ac_cv_func_getpwuid_r" != "yes"; then
+       if test "$ac_cv_func_posix_getpwuid_r" != "yes" && 
+          test "$ac_cv_func_nonposix_getpwuid_r" != "yes"; then
                AC_MSG_WARN($FUNC_NO_GETPWUID_R)
        fi
        if test "$ac_cv_func_localtime_r" != "yes"; then
@@ -1099,6 +1133,50 @@ GLIB_SYSDEFS(
        glibconfig-sysdefs.h,
        =)
 
+dnl ***********************
+dnl *** Tests for iconv ***
+dnl ***********************
+
+AC_ARG_WITH(libiconv, [ --with-libiconv     Use the libiconv library ],,with_libiconv=maybe)
+
+found_iconv=no
+
+if test "x$with_libiconv" != "xyes" ; then
+   # 
+   # Check in the C library 
+   #
+   AC_CHECK_FUNC(iconv_open, with_libiconv=no; found_iconv=yes)
+fi
+
+if test "x$with_libiconv" != "xno" ; then
+   #
+   # Check for libiconv
+   #
+   AC_CHECK_LIB(iconv, libiconv_open, with_libiconv=yes; found_iconv=yes)
+fi
+
+if test "x$found_iconv" = "xno" ; then
+   AC_MSG_ERROR([*** No iconv() implementation found in C library or libiconv])
+fi
+
+if test "x$with_libiconv" = "xyes" ; then
+  ICONV_LIBS="-liconv"
+  AC_DEFINE(USE_LIBICONV)
+fi
+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()
+
+AC_MSG_CHECKING([for EILSEQ])
+AC_TRY_COMPILE([
+#include <errno.h>
+],
+[
+int error = EILSEQ;
+], have_eilseq=yes, have_eilseq=no);
+AC_MSG_RESULT($have_eilseq)
+
 dnl **************************
 dnl *** Checks for gtk-doc ***
 dnl **************************
@@ -1299,6 +1377,20 @@ $glib_inline
 _______EOF
 
        echo >>$outfile
+       if test x$g_have_eilseq = xno; then
+               cat >>$outfile <<_______EOF
+#ifndef EILSEQ
+/* On some systems, like SunOS and NetBSD, EILSEQ is not defined.
+ * The correspondence between this and the corresponding definition
+ * in libiconv is essential.
+ */
+#  define EILSEQ ENOENT
+#endif
+_______EOF
+
+       fi
+
+       echo >>$outfile
        if test x$g_mutex_has_default = xyes; then
                cat >>$outfile <<_______EOF
 $g_enable_threads_def G_THREADS_ENABLED
@@ -1576,6 +1668,8 @@ x$ac_cv_c_bigendian)
   ;;
 esac
 
+g_have_eilseq=$have_eilseq
+
 case x$have_threads in
 xnone) g_enable_threads_def="#undef";;
 *)     g_enable_threads_def="#define";;