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