~ubuntu-branches/ubuntu/precise/gnupg2/precise-proposed

« back to all changes in this revision

Viewing changes to acinclude.m4

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Mueller
  • Date: 2005-03-29 10:30:32 UTC
  • Revision ID: james.westby@ubuntu.com-20050329103032-sj42n2ain3ipx310
Tags: upstream-1.9.15
ImportĀ upstreamĀ versionĀ 1.9.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl macros to configure gnupg
 
2
dnl Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
 
3
dnl
 
4
dnl This file is part of GnuPG.
 
5
dnl
 
6
dnl GnuPG is free software; you can redistribute it and/or modify
 
7
dnl it under the terms of the GNU General Public License as published by
 
8
dnl the Free Software Foundation; either version 2 of the License, or
 
9
dnl (at your option) any later version.
 
10
dnl 
 
11
dnl GnuPG is distributed in the hope that it will be useful,
 
12
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
dnl GNU General Public License for more details.
 
15
dnl 
 
16
dnl You should have received a copy of the GNU General Public License
 
17
dnl along with this program; if not, write to the Free Software
 
18
dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
19
 
 
20
dnl GNUPG_CHECK_TYPEDEF(TYPE, HAVE_NAME)
 
21
dnl Check whether a typedef exists and create a #define $2 if it exists
 
22
dnl
 
