ftp://ftp.redhat.com/pub/redhat/linux/rawhide/SRPMS/SRPMS/gnome-vfs2-2.3.8-1.src.rpm
[gnome-vfs-httpcaptive.git] / acinclude.m4
1 AC_DEFUN(AM_GNOME_CHECK_TYPE,
2   [AC_CACHE_CHECK([$1 in <sys/types.h>], ac_cv_type_$1,
3      [AC_TRY_COMPILE([
4 #include <sys/types.h>
5 #if STDC_HEADERS
6 #include <stdlib.h>
7 #include <stddef.h>
8 #endif
9 ],[$1 foo;],
10      ac_cv_type_$1=yes, ac_cv_type_$1=no)])
11    if test $ac_cv_type_$1 = no; then
12       AC_DEFINE($1, $2, $1)
13    fi
14 ])
15
16 AC_DEFUN(AM_GNOME_SIZE_T,
17   [AM_GNOME_CHECK_TYPE(size_t, unsigned)
18    AC_PROVIDE([AC_TYPE_SIZE_T])
19 ])
20
21 AC_DEFUN(AM_GNOME_OFF_T,
22   [AM_GNOME_CHECK_TYPE(off_t, long)
23    AC_PROVIDE([AC_TYPE_OFF_T])
24 ])
25
26 dnl Autoconf macros for libgnutls
27
28 # Modified for LIBGNUTLS -- nmav
29 # Configure paths for LIBGCRYPT
30 # Shamelessly stolen from the one of XDELTA by Owen Taylor
31 # Werner Koch   99-12-09
32
33 dnl AM_PATH_LIBGNUTLS([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
34 dnl Test for libgnutls, and define LIBGNUTLS_CFLAGS and LIBGNUTLS_LIBS
35 dnl
36 AC_DEFUN(AM_PATH_LIBGNUTLS,
37 [dnl
38 dnl Get the cflags and libraries from the libgnutls-config script
39 dnl
40 AC_ARG_WITH(libgnutls-prefix,
41           [  --with-libgnutls-prefix=PFX   Prefix where libgnutls is installed (optional)],
42           libgnutls_config_prefix="$withval", libgnutls_config_prefix="")
43
44   if test x$libgnutls_config_prefix != x ; then
45      libgnutls_config_args="$libgnutls_config_args --prefix=$libgnutls_config_prefix"
46      if test x${LIBGNUTLS_CONFIG+set} != xset ; then
47         LIBGNUTLS_CONFIG=$libgnutls_config_prefix/bin/libgnutls-config
48      fi
49   fi
50
51   AC_PATH_PROG(LIBGNUTLS_CONFIG, libgnutls-config, no)
52   min_libgnutls_version=ifelse([$1], ,0.1.0,$1)
53   AC_MSG_CHECKING(for libgnutls - version >= $min_libgnutls_version)
54   no_libgnutls=""
55   if test "$LIBGNUTLS_CONFIG" = "no" ; then
56     no_libgnutls=yes
57   else
58     LIBGNUTLS_CFLAGS=`$LIBGNUTLS_CONFIG $libgnutls_config_args --cflags`
59     LIBGNUTLS_LIBS=`$LIBGNUTLS_CONFIG $libgnutls_config_args --libs`
60     libgnutls_config_version=`$LIBGNUTLS_CONFIG $libgnutls_config_args --version`
61
62
63       ac_save_CFLAGS="$CFLAGS"
64       ac_save_LIBS="$LIBS"
65       CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS"
66       LIBS="$LIBS $LIBGNUTLS_LIBS"
67 dnl
68 dnl Now check if the installed libgnutls is sufficiently new. Also sanity
69 dnl checks the results of libgnutls-config to some extent
70 dnl
71       rm -f conf.libgnutlstest
72       AC_TRY_RUN([
73 #include <stdio.h>
74 #include <stdlib.h>
75 #include <string.h>
76 #include <gnutls/gnutls.h>
77
78 int
79 main ()
80 {
81     system ("touch conf.libgnutlstest");
82
83     if( strcmp( gnutls_check_version(NULL), "$libgnutls_config_version" ) )
84     {
85       printf("\n*** 'libgnutls-config --version' returned %s, but LIBGNUTLS (%s)\n",
86              "$libgnutls_config_version", gnutls_check_version(NULL) );
87       printf("*** was found! If libgnutls-config was correct, then it is best\n");
88       printf("*** to remove the old version of LIBGNUTLS. You may also be able to fix the error\n");
89       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
90       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
91       printf("*** required on your system.\n");
92       printf("*** If libgnutls-config was wrong, set the environment variable LIBGNUTLS_CONFIG\n");
93       printf("*** to point to the correct copy of libgnutls-config, and remove the file config.cache\n");
94       printf("*** before re-running configure\n");
95     }
96     else if ( strcmp(gnutls_check_version(NULL), LIBGNUTLS_VERSION ) )
97     {
98       printf("\n*** LIBGNUTLS header file (version %s) does not match\n", LIBGNUTLS_VERSION);
99       printf("*** library (version %s)\n", gnutls_check_version(NULL) );
100     }
101     else
102     {
103       if ( gnutls_check_version( "$min_libgnutls_version" ) )
104       {
105         return 0;
106       }
107      else
108       {
109         printf("no\n*** An old version of LIBGNUTLS (%s) was found.\n",
110                 gnutls_check_version(NULL) );
111         printf("*** You need a version of LIBGNUTLS newer than %s. The latest version of\n",
112                "$min_libgnutls_version" );
113         printf("*** LIBGNUTLS is always available from ftp://gnutls.hellug.gr/pub/gnutls.\n");
114         printf("*** \n");
115         printf("*** If you have already installed a sufficiently new version, this error\n");
116         printf("*** probably means that the wrong copy of the libgnutls-config shell script is\n");
117         printf("*** being found. The easiest way to fix this is to remove the old version\n");
118         printf("*** of LIBGNUTLS, but you can also set the LIBGNUTLS_CONFIG environment to point to the\n");
119         printf("*** correct copy of libgnutls-config. (In this case, you will have to\n");
120         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
121         printf("*** so that the correct libraries are found at run-time))\n");
122       }
123     }
124   return 1;
125 }
126 ],, no_libgnutls=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
127        CFLAGS="$ac_save_CFLAGS"
128        LIBS="$ac_save_LIBS"
129   fi
130
131   if test "x$no_libgnutls" = x ; then
132      AC_MSG_RESULT(yes)
133      ifelse([$2], , :, [$2])
134   else
135      if test -f conf.libgnutlstest ; then
136         :
137      else
138         AC_MSG_RESULT(no)
139      fi
140      if test "$LIBGNUTLS_CONFIG" = "no" ; then
141        echo "*** The libgnutls-config script installed by LIBGNUTLS could not be found"
142        echo "*** If LIBGNUTLS was installed in PREFIX, make sure PREFIX/bin is in"
143        echo "*** your path, or set the LIBGNUTLS_CONFIG environment variable to the"
144        echo "*** full path to libgnutls-config."
145      else
146        if test -f conf.libgnutlstest ; then
147         :
148        else
149           echo "*** Could not run libgnutls test program, checking why..."
150           CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS"
151           LIBS="$LIBS $LIBGNUTLS_LIBS"
152           AC_TRY_LINK([
153 #include <stdio.h>
154 #include <stdlib.h>
155 #include <string.h>
156 #include <gnutls/gnutls.h>
157 ],      [ return !!gnutls_check_version(NULL); ],
158         [ echo "*** The test program compiled, but did not run. This usually means"
159           echo "*** that the run-time linker is not finding LIBGNUTLS or finding the wrong"
160           echo "*** version of LIBGNUTLS. If it is not finding LIBGNUTLS, you'll need to set your"
161           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
162           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
163           echo "*** is required on your system"
164           echo "***"
165           echo "*** If you have an old version installed, it is best to remove it, although"
166           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
167           echo "***" ],
168         [ echo "*** The test program failed to compile or link. See the file config.log for the"
169           echo "*** exact error that occured. This usually means LIBGNUTLS was incorrectly installed"
170           echo "*** or that you have moved LIBGNUTLS since it was installed. In the latter case, you"
171           echo "*** may want to edit the libgnutls-config script: $LIBGNUTLS_CONFIG" ])
172           CFLAGS="$ac_save_CFLAGS"
173           LIBS="$ac_save_LIBS"
174        fi
175      fi
176      LIBGNUTLS_CFLAGS=""
177      LIBGNUTLS_LIBS=""
178      ifelse([$3], , :, [$3])
179   fi
180   rm -f conf.libgnutlstest
181   AC_SUBST(LIBGNUTLS_CFLAGS)
182   AC_SUBST(LIBGNUTLS_LIBS)
183 ])
184
185 dnl end of Autoconf macros for libgnutls