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
115 if test "x$ac_cv_sys_symbol_underscore" = x ; then
116 ac_cv_sys_symbol_underscore=yes
123 if test "$tmp_do_check" = "yes"; then
124 AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])
125 AC_MSG_CHECKING([for _ prefix in compiled symbols])
126 AC_CACHE_VAL(ac_cv_sys_symbol_underscore,
127 [ac_cv_sys_symbol_underscore=no
128 cat > conftest.$ac_ext <<EOF
129 void nm_test_func(){}
130 int main(){nm_test_func;return 0;}
132 if AC_TRY_EVAL(ac_compile); then
133 # Now try to grab the symbols.
135 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
136 # See whether the symbols have a leading underscore.
137 if egrep '^_nm_test_func' "$ac_nlist" >/dev/null; then
138 ac_cv_sys_symbol_underscore=yes
140 if egrep '^nm_test_func ' "$ac_nlist" >/dev/null; then
143 echo "configure: cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
147 echo "configure: cannot run $lt_cv_sys_global_symbol_pipe" >&AC_FD_CC
150 echo "configure: failed program was:" >&AC_FD_CC
151 cat conftest.c >&AC_FD_CC
156 AC_MSG_CHECKING([for _ prefix in compiled symbols])
158 AC_MSG_RESULT($ac_cv_sys_symbol_underscore)
159 if test x$ac_cv_sys_symbol_underscore = xyes; then
160 AC_DEFINE(WITH_SYMBOL_UNDERSCORE,1,
161 [Defined if compiled symbols have a leading underscore])
166 ######################################################################
167 # Check whether mlock is broken (hpux 10.20 raises a SIGBUS if mlock
168 # is not called from uid 0 (not tested whether uid 0 works)
169 # For DECs Tru64 we have also to check whether mlock is in librt
170 # mlock is there a macro using memlk()
171 ######################################################################
172 dnl GNUPG_CHECK_MLOCK
174 define(GNUPG_CHECK_MLOCK,
175 [ AC_CHECK_FUNCS(mlock)
176 if test "$ac_cv_func_mlock" = "no"; then
177 AC_CHECK_HEADERS(sys/mman.h)
178 if test "$ac_cv_header_sys_mman_h" = "yes"; then
180 AC_CHECK_LIB(rt, memlk)
181 AC_CACHE_CHECK([whether mlock is in sys/mman.h],
182 gnupg_cv_mlock_is_in_sys_mman,
185 #ifdef HAVE_SYS_MMAN_H
186 #include <sys/mman.h>
191 /* glibc defines this for functions which it implements
192 * to always fail with ENOSYS. Some functions are actually
193 * named something starting with __ and the normal name
195 #if defined (__stub_mlock) || defined (__stub___mlock)
202 gnupg_cv_mlock_is_in_sys_mman=yes,
203 gnupg_cv_mlock_is_in_sys_mman=no)])
204 if test "$gnupg_cv_mlock_is_in_sys_mman" = "yes"; then
205 AC_DEFINE(HAVE_MLOCK,1,
206 [Defined if the system supports an mlock() call])
210 if test "$ac_cv_func_mlock" = "yes"; then
211 AC_CHECK_FUNCS(sysconf getpagesize)
212 AC_MSG_CHECKING(whether mlock is broken)
213 AC_CACHE_VAL(gnupg_cv_have_broken_mlock,
218 #include <sys/mman.h>
219 #include <sys/types.h>
228 #if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
229 pgsize = sysconf (_SC_PAGESIZE);
230 #elif defined (HAVE_GETPAGESIZE)
231 pgsize = getpagesize();
239 pool = malloc( 4096 + pgsize );
242 pool += (pgsize - ((long int)pool % pgsize));
244 err = mlock( pool, 4096 );
245 if( !err || errno == EPERM || errno == EAGAIN)
252 gnupg_cv_have_broken_mlock="no",
253 gnupg_cv_have_broken_mlock="yes",
254 gnupg_cv_have_broken_mlock="assume-no"
257 if test "$gnupg_cv_have_broken_mlock" = "yes"; then
258 AC_DEFINE(HAVE_BROKEN_MLOCK,1,
259 [Defined if the mlock() call does not work])
262 if test "$gnupg_cv_have_broken_mlock" = "no"; then
265 AC_MSG_RESULT(assuming no)
271 # GNUPG_SYS_LIBTOOL_CYGWIN32 - find tools needed on cygwin32
272 AC_DEFUN([GNUPG_SYS_LIBTOOL_CYGWIN32],
273 [AC_CHECK_TOOL(DLLTOOL, dlltool, false)
274 AC_CHECK_TOOL(AS, as, false)
278 dnl Check whether an element ist contained in a list. Set `found' to
279 dnl `1' if the element is found in the list, to `0' otherwise.
280 AC_DEFUN([LIST_MEMBER],
287 if test "x$name" = "x$n"; then
294 dnl Check for socklen_t: historically on BSD it is an int, and in
295 dnl POSIX 1g it is a type of its own, but some platforms use different
296 dnl types for the argument to getsockopt, getpeername, etc. So we
297 dnl have to test to find something that will work.
298 AC_DEFUN([TYPE_SOCKLEN_T],
300 AC_CHECK_TYPE([socklen_t], ,[
301 AC_MSG_CHECKING([for socklen_t equivalent])
302 AC_CACHE_VAL([socklen_t_equiv],
304 # Systems have either "struct sockaddr *" or
305 # "void *" as the second argument to getpeername
307 for arg2 in "struct sockaddr" void; do
308 for t in int size_t unsigned long "unsigned long"; do
310 #include <sys/types.h>
311 #include <sys/socket.h>
313 int getpeername (int, $arg2 *, $t *);
316 getpeername(0,0,&len);
324 if test "x$socklen_t_equiv" = x; then
325 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
328 AC_MSG_RESULT($socklen_t_equiv)
329 AC_DEFINE_UNQUOTED(socklen_t, $socklen_t_equiv,
330 [type to use in place of socklen_t if not defined])],
331 [#include <sys/types.h>
332 #include <sys/socket.h>])
336 # GNUPG_PTH_VERSION_CHECK(REQUIRED)
338 # If the version is sufficient, HAVE_PTH will be set to yes.
340 # Taken form the m4 macros which come with Pth
341 AC_DEFUN([GNUPG_PTH_VERSION_CHECK],
343 _pth_version=`$PTH_CONFIG --version | awk 'NR==1 {print [$]3}'`
344 _req_version="ifelse([$1],,1.2.0,$1)"
346 AC_MSG_CHECKING(for PTH - version >= $_req_version)
347 for _var in _pth_version _req_version; do
348 eval "_val=\"\$${_var}\""
349 _major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\1/'`
350 _minor=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\2/'`
351 _rtype=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\3/'`
352 _micro=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\4/'`
358 _hex=`echo dummy | awk '{ printf("%d%02d%1d%02d", major, minor, rtype, micro); }' \
359 "major=$_major" "minor=$_minor" "rtype=$_rtype" "micro=$_micro"`
360 eval "${_var}_hex=\"\$_hex\""
363 if test ".$_pth_version_hex" != .; then
364 if test ".$_req_version_hex" != .; then
365 if test $_pth_version_hex -ge $_req_version_hex; then
370 if test $have_pth = yes; then
372 AC_MSG_CHECKING([whether PTH installation is sane])
373 AC_CACHE_VAL(gnupg_cv_pth_is_sane,[
374 _gnupg_pth_save_cflags=$CFLAGS
375 _gnupg_pth_save_ldflags=$LDFLAGS
376 _gnupg_pth_save_libs=$LIBS
377 CFLAGS="$CFLAGS `$PTH_CONFIG --cflags`"
378 LDFLAGS="$LDFLAGS `$PTH_CONFIG --ldflags`"
379 LIBS="$LIBS `$PTH_CONFIG --libs`"
380 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pth.h>
383 gnupg_cv_pth_is_sane=yes,
384 gnupg_cv_pth_is_sane=no)
385 CFLAGS=$_gnupg_pth_save_cflags
386 LDFLAGS=$_gnupg_pth_save_ldflags
387 LIBS=$_gnupg_pth_save_libs
389 if test $gnupg_cv_pth_is_sane != yes; then
392 AC_MSG_RESULT($gnupg_cv_pth_is_sane)