23
AC_DEFUN([GNUPG_CHECK_TYPEDEF],
 
24
  [ AC_MSG_CHECKING(for $1 typedef)
 
25
    AC_CACHE_VAL(gnupg_cv_typedef_$1,
 
26
    [AC_TRY_COMPILE([#define _GNU_SOURCE 1
 
27
    #include <stdlib.h>
 
28
    #include <sys/types.h>], [
 
29
    #undef $1
 
30
    int a = sizeof($1);
 
31
    ], gnupg_cv_typedef_$1=yes, gnupg_cv_typedef_$1=no )])
 
32
    AC_MSG_RESULT($gnupg_cv_typedef_$1)
 
33
    if test "$gnupg_cv_typedef_$1" = yes; then
 
34
        AC_DEFINE($2,1,[Defined if a `]$1[' is typedef'd])
 
35
    fi
 
36
  ])
 
37
 
 
38
 
 
39
dnl GNUPG_CHECK_GNUMAKE
 
40
dnl
 
41
AC_DEFUN([GNUPG_CHECK_GNUMAKE],
 
42
  [ 
 
43
    if ${MAKE-make} --version 2>/dev/null | grep '^GNU ' >/dev/null 2>&1; then
 
44
        :
 
45
    else
 
46
        AC_MSG_WARN([[
 
47
***
 
48
*** It seems that you are not using GNU make.  Some make tools have serious
 
49
*** flaws and you may not be able to build this software at all. Before you
 
50
*** complain, please try GNU make:  GNU make is easy to build and available
 
51
*** at all GNU archives.  It is always available from ftp.gnu.org:/gnu/make.
 
52
***]])
 
53
    fi
 
54
  ])
 
55
 
 
56
dnl GNUPG_CHECK_FAQPROG
 
57
dnl
 
58
AC_DEFUN([GNUPG_CHECK_FAQPROG],
 
59
  [ AC_MSG_CHECKING(for faqprog.pl)
 
60
    if faqprog.pl -V 2>/dev/null | grep '^faqprog.pl ' >/dev/null 2>&1; then
 
61
        working_faqprog=yes
 
62
        FAQPROG="faqprog.pl"
 
63
    else 
 
64
        working_faqprog=no
 
65
        FAQPROG=": "
 
66
    fi
 
67
    AC_MSG_RESULT($working_faqprog)
 
68
    AC_SUBST(FAQPROG)
 
69
    AM_CONDITIONAL(WORKING_FAQPROG, test "$working_faqprog" = "yes" )
 
70
 
 
71
dnl     if test $working_faqprog = no; then
 
72
dnl         AC_MSG_WARN([[
 
73
dnl ***
 
74
dnl *** It seems that the faqprog.pl program is not installed;
 
75
dnl *** however it is only needed if you want to change the FAQ.
 
76
dnl ***  (faqprog.pl should be available at:
 
77
dnl ***    ftp://ftp.gnupg.org/gcrypt/contrib/faqprog.pl )
 
78
dnl *** No need to worry about this warning.
 
79
dnl ***]])
 
80
dnl     fi
 
81
   ])       
 
82
 
 
83
dnl GNUPG_CHECK_DOCBOOK_TO_TEXI
 
84
dnl
 
85
AC_DEFUN([GNUPG_CHECK_DOCBOOK_TO_TEXI],
 
86
  [
 
87
    AC_CHECK_PROG(DOCBOOK_TO_TEXI, docbook2texi, yes, no)
 
88
    AC_MSG_CHECKING(for sgml to texi tools)
 
89
    working_sgmltotexi=no
 
90
    if test "$ac_cv_prog_DOCBOOK_TO_TEXI" = yes; then
 
91
      if sgml2xml -v /dev/null 2>&1 | grep 'SP version' >/dev/null 2>&1 ; then
 
92
            working_sgmltotexi=yes
 
93
      fi
 
94
    fi
 
95
    AC_MSG_RESULT($working_sgmltotexi)
 
96
    AM_CONDITIONAL(HAVE_DOCBOOK_TO_TEXI, test "$working_sgmltotexi" = "yes" )
 
97
   ])       
 
98
 
 
99
 
 
100
 
 
101
dnl GNUPG_CHECK_ENDIAN
 
102
dnl define either LITTLE_ENDIAN_HOST or BIG_ENDIAN_HOST
 
103
dnl
 
104
AC_DEFUN([GNUPG_CHECK_ENDIAN],
 
105
  [
 
106
    tmp_assumed_endian=big
 
107
    if test "$cross_compiling" = yes; then
 
108
      case "$host_cpu" in
 
109
         i@<:@345678@:>@* )
 
110
            tmp_assumed_endian=little
 
111
            ;;
 
112
         *)
 
113
            ;;
 
114
      esac
 
115
      AC_MSG_WARN(cross compiling; assuming $tmp_assumed_endian endianess)
 
116
    fi
 
117
    AC_MSG_CHECKING(endianess)
 
118
    AC_CACHE_VAL(gnupg_cv_c_endian,
 
119
      [ gnupg_cv_c_endian=unknown
 
120
        # See if sys/param.h defines the BYTE_ORDER macro.
 
121
        AC_TRY_COMPILE([#include <sys/types.h>
 
122
        #include <sys/param.h>], [
 
123
        #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
 
124
         bogus endian macros
 
125
        #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
 
126
        AC_TRY_COMPILE([#include <sys/types.h>
 
127
        #include <sys/param.h>], [
 
128
        #if BYTE_ORDER != BIG_ENDIAN
 
129
         not big endian
 
130
        #endif], gnupg_cv_c_endian=big, gnupg_cv_c_endian=little)])
 
131
        if test "$gnupg_cv_c_endian" = unknown; then
 
132
            AC_TRY_RUN([main () {
 
133
              /* Are we little or big endian?  From Harbison&Steele.  */
 
134
              union
 
135
              {
 
136
                long l;
 
137
                char c[sizeof (long)];
 
138
              } u;
 
139
              u.l = 1;
 
140
              exit (u.c[sizeof (long) - 1] == 1);
 
141
              }],
 
142
              gnupg_cv_c_endian=little,
 
143
              gnupg_cv_c_endian=big,
 
144
              gnupg_cv_c_endian=$tmp_assumed_endian
 
145
            )
 
146
        fi
 
147
      ])
 
148
    AC_MSG_RESULT([$gnupg_cv_c_endian])
 
149
    if test "$gnupg_cv_c_endian" = little; then
 
150
      AC_DEFINE(LITTLE_ENDIAN_HOST,1,
 
151
                [Defined if the host has little endian byte ordering])
 
152
    else
 
153
      AC_DEFINE(BIG_ENDIAN_HOST,1,
 
154
                [Defined if the host has big endian byte ordering])
 
155
    fi
 
156
  ])
 
157
 
 
158
 
 
159
 
 
160
# Check for the getsockopt SO_PEERCRED
 
161
AC_DEFUN([GNUPG_SYS_SO_PEERCRED],
 
162
  [ AC_MSG_CHECKING(for SO_PEERCRED)
 
163
    AC_CACHE_VAL(gnupg_cv_sys_so_peercred,
 
164
      [AC_TRY_COMPILE([#include <sys/socket.h>], 
 
165
                    [struct ucred cr; 
 
166
                     int cl = sizeof cr;
 
167
                     getsockopt (1, SOL_SOCKET, SO_PEERCRED, &cr, &cl);],
 
168
                    gnupg_cv_sys_so_peercred=yes,
 
169
                    gnupg_cv_sys_so_peercred=no)
 
170
      ])
 
171
    AC_MSG_RESULT($gnupg_cv_sys_so_peercred) 
 
172
    if test $gnupg_cv_sys_so_peercred = yes; then
 
173
         AC_DEFINE(HAVE_SO_PEERCRED, 1,
 
174
                            [Defined if SO_PEERCRED is supported (Linux)])
 
175
    fi
 
176
  ])
 
177
 
 
178
 
 
179
 
 
180
# GNUPG_BUILD_PROGRAM(NAME,DEFAULT)
 
181
# Add a --enable-NAME option to configure an set the
 
182
# shell variable build_NAME either to "yes" or "no".  DEFAULT must
 
183
# either be "yes" or "no" and decided on the default value for
 
184
# build_NAME and whether --enable-NAME or --disable-NAME is shown with 
 
185
# ./configure --help
 
186
AC_DEFUN([GNUPG_BUILD_PROGRAM],
 
187
  [build_$1=$2
 
188
   m4_if([$2],[yes],[
 
189
      AC_ARG_ENABLE([$1], AC_HELP_STRING([--disable-$1],
 
190
                                         [do not build the $1 program]),
 
191
                           build_$1=$enableval, build_$1=$2)
 
192
    ],[
 
193
      AC_ARG_ENABLE([$1], AC_HELP_STRING([--enable-$1],
 
194
                                         [build the $1 program]),
 
195
                           build_$1=$enableval, build_$1=$2)
 
196
    ])
 
197
   case "$build_$1" in
 
198
         no|yes)
 
199
           ;;
 
200
         *) 
 
201
           AC_MSG_ERROR([only yes or no allowed for feature --enable-$1])
 
202
           ;;
 
203
   esac
 
204
  ])
 
205
 
 
206
 
 
207
 
 
208
# GNUPG_PTH_VERSION_CHECK(REQUIRED)
 
209
 
210
# If the version is sufficient, HAVE_PTH will be set to yes.
 
211
#
 
212
# Taken form the m4 macros which come with Pth
 
213
AC_DEFUN([GNUPG_PTH_VERSION_CHECK],
 
214
  [
 
215
    _pth_version=`$PTH_CONFIG --version | awk 'NR==1 {print [$]3}'`
 
216
    _req_version="ifelse([$1],,1.2.0,$1)"
 
217
 
 
218
    AC_MSG_CHECKING(for PTH - version >= $_req_version)
 
219
    for _var in _pth_version _req_version; do
 
220
        eval "_val=\"\$${_var}\""
 
221
        _major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\1/'`
 
222
        _minor=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\2/'`
 
223
        _rtype=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\3/'`
 
224
        _micro=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\4/'`
 
225
        case $_rtype in
 
226
            "a" ) _rtype=0 ;;
 
227
            "b" ) _rtype=1 ;;
 
228
            "." ) _rtype=2 ;;
 
229
        esac
 
230
        _hex=`echo dummy | awk '{ printf("%d%02d%1d%02d", major, minor, rtype, micro); }' \
 
231
              "major=$_major" "minor=$_minor" "rtype=$_rtype" "micro=$_micro"`
 
232
        eval "${_var}_hex=\"\$_hex\""
 
233
    done
 
234
    have_pth=no
 
235
    if test ".$_pth_version_hex" != .; then
 
236
        if test ".$_req_version_hex" != .; then
 
237
            if test $_pth_version_hex -ge $_req_version_hex; then
 
238
                have_pth=yes
 
239
            fi
 
240
        fi
 
241
    fi
 
242
    if test $have_pth = yes; then
 
243
       AC_MSG_RESULT(yes)
 
244
       AC_MSG_CHECKING([whether PTH installation is sane])
 
245
       AC_CACHE_VAL(gnupg_cv_pth_is_sane,[
 
246
         _gnupg_pth_save_cflags=$CFLAGS
 
247
         _gnupg_pth_save_ldflags=$LDFLAGS
 
248
         _gnupg_pth_save_libs=$LIBS
 
249
         CFLAGS="$CFLAGS `$PTH_CONFIG --ldflags`"
 
250
         LDFLAGS="$LDFLAGS `$PTH_CONFIG --ldflags`"
 
251
         LIBS="$LIBS `$PTH_CONFIG --libs`"
 
252
         AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pth.h>
 
253
                                         ],
 
254
                                         [[ pth_init ();]])],
 
