added g_strlcat() and g_strlcpy() wrappers, supplied by David Wheeler
[platform/upstream/glib.git] / configure.in
index 7531b43..3722b19 100644 (file)
@@ -19,7 +19,7 @@ dnl we need to AC_DIVERT_PUSH/AC_DIVERT_POP these variable definitions so they
 dnl are available for $ac_help expansion (don't we all *love* autoconf?)
 AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
 #
-# The following version number definitions apply to GLib, GModule and GThread
+# 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.
 #
@@ -105,6 +105,7 @@ AC_ARG_ENABLE(debug, [  --enable-debug=[no/minimum/yes] turn on debugging [defau
 AC_ARG_ENABLE(msg-prefix, [  --enable-msg-prefix     turn on program name and PID prefixing of messages and warnings],,enable_msg_prefix=no)
 AC_ARG_ENABLE(mem_check, [  --enable-mem-check      turn on malloc/free sanity checking [default=no]],,enable_mem_check=no)
 AC_ARG_ENABLE(mem_profile, [  --enable-mem-profile    turn on malloc profiling atexit [default=no]],,enable_mem_profile=no)
+AC_ARG_ENABLE(gc_friendly, [  --enable-gc-friendly    turn on garbage collector friendliness [default=no]],,enable_gc_friendly=no)
 AC_ARG_ENABLE(ansi, [  --enable-ansi           turn on strict ansi [default=no]],
                    , enable_ansi=no)
 AC_ARG_ENABLE(threads, [  --enable-threads        turn on basic thread support [default=yes]
@@ -132,6 +133,15 @@ else
   AC_MSG_RESULT(no)
 fi
 
+AC_MSG_CHECKING(whether to enable garbage collector friendliness)
+if test "x$enable_gc_friendly" = "xyes"; then
+  AC_DEFINE(ENABLE_GC_FRIENDLY, 1)
+  AC_SUBST(ENABLE_GC_FRIENDLY)
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+fi
+
 if test "x$enable_debug" = "xyes"; then
   test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
   GLIB_DEBUG_FLAGS="-DG_ENABLE_DEBUG"
@@ -295,7 +305,7 @@ esac
 # check for bytesex stuff
 AC_C_BIGENDIAN
 
-# xhexk for header files
+# check for header files
 AC_CHECK_HEADERS(float.h, AC_DEFINE(HAVE_FLOAT_H))
 AC_CHECK_HEADERS(limits.h, AC_DEFINE(HAVE_LIMITS_H))
 AC_CHECK_HEADERS(pwd.h, AC_DEFINE(HAVE_PWD_H))
@@ -308,11 +318,25 @@ AC_CHECK_HEADERS(unistd.h, AC_DEFINE(HAVE_UNISTD_H))
 AC_CHECK_HEADERS(values.h, AC_DEFINE(HAVE_VALUES_H))
 AC_CHECK_HEADERS(stdint.h, AC_DEFINE(HAVE_VALUES_H))
 
+AC_MSG_CHECKING(whether make is GNU Make)
+STRIP_BEGIN=
+STRIP_END=
+if $ac_make --version 2>/dev/null | grep '^GNU Make ' >/dev/null ; then
+        STRIP_BEGIN='$(strip $(STRIP_DUMMY)'
+        STRIP_END=')'
+        AC_MSG_RESULT(yes)
+else
+        AC_MSG_RESULT(no)
+fi
+STRIP_DUMMY=
+AC_SUBST(STRIP_DUMMY)
+AC_SUBST(STRIP_BEGIN)
+AC_SUBST(STRIP_END)
+
 # check additional type sizes
 size_includes=["
 #include <stdarg.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <ctype.h>
 #include <string.h>
 "]
@@ -374,7 +398,7 @@ fi
 AC_MSG_CHECKING(for sys_siglist)
 AC_TRY_LINK(, [
 extern char *sys_siglist[];
-strlen (sys_siglist[0]);
+exit (sys_siglist[0]);
 ], glib_ok=yes, glib_ok=no)
 AC_MSG_RESULT($glib_ok)
 if test $glib_ok = no; then
@@ -424,6 +448,33 @@ AC_CACHE_VAL(glib_cv_sane_realloc,[
 ])
 AC_MSG_RESULT($glib_cv_sane_realloc)
 
+dnl Check for nl_langinfo and CODESET
+
+AC_MSG_CHECKING([for nl_langinfo (CODESET)])
+AC_TRY_COMPILE([#include <langinfo.h>],
+       [char *codeset = nl_langinfo (CODESET);],
+   AC_DEFINE(HAVE_CODESET)
+   have_codeset=yes,
+   have_codeset=no)
+AC_MSG_RESULT($have_codeset)
+
+
+dnl ****************************************
+dnl *** strlcpy/strlcat                  ***
+dnl ****************************************
+# Check for strlcpy
+AC_MSG_CHECKING(for strlcpy/strlcat)
+AC_TRY_LINK([#include <stdlib.h>
+#include <string.h>], [
+char *p = malloc(10);
+(void) strlcpy(p, "hi", 10);
+(void) strlcat(p, "bye", 10);
+], glib_ok=yes, glib_ok=no)
+AC_MSG_RESULT($glib_ok)
+if test $glib_ok = yes; then
+    AC_DEFINE(HAVE_STRLCPY)
+fi
+  
 
 dnl **********************
 dnl *** va_copy checks ***
@@ -733,8 +784,6 @@ case $have_threads in
                G_THREAD_LIBS=error
                glib_save_LIBS="$LIBS"
                for thread_lib in "" pthread pthreads c_r thread dce; do
-                       # This is not AC_CHECK_LIB to also work with function
-                       # name mangling in header files.
                        if test x"$thread_lib" = x; then
                                add_thread_lib=""
                                IN=""
@@ -750,19 +799,47 @@ case $have_threads in
                        
                        LIBS="$glib_save_LIBS $add_thread_lib"
                        
-                       AC_MSG_CHECKING(for pthread_create$IN)
+                       AC_MSG_CHECKING(for pthread_create/pthread_join$IN)
                        AC_TRY_RUN([#include <pthread.h> 
-                               void* func(void* data) {}
+                               int check_me = 0;
+                               void* func(void* data) {check_me = 42;}
                                 main()
                                { pthread_t t; 
-                                 exit(pthread_create (&t, $defattr, func, 
-                                               NULL));
+                                 void *ret;
+                                 pthread_create (&t, $defattr, func, NULL);
+                                 pthread_join (t, &ret);
+                                 exit (check_me != 42);
                                }],
                                [AC_MSG_RESULT(yes)
                                G_THREAD_LIBS="$add_thread_lib"
                                break],
                                [AC_MSG_RESULT(no)])
                done
+               for thread_lib in "" rt; do
+                       if test x"$thread_lib" = x; then
+                               add_thread_lib=""
+                               IN=""
+                       else
+                               add_thread_lib="-l$thread_lib"
+                               IN=" in -l$thread_lib"
+                       fi
+                       LIBS="$glib_save_LIBS $add_thread_lib"
+                       
+                       AC_MSG_CHECKING(for sched_get_priority_min$IN)
+                       AC_TRY_RUN([#include <sched.h>
+                               #include <errno.h>
+                               int main() {
+                               errno = 0;
+                                return sched_get_priority_min(SCHED_OTHER)==-1
+                                       && errno != 0;
+                               }],
+                               [AC_MSG_RESULT(yes)
+                               G_THREAD_LIBS="$G_THREAD_LIBS $add_thread_lib"
+                               posix_priority_min="sched_get_priority_min(SCHED_OTHER)"
+                               posix_priority_max="sched_get_priority_max(SCHED_OTHER)"
+                               break],
+                               [AC_MSG_RESULT(no)])
+               done
                LIBS="$glib_save_LIBS"
                 mutex_has_default=yes
                 mutex_default_type='pthread_mutex_t'
@@ -884,8 +961,8 @@ if test x"$enable_threads" = xyes; then
                        # 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>],
+                               #include <sys/types.h>
+                               #include <stdlib.h>],
                                [getpwuid_r((uid_t)0, NULL, NULL, (size_t)0, NULL);],
                                [AC_DEFINE(HAVE_GETPWUID_R_POSIX)
                                AC_MSG_RESULT(yes)],
@@ -907,26 +984,7 @@ if test x"$enable_threads" = xyes; then
                        [AC_MSG_RESULT(yes)
                        AC_DEFINE(HAVE_PTHREAD_ATTR_SETSTACKSIZE)],
                        [AC_MSG_RESULT(no)])
-               # If sched_get_priority_min(SCHED_OTHER) returns something 
-               # negative, we ignore it.
                AC_MSG_CHECKING(for minimal/maximal thread priority)
-               AC_TRY_RUN([#include <pthread.h>
-                    int main () 
-                    { return sched_get_priority_min(SCHED_OTHER) == -1;}],
-                    [posix_priority_min="sched_get_priority_min(SCHED_OTHER)"
-                    posix_priority_max="sched_get_priority_max(SCHED_OTHER)"],
-                    [posix_priority_min=none])
-               # On some platforms we need to link to -lrt to use the 
-               # sched_* functions
-               LIBS="$LIBS -lrt"
-               AC_TRY_RUN([#include <pthread.h>
-                    int main () 
-                    { return sched_get_priority_min(SCHED_OTHER) == -1;}],
-                    [posix_priority_min="sched_get_priority_min(SCHED_OTHER)"
-                    posix_priority_max="sched_get_priority_max(SCHED_OTHER)"
-                    G_THREAD_LIBS="$G_THREAD_LIBS -lrt"],
-                    [posix_priority_min=none])
-               LIBS="$glib_save_LIBS $G_THREAD_LIBS"
                if test x"$posix_priority_min" = xnone; then
                        AC_EGREP_CPP(PX_PRIO_MIN,[#include <pthread.h>
                                PX_PRIO_MIN],,[
@@ -939,7 +997,7 @@ if test x"$enable_threads" = xyes; then
                                posix_priority_min=PRI_OTHER_MIN        
                                posix_priority_max=PRI_OTHER_MAX])
                fi
-               if test x"$posix_priority_min" = xnone; then
+               if test x"$posix_priority_min" = x; then
                        AC_MSG_RESULT(none found)
                        AC_MSG_WARN($POSIX_NO_PRIORITIES)
                        posix_priority_min=-1
@@ -1070,10 +1128,6 @@ case "$CONFIG_OTHER" in
 #ifndef GLIBCONFIG_H
 #define GLIBCONFIG_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
 _______EOF
 
        if test x$glib_limits_h = xyes; then
@@ -1094,6 +1148,10 @@ _______EOF
 
        cat >> $outfile <<_______EOF
 
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
 #define G_MINFLOAT     $glib_mf
 #define G_MAXFLOAT     $glib_Mf
 #define G_MINDOUBLE    $glib_md
@@ -1148,9 +1206,23 @@ ${glib_extension}typedef unsigned $gint64 guint64;
 #define G_GINT64_FORMAT $gint64_format
 #define G_GUINT64_FORMAT $guint64_format
 #define G_GINT64_CONSTANT(val) $gint64_constant
+
 _______EOF
        fi
 
+       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
 
        if test -z "$glib_unknown_void_p"; then
          cat >>$outfile <<_______EOF
@@ -1367,6 +1439,7 @@ $ac_cv_sizeof_long_long)
   gint64_constant='(G_GNUC_EXTENSION (val##LL))'
   ;;
 esac
+glib_size_t=$glib_cv_sizeof_size_t
 
 gintbits=`expr $ac_cv_sizeof_int \* 8`
 glongbits=`expr $ac_cv_sizeof_long \* 8`
@@ -1473,7 +1546,7 @@ case $host in
   *-*-cygwin*)
     glib_os="#define G_OS_UNIX
 #define G_WITH_CYGWIN"
-    ;;
+v    ;;
   *)
     glib_os="#define G_OS_UNIX"
     ;;
@@ -1483,15 +1556,18 @@ esac
 AC_OUTPUT([
 glib.spec
 Makefile
-glib-config
+glib-config-2.0
+build/Makefile
+build/win32/Makefile
 gmodule/gmoduleconf.h
 gmodule/Makefile
+gobject/Makefile
 gthread/Makefile
 docs/Makefile
 docs/glib-config.1
 tests/Makefile
 ],[case "$CONFIG_FILES" in
-*glib-config*)chmod +x glib-config;;
+*glib-config-2.0*)chmod +x glib-config-2.0;;
 esac
 echo ""
 echo " *** IMPORTANT *** "
@@ -1503,12 +1579,6 @@ echo ""
 echo "  * You should not base stable software on this version of GLib."
 echo "  * GNOME developers should use a stable version of GLib."
 echo ""
-echo "Distributions should *NOT* ship a development package of this GLib."
-echo "Do not ship the headers and do not ship the glib-config script.  These"
-echo "things will conflict with the stable 1.2 series.  Package only enough"
-echo "to satisfy the requirements of some other package.  Package only the"
-echo "library itself.  Doing otherwise will do no favors to the community."
-echo ""
 echo "If you install this version of GLib, we strongly recommend that you"
 echo "install it in a different prefix than GLib 1.2.  Use --prefix as an"
 echo "argument to configure to do this.  Otherwise, you will not be able to"