Changed name to libgcrypt
[libgcrypt.git] / acinclude.m4
1 dnl macros to configure g10
2
3
4 dnl GNUPG_MSG_PRINT(STRING)
5 dnl print a message
6 dnl
7 define(GNUPG_MSG_PRINT,
8   [ echo $ac_n "$1"" $ac_c" 1>&AC_FD_MSG
9   ])
10
11
12 dnl GNUPG_CHECK_TYPEDEF(TYPE, HAVE_NAME)
13 dnl Check whether a typedef exists and create a #define $2 if it exists
14 dnl
15 AC_DEFUN(GNUPG_CHECK_TYPEDEF,
16   [ AC_MSG_CHECKING(for $1 typedef)
17     AC_CACHE_VAL(gnupg_cv_typedef_$1,
18     [AC_TRY_COMPILE([#include <stdlib.h>
19     #include <sys/types.h>], [
20     #undef $1
21     int a = sizeof($1);
22     ], gnupg_cv_typedef_$1=yes, gnupg_cv_typedef_$1=no )])
23     AC_MSG_RESULT($gnupg_cv_typedef_$1)
24     if test "$gnupg_cv_typedef_$1" = yes; then
25         AC_DEFINE($2)
26     fi
27   ])
28
29
30 dnl GNUPG_FIX_HDR_VERSION(FILE, NAME)
31 dnl Make the version number in gcrypt/gcrypt.h the same as the one here.
32 dnl (this is easier than to have a .in file just for one substitution)
33 dnl
34 AC_DEFUN(GNUPG_FIX_HDR_VERSION,
35   [ sed "s/^#define $2 \".*/#define $2 \"$VERSION\"/" $srcdir/$1 > $srcdir/$1.tmp
36     if cmp -s $srcdir/$1 $srcdir/$1.tmp 2>/dev/null; then
37         rm -f $srcdir/$1.tmp
38     else
39         rm -f $srcdir/$1
40         if mv $srcdir/$1.tmp $srcdir/$1 ; then
41             :
42         else
43             AC_MSG_ERROR([[
44 *** Failed to fix the version string macro $2 in $1.
45 *** The old file has been saved as $1.tmp
46                          ]])
47         fi
48         AC_MSG_WARN([fixed the $2 macro in $1])
49     fi
50   ])
51
52
53 dnl GNUPG_CHECK_GNUMAKE
54 dnl
55 AC_DEFUN(GNUPG_CHECK_GNUMAKE,
56   [
57     if ${MAKE-make} --version 2>/dev/null | grep '^GNU ' >/dev/null 2>&1; then
58         :
59     else
60         AC_MSG_WARN([[
61 ***
62 *** It seems that you are not using GNU make.  Some make tools have serious
63 *** flaws and you may not be able to build this software at all. Before you
64 *** complain, please try GNU make:  GNU make is easy to build and available
65 *** at all GNU archives.  It is always available from ftp.gnu.org:/gnu/make.
66 ***]])
67     fi
68   ])
69
70 dnl GNUPG_CHECK_FAQPROG
71 dnl
72 AC_DEFUN(GNUPG_CHECK_FAQPROG,
73   [ AC_MSG_CHECKING(for faqprog.pl)
74     if faqprog.pl -V 2>/dev/null | grep '^faqprog.pl ' >/dev/null 2>&1; then
75         working_faqprog=yes
76         FAQPROG="faqprog.pl"
77     else 
78         working_faqprog=no
79         FAQPROG=": "
80     fi
81     AC_MSG_RESULT($working_faqprog)
82     AC_SUBST(FAQPROG)
83     AM_CONDITIONAL(WORKING_FAQPROG, test "$working_faqprog" = "yes" )
84
85     if test $working_faqprog = no; then
86         AC_MSG_WARN([[
87 ***
88 *** It seems that the faqprog.pl program is not installed.
89 *** Unless you do not change the source of the FAQs it is not required.
90 *** The working version of this utility should be available at:
91 ***   ftp://ftp.gnupg.org/pub/gcrypt/contrib/faqprog.pl
92 ***]])
93     fi
94   ])       
95
96
97
98 dnl GNUPG_LINK_FILES( SRC, DEST )
99 dnl same as AC_LINK_FILES, but collect the files to link in
100 dnl some special variables and do the link
101 dnl when GNUPG_DO_LINK_FILES is called
102 dnl This is a workaround for AC_LINK_FILES, because it does not work
103 dnl correct when using a caching scheme
104 dnl
105 define(GNUPG_LINK_FILES,
106   [ if test "x$wk_link_files_src" = "x"; then
107         wk_link_files_src="$1"
108         wk_link_files_dst="$2"
109     else
110         wk_link_files_src="$wk_link_files_src $1"
111         wk_link_files_dst="$wk_link_files_dst $2"
112     fi
113   ])
114 define(GNUPG_DO_LINK_FILES,
115   [ AC_LINK_FILES( $wk_link_files_src, $wk_link_files_dst )
116   ])
117
118
119
120
121 dnl GNUPG_CHECK_ENDIAN
122 dnl define either LITTLE_ENDIAN_HOST or BIG_ENDIAN_HOST
123 dnl
124 define(GNUPG_CHECK_ENDIAN,
125   [ if test "$cross_compiling" = yes; then
126         AC_MSG_WARN(cross compiling; assuming little endianess)
127     fi
128     AC_MSG_CHECKING(endianess)
129     AC_CACHE_VAL(gnupg_cv_c_endian,
130       [ gnupg_cv_c_endian=unknown
131         # See if sys/param.h defines the BYTE_ORDER macro.
132         AC_TRY_COMPILE([#include <sys/types.h>
133         #include <sys/param.h>], [
134         #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
135          bogus endian macros
136         #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
137         AC_TRY_COMPILE([#include <sys/types.h>
138         #include <sys/param.h>], [
139         #if BYTE_ORDER != BIG_ENDIAN
140          not big endian
141         #endif], gnupg_cv_c_endian=big, gnupg_cv_c_endian=little)])
142         if test "$gnupg_cv_c_endian" = unknown; then
143             AC_TRY_RUN([main () {
144               /* Are we little or big endian?  From Harbison&Steele.  */
145               union
146               {
147                 long l;
148                 char c[sizeof (long)];
149               } u;
150               u.l = 1;
151               exit (u.c[sizeof (long) - 1] == 1);
152               }],
153               gnupg_cv_c_endian=little,
154               gnupg_cv_c_endian=big,
155               gnupg_cv_c_endian=little
156             )
157         fi
158       ])
159     AC_MSG_RESULT([$gnupg_cv_c_endian])
160     if test "$gnupg_cv_c_endian" = little; then
161       AC_DEFINE(LITTLE_ENDIAN_HOST)
162     else
163       AC_DEFINE(BIG_ENDIAN_HOST)
164     fi
165   ])
166
167 dnl GNUPG_CHECK_CACHE
168 dnl
169 define(GNUPG_CHECK_CACHE,
170   [ AC_MSG_CHECKING(cached information)
171     gnupg_hostcheck="$target"
172     AC_CACHE_VAL(gnupg_cv_hostcheck, [ gnupg_cv_hostcheck="$gnupg_hostcheck" ])
173     if test "$gnupg_cv_hostcheck" != "$gnupg_hostcheck"; then
174         AC_MSG_RESULT(changed)
175         AC_MSG_WARN(config.cache exists!)
176         AC_MSG_ERROR(you must do 'make distclean' first to compile for
177                  different target or different parameters.)
178     else
179         AC_MSG_RESULT(ok)
180     fi
181   ])
182
183
184 ######################################################################
185 # Check for -fPIC etc (taken from libtool)
186 # This sets CFLAGS_PIC to the required flags
187 #           NO_PIC to yes if it is not possible to
188 #                  generate PIC
189 ######################################################################
190 dnl GNUPG_CHECK_PIC
191 dnl
192 define(GNUPG_CHECK_PIC,
193   [ AC_MSG_CHECKING(for option to create PIC)
194     CFLAGS_PIC=
195     NO_PIC=no
196     if test "$cross_compiling" = yes; then
197         AC_MSG_RESULT(assume none)
198     else
199         if test "$GCC" = yes; then
200             CFLAGS_PIC="-fPIC"
201         else
202             case "$host_os" in
203               aix3* | aix4*)
204                 # All rs/6000 code is PIC
205                 # but is there any non-rs/6000 AIX platform?
206                 ;;
207
208               hpux9* | hpux10*)
209                 CFLAGS_PIC="+Z"
210                 ;;
211
212               irix5* | irix6*)
213                 # PIC (with -KPIC) is the default.
214                 ;;
215
216               osf3* | osf4*)
217                 # FIXME - pic_flag is probably required for
218                 # hppa*-osf* and i860-osf*
219                 ;;
220
221               sco3.2v5*)
222                 CFLAGS_PIC='-Kpic'
223                 ;;
224
225               solaris2* | solaris7* )
226                 CFLAGS_PIC='-KPIC'
227                 ;;
228
229               sunos4*)
230                 CFLAGS_PIC='-PIC'
231                 ;;
232
233               *)
234                 NO_PIC=yes
235                 ;;
236             esac
237         fi
238
239         case "$host_cpu" in
240         rs6000 | powerpc | powerpcle)
241           # Yippee! All RS/6000 and PowerPC code is position-independent.
242           CFLAGS_PIC=""
243           ;;
244         esac
245
246         if test "$NO_PIC" = yes; then
247             AC_MSG_RESULT(not possible)
248         else
249             if test -z "$CFLAGS_PIC"; then
250                AC_MSG_RESULT(none)
251             else
252                 AC_MSG_RESULT($CFLAGS_PIC)
253             fi
254         fi
255     fi
256   ])
257
258
259 ######################################################################
260 # Check for export-dynamic flag
261 # This sets CFLAGS_EXPORTDYNAMIC to the required flags
262 ######################################################################
263 dnl GNUPG_CHECK_EXPORTDYNAMIC
264 dnl
265 define(GNUPG_CHECK_EXPORTDYNAMIC,
266   [ AC_MSG_CHECKING(how to specify -export-dynamic)
267     if test "$cross_compiling" = yes; then
268       AC_MSG_RESULT(assume none)
269       CFLAGS_EXPORTDYNAMIC=""
270     else
271       AC_CACHE_VAL(gnupg_cv_export_dynamic,[
272       if AC_TRY_COMMAND([${CC-cc} $CFLAGS -Wl,--version 2>&1 |
273                                           grep "GNU ld" >/dev/null]); then
274           # using gnu's linker
275           gnupg_cv_export_dynamic="-Wl,-export-dynamic"
276       else
277           case "$host_os" in
278             hpux* )
279               gnupg_cv_export_dynamic="-Wl,-E"
280               ;;
281             * )
282               gnupg_cv_export_dynamic=""
283               ;;
284           esac
285       fi
286       ])
287       AC_MSG_RESULT($gnupg_cv_export_dynamic)
288       CFLAGS_EXPORTDYNAMIC="$gnupg_cv_export_dynamic"
289     fi
290   ])
291
292 #####################################################################
293 # Check for SysV IPC  (from GIMP)
294 #   And see whether we have a SHM_LOCK (FreeBSD does not have it).
295 #####################################################################
296 dnl GNUPG_CHECK_IPC
297 dnl
298 define(GNUPG_CHECK_IPC,
299    [ AC_CHECK_HEADERS(sys/ipc.h sys/shm.h)
300      if test "$ac_cv_header_sys_shm_h" = "yes"; then
301        AC_MSG_CHECKING(whether IPC_RMID allowes subsequent attaches)
302        AC_CACHE_VAL(gnupg_cv_ipc_rmid_deferred_release,
303           AC_TRY_RUN([
304              #include <sys/types.h>
305              #include <sys/ipc.h>
306              #include <sys/shm.h>
307              int main()
308              {
309                int id;
310                char *shmaddr;
311              id = shmget (IPC_PRIVATE, 4, IPC_CREAT | 0777);
312              if (id == -1)
313                exit (2);
314                shmaddr = shmat (id, 0, 0);
315                shmctl (id, IPC_RMID, 0);
316                if ((char*) shmat (id, 0, 0) == (char*) -1)
317                {
318                  shmdt (shmaddr);
319                  exit (1);
320                }
321                shmdt (shmaddr);
322                shmdt (shmaddr);
323                exit (0);
324              }
325          ],
326          gnupg_cv_ipc_rmid_deferred_release="yes",
327          gnupg_cv_ipc_rmid_deferred_release="no",
328          gnupg_cv_ipc_rmid_deferred_release="assume-no")
329        )
330        if test "$gnupg_cv_ipc_rmid_deferred_release" = "yes"; then
331            AC_DEFINE(IPC_RMID_DEFERRED_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
340
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)
355          AC_MSG_RESULT(yes)
356        else
357          AC_MSG_RESULT(no)
358        fi
359      fi
360    ])
361
362
363 ######################################################################
364 # Check whether mlock is broken (hpux 10.20 raises a SIGBUS if mlock
365 # is not called from uid 0 (not tested whether uid 0 works)
366 # For DECs Tru64 we have also to check whether mlock is in librt
367 # mlock is there a macro using memlk()
368 ######################################################################
369 dnl GNUPG_CHECK_MLOCK
370 dnl
371 define(GNUPG_CHECK_MLOCK,
372   [ AC_CHECK_FUNCS(mlock)
373     if test "$ac_cv_func_mlock" = "no"; then
374         AC_CHECK_HEADERS(sys/mman.h)
375         if test "$ac_cv_header_sys_mman_h" = "yes"; then
376             # Add librt to LIBS:
377             AC_CHECK_LIB(rt, memlk)
378             AC_CACHE_CHECK([whether mlock is in sys/mman.h],
379                             gnupg_cv_mlock_is_in_sys_mman,
380                 [AC_TRY_LINK([
381                     #include <assert.h>
382                     #ifdef HAVE_SYS_MMAN_H
383                     #include <sys/mman.h>
384                     #endif
385                 ], [
386                     int i;
387                     
388                     /* glibc defines this for functions which it implements
389                      * to always fail with ENOSYS.  Some functions are actually
390                      * named something starting with __ and the normal name
391                      * is an alias.  */
392                     #if defined (__stub_mlock) || defined (__stub___mlock)
393                     choke me
394                     #else
395                     mlock(&i, 4);
396                     #endif
397                     ; return 0;
398                 ],
399                 gnupg_cv_mlock_is_in_sys_mman=yes,
400                 gnupg_cv_mlock_is_in_sys_mman=no)])
401             if test "$gnupg_cv_mlock_is_in_sys_mman" = "yes"; then
402                 AC_DEFINE(HAVE_MLOCK)
403             fi
404         fi
405     fi
406     if test "$ac_cv_func_mlock" = "yes"; then
407         AC_MSG_CHECKING(whether mlock is broken)
408           AC_CACHE_VAL(gnupg_cv_have_broken_mlock,
409              AC_TRY_RUN([
410                 #include <stdlib.h>
411                 #include <unistd.h>
412                 #include <errno.h>
413                 #include <sys/mman.h>
414                 #include <sys/types.h>
415                 #include <fcntl.h>
416
417                 int main()
418                 {
419                     char *pool;
420                     int err;
421                     long int pgsize = getpagesize();
422
423                     pool = malloc( 4096 + pgsize );
424                     if( !pool )
425                         return 2;
426                     pool += (pgsize - ((long int)pool % pgsize));
427
428                     err = mlock( pool, 4096 );
429                     if( !err || errno == EPERM )
430                         return 0; /* okay */
431
432                     return 1;  /* hmmm */
433                 }
434
435             ],
436             gnupg_cv_have_broken_mlock="no",
437             gnupg_cv_have_broken_mlock="yes",
438             gnupg_cv_have_broken_mlock="assume-no"
439            )
440          )
441          if test "$gnupg_cv_have_broken_mlock" = "yes"; then
442              AC_DEFINE(HAVE_BROKEN_MLOCK)
443              AC_MSG_RESULT(yes)
444          else
445             if test "$gnupg_cv_have_broken_mlock" = "no"; then
446                 AC_MSG_RESULT(no)
447             else
448                 AC_MSG_RESULT(assuming no)
449             fi
450          fi
451     fi
452   ])
453
454
455
456 ################################################################
457 # GNUPG_PROG_NM - find the path to a BSD-compatible name lister
458 ################################################################
459 AC_DEFUN(GNUPG_PROG_NM,
460 [AC_MSG_CHECKING([for BSD-compatible nm])
461 AC_CACHE_VAL(ac_cv_path_NM,
462 [if test -n "$NM"; then
463   # Let the user override the test.
464   ac_cv_path_NM="$NM"
465 else
466   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
467   for ac_dir in /usr/ucb /usr/ccs/bin $PATH /bin; do
468     test -z "$ac_dir" && ac_dir=.
469     if test -f $ac_dir/nm; then
470       # Check to see if the nm accepts a BSD-compat flag.
471       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
472       #   nm: unknown option "B" ignored
473       if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
474         ac_cv_path_NM="$ac_dir/nm -B"
475       elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
476         ac_cv_path_NM="$ac_dir/nm -p"
477       else
478         ac_cv_path_NM="$ac_dir/nm"
479       fi
480       break
481     fi
482   done
483   IFS="$ac_save_ifs"
484   test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
485 fi])
486 NM="$ac_cv_path_NM"
487 AC_MSG_RESULT([$NM])
488 AC_SUBST(NM)
489 ])
490
491 # GNUPG_SYS_NM_PARSE - Check for command ro grab the raw symbol name followed
492 # by C symbol name from nm.
493 AC_DEFUN(GNUPG_SYS_NM_PARSE,
494 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
495 AC_REQUIRE([GNUPG_PROG_NM])dnl
496 # Check for command to grab the raw symbol name followed by C symbol from nm.
497 AC_MSG_CHECKING([command to parse $NM output])
498 AC_CACHE_VAL(ac_cv_sys_global_symbol_pipe,
499 [# These are sane defaults that work on at least a few old systems.
500 # {They come from Ultrix.  What could be older than Ultrix?!! ;)}
501
502 changequote(,)dnl
503 # Character class describing NM global symbol codes.
504 ac_symcode='[BCDEGRSTU]'
505
506 # Regexp to match symbols that can be accessed directly from C.
507 ac_sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
508
509 # Transform the above into a raw symbol and a C symbol.
510 ac_symxfrm='\1 \1'
511
512 # Define system-specific variables.
513 case "$host_os" in
514 aix*)
515   ac_symcode='[BCDTU]'
516   ;;
517 freebsd* | netbsd* | openbsd* | bsdi* | sunos* | cygwin32* | mingw32*)
518   ac_sympat='_\([_A-Za-z][_A-Za-z0-9]*\)'
519   ac_symxfrm='_\1 \1'
520   ;;
521 irix*)
522   # Cannot use undefined symbols on IRIX because inlined functions mess us up.
523   ac_symcode='[BCDEGRST]'
524   ;;
525 solaris*)
526   ac_symcode='[BDTU]'
527   ;;
528 esac
529
530 # If we're using GNU nm, then use its standard symbol codes.
531 if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then
532   ac_symcode='[ABCDGISTUW]'
533 fi
534
535 case "$host_os" in
536 cygwin32* | mingw32*)
537   # We do not want undefined symbols on cygwin32.  The user must
538   # arrange to define them via -l arguments.
539   ac_symcode='[ABCDGISTW]'
540   ;;
541 esac
542 changequote([,])dnl
543
544 # Write the raw and C identifiers.
545 ac_cv_sys_global_symbol_pipe="sed -n -e 's/^.* $ac_symcode $ac_sympat$/$ac_symxfrm/p'"
546
547 # Check to see that the pipe works correctly.
548 ac_pipe_works=no
549 cat > conftest.$ac_ext <<EOF
550 #ifdef __cplusplus
551 extern "C" {
552 #endif
553 char nm_test_var;
554 void nm_test_func(){}
555 #ifdef __cplusplus
556 }
557 #endif
558 int main(){nm_test_var='a';nm_test_func;return 0;}
559 EOF
560 if AC_TRY_EVAL(ac_compile); then
561   # Now try to grab the symbols.
562   ac_nlist=conftest.nm
563   if AC_TRY_EVAL(NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
564
565     # Try sorting and uniquifying the output.
566     if sort "$ac_nlist" | uniq > "$ac_nlist"T; then
567       mv -f "$ac_nlist"T "$ac_nlist"
568       ac_wcout=`wc "$ac_nlist" 2>/dev/null`
569 changequote(,)dnl
570       ac_count=`echo "X$ac_wcout" | sed -e 's,^X,,' -e 's/^[    ]*\([0-9][0-9]*\).*$/\1/'`
571 changequote([,])dnl
572       (test "$ac_count" -ge 0) 2>/dev/null || ac_count=-1
573     else
574       rm -f "$ac_nlist"T
575       ac_count=-1
576     fi
577
578     # Make sure that we snagged all the symbols we need.
579     if egrep ' nm_test_var$' "$ac_nlist" >/dev/null; then
580       if egrep ' nm_test_func$' "$ac_nlist" >/dev/null; then
581         cat <<EOF > conftest.c
582 #ifdef __cplusplus
583 extern "C" {
584 #endif
585
586 EOF
587         # Now generate the symbol file.
588         sed 's/^.* \(.*\)$/extern char \1;/' < "$ac_nlist" >> conftest.c
589
590         cat <<EOF >> conftest.c
591 #if defined (__STDC__) && __STDC__
592 # define __ptr_t void *
593 #else
594 # define __ptr_t char *
595 #endif
596
597 /* The number of symbols in dld_preloaded_symbols, -1 if unsorted. */
598 int dld_preloaded_symbol_count = $ac_count;
599
600 /* The mapping between symbol names and symbols. */
601 struct {
602   char *name;
603   __ptr_t address;
604 }
605 changequote(,)dnl
606 dld_preloaded_symbols[] =
607 changequote([,])dnl
608 {
609 EOF
610         sed 's/^\(.*\) \(.*\)$/  {"\1", (__ptr_t) \&\2},/' < "$ac_nlist" >> conftest.c
611         cat <<\EOF >> conftest.c
612   {0, (__ptr_t) 0}
613 };
614
615 #ifdef __cplusplus
616 }
617 #endif
618 EOF
619         # Now try linking the two files.
620         mv conftest.$ac_objext conftestm.$ac_objext
621         ac_save_LIBS="$LIBS"
622         ac_save_CFLAGS="$CFLAGS"
623         LIBS="conftestm.$ac_objext"
624         CFLAGS="$CFLAGS$no_builtin_flag"
625         if AC_TRY_EVAL(ac_link) && test -s conftest; then
626           ac_pipe_works=yes
627         else
628           echo "configure: failed program was:" >&AC_FD_CC
629           cat conftest.c >&AC_FD_CC
630         fi
631         LIBS="$ac_save_LIBS"
632         CFLAGS="$ac_save_CFLAGS"
633       else
634         echo "cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
635       fi
636     else
637       echo "cannot find nm_test_var in $ac_nlist" >&AC_FD_CC
638     fi
639   else
640     echo "cannot run $ac_cv_sys_global_symbol_pipe" >&AC_FD_CC
641   fi
642 else
643   echo "$progname: failed program was:" >&AC_FD_CC
644   cat conftest.c >&AC_FD_CC
645 fi
646 rm -rf conftest*
647
648 # Do not use the global_symbol_pipe unless it works.
649 test "$ac_pipe_works" = yes || ac_cv_sys_global_symbol_pipe=
650 ])
651
652 ac_result=yes
653 if test -z "$ac_cv_sys_global_symbol_pipe"; then
654    ac_result=no
655 fi
656 AC_MSG_RESULT($ac_result)
657 ])
658
659 # GNUPG_SYS_LIBTOOL_CYGWIN32 - find tools needed on cygwin32
660 AC_DEFUN(GNUPG_SYS_LIBTOOL_CYGWIN32,
661 [AC_CHECK_TOOL(DLLTOOL, dlltool, false)
662 AC_CHECK_TOOL(AS, as, false)
663 ])
664
665 # GNUPG_SYS_SYMBOL_UNDERSCORE - does the compiler prefix global symbols
666 #                              with an underscore?
667 AC_DEFUN(GNUPG_SYS_SYMBOL_UNDERSCORE,
668 [tmp_do_check="no"
669 case "${target}" in
670     i386-emx-os2 | i[3456]86-pc-os2*emx | i386-pc-msdosdjgpp)
671         ac_cv_sys_symbol_underscore=yes
672         ;;
673     *)
674       if test "$cross_compiling" = yes; then
675          ac_cv_sys_symbol_underscore=yes
676       else
677          tmp_do_check="yes"
678       fi
679        ;;
680 esac
681
682 if test "$tmp_do_check" = "yes"; then
683 AC_REQUIRE([GNUPG_PROG_NM])dnl
684 AC_REQUIRE([GNUPG_SYS_NM_PARSE])dnl
685 AC_MSG_CHECKING([for _ prefix in compiled symbols])
686 AC_CACHE_VAL(ac_cv_sys_symbol_underscore,
687 [ac_cv_sys_symbol_underscore=no
688 cat > conftest.$ac_ext <<EOF
689 void nm_test_func(){}
690 int main(){nm_test_func;return 0;}
691 EOF
692 if AC_TRY_EVAL(ac_compile); then
693   # Now try to grab the symbols.
694   ac_nlist=conftest.nm
695   if AC_TRY_EVAL(NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
696     # See whether the symbols have a leading underscore.
697     if egrep '^_nm_test_func' "$ac_nlist" >/dev/null; then
698       ac_cv_sys_symbol_underscore=yes
699     else
700       if egrep '^nm_test_func ' "$ac_nlist" >/dev/null; then
701         :
702       else
703         echo "configure: cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
704       fi
705     fi
706   else
707     echo "configure: cannot run $ac_cv_sys_global_symbol_pipe" >&AC_FD_CC
708   fi
709 else
710   echo "configure: failed program was:" >&AC_FD_CC
711   cat conftest.c >&AC_FD_CC
712 fi
713 rm -rf conftest*
714 ])
715 else
716 AC_MSG_CHECKING([for _ prefix in compiled symbols])
717 fi
718 AC_MSG_RESULT($ac_cv_sys_symbol_underscore)
719 if test x$ac_cv_sys_symbol_underscore = xyes; then
720   AC_DEFINE(WITH_SYMBOL_UNDERSCORE,1,
721   [define if compiled symbols have a leading underscore])
722 fi
723 ])
724
725 dnl Stolen from gcc
726 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
727 dnl of the usual 2.
728 AC_DEFUN(GNUPG_FUNC_MKDIR_TAKES_ONE_ARG,
729 [AC_CHECK_HEADERS(sys/stat.h unistd.h direct.h)
730 AC_CACHE_CHECK([if mkdir takes one argument], gnupg_cv_mkdir_takes_one_arg,
731 [AC_TRY_COMPILE([
732 #include <sys/types.h>
733 #ifdef HAVE_SYS_STAT_H
734 # include <sys/stat.h>
735 #endif
736 #ifdef HAVE_UNISTD_H
737 # include <unistd.h>
738 #endif
739 #ifdef HAVE_DIRECT_H
740 # include <direct.h>
741 #endif], [mkdir ("foo", 0);],
742         gnupg_cv_mkdir_takes_one_arg=no, gnupg_cv_mkdir_takes_one_arg=yes)])
743 if test $gnupg_cv_mkdir_takes_one_arg = yes ; then
744   AC_DEFINE(MKDIR_TAKES_ONE_ARG)
745 fi
746 ])
747
748 dnl GPH_PROG_DOCBOOK()
749 dnl Check whether we have the needed Docbook environment
750 dnl and issue a warning if this is not the case.
751 dnl
752 dnl This test defines these variables for substitution:
753 dnl    DB2HTML - command used to convert Docbook to HTML
754 dnl    DB2TEX  - command used to convert Docbook to TeX
755 dnl    DB2MAN  - command used to convert Docbook to man pages
756 dnl    JADE    - command to invoke jade
757 dnl    JADETEX - command to invoke jadetex
758 dnl    DSL_FOR_HTML - the stylesheet used to for the Docbook->HTML conversion
759 dnl The following make conditionals are defined
760 dnl    HAVE_DB2MAN  - defined when db2man is available
761 dnl    HAVE_DB2TEX  - defined when db2tex is available
762 dnl    HAVE_DB2HTML - defined when db2html is available
763 dnl    HAVE_DOCBOOK - defined when the entire Docbook environment is present
764 dnl    HAVE_JADE    - defined when jade is installed
765 dnl    HAVE_JADETEX - defined when jadetex is installed
766 dnl
767 dnl (wk 2000-02-17)
768 dnl
769 AC_DEFUN(GPH_PROG_DOCBOOK,
770   [  AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
771      all=yes
772      AC_PATH_PROG(DB2MAN, docbook-to-man, no)
773      test "$DB2MAN" = no && all=no
774      AM_CONDITIONAL(HAVE_DB2MAN, test "$DB2MAN" != no )
775
776      AC_PATH_PROG(JADE, jade, no)
777      test "$JADE" = no && all=no
778      AM_CONDITIONAL(HAVE_JADE, test "$JADE" != no )
779
780      AC_PATH_PROG(JADETEX, jadetex, no)
781      test "$JADETEX" = no && all=no
782      AM_CONDITIONAL(HAVE_JADETEX, test "$JADETEX" != no )
783
784      stylesheet_dirs='
785 /usr/local/lib/dsssl/stylesheets/docbook
786 /usr/local/share/dsssl/stylesheets/docbook
787 /usr/local/lib/sgml/stylesheet/dsssl/docbook/nwalsh
788 /usr/local/share/sgml/stylesheet/dsssl/docbook/nwalsh
789 /usr/lib/dsssl/stylesheets/docbook
790 /usr/share/dsssl/stylesheets/docbook
791 /usr/lib/sgml/stylesheet/dsssl/docbook/nwalsh
792 /usr/share/sgml/stylesheet/dsssl/docbook/nwalsh
793 '
794
795     AC_MSG_CHECKING(for TeX stylesheet)
796     dsl=none
797     for d in ${stylesheet_dirs}; do
798         file=${d}/print/docbook.dsl
799         if test -f $file; then
800             dsl=$file
801             break
802         fi
803     done
804     AC_MSG_RESULT([$dsl])
805     okay=no
806     if test $dsl = none ; then
807        DB2TEX="$missing_dir/missing db2tex"
808        all=no
809     else
810        DB2TEX="$JADE -t tex -i tex -d $dsl"
811        okay=yes
812     fi
813     AC_SUBST(DB2TEX)
814     AM_CONDITIONAL(HAVE_DB2TEX, test $okay = yes )
815
816     if ( $ac_aux_dir/db2html.in --version) < /dev/null > /dev/null 2>&1; then
817         :
818     else
819         AC_ERROR([needed $ac_aux_dir/db2html.in not found])
820     fi
821
822     AC_MSG_CHECKING(for HTML stylesheet)
823     DSL_FOR_HTML="none"
824     for d in ${stylesheet_dirs}; do
825         file=${d}/html/docbook.dsl
826         if test -f $file; then
827             DSL_FOR_HTML=$file
828             break
829         fi
830     done
831     AC_MSG_RESULT([$DSL_FOR_HTML])
832     okay=no
833     if test $DSL_FOR_HTML = none ; then
834        DB2HTML="$missing_dir/missing db2html"
835        all=no
836     else
837        DB2HTML="`cd $ac_aux_dir && pwd`/db2html --copyfiles"
838        okay=yes
839     fi
840     AC_SUBST(DB2HTML)
841     AC_SUBST(DSL_FOR_HTML)
842     AM_CONDITIONAL(HAVE_DB2HTML, test $okay = yes )
843
844     AM_CONDITIONAL(HAVE_DOCBOOK, test "$all" != yes )
845     if test $all = no ; then
846         AC_MSG_WARN([[
847 ***
848 *** It seems that the Docbook environment is not installed as required.
849 *** We will try to build everything,  but if you either touch some files
850 *** or use a bogus make tool, you may run into problems.
851 *** Docbook is normally only needed to build the documentation.
852 ***]])
853     fi
854   ])
855
856
857
858
859 dnl *-*wedit:notab*-*  Please keep this as the last line.