255
                        gnupg_cv_pth_is_sane=yes,
 
256
                        gnupg_cv_pth_is_sane=no)
 
257
         CFLAGS=$_gnupg_pth_save_cflags
 
258
         LDFLAGS=$_gnupg_pth_save_ldflags
 
259
         LIBS=$_gnupg_pth_save_libs
 
260
       ])
 
261
       if test $gnupg_cv_pth_is_sane != yes; then
 
262
          have_pth=no
 
263
       fi
 
264
       AC_MSG_RESULT($gnupg_cv_pth_is_sane)
 
265
    else
 
266
       AC_MSG_RESULT(no)
 
267
    fi    
 
268
  ])
 
269
 
 
270
 
 
271
 
 
272
 
 
273
# Check whether mlock is broken (hpux 10.20 raises a SIGBUS if mlock
 
274
# is not called from uid 0 (not tested whether uid 0 works)
 
275
# For DECs Tru64 we have also to check whether mlock is in librt
 
276
# mlock is there a macro using memlk()
 
277
dnl GNUPG_CHECK_MLOCK
 
278
dnl
 
279
AC_DEFUN([GNUPG_CHECK_MLOCK],
 
280
  [ AC_CHECK_FUNCS(mlock)
 
281
    if test "$ac_cv_func_mlock" = "no"; then
 
282
        AC_CHECK_HEADERS(sys/mman.h)
 
283
        if test "$ac_cv_header_sys_mman_h" = "yes"; then
 
284
            # Add librt to LIBS:
 
285
            AC_CHECK_LIB(rt, memlk)
 
286
            AC_CACHE_CHECK([whether mlock is in sys/mman.h],
 
287
                            gnupg_cv_mlock_is_in_sys_mman,
 
288
                [AC_TRY_LINK([
 
289
                    #include <assert.h>
 
290
                    #ifdef HAVE_SYS_MMAN_H
 
291
                    #include <sys/mman.h>
 
292
                    #endif
 
293
                ], [
 
294
                    int i;
 
295
 
 
296
                    /* glibc defines this for functions which it implements
 
297
                     * to always fail with ENOSYS.  Some functions are actually
 
298
                     * named something starting with __ and the normal name
 
299
                     * is an alias.  */
 
300
                    #if defined (__stub_mlock) || defined (__stub___mlock)
 
301
                    choke me
 
302
                    #else
 
303
                    mlock(&i, 4);
 
304
                    #endif
 
305
                    ; return 0;
 
306
                ],
 
307
                gnupg_cv_mlock_is_in_sys_mman=yes,
 
308
                gnupg_cv_mlock_is_in_sys_mman=no)])
 
309
            if test "$gnupg_cv_mlock_is_in_sys_mman" = "yes"; then
 
310
                AC_DEFINE(HAVE_MLOCK,1,
 
311
                          [Defined if the system supports an mlock() call])
 
312
            fi
 
313
        fi
 
314
    fi
 
315
    if test "$ac_cv_func_mlock" = "yes"; then
 
316
        AC_MSG_CHECKING(whether mlock is broken)
 
317
          AC_CACHE_VAL(gnupg_cv_have_broken_mlock,
 
318
             AC_TRY_RUN([
 
319
                #include <stdlib.h>
 
320
                #include <unistd.h>
 
321
                #include <errno.h>
 
322
                #include <sys/mman.h>
 
323
                #include <sys/types.h>
 
324
                #include <fcntl.h>
 
325
 
 
326
                int main()
 
327
                {
 
328
                    char *pool;
 
329
                    int err;
 
330
                    long int pgsize = getpagesize();
 
331
 
 
332
                    pool = malloc( 4096 + pgsize );
 
333
                    if( !pool )
 
334
                        return 2;
 
335
                    pool += (pgsize - ((long int)pool % pgsize));
 
336
 
 
337
                    err = mlock( pool, 4096 );
 
338
                    if( !err || errno == EPERM )
 
339
                        return 0; /* okay */
 
340
 
 
341
                    return 1;  /* hmmm */
 
342
                }
 
343
 
 
344
            ],
 
345
            gnupg_cv_have_broken_mlock="no",
 
346
            gnupg_cv_have_broken_mlock="yes",
 
347
            gnupg_cv_have_broken_mlock="assume-no"
 
348
           )
 
349
         )
 
350
         if test "$gnupg_cv_have_broken_mlock" = "yes"; then
 
351
             AC_DEFINE(HAVE_BROKEN_MLOCK,1,
 
352
                       [Defined if the mlock() call does not work])
 
353
             AC_MSG_RESULT(yes)
 
354
             AC_CHECK_FUNCS(plock)
 
355
         else
 
356
            if test "$gnupg_cv_have_broken_mlock" = "no"; then
 
357
                AC_MSG_RESULT(no)
 
358
            else
 
359
                AC_MSG_RESULT(assuming no)
 
360
            fi
 
361
         fi
 
362
    fi
 
363
  ])
 
