1 dnl macros to configure Libgcrypt
2 dnl Copyright (C) 1998, 1999, 2000, 2001, 2002,
3 dnl 2003 Free Software Foundation, Inc.
4 dnl Copyright (C) 2013 g10 Code GmbH
6 dnl This file is part of Libgcrypt.
8 dnl Libgcrypt is free software; you can redistribute it and/or modify
9 dnl it under the terms of the GNU Lesser General Public License as
10 dnl published by the Free Software Foundation; either version 2.1 of
11 dnl the License, or (at your option) any later version.
13 dnl Libgcrypt is distributed in the hope that it will be useful,
14 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
15 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 dnl GNU Lesser General Public License for more details.
18 dnl You should have received a copy of the GNU Lesser General Public
19 dnl License along with this program; if not, write to the Free Software
20 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
22 dnl GCRY_MSG_SHOW(PREFIX,STRING)
23 dnl Print a message with a prefix.
25 define([GCRY_MSG_SHOW],
27 echo " $1 $2" 1>&AS_MESSAGE_FD([])
30 dnl GCRY_MSG_WRAP(PREFIX, ALGOLIST)
31 dnl Print a nicely formatted list of algorithms
32 dnl with an appropriate line wrap.
34 define([GCRY_MSG_WRAP],
38 if test "${#tmpi}" -ne 3 >/dev/null 2>&1 ; then
39 dnl Without a POSIX shell, we don't botter to wrap it
40 echo "$tmp $2" 1>&AS_MESSAGE_FD([])
42 tmpi=`echo "$tmp"| sed 's/./ /g'`
43 echo $2 EOF | tr ' ' '\n' | \
45 if test "${#tmp}" -gt 70 ; then
46 echo "$tmp" 1>&AS_MESSAGE_FD([])
49 if test "$word" = "EOF" ; then
50 echo "$tmp" 1>&AS_MESSAGE_FD([])
59 dnl GNUPG_CHECK_TYPEDEF(TYPE, HAVE_NAME)
60 dnl Check whether a typedef exists and create a #define $2 if it exists
62 AC_DEFUN([GNUPG_CHECK_TYPEDEF],
63 [ AC_MSG_CHECKING(for $1 typedef)
64 AC_CACHE_VAL(gnupg_cv_typedef_$1,
65 [AC_TRY_COMPILE([#define _GNU_SOURCE 1
67 #include <sys/types.h>], [
70 ], gnupg_cv_typedef_$1=yes, gnupg_cv_typedef_$1=no )])
71 AC_MSG_RESULT($gnupg_cv_typedef_$1)
72 if test "$gnupg_cv_typedef_$1" = yes; then
73 AC_DEFINE($2,1,[Defined if a `]$1[' is typedef'd])
78 dnl GNUPG_CHECK_GNUMAKE
80 AC_DEFUN([GNUPG_CHECK_GNUMAKE],
82 if ${MAKE-make} --version 2>/dev/null | grep '^GNU ' >/dev/null 2>&1; then
87 *** It seems that you are not using GNU make. Some make tools have serious
88 *** flaws and you may not be able to build this software at all. Before you
89 *** complain, please try GNU make: GNU make is easy to build and available
90 *** at all GNU archives. It is always available from ftp.gnu.org:/gnu/make.
97 # GNUPG_SYS_SYMBOL_UNDERSCORE
98 # Does the compiler prefix global symbols with an underscore?
100 # Taken from GnuPG 1.2 and modified to use the libtool macros.
101 AC_DEFUN([GNUPG_SYS_SYMBOL_UNDERSCORE],
104 i?86-mingw32* | i?86-*-mingw32*)
105 ac_cv_sys_symbol_underscore=yes
108 ac_cv_sys_symbol_underscore=no
110 i386-emx-os2 | i[3456]86-pc-os2*emx | i386-pc-msdosdjgpp)
111 ac_cv_sys_symbol_underscore=yes
114 if test "$cross_compiling" != yes; then
119 if test "$tmp_do_check" = "yes"; then
120 AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])
121 AC_MSG_CHECKING([for _ prefix in compiled symbols])
122 AC_CACHE_VAL(ac_cv_sys_symbol_underscore,
123 [ac_cv_sys_symbol_underscore=no
124 cat > conftest.$ac_ext <<EOF
125 void nm_test_func(){}
126 int main(){nm_test_func;return 0;}
128 if AC_TRY_EVAL(ac_compile); then
129 # Now try to grab the symbols.
131 if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \| cut -d \' \' -f 2 \> $ac_nlist) && test -s "$ac_nlist"; then
132 # See whether the symbols have a leading underscore.
133 if egrep '^_nm_test_func' "$ac_nlist" >/dev/null; then
134 ac_cv_sys_symbol_underscore=yes
136 if egrep '^nm_test_func ' "$ac_nlist" >/dev/null; then
139 echo "configure: cannot find nm_test_func in $ac_nlist" >&AS_MESSAGE_LOG_FD
143 echo "configure: cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
146 echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
147 cat conftest.c >&AS_MESSAGE_LOG_FD
152 AC_MSG_CHECKING([for _ prefix in compiled symbols])
154 AC_MSG_RESULT($ac_cv_sys_symbol_underscore)
155 if test x$ac_cv_sys_symbol_underscore = xyes; then
156 AC_DEFINE(WITH_SYMBOL_UNDERSCORE,1,
157 [Defined if compiled symbols have a leading underscore])
162 ######################################################################
163 # Check whether mlock is broken (hpux 10.20 raises a SIGBUS if mlock
164 # is not called from uid 0 (not tested whether uid 0 works)
165 # For DECs Tru64 we have also to check whether mlock is in librt
166 # mlock is there a macro using memlk()
167 ######################################################################
168 dnl GNUPG_CHECK_MLOCK
170 define(GNUPG_CHECK_MLOCK,
171 [ AC_CHECK_FUNCS(mlock)
172 if test "$ac_cv_func_mlock" = "no"; then
173 AC_CHECK_HEADERS(sys/mman.h)
174 if test "$ac_cv_header_sys_mman_h" = "yes"; then
176 AC_CHECK_LIB(rt, memlk)
177 AC_CACHE_CHECK([whether mlock is in sys/mman.h],
178 gnupg_cv_mlock_is_in_sys_mman,
182 #ifdef HAVE_SYS_MMAN_H
183 #include <sys/mman.h>
188 /* glibc defines this for functions which it implements
189 * to always fail with ENOSYS. Some functions are actually
190 * named something starting with __ and the normal name
192 #if defined (__stub_mlock) || defined (__stub___mlock)
199 gnupg_cv_mlock_is_in_sys_mman=yes,
200 gnupg_cv_mlock_is_in_sys_mman=no)])
201 if test "$gnupg_cv_mlock_is_in_sys_mman" = "yes"; then
202 AC_DEFINE(HAVE_MLOCK,1,
203 [Defined if the system supports an mlock() call])
207 if test "$ac_cv_func_mlock" = "yes"; then
208 AC_CHECK_FUNCS(sysconf getpagesize)
209 AC_MSG_CHECKING(whether mlock is broken)
210 AC_CACHE_VAL(gnupg_cv_have_broken_mlock,
211 AC_RUN_IFELSE([AC_LANG_SOURCE([[
215 #include <sys/mman.h>
216 #include <sys/types.h>
225 #if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
226 pgsize = sysconf (_SC_PAGESIZE);
227 #elif defined (HAVE_GETPAGESIZE)
228 pgsize = getpagesize();
236 pool = malloc( 4096 + pgsize );
239 pool += (pgsize - ((size_t)pool % pgsize));
241 err = mlock( pool, 4096 );
242 if( !err || errno == EPERM || errno == EAGAIN)
248 gnupg_cv_have_broken_mlock="no",
249 gnupg_cv_have_broken_mlock="yes",
250 gnupg_cv_have_broken_mlock="assume-no"
253 if test "$gnupg_cv_have_broken_mlock" = "yes"; then
254 AC_DEFINE(HAVE_BROKEN_MLOCK,1,
255 [Defined if the mlock() call does not work])
258 if test "$gnupg_cv_have_broken_mlock" = "no"; then
261 AC_MSG_RESULT(assuming no)
267 # GNUPG_SYS_LIBTOOL_CYGWIN32 - find tools needed on cygwin32
268 AC_DEFUN([GNUPG_SYS_LIBTOOL_CYGWIN32],
269 [AC_CHECK_TOOL(DLLTOOL, dlltool, false)
270 AC_CHECK_TOOL(AS, as, false)
274 dnl Check whether an element ist contained in a list. Set `found' to
275 dnl `1' if the element is found in the list, to `0' otherwise.
276 AC_DEFUN([LIST_MEMBER],
283 if test "x$name" = "x$n"; then
290 dnl Check for socklen_t: historically on BSD it is an int, and in
291 dnl POSIX 1g it is a type of its own, but some platforms use different
292 dnl types for the argument to getsockopt, getpeername, etc. So we
293 dnl have to test to find something that will work.
294 AC_DEFUN([TYPE_SOCKLEN_T],
296 AC_CHECK_TYPE([socklen_t], ,[
297 AC_MSG_CHECKING([for socklen_t equivalent])
298 AC_CACHE_VAL([socklen_t_equiv],
300 # Systems have either "struct sockaddr *" or
301 # "void *" as the second argument to getpeername
303 for arg2 in "struct sockaddr" void; do
304 for t in int size_t unsigned long "unsigned long"; do
306 #include <sys/types.h>
307 #include <sys/socket.h>
309 int getpeername (int, $arg2 *, $t *);
312 getpeername(0,0,&len);
320 if test "x$socklen_t_equiv" = x; then
321 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
324 AC_MSG_RESULT($socklen_t_equiv)
325 AC_DEFINE_UNQUOTED(socklen_t, $socklen_t_equiv,
326 [type to use in place of socklen_t if not defined])],
327 [#include <sys/types.h>
328 #include <sys/socket.h>])
332 # GNUPG_PTH_VERSION_CHECK(REQUIRED)
334 # If the version is sufficient, HAVE_PTH will be set to yes.
336 # Taken form the m4 macros which come with Pth
337 AC_DEFUN([GNUPG_PTH_VERSION_CHECK],
339 _pth_version=`$PTH_CONFIG --version | awk 'NR==1 {print [$]3}'`
340 _req_version="ifelse([$1],,1.2.0,$1)"
342 AC_MSG_CHECKING(for PTH - version >= $_req_version)
343 for _var in _pth_version _req_version; do
344 eval "_val=\"\$${_var}\""
345 _major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\1/'`
346 _minor=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\2/'`
347 _rtype=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\3/'`
348 _micro=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\4/'`
354 _hex=`echo dummy | awk '{ printf("%d%02d%1d%02d", major, minor, rtype, micro); }' \
355 "major=$_major" "minor=$_minor" "rtype=$_rtype" "micro=$_micro"`
356 eval "${_var}_hex=\"\$_hex\""
359 if test ".$_pth_version_hex" != .; then
360 if test ".$_req_version_hex" != .; then
361 if test $_pth_version_hex -ge $_req_version_hex; then
366 if test $have_pth = yes; then
368 AC_MSG_CHECKING([whether PTH installation is sane])
369 AC_CACHE_VAL(gnupg_cv_pth_is_sane,[
370 _gnupg_pth_save_cflags=$CFLAGS
371 _gnupg_pth_save_ldflags=$LDFLAGS
372 _gnupg_pth_save_libs=$LIBS
373 CFLAGS="$CFLAGS `$PTH_CONFIG --cflags`"
374 LDFLAGS="$LDFLAGS `$PTH_CONFIG --ldflags`"
375 LIBS="$LIBS `$PTH_CONFIG --libs`"
376 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pth.h>
379 gnupg_cv_pth_is_sane=yes,
380 gnupg_cv_pth_is_sane=no)
381 CFLAGS=$_gnupg_pth_save_cflags
382 LDFLAGS=$_gnupg_pth_save_ldflags
383 LIBS=$_gnupg_pth_save_libs
385 if test $gnupg_cv_pth_is_sane != yes; then
388 AC_MSG_RESULT($gnupg_cv_pth_is_sane)