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