364
 
 
365
 
 
366
dnl Stolen from gcc
 
367
dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
 
368
dnl of the usual 2.
 
369
AC_DEFUN([GNUPG_FUNC_MKDIR_TAKES_ONE_ARG],
 
370
[AC_CHECK_HEADERS(sys/stat.h unistd.h direct.h)
 
371
AC_CACHE_CHECK([if mkdir takes one argument], gnupg_cv_mkdir_takes_one_arg,
 
372
[AC_TRY_COMPILE([
 
373
#include <sys/types.h>
 
374
#ifdef HAVE_SYS_STAT_H
 
375
# include <sys/stat.h>
 
376
#endif
 
377
#ifdef HAVE_UNISTD_H
 
378
# include <unistd.h>
 
379
#endif
 
380
#ifdef HAVE_DIRECT_H
 
381
# include <direct.h>
 
382
#endif], [mkdir ("foo", 0);],
 
383
        gnupg_cv_mkdir_takes_one_arg=no, gnupg_cv_mkdir_takes_one_arg=yes)])
 
384
if test $gnupg_cv_mkdir_takes_one_arg = yes ; then
 
385
  AC_DEFINE(MKDIR_TAKES_ONE_ARG,1,
 
386
            [Defined if mkdir() does not take permission flags])
 
387
fi
 
388
])
 
389
 
 
390
 
 
391
 
 
392
 
 
393
dnl AM_PATH_OPENSC([MINIMUM-VERSION,
 
394
dnl               [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
 
395
dnl Test for OpenSC and define OPENSC_CFLAGS and OPENSC_LIBS
 
396
dnl
 
397
AC_DEFUN([AM_PATH_OPENSC],
 
398
[ AC_ARG_WITH(opensc-prefix,
 
399
            AC_HELP_STRING([--with-opensc-prefix=PFX],
 
400
                           [prefix where OpenSC is installed (optional)]),
 
401
     opensc_config_prefix="$withval", opensc_config_prefix="")
 
402
  if test x$opensc_config_prefix != x ; then
 
403
     opensc_config_args="$opensc_config_args --prefix=$opensc_config_prefix"
 
404
     if test x${OPENSC_CONFIG+set} != xset ; then
 
405
        OPENSC_CONFIG=$opensc_config_prefix/bin/opensc-config
 
406
     fi
 
407
  fi
 
408
 
 
409
  AC_PATH_PROG(OPENSC_CONFIG, opensc-config, no)
 
410
  min_opensc_version=ifelse([$1], ,0.7.0,$1)
 
411
  AC_MSG_CHECKING(for OpenSC - version >= $min_opensc_version)
 
412
  ok=no
 
413
  if test "$OPENSC_CONFIG" != "no" ; then
 
414
    req_major=`echo $min_opensc_version | \
 
415
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
 
416
    req_minor=`echo $min_opensc_version | \
 
417
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
 
418
    req_micro=`echo $min_opensc_version | \
 
419
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
 
420
    opensc_config_version=`$OPENSC_CONFIG $opensc_config_args --version 2>/dev/null || echo 0.0.0`
 
421
    major=`echo $opensc_config_version | \
 
422
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
 
423
    minor=`echo $opensc_config_version | \
 
424
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
 
425
    micro=`echo $opensc_config_version | \
 
426
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
 
427
    if test "$major" -gt "$req_major"; then
 
428
        ok=yes
 
429
    else 
 
430
        if test "$major" -eq "$req_major"; then
 
431
            if test "$minor" -gt "$req_minor"; then
 
432
               ok=yes
 
433
            else
 
434
               if test "$minor" -eq "$req_minor"; then
 
435
                   if test "$micro" -ge "$req_micro"; then
 
436
                     ok=yes
 
437
                   fi
 
438
               fi
 
439
            fi
 
440
        fi
 
441
    fi
 
442
  fi
 
443
  if test $ok = yes; then
 
444
    OPENSC_CFLAGS=`$OPENSC_CONFIG $opensc_config_args --cflags`
 
445
    OPENSC_LIBS=`$OPENSC_CONFIG $opensc_config_args --libs`
 
446
    OPENSC_LIBS="$OPENSC_LIBS -lpcsclite -lpthread"
 
447
    AC_MSG_RESULT(yes)
 
448
    ifelse([$2], , :, [$2])
 
449
  else
 
450
    OPENSC_CFLAGS=""
 
451
    OPENSC_LIBS=""
 
452
    AC_MSG_RESULT(no)
 
453
    ifelse([$3], , :, [$3])
 
454
  fi
 
455
  AC_SUBST(OPENSC_CFLAGS)
 
456
  AC_SUBST(OPENSC_LIBS)
 
457
])
 
458
 
 
459