Added pwmd_socket_type() which sets a parameter to PWMD_SOCKET_UDS or
[libpwmd.git] / assuan / acinclude.m4
blob3c264e54539716912652f636c9bce8936e9c3a3a
1 dnl GnuPG's check for Pth.
2 dnl       Copyright (C) 2003 Free Software Foundation, Inc.
3 dnl
4 dnl This file is free software; as a special exception the author gives
5 dnl unlimited permission to copy and/or distribute it, with or without
6 dnl modifications, as long as this notice is preserved.
7 dnl
8 dnl This file is distributed in the hope that it will be useful, but
9 dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
10 dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 # GNUPG_PTH_VERSION_CHECK(REQUIRED)
14
15 # If the version is sufficient, HAVE_PTH will be set to yes.
17 # Taken and modified from the m4 macros which come with Pth.
18 AC_DEFUN([GNUPG_PTH_VERSION_CHECK],
19   [
20     _pth_version=`$PTH_CONFIG --version | awk 'NR==1 {print [$]3}'`
21     _req_version="ifelse([$1],,1.2.0,$1)"
23     AC_MSG_CHECKING(for PTH - version >= $_req_version)
24     for _var in _pth_version _req_version; do
25         eval "_val=\"\$${_var}\""
26         _major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\1/'`
27         _minor=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\2/'`
28         _rtype=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\3/'`
29         _micro=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\4/'`
30         case $_rtype in
31             "a" ) _rtype=0 ;;
32             "b" ) _rtype=1 ;;
33             "." ) _rtype=2 ;;
34         esac
35         _hex=`echo dummy | awk '{ printf("%d%02d%1d%02d", major, minor, rtype, micro); }' \
36               "major=$_major" "minor=$_minor" "rtype=$_rtype" "micro=$_micro"`
37         eval "${_var}_hex=\"\$_hex\""
38     done
39     have_pth=no
40     if test ".$_pth_version_hex" != .; then
41         if test ".$_req_version_hex" != .; then
42             if test $_pth_version_hex -ge $_req_version_hex; then
43                 have_pth=yes
44             fi
45         fi
46     fi
47     if test $have_pth = yes; then
48        AC_MSG_RESULT(yes)
49        AC_MSG_CHECKING([whether PTH installation is sane])
50        AC_CACHE_VAL(gnupg_cv_pth_is_sane,[
51          _gnupg_pth_save_cflags=$CFLAGS
52          _gnupg_pth_save_ldflags=$LDFLAGS
53          _gnupg_pth_save_libs=$LIBS
54          CFLAGS="$CFLAGS `$PTH_CONFIG --cflags`"
55          LDFLAGS="$LDFLAGS `$PTH_CONFIG --ldflags`"
56          LIBS="$LIBS `$PTH_CONFIG --libs --all`"
57          AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pth.h>
58                                          ],
59                                          [[ pth_init ();]])],
60                         gnupg_cv_pth_is_sane=yes,
61                         gnupg_cv_pth_is_sane=no)
62          CFLAGS=$_gnupg_pth_save_cflags
63          LDFLAGS=$_gnupg_pth_save_ldflags
64          LIBS=$_gnupg_pth_save_libs
65        ])
66        if test $gnupg_cv_pth_is_sane != yes; then
67           have_pth=no
68        fi
69        AC_MSG_RESULT($gnupg_cv_pth_is_sane)
70     else
71        AC_MSG_RESULT(no)
72     fi    
73   ])
77 # GNUPG_PATH_PTH([MINIMUM_VERSION])
79 # On return $have_pth is set as well as HAVE_PTH is defined and
80 # PTH_CLFAGS and PTH_LIBS are AS_SUBST.
82 AC_DEFUN([GNUPG_PATH_PTH],
83 [ AC_ARG_WITH(pth-prefix,
84              AC_HELP_STRING([--with-pth-prefix=PFX],
85                            [prefix where GNU Pth is installed (optional)]),
86      pth_config_prefix="$withval", pth_config_prefix="")
87   if test x$pth_config_prefix != x ; then
88      PTH_CONFIG="$pth_config_prefix/bin/pth-config"
89   fi
90   AC_PATH_PROG(PTH_CONFIG, pth-config, no)
91   tmp=ifelse([$1], ,1.3.7,$1)
92   if test "$PTH_CONFIG" != "no"; then
93     GNUPG_PTH_VERSION_CHECK($tmp)
94     if test $have_pth = yes; then      
95        PTH_CFLAGS=`$PTH_CONFIG --cflags`
96        PTH_LIBS=`$PTH_CONFIG --ldflags`
97        PTH_LIBS="$PTH_LIBS `$PTH_CONFIG --libs --all`"
98        AC_DEFINE(HAVE_PTH, 1,
99                 [Defined if the GNU Pth is available])
100     fi
101   fi
102   AC_SUBST(PTH_CFLAGS)
103   AC_SUBST(PTH_LIBS)
106 # socklen.m4 serial 4
107 dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
108 dnl This file is free software; the Free Software Foundation
109 dnl gives unlimited permission to copy and/or distribute it,
110 dnl with or without modifications, as long as this notice is preserved.
112 dnl From Albert Chin, Windows fixes from Simon Josefsson.
114 dnl Check for socklen_t: historically on BSD it is an int, and in
115 dnl POSIX 1g it is a type of its own, but some platforms use different
116 dnl types for the argument to getsockopt, getpeername, etc.  So we
117 dnl have to test to find something that will work.
119 dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find
120 dnl it there first.  That file is included by gnulib's socket_.h, which
121 dnl all users of this module should include.  Cygwin must not include
122 dnl ws2tcpip.h.
123 AC_DEFUN([gl_TYPE_SOCKLEN_T],
124   [AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl
125    AC_CHECK_TYPE([socklen_t], ,
126      [AC_MSG_CHECKING([for socklen_t equivalent])
127       AC_CACHE_VAL([gl_cv_gl_cv_socklen_t_equiv],
128         [# Systems have either "struct sockaddr *" or
129          # "void *" as the second argument to getpeername
130          gl_cv_socklen_t_equiv=
131          for arg2 in "struct sockaddr" void; do
132            for t in int size_t "unsigned int" "long int" "unsigned long int"; do
133              AC_TRY_COMPILE(
134                [#include <sys/types.h>
135                 #include <sys/socket.h>
137                 int getpeername (int, $arg2 *, $t *);],
138                [$t len;
139                 getpeername (0, 0, &len);],
140                [gl_cv_socklen_t_equiv="$t"])
141              test "$gl_cv_socklen_t_equiv" != "" && break
142            done
143            test "$gl_cv_socklen_t_equiv" != "" && break
144          done
145       ])
146       if test "$gl_cv_socklen_t_equiv" = ""; then
147         AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
148       fi
149       AC_MSG_RESULT([$gl_cv_socklen_t_equiv])
150       AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv],
151         [type to use in place of socklen_t if not defined])],
152      [#include <sys/types.h>
153       #if HAVE_SYS_SOCKET_H
154       # include <sys/socket.h>
155       #elif HAVE_WS2TCPIP_H
156       # include <ws2tcpip.h>
157       #endif])])
158 # sys_socket_h.m4 serial 2
159 dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
160 dnl This file is free software; the Free Software Foundation
161 dnl gives unlimited permission to copy and/or distribute it,
162 dnl with or without modifications, as long as this notice is preserved.
164 dnl From Simon Josefsson.
166 AC_DEFUN([gl_HEADER_SYS_SOCKET],
168   AC_CHECK_HEADERS_ONCE([sys/socket.h])
169   if test $ac_cv_header_sys_socket_h = yes; then
170     SYS_SOCKET_H=''
171   else
172     dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
173     dnl the check for those headers unconditional; yet cygwin reports
174     dnl that the headers are present but cannot be compiled (since on
175     dnl cygwin, all socket information should come from sys/socket.h).
176     AC_CHECK_HEADERS([winsock2.h ws2tcpip.h])
177     SYS_SOCKET_H='sys/socket.h'
178   fi
179   AC_SUBST(SYS_SOCKET_H)
181 # autobuild.m4 serial 2 (autobuild-3.3)
182 # Copyright (C) 2004 Simon Josefsson
184 # This file is free software, distributed under the terms of the GNU
185 # General Public License.  As a special exception to the GNU General
186 # Public License, this file may be distributed as part of a program
187 # that contains a configuration script generated by Autoconf, under
188 # the same distribution terms as the rest of that program.
190 # This file can can be used in projects which are not available under
191 # the GNU General Public License or the GNU Library General Public
192 # License but which still want to provide support for Autobuild.
194 # Usage: AB_INIT([MODE]).
195 AC_DEFUN([AB_INIT],
197         AC_REQUIRE([AC_CANONICAL_BUILD])
198         AC_REQUIRE([AC_CANONICAL_HOST])
200         AC_MSG_NOTICE([autobuild project... ${PACKAGE_NAME:-$PACKAGE}])
201         AC_MSG_NOTICE([autobuild revision... ${PACKAGE_VERSION:-$VERSION}])
202         hostname=`hostname`
203         if test "$hostname"; then
204            AC_MSG_NOTICE([autobuild hostname... $hostname])
205         fi
206         ifelse([$1],[],,[AC_MSG_NOTICE([autobuild mode... $1])])
207         date=`date +%Y%m%d-%H%M%S`
208         if test "$?" != 0; then
209            date=`date`
210         fi
211         if test "$date"; then
212            AC_MSG_NOTICE([autobuild timestamp... $date])
213         fi