* THANKS: Changes from stable branch.
[gnupg.git] / acinclude.m4
1 dnl macros to configure gnupg
2 dnl Copyright (C) 1998, 1999, 2000, 2001 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_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   ])
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 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" )
79
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/pub/gcrypt/contrib/faqprog.pl )
87 dnl *** No need to worry about this warning.
88 dnl ***]])
89 dnl     fi
90    ])       
91
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    ])       
107
108
109
110 dnl GNUPG_CHECK_ENDIAN
111 dnl define either LITTLE_ENDIAN_HOST or BIG_ENDIAN_HOST
112 dnl
113 define(GNUPG_CHECK_ENDIAN,
114   [ if test "$cross_compiling" = yes; then
115         AC_MSG_WARN(cross compiling; assuming little 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=little
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 dnl GNUPG_CHECK_CACHE
159 dnl
160 define(GNUPG_CHECK_CACHE,
161   [ AC_MSG_CHECKING(cached information)
162     gnupg_hostcheck="$target"
163     AC_CACHE_VAL(gnupg_cv_hostcheck, [ gnupg_cv_hostcheck="$gnupg_hostcheck" ])
164     if test "$gnupg_cv_hostcheck" != "$gnupg_hostcheck"; then
165         AC_MSG_RESULT(changed)
166         AC_MSG_WARN(config.cache exists!)
167         AC_MSG_ERROR(you must do 'make distclean' first to compile for
168                  different target or different parameters.)
169     else
170         AC_MSG_RESULT(ok)
171     fi
172   ])
173
174
175 ######################################################################
176 # Check for -fPIC etc (taken from libtool)
177 # This sets CFLAGS_PIC to the required flags
178 #           NO_PIC to yes if it is not possible to
179 #                  generate PIC
180 ######################################################################
181 dnl GNUPG_CHECK_PIC
182 dnl
183 define(GNUPG_CHECK_PIC,
184   [ AC_MSG_CHECKING(for option to create PIC)
185     CFLAGS_PIC=
186     NO_PIC=no
187     if test "$cross_compiling" = yes; then
188         AC_MSG_RESULT(assume none)
189     else
190         if test "$GCC" = yes; then
191             CFLAGS_PIC="-fPIC"
192         else
193             case "$host_os" in
194               aix3* | aix4*)
195                 # All rs/6000 code is PIC
196                 # but is there any non-rs/6000 AIX platform?
197                 ;;
198
199               hpux9* | hpux10*)
200                 CFLAGS_PIC="+Z"
201                 ;;
202
203               irix5* | irix6*)
204                 # PIC (with -KPIC) is the default.
205                 ;;
206
207               osf3* | osf4*)
208                 # FIXME - pic_flag is probably required for
209                 # hppa*-osf* and i860-osf*
210                 ;;
211
212               sco3.2v5*)
213                 CFLAGS_PIC='-Kpic'
214                 ;;
215
216               solaris2* | solaris7* )
217                 CFLAGS_PIC='-KPIC'
218                 ;;
219
220               sunos4*)
221                 CFLAGS_PIC='-PIC'
222                 ;;
223
224               *)
225                 NO_PIC=yes
226                 ;;
227             esac
228         fi
229
230         case "$host_cpu" in
231         rs6000 | powerpc | powerpcle)
232           # Yippee! All RS/6000 and PowerPC code is position-independent.
233           CFLAGS_PIC=""
234           ;;
235         esac
236
237         if test "$NO_PIC" = yes; then
238             AC_MSG_RESULT(not possible)
239         else
240             if test -z "$CFLAGS_PIC"; then
241                AC_MSG_RESULT(none)
242             else
243                 AC_MSG_RESULT($CFLAGS_PIC)
244             fi
245         fi
246     fi
247   ])
248
249
250 ######################################################################
251 # Check for export-dynamic flag
252 # This sets CFLAGS_EXPORTDYNAMIC to the required flags
253 ######################################################################
254 dnl GNUPG_CHECK_EXPORTDYNAMIC
255 dnl
256 define(GNUPG_CHECK_EXPORTDYNAMIC,
257   [ AC_MSG_CHECKING(how to specify -export-dynamic)
258     if test "$cross_compiling" = yes; then
259       AC_MSG_RESULT(assume none)
260       CFLAGS_EXPORTDYNAMIC=""
261     else
262       AC_CACHE_VAL(gnupg_cv_export_dynamic,[
263       if AC_TRY_COMMAND([${CC-cc} $CFLAGS -Wl,--version 2>&1 |
264                                           grep "GNU ld" >/dev/null]); then
265           # using gnu's linker
266           gnupg_cv_export_dynamic="-Wl,-export-dynamic"
267       else
268           case "$host_os" in
269             hpux* )
270               gnupg_cv_export_dynamic="-Wl,-E"
271               ;;
272             * )
273               gnupg_cv_export_dynamic=""
274               ;;
275           esac
276       fi
277       ])
278       AC_MSG_RESULT($gnupg_cv_export_dynamic)
279       CFLAGS_EXPORTDYNAMIC="$gnupg_cv_export_dynamic"
280     fi
281   ])
282
283 #####################################################################
284 # Check for SysV IPC  (from GIMP)
285 #   And see whether we have a SHM_LOCK (FreeBSD does not have it).
286 #####################################################################
287 dnl GNUPG_CHECK_IPC
288 dnl
289 define(GNUPG_CHECK_IPC,
290    [ AC_CHECK_HEADERS(sys/ipc.h sys/shm.h)
291      if test "$ac_cv_header_sys_shm_h" = "yes"; then
292        AC_MSG_CHECKING(whether IPC_RMID allowes subsequent attaches)
293        AC_CACHE_VAL(gnupg_cv_ipc_rmid_deferred_release,
294           AC_TRY_RUN([
295              #include <sys/types.h>
296              #include <sys/ipc.h>
297              #include <sys/shm.h>
298              int main()
299              {
300                int id;
301                char *shmaddr;
302              id = shmget (IPC_PRIVATE, 4, IPC_CREAT | 0777);
303              if (id == -1)
304                exit (2);
305                shmaddr = shmat (id, 0, 0);
306                shmctl (id, IPC_RMID, 0);
307                if ((char*) shmat (id, 0, 0) == (char*) -1)
308                {
309                  shmdt (shmaddr);
310                  exit (1);
311                }
312                shmdt (shmaddr);
313                shmdt (shmaddr);
314                exit (0);
315              }
316          ],
317          gnupg_cv_ipc_rmid_deferred_release="yes",
318          gnupg_cv_ipc_rmid_deferred_release="no",
319          gnupg_cv_ipc_rmid_deferred_release="assume-no")
320        )
321        if test "$gnupg_cv_ipc_rmid_deferred_release" = "yes"; then
322            AC_DEFINE(IPC_RMID_DEFERRED_RELEASE,1,
323                      [Defined if we can do a deferred shm release])
324            AC_MSG_RESULT(yes)
325        else
326           if test "$gnupg_cv_ipc_rmid_deferred_release" = "no"; then
327               AC_MSG_RESULT(no)
328           else
329               AC_MSG_RESULT([assuming no])
330           fi
331        fi
332
333        AC_MSG_CHECKING(whether SHM_LOCK is available)
334        AC_CACHE_VAL(gnupg_cv_ipc_have_shm_lock,
335           AC_TRY_COMPILE([#include <sys/types.h>
336              #include <sys/ipc.h>
337              #include <sys/shm.h>],[
338              int shm_id;
339              shmctl(shm_id, SHM_LOCK, 0);
340              ],
341              gnupg_cv_ipc_have_shm_lock="yes",
342              gnupg_cv_ipc_have_shm_lock="no"
343           )
344        )
345        if test "$gnupg_cv_ipc_have_shm_lock" = "yes"; then
346          AC_DEFINE(IPC_HAVE_SHM_LOCK,1,
347                    [Defined if a SysV shared memory supports the LOCK flag])
348          AC_MSG_RESULT(yes)
349        else
350          AC_MSG_RESULT(no)
351        fi
352      fi
353    ])
354
355
356 ######################################################################
357 # Check whether mlock is broken (hpux 10.20 raises a SIGBUS if mlock
358 # is not called from uid 0 (not tested whether uid 0 works)
359 # For DECs Tru64 we have also to check whether mlock is in librt
360 # mlock is there a macro using memlk()
361 ######################################################################
362 dnl GNUPG_CHECK_MLOCK
363 dnl
364 define(GNUPG_CHECK_MLOCK,
365   [ AC_CHECK_FUNCS(mlock)
366     if test "$ac_cv_func_mlock" = "no"; then
367         AC_CHECK_HEADERS(sys/mman.h)
368         if test "$ac_cv_header_sys_mman_h" = "yes"; then
369             # Add librt to LIBS:
370             AC_CHECK_LIB(rt, memlk)
371             AC_CACHE_CHECK([whether mlock is in sys/mman.h],
372                             gnupg_cv_mlock_is_in_sys_mman,
373                 [AC_TRY_LINK([
374                     #include <assert.h>
375                     #ifdef HAVE_SYS_MMAN_H
376                     #include <sys/mman.h>
377                     #endif
378                 ], [
379                     int i;
380
381                     /* glibc defines this for functions which it implements
382                      * to always fail with ENOSYS.  Some functions are actually
383                      * named something starting with __ and the normal name
384                      * is an alias.  */
385                     #if defined (__stub_mlock) || defined (__stub___mlock)
386                     choke me
387                     #else
388                     mlock(&i, 4);
389                     #endif
390                     ; return 0;
391                 ],
392                 gnupg_cv_mlock_is_in_sys_mman=yes,
393                 gnupg_cv_mlock_is_in_sys_mman=no)])
394             if test "$gnupg_cv_mlock_is_in_sys_mman" = "yes"; then
395                 AC_DEFINE(HAVE_MLOCK,1,
396                           [Defined if the system supports an mlock() call])
397             fi
398         fi
399     fi
400     if test "$ac_cv_func_mlock" = "yes"; then
401         AC_MSG_CHECKING(whether mlock is broken)
402           AC_CACHE_VAL(gnupg_cv_have_broken_mlock,
403              AC_TRY_RUN([
404                 #include <stdlib.h>
405                 #include <unistd.h>
406                 #include <errno.h>
407                 #include <sys/mman.h>
408                 #include <sys/types.h>
409                 #include <fcntl.h>
410
411                 int main()
412                 {
413                     char *pool;
414                     int err;
415                     long int pgsize = getpagesize();
416
417                     pool = malloc( 4096 + pgsize );
418                     if( !pool )
419                         return 2;
420                     pool += (pgsize - ((long int)pool % pgsize));
421
422                     err = mlock( pool, 4096 );
423                     if( !err || errno == EPERM )
424                         return 0; /* okay */
425
426                     return 1;  /* hmmm */
427                 }
428
429             ],
430             gnupg_cv_have_broken_mlock="no",
431             gnupg_cv_have_broken_mlock="yes",
432             gnupg_cv_have_broken_mlock="assume-no"
433            )
434          )
435          if test "$gnupg_cv_have_broken_mlock" = "yes"; then
436              AC_DEFINE(HAVE_BROKEN_MLOCK,1,
437                        [Defined if the mlock() call does not work])
438              AC_MSG_RESULT(yes)
439              AC_CHECK_FUNCS(plock)
440          else
441             if test "$gnupg_cv_have_broken_mlock" = "no"; then
442                 AC_MSG_RESULT(no)
443             else
444                 AC_MSG_RESULT(assuming no)
445             fi
446          fi
447     fi
448   ])
449
450
451 ################################################################
452 # GNUPG_PROG_NM - find the path to a BSD-compatible name lister
453 AC_DEFUN(GNUPG_PROG_NM,
454 [AC_MSG_CHECKING([for BSD-compatible nm])
455 AC_CACHE_VAL(ac_cv_path_NM,
456 [if test -n "$NM"; then
457   # Let the user override the test.
458   ac_cv_path_NM="$NM"
459 else
460   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
461   for ac_dir in /usr/ucb /usr/ccs/bin $PATH /bin; do
462     test -z "$ac_dir" && ac_dir=.
463     if test -f $ac_dir/nm; then
464       # Check to see if the nm accepts a BSD-compat flag.
465       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
466       #   nm: unknown option "B" ignored
467       if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
468         ac_cv_path_NM="$ac_dir/nm -B"
469       elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
470         ac_cv_path_NM="$ac_dir/nm -p"
471       else
472         ac_cv_path_NM="$ac_dir/nm"
473       fi
474       break
475     fi
476   done
477   IFS="$ac_save_ifs"
478   test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
479 fi])
480 NM="$ac_cv_path_NM"
481 AC_MSG_RESULT([$NM])
482 AC_SUBST(NM)
483 ])
484
485 # GNUPG_SYS_NM_PARSE - Check for command ro grab the raw symbol name followed
486 # by C symbol name from nm.
487 AC_DEFUN(GNUPG_SYS_NM_PARSE,
488 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
489 AC_REQUIRE([GNUPG_PROG_NM])dnl
490 # Check for command to grab the raw symbol name followed by C symbol from nm.
491 AC_MSG_CHECKING([command to parse $NM output])
492 AC_CACHE_VAL(ac_cv_sys_global_symbol_pipe,
493 [# These are sane defaults that work on at least a few old systems.
494 # {They come from Ultrix.  What could be older than Ultrix?!! ;)}
495
496 changequote(,)dnl
497 # Character class describing NM global symbol codes.
498 ac_symcode='[BCDEGRSTU]'
499
500 # Regexp to match symbols that can be accessed directly from C.
501 ac_sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
502
503 # Transform the above into a raw symbol and a C symbol.
504 ac_symxfrm='\1 \1'
505
506 # Define system-specific variables.
507 case "$host_os" in
508 aix*)
509   ac_symcode='[BCDTU]'
510   ;;
511 freebsd* | netbsd* | openbsd* | bsdi* | sunos* | cygwin32* | mingw32*)
512   ac_sympat='_\([_A-Za-z][_A-Za-z0-9]*\)'
513   ac_symxfrm='_\1 \1'
514   ;;
515 irix*)
516   # Cannot use undefined symbols on IRIX because inlined functions mess us up.
517   ac_symcode='[BCDEGRST]'
518   ;;
519 solaris*)
520   ac_symcode='[BDTU]'
521   ;;
522 esac
523
524 # If we're using GNU nm, then use its standard symbol codes.
525 if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then
526   ac_symcode='[ABCDGISTUW]'
527 fi
528
529 case "$host_os" in
530 cygwin32* | mingw32*)
531   # We do not want undefined symbols on cygwin32.  The user must
532   # arrange to define them via -l arguments.
533   ac_symcode='[ABCDGISTW]'
534   ;;
535 esac
536 changequote([,])dnl
537
538 # Write the raw and C identifiers.
539 ac_cv_sys_global_symbol_pipe="sed -n -e 's/^.* $ac_symcode $ac_sympat$/$ac_symxfrm/p'"
540
541 # Check to see that the pipe works correctly.
542 ac_pipe_works=no
543 cat > conftest.$ac_ext <<EOF
544 #ifdef __cplusplus
545 extern "C" {
546 #endif
547 char nm_test_var;
548 void nm_test_func(){}
549 #ifdef __cplusplus
550 }
551 #endif
552 int main(){nm_test_var='a';nm_test_func;return 0;}
553 EOF
554 if AC_TRY_EVAL(ac_compile); then
555   # Now try to grab the symbols.
556   ac_nlist=conftest.nm
557   if AC_TRY_EVAL(NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
558
559     # Try sorting and uniquifying the output.
560     if sort "$ac_nlist" | uniq > "$ac_nlist"T; then
561       mv -f "$ac_nlist"T "$ac_nlist"
562       ac_wcout=`wc "$ac_nlist" 2>/dev/null`
563 changequote(,)dnl
564       ac_count=`echo "X$ac_wcout" | sed -e 's,^X,,' -e 's/^[    ]*\([0-9][0-9]*\).*$/\1/'`
565 changequote([,])dnl
566       (test "$ac_count" -ge 0) 2>/dev/null || ac_count=-1
567     else
568       rm -f "$ac_nlist"T
569       ac_count=-1
570     fi
571
572     # Make sure that we snagged all the symbols we need.
573     if egrep ' _?nm_test_var$' "$ac_nlist" >/dev/null; then
574       if egrep ' _?nm_test_func$' "$ac_nlist" >/dev/null; then
575         cat <<EOF > conftest.c
576 #ifdef __cplusplus
577 extern "C" {
578 #endif
579
580 EOF
581         # Now generate the symbol file.
582         sed 's/^.* _\?\(.*\)$/extern char \1;/' < "$ac_nlist" >> conftest.c
583
584         cat <<EOF >> conftest.c
585 #if defined (__STDC__) && __STDC__
586 # define __ptr_t void *
587 #else
588 # define __ptr_t char *
589 #endif
590
591 /* The number of symbols in dld_preloaded_symbols, -1 if unsorted. */
592 int dld_preloaded_symbol_count = $ac_count;
593
594 /* The mapping between symbol names and symbols. */
595 struct {
596   char *name;
597   __ptr_t address;
598 }
599 changequote(,)dnl
600 dld_preloaded_symbols[] =
601 changequote([,])dnl
602 {
603 EOF
604         sed 's/^_\?\(.*\) _\?\(.*\)$/  {"\1", (__ptr_t) \&\2},/' < "$ac_nlist" >> conftest.c
605         cat <<\EOF >> conftest.c
606   {0, (__ptr_t) 0}
607 };
608
609 #ifdef __cplusplus
610 }
611 #endif
612 EOF
613         # Now try linking the two files.
614         mv conftest.$ac_objext conftestm.$ac_objext
615         ac_save_LIBS="$LIBS"
616         ac_save_CFLAGS="$CFLAGS"
617         LIBS="conftestm.$ac_objext"
618         CFLAGS="$CFLAGS$no_builtin_flag"
619         if AC_TRY_EVAL(ac_link) && test -s conftest; then
620           ac_pipe_works=yes
621         else
622           echo "configure: failed program was:" >&AC_FD_CC
623           cat conftest.c >&AC_FD_CC
624         fi
625         LIBS="$ac_save_LIBS"
626         CFLAGS="$ac_save_CFLAGS"
627       else
628         echo "cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
629       fi
630     else
631       echo "cannot find nm_test_var in $ac_nlist" >&AC_FD_CC
632     fi
633   else
634     echo "cannot run $ac_cv_sys_global_symbol_pipe" >&AC_FD_CC
635   fi
636 else
637   echo "$progname: failed program was:" >&AC_FD_CC
638   cat conftest.c >&AC_FD_CC
639 fi
640 rm -rf conftest*
641
642 # Do not use the global_symbol_pipe unless it works.
643 test "$ac_pipe_works" = yes || ac_cv_sys_global_symbol_pipe=
644 ])
645
646 ac_result=yes
647 if test -z "$ac_cv_sys_global_symbol_pipe"; then
648    ac_result=no
649 fi
650 AC_MSG_RESULT($ac_result)
651 ])
652
653 # GNUPG_SYS_LIBTOOL_CYGWIN32 - find tools needed on cygwin32
654 AC_DEFUN(GNUPG_SYS_LIBTOOL_CYGWIN32,
655 [AC_CHECK_TOOL(DLLTOOL, dlltool, false)
656 AC_CHECK_TOOL(AS, as, false)
657 ])
658
659 # GNUPG_SYS_SYMBOL_UNDERSCORE - does the compiler prefix global symbols
660 #                              with an underscore?
661 AC_DEFUN(GNUPG_SYS_SYMBOL_UNDERSCORE,
662 [tmp_do_check="no"
663 case "${target}" in
664     i386-emx-os2 | i[3456]86-pc-os2*emx | i386-pc-msdosdjgpp)
665         ac_cv_sys_symbol_underscore=yes
666         ;;
667     *)
668       if test "$cross_compiling" = yes; then
669          ac_cv_sys_symbol_underscore=yes
670       else
671          tmp_do_check="yes"
672       fi
673        ;;
674 esac
675
676 if test "$tmp_do_check" = "yes"; then
677 AC_REQUIRE([GNUPG_PROG_NM])dnl
678 AC_REQUIRE([GNUPG_SYS_NM_PARSE])dnl
679 AC_MSG_CHECKING([for _ prefix in compiled symbols])
680 AC_CACHE_VAL(ac_cv_sys_symbol_underscore,
681 [ac_cv_sys_symbol_underscore=no
682 cat > conftest.$ac_ext <<EOF
683 void nm_test_func(){}
684 int main(){nm_test_func;return 0;}
685 EOF
686 if AC_TRY_EVAL(ac_compile); then
687   # Now try to grab the symbols.
688   ac_nlist=conftest.nm
689   if AC_TRY_EVAL(NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
690     # See whether the symbols have a leading underscore.
691     if egrep '^_nm_test_func' "$ac_nlist" >/dev/null; then
692       ac_cv_sys_symbol_underscore=yes
693     else
694       if egrep '^nm_test_func ' "$ac_nlist" >/dev/null; then
695         :
696       else
697         echo "configure: cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
698       fi
699     fi
700   else
701     echo "configure: cannot run $ac_cv_sys_global_symbol_pipe" >&AC_FD_CC
702   fi
703 else
704   echo "configure: failed program was:" >&AC_FD_CC
705   cat conftest.c >&AC_FD_CC
706 fi
707 rm -rf conftest*
708 ])
709 else
710 AC_MSG_CHECKING([for _ prefix in compiled symbols])
711 fi
712 AC_MSG_RESULT($ac_cv_sys_symbol_underscore)
713 if test x$ac_cv_sys_symbol_underscore = xyes; then
714   AC_DEFINE(WITH_SYMBOL_UNDERSCORE,1,
715             [Defined if compiled symbols have a leading underscore])
716 fi
717 ])
718
719 dnl Stolen from gcc
720 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
721 dnl of the usual 2.
722 AC_DEFUN(GNUPG_FUNC_MKDIR_TAKES_ONE_ARG,
723 [AC_CHECK_HEADERS(sys/stat.h unistd.h direct.h)
724 AC_CACHE_CHECK([if mkdir takes one argument], gnupg_cv_mkdir_takes_one_arg,
725 [AC_TRY_COMPILE([
726 #include <sys/types.h>
727 #ifdef HAVE_SYS_STAT_H
728 # include <sys/stat.h>
729 #endif
730 #ifdef HAVE_UNISTD_H
731 # include <unistd.h>
732 #endif
733 #ifdef HAVE_DIRECT_H
734 # include <direct.h>
735 #endif], [mkdir ("foo", 0);],
736         gnupg_cv_mkdir_takes_one_arg=no, gnupg_cv_mkdir_takes_one_arg=yes)])
737 if test $gnupg_cv_mkdir_takes_one_arg = yes ; then
738   AC_DEFINE(MKDIR_TAKES_ONE_ARG,1,
739             [Defined if mkdir() does not take permission flags])
740 fi
741 ])
742