* gpgkeys_hkp.c (send_key), gpgkeys_ldap.c (send_key, send_key_keyserver):
[gnupg.git] / acinclude.m4
blobb38712f70388500bfa3d233a01d8172316efcca0
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20 dnl GNUPG_MSG_PRINT(STRING)
21 dnl print a message
22 dnl
23 define(GNUPG_MSG_PRINT,
24   [ echo $ac_n "$1"" $ac_c" 1>&AC_FD_MSG
25   ])
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   ])
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   ])
65 dnl GNUPG_CHECK_FAQPROG
66 dnl
67 AC_DEFUN([GNUPG_CHECK_FAQPROG],
68   [ AC_MSG_CHECKING(for faqprog.pl)
69     if faqprog.pl -V 2>/dev/null | grep '^faqprog.pl ' >/dev/null 2>&1; then
70         working_faqprog=yes
71         FAQPROG="faqprog.pl"
72     else 
73         working_faqprog=no
74         FAQPROG=": "
75     fi
76     AC_MSG_RESULT($working_faqprog)
77     AC_SUBST(FAQPROG)
78     AM_CONDITIONAL(WORKING_FAQPROG, test "$working_faqprog" = "yes" )
80 dnl     if test $working_faqprog = no; then
81 dnl         AC_MSG_WARN([[
82 dnl ***
83 dnl *** It seems that the faqprog.pl program is not installed;
84 dnl *** however it is only needed if you want to change the FAQ.
85 dnl ***  (faqprog.pl should be available at:
86 dnl ***    ftp://ftp.gnupg.org/gcrypt/contrib/faqprog.pl )
87 dnl *** No need to worry about this warning.
88 dnl ***]])
89 dnl     fi
90    ])       
92 dnl GNUPG_CHECK_DOCBOOK_TO_TEXI
93 dnl
94 AC_DEFUN([GNUPG_CHECK_DOCBOOK_TO_TEXI],
95   [
96     AC_CHECK_PROG(DOCBOOK_TO_TEXI, docbook2texi, yes, no)
97     AC_MSG_CHECKING(for sgml to texi tools)
98     working_sgmltotexi=no
99     if test "$ac_cv_prog_DOCBOOK_TO_TEXI" = yes; then
100       if sgml2xml -v /dev/null 2>&1 | grep 'SP version' >/dev/null 2>&1 ; then
101             working_sgmltotexi=yes
102       fi
103     fi
104     AC_MSG_RESULT($working_sgmltotexi)
105     AM_CONDITIONAL(HAVE_DOCBOOK_TO_TEXI, test "$working_sgmltotexi" = "yes" )
106    ])       
109 dnl GNUPG_CHECK_ENDIAN
110 dnl define either LITTLE_ENDIAN_HOST or BIG_ENDIAN_HOST
112 define([GNUPG_CHECK_ENDIAN],
113   [
114     tmp_assumed_endian=big
115     if test "$cross_compiling" = yes; then
116       case "$host_cpu" in
117          i@<:@345678@:>@* )
118             tmp_assumed_endian=little
119             ;;
120          *)
121             ;;
122       esac
123       AC_MSG_WARN(cross compiling; assuming $tmp_assumed_endian endianess)
124     fi
125     AC_MSG_CHECKING(endianess)
126     AC_CACHE_VAL(gnupg_cv_c_endian,
127       [ gnupg_cv_c_endian=unknown
128         # See if sys/param.h defines the BYTE_ORDER macro.
129         AC_TRY_COMPILE([#include <sys/types.h>
130         #include <sys/param.h>], [
131         #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
132          bogus endian macros
133         #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
134         AC_TRY_COMPILE([#include <sys/types.h>
135         #include <sys/param.h>], [
136         #if BYTE_ORDER != BIG_ENDIAN
137          not big endian
138         #endif], gnupg_cv_c_endian=big, gnupg_cv_c_endian=little)])
139         if test "$gnupg_cv_c_endian" = unknown; then
140             AC_TRY_RUN([main () {
141               /* Are we little or big endian?  From Harbison&Steele.  */
142               union
143               {
144                 long l;
145                 char c[sizeof (long)];
146               } u;
147               u.l = 1;
148               exit (u.c[sizeof (long) - 1] == 1);
149               }],
150               gnupg_cv_c_endian=little,
151               gnupg_cv_c_endian=big,
152               gnupg_cv_c_endian=$tmp_assumed_endian
153             )
154         fi
155       ])
156     AC_MSG_RESULT([$gnupg_cv_c_endian])
157     if test "$gnupg_cv_c_endian" = little; then
158       AC_DEFINE(LITTLE_ENDIAN_HOST,1,
159                 [Defined if the host has little endian byte ordering])
160     else
161       AC_DEFINE(BIG_ENDIAN_HOST,1,
162                 [Defined if the host has big endian byte ordering])
163     fi
164   ])
166 dnl GNUPG_CHECK_CACHE
168 define(GNUPG_CHECK_CACHE,
169   [ AC_MSG_CHECKING(cached information)
170     gnupg_hostcheck="$target"
171     AC_CACHE_VAL(gnupg_cv_hostcheck, [ gnupg_cv_hostcheck="$gnupg_hostcheck" ])
172     if test "$gnupg_cv_hostcheck" != "$gnupg_hostcheck"; then
173         AC_MSG_RESULT(changed)
174         AC_MSG_WARN(config.cache exists!)
175         AC_MSG_ERROR(you must do 'make distclean' first to compile for
176                  different target or different parameters.)
177     else
178         AC_MSG_RESULT(ok)
179     fi
180   ])
183 ######################################################################
184 # Check for -fPIC etc (taken from libtool)
185 # This sets CFLAGS_PIC to the required flags
186 #           NO_PIC to yes if it is not possible to
187 #                  generate PIC
188 ######################################################################
189 dnl GNUPG_CHECK_PIC
191 define(GNUPG_CHECK_PIC,
192   [ AC_MSG_CHECKING(for option to create PIC)
193     CFLAGS_PIC=
194     NO_PIC=no
195     if test "$cross_compiling" = yes; then
196         AC_MSG_RESULT(assume none)
197     else
198         if test "$GCC" = yes; then
199             CFLAGS_PIC="-fPIC"
200         else
201             case "$host_os" in
202               aix3* | aix4*)
203                 # All rs/6000 code is PIC
204                 # but is there any non-rs/6000 AIX platform?
205                 ;;
207               hpux9* | hpux10*)
208                 CFLAGS_PIC="+Z"
209                 ;;
211               irix5* | irix6*)
212                 # PIC (with -KPIC) is the default.
213                 ;;
215               osf3* | osf4*)
216                 # FIXME - pic_flag is probably required for
217                 # hppa*-osf* and i860-osf*
218                 ;;
220               sco3.2v5*)
221                 CFLAGS_PIC='-Kpic'
222                 ;;
224               solaris2* | solaris7* )
225                 CFLAGS_PIC='-KPIC'
226                 ;;
228               sunos4*)
229                 CFLAGS_PIC='-PIC'
230                 ;;
232               *)
233                 NO_PIC=yes
234                 ;;
235             esac
236         fi
238         case "$host_cpu" in
239         rs6000 | powerpc | powerpcle)
240           # Yippee! All RS/6000 and PowerPC code is position-independent.
241           CFLAGS_PIC=""
242           ;;
243         esac
245         if test "$NO_PIC" = yes; then
246             AC_MSG_RESULT(not possible)
247         else
248             if test -z "$CFLAGS_PIC"; then
249                AC_MSG_RESULT(none)
250             else
251                 AC_MSG_RESULT($CFLAGS_PIC)
252             fi
253         fi
254     fi
255   ])
258 ######################################################################
259 # Check for export-dynamic flag
260 # This sets CFLAGS_EXPORTDYNAMIC to the required flags
261 ######################################################################
262 dnl GNUPG_CHECK_EXPORTDYNAMIC
264 define(GNUPG_CHECK_EXPORTDYNAMIC,
265   [ AC_MSG_CHECKING(how to specify -export-dynamic)
266     if test "$cross_compiling" = yes; then
267       AC_MSG_RESULT(assume none)
268       CFLAGS_EXPORTDYNAMIC=""
269     else
270       AC_CACHE_VAL(gnupg_cv_export_dynamic,[
271       if AC_TRY_COMMAND([${CC-cc} $CFLAGS -Wl,--version 2>&1 |
272                                           grep "GNU ld" >/dev/null]); then
273           # using gnu's linker
274           gnupg_cv_export_dynamic="-Wl,-export-dynamic"
275       else
276           case "$host_os" in
277             hpux* )
278               gnupg_cv_export_dynamic="-Wl,-E"
279               ;;
280             * )
281               gnupg_cv_export_dynamic=""
282               ;;
283           esac
284       fi
285       ])
286       AC_MSG_RESULT($gnupg_cv_export_dynamic)
287       CFLAGS_EXPORTDYNAMIC="$gnupg_cv_export_dynamic"
288     fi
289   ])
291 #####################################################################
292 # Check for SysV IPC  (from GIMP)
293 #   And see whether we have a SHM_LOCK (FreeBSD does not have it).
294 #####################################################################
295 dnl GNUPG_CHECK_IPC
297 define(GNUPG_CHECK_IPC,
298    [ AC_CHECK_HEADERS(sys/ipc.h sys/shm.h)
299      if test "$ac_cv_header_sys_shm_h" = "yes"; then
300        AC_MSG_CHECKING(whether IPC_RMID allowes subsequent attaches)
301        AC_CACHE_VAL(gnupg_cv_ipc_rmid_deferred_release,
302           AC_TRY_RUN([
303              #include <sys/types.h>
304              #include <sys/ipc.h>
305              #include <sys/shm.h>
306              int main()
307              {
308                int id;
309                char *shmaddr;
310              id = shmget (IPC_PRIVATE, 4, IPC_CREAT | 0777);
311              if (id == -1)
312                exit (2);
313                shmaddr = shmat (id, 0, 0);
314                shmctl (id, IPC_RMID, 0);
315                if ((char*) shmat (id, 0, 0) == (char*) -1)
316                {
317                  shmdt (shmaddr);
318                  exit (1);
319                }
320                shmdt (shmaddr);
321                shmdt (shmaddr);
322                exit (0);
323              }
324          ],
325          gnupg_cv_ipc_rmid_deferred_release="yes",
326          gnupg_cv_ipc_rmid_deferred_release="no",
327          gnupg_cv_ipc_rmid_deferred_release="assume-no")
328        )
329        if test "$gnupg_cv_ipc_rmid_deferred_release" = "yes"; then
330            AC_DEFINE(IPC_RMID_DEFERRED_RELEASE,1,
331                      [Defined if we can do a deferred shm release])
332            AC_MSG_RESULT(yes)
333        else
334           if test "$gnupg_cv_ipc_rmid_deferred_release" = "no"; then
335               AC_MSG_RESULT(no)
336           else
337               AC_MSG_RESULT([assuming no])
338           fi
339        fi
341        AC_MSG_CHECKING(whether SHM_LOCK is available)
342        AC_CACHE_VAL(gnupg_cv_ipc_have_shm_lock,
343           AC_TRY_COMPILE([#include <sys/types.h>
344              #include <sys/ipc.h>
345              #include <sys/shm.h>],[
346              int shm_id;
347              shmctl(shm_id, SHM_LOCK, 0);
348              ],
349              gnupg_cv_ipc_have_shm_lock="yes",
350              gnupg_cv_ipc_have_shm_lock="no"
351           )
352        )
353        if test "$gnupg_cv_ipc_have_shm_lock" = "yes"; then
354          AC_DEFINE(IPC_HAVE_SHM_LOCK,1,
355                    [Defined if a SysV shared memory supports the LOCK flag])
356          AC_MSG_RESULT(yes)
357        else
358          AC_MSG_RESULT(no)
359        fi
360      fi
361    ])
364 ######################################################################
365 # Check whether mlock is broken (hpux 10.20 raises a SIGBUS if mlock
366 # is not called from uid 0 (not tested whether uid 0 works)
367 # For DECs Tru64 we have also to check whether mlock is in librt
368 # mlock is there a macro using memlk()
369 ######################################################################
370 dnl GNUPG_CHECK_MLOCK
372 define(GNUPG_CHECK_MLOCK,
373   [ AC_CHECK_FUNCS(mlock)
374     if test "$ac_cv_func_mlock" = "no"; then
375         AC_CHECK_HEADERS(sys/mman.h)
376         if test "$ac_cv_header_sys_mman_h" = "yes"; then
377             # Add librt to LIBS:
378             AC_CHECK_LIB(rt, memlk)
379             AC_CACHE_CHECK([whether mlock is in sys/mman.h],
380                             gnupg_cv_mlock_is_in_sys_mman,
381                 [AC_TRY_LINK([
382                     #include <assert.h>
383                     #ifdef HAVE_SYS_MMAN_H
384                     #include <sys/mman.h>
385                     #endif
386                 ], [
387                     int i;
389                     /* glibc defines this for functions which it implements
390                      * to always fail with ENOSYS.  Some functions are actually
391                      * named something starting with __ and the normal name
392                      * is an alias.  */
393                     #if defined (__stub_mlock) || defined (__stub___mlock)
394                     choke me
395                     #else
396                     mlock(&i, 4);
397                     #endif
398                     ; return 0;
399                 ],
400                 gnupg_cv_mlock_is_in_sys_mman=yes,
401                 gnupg_cv_mlock_is_in_sys_mman=no)])
402             if test "$gnupg_cv_mlock_is_in_sys_mman" = "yes"; then
403                 AC_DEFINE(HAVE_MLOCK,1,
404                           [Defined if the system supports an mlock() call])
405             fi
406         fi
407     fi
408     if test "$ac_cv_func_mlock" = "yes"; then
409         AC_MSG_CHECKING(whether mlock is broken)
410           AC_CACHE_VAL(gnupg_cv_have_broken_mlock,
411              AC_TRY_RUN([
412                 #include <stdlib.h>
413                 #include <unistd.h>
414                 #include <errno.h>
415                 #include <sys/mman.h>
416                 #include <sys/types.h>
417                 #include <fcntl.h>
419                 int main()
420                 {
421                     char *pool;
422                     int err;
423                     long int pgsize = getpagesize();
425                     pool = malloc( 4096 + pgsize );
426                     if( !pool )
427                         return 2;
428                     pool += (pgsize - ((long int)pool % pgsize));
430                     err = mlock( pool, 4096 );
431                     if( !err || errno == EPERM )
432                         return 0; /* okay */
434                     return 1;  /* hmmm */
435                 }
437             ],
438             gnupg_cv_have_broken_mlock="no",
439             gnupg_cv_have_broken_mlock="yes",
440             gnupg_cv_have_broken_mlock="assume-no"
441            )
442          )
443          if test "$gnupg_cv_have_broken_mlock" = "yes"; then
444              AC_DEFINE(HAVE_BROKEN_MLOCK,1,
445                        [Defined if the mlock() call does not work])
446              AC_MSG_RESULT(yes)
447              AC_CHECK_FUNCS(plock)
448          else
449             if test "$gnupg_cv_have_broken_mlock" = "no"; then
450                 AC_MSG_RESULT(no)
451             else
452                 AC_MSG_RESULT(assuming no)
453             fi
454          fi
455     fi
456   ])
459 ################################################################
460 # GNUPG_PROG_NM - find the path to a BSD-compatible name lister
461 AC_DEFUN([GNUPG_PROG_NM],
462 [AC_MSG_CHECKING([for BSD-compatible nm])
463 AC_CACHE_VAL(ac_cv_path_NM,
464 [if test -n "$NM"; then
465   # Let the user override the test.
466   ac_cv_path_NM="$NM"
467 else
468   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
469   for ac_dir in /usr/ucb /usr/ccs/bin $PATH /bin; do
470     test -z "$ac_dir" && ac_dir=.
471     if test -f $ac_dir/nm; then
472       # Check to see if the nm accepts a BSD-compat flag.
473       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
474       #   nm: unknown option "B" ignored
475       if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
476         ac_cv_path_NM="$ac_dir/nm -B"
477       elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
478         ac_cv_path_NM="$ac_dir/nm -p"
479       else
480         ac_cv_path_NM="$ac_dir/nm"
481       fi
482       break
483     fi
484   done
485   IFS="$ac_save_ifs"
486   test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
487 fi])
488 NM="$ac_cv_path_NM"
489 AC_MSG_RESULT([$NM])
490 AC_SUBST(NM)
493 # GNUPG_SYS_NM_PARSE - Check for command ro grab the raw symbol name followed
494 # by C symbol name from nm.
495 AC_DEFUN([GNUPG_SYS_NM_PARSE],
496 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
497 AC_REQUIRE([GNUPG_PROG_NM])dnl
498 # Check for command to grab the raw symbol name followed by C symbol from nm.
499 AC_MSG_CHECKING([command to parse $NM output])
500 AC_CACHE_VAL(ac_cv_sys_global_symbol_pipe,
501 [# These are sane defaults that work on at least a few old systems.
502 # {They come from Ultrix.  What could be older than Ultrix?!! ;)}
504 changequote(,)dnl
505 # Character class describing NM global symbol codes.
506 ac_symcode='[BCDEGRSTU]'
508 # Regexp to match symbols that can be accessed directly from C.
509 ac_sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
511 # Transform the above into a raw symbol and a C symbol.
512 ac_symxfrm='\1 \1'
514 # Define system-specific variables.
515 case "$host_os" in
516 aix*)
517   ac_symcode='[BCDTU]'
518   ;;
519 freebsd* | netbsd* | openbsd* | bsdi* | sunos* | cygwin32* | mingw32*)
520   ac_sympat='_\([_A-Za-z][_A-Za-z0-9]*\)'
521   ac_symxfrm='_\1 \1'
522   ;;
523 irix*)
524   # Cannot use undefined symbols on IRIX because inlined functions mess us up.
525   ac_symcode='[BCDEGRST]'
526   ;;
527 solaris*)
528   ac_symcode='[BDTU]'
529   ;;
530 esac
532 # If we're using GNU nm, then use its standard symbol codes.
533 if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then
534   ac_symcode='[ABCDGISTUW]'
537 case "$host_os" in
538 cygwin32* | mingw32*)
539   # We do not want undefined symbols on cygwin32.  The user must
540   # arrange to define them via -l arguments.
541   ac_symcode='[ABCDGISTW]'
542   ;;
543 esac
544 changequote([,])dnl
546 # Write the raw and C identifiers.
547 ac_cv_sys_global_symbol_pipe="sed -n -e 's/^.* $ac_symcode $ac_sympat$/$ac_symxfrm/p'"
549 # Check to see that the pipe works correctly.
550 ac_pipe_works=no
551 cat > conftest.$ac_ext <<EOF
552 #ifdef __cplusplus
553 extern "C" {
554 #endif
555 char nm_test_var;
556 void nm_test_func(){}
557 #ifdef __cplusplus
559 #endif
560 int main(){nm_test_var='a';nm_test_func;return 0;}
562 if AC_TRY_EVAL(ac_compile); then
563   # Now try to grab the symbols.
564   ac_nlist=conftest.nm
565   if AC_TRY_EVAL(NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
567     # Try sorting and uniquifying the output.
568     if sort "$ac_nlist" | uniq > "$ac_nlist"T; then
569       mv -f "$ac_nlist"T "$ac_nlist"
570       ac_wcout=`wc "$ac_nlist" 2>/dev/null`
571 changequote(,)dnl
572       ac_count=`echo "X$ac_wcout" | sed -e 's,^X,,' -e 's/^[    ]*\([0-9][0-9]*\).*$/\1/'`
573 changequote([,])dnl
574       (test "$ac_count" -ge 0) 2>/dev/null || ac_count=-1
575     else
576       rm -f "$ac_nlist"T
577       ac_count=-1
578     fi
580     # Make sure that we snagged all the symbols we need.
581     if egrep ' _?nm_test_var$' "$ac_nlist" >/dev/null; then
582       if egrep ' _?nm_test_func$' "$ac_nlist" >/dev/null; then
583         cat <<EOF > conftest.c
584 #ifdef __cplusplus
585 extern "C" {
586 #endif
589        # Now generate the symbol file.
590        sed 's/^.* _\{0,1\}\(.*\)$/extern char \1;/' < "$ac_nlist" >> conftest.c
592         cat <<EOF >> conftest.c
593 #if defined (__STDC__) && __STDC__
594 # define __ptr_t void *
595 #else
596 # define __ptr_t char *
597 #endif
599 /* The number of symbols in dld_preloaded_symbols, -1 if unsorted. */
600 int dld_preloaded_symbol_count = $ac_count;
602 /* The mapping between symbol names and symbols. */
603 struct {
604   char *name;
605   __ptr_t address;
607 changequote(,)dnl
608 dld_preloaded_symbols[] =
609 changequote([,])dnl
612         sed 's/^_\{0,1\}\(.*\) _\{0,1\}\(.*\)$/  {"\1", (__ptr_t) \&\2},/' < "$ac_nlist" >> conftest.c
613         cat <<\EOF >> conftest.c
614   {0, (__ptr_t) 0}
617 #ifdef __cplusplus
619 #endif
621         # Now try linking the two files.
622         mv conftest.$ac_objext conftestm.$ac_objext
623         ac_save_LIBS="$LIBS"
624         ac_save_CFLAGS="$CFLAGS"
625         LIBS="conftestm.$ac_objext"
626         CFLAGS="$CFLAGS$no_builtin_flag"
627         if AC_TRY_EVAL(ac_link) && test -s conftest; then
628           ac_pipe_works=yes
629         else
630           echo "configure: failed program was:" >&AC_FD_CC
631           cat conftest.c >&AC_FD_CC
632         fi
633         LIBS="$ac_save_LIBS"
634         CFLAGS="$ac_save_CFLAGS"
635       else
636         echo "cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
637       fi
638     else
639       echo "cannot find nm_test_var in $ac_nlist" >&AC_FD_CC
640     fi
641   else
642     echo "cannot run $ac_cv_sys_global_symbol_pipe" >&AC_FD_CC
643   fi
644 else
645   echo "$progname: failed program was:" >&AC_FD_CC
646   cat conftest.c >&AC_FD_CC
648 rm -rf conftest*
650 # Do not use the global_symbol_pipe unless it works.
651 test "$ac_pipe_works" = yes || ac_cv_sys_global_symbol_pipe=
654 ac_result=yes
655 if test -z "$ac_cv_sys_global_symbol_pipe"; then
656    ac_result=no
658 AC_MSG_RESULT($ac_result)
661 # GNUPG_SYS_LIBTOOL_CYGWIN32 - find tools needed on cygwin32
662 AC_DEFUN([GNUPG_SYS_LIBTOOL_CYGWIN32],
663 [AC_CHECK_TOOL(DLLTOOL, dlltool, false)
664 AC_CHECK_TOOL(AS, as, false)
667 # GNUPG_SYS_SYMBOL_UNDERSCORE - does the compiler prefix global symbols
668 #                              with an underscore?
669 AC_DEFUN([GNUPG_SYS_SYMBOL_UNDERSCORE],
670 [tmp_do_check="no"
671 case "${target}" in
672     i386-emx-os2 | i[3456]86-pc-os2*emx | i386-pc-msdosdjgpp)
673         ac_cv_sys_symbol_underscore=yes
674         ;;
675     *)
676       if test "$cross_compiling" = yes; then
677          ac_cv_sys_symbol_underscore=yes
678       else
679          tmp_do_check="yes"
680       fi
681        ;;
682 esac
684 if test "$tmp_do_check" = "yes"; then
685 AC_REQUIRE([GNUPG_PROG_NM])dnl
686 AC_REQUIRE([GNUPG_SYS_NM_PARSE])dnl
687 AC_MSG_CHECKING([for _ prefix in compiled symbols])
688 AC_CACHE_VAL(ac_cv_sys_symbol_underscore,
689 [ac_cv_sys_symbol_underscore=no
690 cat > conftest.$ac_ext <<EOF
691 void nm_test_func(){}
692 int main(){nm_test_func;return 0;}
694 if AC_TRY_EVAL(ac_compile); then
695   # Now try to grab the symbols.
696   ac_nlist=conftest.nm
697   if AC_TRY_EVAL(NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
698     # See whether the symbols have a leading underscore.
699     if egrep '^_nm_test_func' "$ac_nlist" >/dev/null; then
700       ac_cv_sys_symbol_underscore=yes
701     else
702       if egrep '^nm_test_func ' "$ac_nlist" >/dev/null; then
703         :
704       else
705         echo "configure: cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
706       fi
707     fi
708   else
709     echo "configure: cannot run $ac_cv_sys_global_symbol_pipe" >&AC_FD_CC
710   fi
711 else
712   echo "configure: failed program was:" >&AC_FD_CC
713   cat conftest.c >&AC_FD_CC
715 rm -rf conftest*
717 else
718 AC_MSG_CHECKING([for _ prefix in compiled symbols])
720 AC_MSG_RESULT($ac_cv_sys_symbol_underscore)
721 if test x$ac_cv_sys_symbol_underscore = xyes; then
722   AC_DEFINE(WITH_SYMBOL_UNDERSCORE,1,
723             [Defined if compiled symbols have a leading underscore])
727 dnl Stolen from gcc
728 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
729 dnl of the usual 2.
730 AC_DEFUN([GNUPG_FUNC_MKDIR_TAKES_ONE_ARG],
731 [AC_CHECK_HEADERS(sys/stat.h unistd.h direct.h)
732 AC_CACHE_CHECK([if mkdir takes one argument], gnupg_cv_mkdir_takes_one_arg,
733 [AC_TRY_COMPILE([
734 #include <sys/types.h>
735 #ifdef HAVE_SYS_STAT_H
736 # include <sys/stat.h>
737 #endif
738 #ifdef HAVE_UNISTD_H
739 # include <unistd.h>
740 #endif
741 #ifdef HAVE_DIRECT_H
742 # include <direct.h>
743 #endif], [mkdir ("foo", 0);],
744         gnupg_cv_mkdir_takes_one_arg=no, gnupg_cv_mkdir_takes_one_arg=yes)])
745 if test $gnupg_cv_mkdir_takes_one_arg = yes ; then
746   AC_DEFINE(MKDIR_TAKES_ONE_ARG,1,
747             [Defined if mkdir() does not take permission flags])
751 # GNUPG_AC_INIT([PACKAGE, VERSION, [ISDEVEL], BUG-REPORT)
752 # ----------------------------------------
753 # Call AC_INIT with an additional argument to indicate a development
754 # version.  If this is called ""svn", the global revision of the
755 # repository will be appended, so that a version.  The variable
756 # SVN_REVISION will always be set.  In case svn is not available 0
757 # will be used for the revision.
758 m4_define([GNUPG_AC_INIT],
760 m4_define(gnupg_ac_init_tmp, m4_esyscmd([echo -n $((svn info 2>/dev/null || \
761           echo 'Revision: 0') |sed -n '/^Revision:/ {s/[^0-9]//gp;q}')]))
762 SVN_REVISION="gnupg_ac_init_tmp[]"
763 AC_INIT([$1], [$2][]m4_ifval([$3],[-[$3][]gnupg_ac_init_tmp],[]), [$4])