~ubuntu-branches/ubuntu/natty/libgcrypt11/natty-proposed

1.1.1 by Matthias Urlichs
Import upstream version 1.2.1
1
dnl macros to configure Libgcrypt
2
dnl Copyright (C) 1998, 1999, 2000, 2001, 2002,
3
dnl               2003 Free Software Foundation, Inc.
4
dnl
5
dnl This file is part of Libgcrypt.
6
dnl
7
dnl Libgcrypt is free software; you can redistribute it and/or modify
8
dnl it under the terms of the GNU Lesser General Public License as
9
dnl published by the Free Software Foundation; either version 2.1 of
10
dnl the License, or (at your option) any later version.
11
dnl
12
dnl Libgcrypt is distributed in the hope that it will be useful,
13
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
dnl GNU Lesser General Public License for more details.
16
dnl
17
dnl You should have received a copy of the GNU Lesser General Public
18
dnl License along with this program; if not, write to the Free Software
19
dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20
21
dnl GNUPG_MSG_PRINT(STRING)
22
dnl print a message
23
dnl
24
define([GNUPG_MSG_PRINT],
25
  [ echo $ac_n "$1"" $ac_c" 1>&AS_MESSAGE_FD([])
26
  ])
27
28
dnl GNUPG_CHECK_TYPEDEF(TYPE, HAVE_NAME)
29
dnl Check whether a typedef exists and create a #define $2 if it exists
30
dnl
31
AC_DEFUN([GNUPG_CHECK_TYPEDEF],
32
  [ AC_MSG_CHECKING(for $1 typedef)
33
    AC_CACHE_VAL(gnupg_cv_typedef_$1,
34
    [AC_TRY_COMPILE([#define _GNU_SOURCE 1
35
    #include <stdlib.h>
36
    #include <sys/types.h>], [
37
    #undef $1
38
    int a = sizeof($1);
39
    ], gnupg_cv_typedef_$1=yes, gnupg_cv_typedef_$1=no )])
40
    AC_MSG_RESULT($gnupg_cv_typedef_$1)
41
    if test "$gnupg_cv_typedef_$1" = yes; then
42
        AC_DEFINE($2,1,[Defined if a `]$1[' is typedef'd])
43
    fi
44
  ])
45
46
47
dnl GNUPG_CHECK_GNUMAKE
48
dnl
49
AC_DEFUN([GNUPG_CHECK_GNUMAKE],
50
  [
51
    if ${MAKE-make} --version 2>/dev/null | grep '^GNU ' >/dev/null 2>&1; then
52
        :
53
    else
54
        AC_MSG_WARN([[
55
***
56
*** It seems that you are not using GNU make.  Some make tools have serious
57
*** flaws and you may not be able to build this software at all. Before you
58
*** complain, please try GNU make:  GNU make is easy to build and available
59
*** at all GNU archives.  It is always available from ftp.gnu.org:/gnu/make.
60
***]])
61
    fi
62
  ])
63
64
65
#
66
# GNUPG_SYS_SYMBOL_UNDERSCORE
67
# Does the compiler prefix global symbols with an underscore?
68
#
69
# Taken from GnuPG 1.2 and modified to use the libtool macros.
70
AC_DEFUN([GNUPG_SYS_SYMBOL_UNDERSCORE],
71
[tmp_do_check="no"
1.2.2 by Andreas Metzler
Import upstream version 1.4.1
72
case "${host}" in
73
    *-mingw32msvc*)
74
        ac_cv_sys_symbol_underscore=yes
75
        ;;
1.1.1 by Matthias Urlichs
Import upstream version 1.2.1
76
    i386-emx-os2 | i[3456]86-pc-os2*emx | i386-pc-msdosdjgpp)
77
        ac_cv_sys_symbol_underscore=yes
78
        ;;
79
    *)
80
      if test "$cross_compiling" = yes; then
1.2.2 by Andreas Metzler
Import upstream version 1.4.1
81
        if test "x$ac_cv_sys_symbol_underscore" = x ; then
82
           ac_cv_sys_symbol_underscore=yes
83
        fi
1.1.1 by Matthias Urlichs
Import upstream version 1.2.1
84
      else
85
         tmp_do_check="yes"
86
      fi
87
       ;;
88
esac
89
if test "$tmp_do_check" = "yes"; then
90
  AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])
91
  AC_MSG_CHECKING([for _ prefix in compiled symbols])
92
  AC_CACHE_VAL(ac_cv_sys_symbol_underscore,
93
  [ac_cv_sys_symbol_underscore=no
94
   cat > conftest.$ac_ext <<EOF
95
      void nm_test_func(){}
1.2.2 by Andreas Metzler
Import upstream version 1.4.1
96
      int main(){nm_test_func;return 0;}
1.1.1 by Matthias Urlichs
Import upstream version 1.2.1
97
EOF
98
  if AC_TRY_EVAL(ac_compile); then
99
    # Now try to grab the symbols.
100
    ac_nlist=conftest.nm
1.2.2 by Andreas Metzler
Import upstream version 1.4.1
101
    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
1.1.1 by Matthias Urlichs
Import upstream version 1.2.1
102
      # See whether the symbols have a leading underscore.
103
      if egrep '^_nm_test_func' "$ac_nlist" >/dev/null; then
104
        ac_cv_sys_symbol_underscore=yes
105
      else
106
        if egrep '^nm_test_func ' "$ac_nlist" >/dev/null; then
107
          :
108
        else
109
          echo "configure: cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
110
        fi
111
      fi
112
    else
1.2.2 by Andreas Metzler
Import upstream version 1.4.1
113
      echo "configure: cannot run $lt_cv_sys_global_symbol_pipe" >&AC_FD_CC
1.1.1 by Matthias Urlichs
Import upstream version 1.2.1
114
    fi
115
  else
116
    echo "configure: failed program was:" >&AC_FD_CC
117
    cat conftest.c >&AC_FD_CC
118
  fi
119
  rm -rf conftest*
120
  ])
121
  else
122
  AC_MSG_CHECKING([for _ prefix in compiled symbols])
123
  fi
124
AC_MSG_RESULT($ac_cv_sys_symbol_underscore)
125
if test x$ac_cv_sys_symbol_underscore = xyes; then
126
  AC_DEFINE(WITH_SYMBOL_UNDERSCORE,1,
127
            [Defined if compiled symbols have a leading underscore])
128
fi
129
])
130
131
132
######################################################################
133
# Check whether mlock is broken (hpux 10.20 raises a SIGBUS if mlock
134
# is not called from uid 0 (not tested whether uid 0 works)
135
# For DECs Tru64 we have also to check whether mlock is in librt
136
# mlock is there a macro using memlk()
137
######################################################################
138
dnl GNUPG_CHECK_MLOCK
139
dnl
1.2.2 by Andreas Metzler
Import upstream version 1.4.1
140
define(GNUPG_CHECK_MLOCK,
1.1.1 by Matthias Urlichs
Import upstream version 1.2.1
141
  [ AC_CHECK_FUNCS(mlock)
142
    if test "$ac_cv_func_mlock" = "no"; then
143
        AC_CHECK_HEADERS(sys/mman.h)
144
        if test "$ac_cv_header_sys_mman_h" = "yes"; then
145
            # Add librt to LIBS:
146
            AC_CHECK_LIB(rt, memlk)
147
            AC_CACHE_CHECK([whether mlock is in sys/mman.h],
148
                            gnupg_cv_mlock_is_in_sys_mman,
149
                [AC_TRY_LINK([
150
                    #include <assert.h>
151
                    #ifdef HAVE_SYS_MMAN_H
152
                    #include <sys/mman.h>
153
                    #endif
154
                ], [
1.2.2 by Andreas Metzler
Import upstream version 1.4.1
155
int i;
156
157
/* glibc defines this for functions which it implements
158
 * to always fail with ENOSYS.  Some functions are actually
159
 * named something starting with __ and the normal name
160
 * is an alias.  */
161
#if defined (__stub_mlock) || defined (__stub___mlock)
162
choke me
163
#else
164
mlock(&i, 4);
165
#endif
166
; return 0;
1.1.1 by Matthias Urlichs
Import upstream version 1.2.1
167
                ],
168
                gnupg_cv_mlock_is_in_sys_mman=yes,
169
                gnupg_cv_mlock_is_in_sys_mman=no)])
170
            if test "$gnupg_cv_mlock_is_in_sys_mman" = "yes"; then
171
                AC_DEFINE(HAVE_MLOCK,1,
172
                          [Defined if the system supports an mlock() call])
173
            fi
174
        fi
175
    fi
176
    if test "$ac_cv_func_mlock" = "yes"; then
1.2.2 by Andreas Metzler
Import upstream version 1.4.1
177
        AC_CHECK_FUNCS(sysconf getpagesize)
1.1.1 by Matthias Urlichs
Import upstream version 1.2.1
178
        AC_MSG_CHECKING(whether mlock is broken)
179
          AC_CACHE_VAL(gnupg_cv_have_broken_mlock,
180
             AC_TRY_RUN([
1.2.2 by Andreas Metzler
Import upstream version 1.4.1
181
#include <stdlib.h>
182
#include <unistd.h>
183
#include <errno.h>
184
#include <sys/mman.h>
185
#include <sys/types.h>
186
#include <fcntl.h>
187
188
int main()
189
{
190
    char *pool;
191
    int err;
192
    long int pgsize;
193
194
#if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
195
    pgsize = sysconf (_SC_PAGESIZE);
196
#elif defined (HAVE_GETPAGESIZE)
197
    pgsize = getpagesize();       
198
#else
199
    pgsize = -1;
200
#endif
201
202
    if (pgsize == -1)
203
      pgsize = 4096;
204
205
    pool = malloc( 4096 + pgsize );
206
    if( !pool )
207
        return 2;
208
    pool += (pgsize - ((long int)pool % pgsize));
209
210
    err = mlock( pool, 4096 );
211
    if( !err || errno == EPERM )
212
        return 0; /* okay */
213
214
    return 1;  /* hmmm */
215
}
1.1.1 by Matthias Urlichs
Import upstream version 1.2.1
216
217
            ],
218
            gnupg_cv_have_broken_mlock="no",
219
            gnupg_cv_have_broken_mlock="yes",
220
            gnupg_cv_have_broken_mlock="assume-no"
221
           )
222
         )
223
         if test "$gnupg_cv_have_broken_mlock" = "yes"; then
224
             AC_DEFINE(HAVE_BROKEN_MLOCK,1,
225
                       [Defined if the mlock() call does not work])
226
             AC_MSG_RESULT(yes)
227
         else
228
            if test "$gnupg_cv_have_broken_mlock" = "no"; then
229
                AC_MSG_RESULT(no)
230
            else
231
                AC_MSG_RESULT(assuming no)
232
            fi
233
         fi
234
    fi
235
  ])
236
237
# GNUPG_SYS_LIBTOOL_CYGWIN32 - find tools needed on cygwin32
238
AC_DEFUN([GNUPG_SYS_LIBTOOL_CYGWIN32],
239
[AC_CHECK_TOOL(DLLTOOL, dlltool, false)
240
AC_CHECK_TOOL(AS, as, false)
241
])
242
243
dnl LIST_MEMBER()
244
dnl Check wether an element ist contained in a list.  Set `found' to
245
dnl `1' if the element is found in the list, to `0' otherwise.
246
AC_DEFUN([LIST_MEMBER],
247
[
248
name=$1
249
list=$2
250
found=0
251
252
for n in $list; do
253
  if test "x$name" = "x$n"; then
254
    found=1
255
  fi
256
done
257
])
258
259
dnl AM_PATH_GPG_ERROR([MINIMUM-VERSION,
260
dnl                   [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
261
dnl Test for libgpg-error and define GPG_ERROR_CFLAGS and GPG_ERROR_LIBS
262
dnl
263
AC_DEFUN([AM_PATH_GPG_ERROR],
264
[ AC_ARG_WITH(gpg-error-prefix,
265
            AC_HELP_STRING([--with-gpg-error-prefix=PFX],
266
                           [prefix where GPG Error is installed (optional)]),
267
     gpg_error_config_prefix="$withval", gpg_error_config_prefix="")
268
  if test x$gpg_error_config_prefix != x ; then
269
     if test x${GPG_ERROR_CONFIG+set} != xset ; then
270
        GPG_ERROR_CONFIG=$gpg_error_config_prefix/bin/gpg-error-config
271
     fi
272
  fi
273
274
  AC_PATH_PROG(GPG_ERROR_CONFIG, gpg-error-config, no)
275
  min_gpg_error_version=ifelse([$1], ,0.0,$1)
276
  AC_MSG_CHECKING(for GPG Error - version >= $min_gpg_error_version)
277
  ok=no
278
  if test "$GPG_ERROR_CONFIG" != "no" ; then
279
    req_major=`echo $min_gpg_error_version | \
280
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
281
    req_minor=`echo $min_gpg_error_version | \
282
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
283
    gpg_error_config_version=`$GPG_ERROR_CONFIG $gpg_error_config_args --version`
284
    if test "$gpg_error_config_version"; then
285
      major=`echo $gpg_error_config_version | \
286
                 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
287
      minor=`echo $gpg_error_config_version | \
288
                 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
289
      if test "$major" -gt "$req_major"; then
290
          ok=yes
291
      else 
292
          if test "$major" -eq "$req_major"; then
293
              if test "$minor" -ge "$req_minor"; then
294
                 ok=yes
295
              fi
296
          fi
297
      fi
298
    fi
299
  fi
300
  if test $ok = yes; then
301
    GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --cflags`
302
    GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --libs`
303
    AC_MSG_RESULT(yes)
304
    ifelse([$2], , :, [$2])
305
  else
306
    GPG_ERROR_CFLAGS=""
307
    GPG_ERROR_LIBS=""
308
    AC_MSG_RESULT(no)
309
    ifelse([$3], , :, [$3])
310
  fi
311
  AC_SUBST(GPG_ERROR_CFLAGS)
312
  AC_SUBST(GPG_ERROR_LIBS)
313
])
314
1.2.2 by Andreas Metzler
Import upstream version 1.4.1
315
316
dnl Check for socklen_t: historically on BSD it is an int, and in
317
dnl POSIX 1g it is a type of its own, but some platforms use different
318
dnl types for the argument to getsockopt, getpeername, etc.  So we
319
dnl have to test to find something that will work.
320
AC_DEFUN([TYPE_SOCKLEN_T],
321
[
322
   AC_CHECK_TYPE([socklen_t], ,[
323
      AC_MSG_CHECKING([for socklen_t equivalent])
324
      AC_CACHE_VAL([socklen_t_equiv],
325
      [
326
         # Systems have either "struct sockaddr *" or
327
         # "void *" as the second argument to getpeername
328
         socklen_t_equiv=
329
         for arg2 in "struct sockaddr" void; do
330
            for t in int size_t unsigned long "unsigned long"; do
331
               AC_TRY_COMPILE([
332
#include <sys/types.h>
333
#include <sys/socket.h>
334
335
int getpeername (int, $arg2 *, $t *);
336
               ],[
337
                  $t len;
338
                  getpeername(0,0,&len);
339
               ],[
340
                  socklen_t_equiv="$t"
341
                  break
342
               ])
343
            done
344
         done
345
346
         if test "x$socklen_t_equiv" = x; then
347
            AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
348
         fi
349
      ])
350
      AC_MSG_RESULT($socklen_t_equiv)
351
      AC_DEFINE_UNQUOTED(socklen_t, $socklen_t_equiv,
352
			[type to use in place of socklen_t if not defined])],
353
      [#include <sys/types.h>
354
#include <sys/socket.h>])
355
])
356
357
358
# GNUPG_PTH_VERSION_CHECK(REQUIRED)
359
# 
360
# If the version is sufficient, HAVE_PTH will be set to yes.
361
#
362
# Taken form the m4 macros which come with Pth
363
AC_DEFUN([GNUPG_PTH_VERSION_CHECK],
364
  [
365
    _pth_version=`$PTH_CONFIG --version | awk 'NR==1 {print [$]3}'`
366
    _req_version="ifelse([$1],,1.2.0,$1)"
367
368
    AC_MSG_CHECKING(for PTH - version >= $_req_version)
1.1.1 by Matthias Urlichs
Import upstream version 1.2.1
369
    for _var in _pth_version _req_version; do
370
        eval "_val=\"\$${_var}\""
371
        _major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\1/'`
372
        _minor=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\2/'`
373
        _rtype=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\3/'`
374
        _micro=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\4/'`
375
        case $_rtype in
376
            "a" ) _rtype=0 ;;
377
            "b" ) _rtype=1 ;;
378
            "." ) _rtype=2 ;;
379
        esac
380
        _hex=`echo dummy | awk '{ printf("%d%02d%1d%02d", major, minor, rtype, micro); }' \
381
              "major=$_major" "minor=$_minor" "rtype=$_rtype" "micro=$_micro"`
382
        eval "${_var}_hex=\"\$_hex\""
383
    done
1.2.2 by Andreas Metzler
Import upstream version 1.4.1
384
    have_pth=no
1.1.1 by Matthias Urlichs
Import upstream version 1.2.1
385
    if test ".$_pth_version_hex" != .; then
386
        if test ".$_req_version_hex" != .; then
387
            if test $_pth_version_hex -ge $_req_version_hex; then
1.2.2 by Andreas Metzler
Import upstream version 1.4.1
388
                have_pth=yes
389
            fi
390
        fi
391
    fi
392
    if test $have_pth = yes; then
393
       AC_MSG_RESULT(yes)
394
       AC_MSG_CHECKING([whether PTH installation is sane])
395
       AC_CACHE_VAL(gnupg_cv_pth_is_sane,[
396
         _gnupg_pth_save_cflags=$CFLAGS
397
         _gnupg_pth_save_ldflags=$LDFLAGS
398
         _gnupg_pth_save_libs=$LIBS
399
         CFLAGS="$CFLAGS `$PTH_CONFIG --cflags`"
400
         LDFLAGS="$LDFLAGS `$PTH_CONFIG --ldflags`"
401
         LIBS="$LIBS `$PTH_CONFIG --libs`"
402
         AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pth.h>
403
                                         ],
404
                                         [[ pth_init ();]])],
405
                        gnupg_cv_pth_is_sane=yes,
406
                        gnupg_cv_pth_is_sane=no)
407
         CFLAGS=$_gnupg_pth_save_cflags
408
         LDFLAGS=$_gnupg_pth_save_ldflags
409
         LIBS=$_gnupg_pth_save_libs
410
       ])
411
       if test $gnupg_cv_pth_is_sane != yes; then
412
          have_pth=no
413
       fi
414
       AC_MSG_RESULT($gnupg_cv_pth_is_sane)
1.1.1 by Matthias Urlichs
Import upstream version 1.2.1
415
    else
1.2.2 by Andreas Metzler
Import upstream version 1.4.1
416
       AC_MSG_RESULT(no)
417
    fi    
418
  ])
419
1.1.1 by Matthias Urlichs
Import upstream version 1.2.1
420