1 dnl macros to configure Libgcrypt
2 dnl Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
4 dnl This file is part of Libgcrypt.
6 dnl Libgcrypt is free software; you can redistribute it and/or modify
7 dnl it under the terms of the GNU Lesser General Public License as
8 dnl published by the Free Software Foundation; either version 2.1 of
9 dnl the License, or (at your option) any later version.
11 dnl Libgcrypt 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 Lesser General Public License for more details.
16 dnl You should have received a copy of the GNU Lesser General Public
17 dnl License 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
22 dnl GNUPG_MSG_PRINT(STRING)
25 define(GNUPG_MSG_PRINT,
26 [ echo $ac_n "$1"" $ac_c" 1>&AS_MESSAGE_FD([])
30 dnl GNUPG_CHECK_TYPEDEF(TYPE, HAVE_NAME)
31 dnl Check whether a typedef exists and create a #define $2 if it exists
33 AC_DEFUN(GNUPG_CHECK_TYPEDEF,
34 [ AC_MSG_CHECKING(for $1 typedef)
35 AC_CACHE_VAL(gnupg_cv_typedef_$1,
36 [AC_TRY_COMPILE([#define _GNU_SOURCE 1
38 #include <sys/types.h>], [
41 ], gnupg_cv_typedef_$1=yes, gnupg_cv_typedef_$1=no )])
42 AC_MSG_RESULT($gnupg_cv_typedef_$1)
43 if test "$gnupg_cv_typedef_$1" = yes; then
44 AC_DEFINE($2,1,[Defined if a `]$1[' is typedef'd])
49 dnl GNUPG_FIX_HDR_VERSION(FILE, NAME)
50 dnl Make the version number in gcrypt/gcrypt.h the same as the one here.
51 dnl (this is easier than to have a .in file just for one substitution)
52 dnl We must use a temp file in the current directory because make distcheck
53 dnl install all sourcefiles RO.
55 AC_DEFUN(GNUPG_FIX_HDR_VERSION,
56 [ sed "s/^#define $2 \".*/#define $2 \"$VERSION\"/" $srcdir/$1 > fixhdr.tmp
57 if cmp -s $srcdir/$1 fixhdr.tmp 2>/dev/null; then
61 if mv fixhdr.tmp $srcdir/$1 ; then
66 *** Failed to fix the version string macro $2 in $1.
67 *** The old file has been saved as fixhdr.tmp
70 AC_MSG_WARN([fixed the $2 macro in $1])
75 dnl GNUPG_CHECK_GNUMAKE
77 AC_DEFUN(GNUPG_CHECK_GNUMAKE,
79 if ${MAKE-make} --version 2>/dev/null | grep '^GNU ' >/dev/null 2>&1; then
84 *** It seems that you are not using GNU make. Some make tools have serious
85 *** flaws and you may not be able to build this software at all. Before you
86 *** complain, please try GNU make: GNU make is easy to build and available
87 *** at all GNU archives. It is always available from ftp.gnu.org:/gnu/make.
92 dnl GNUPG_CHECK_FAQPROG
94 AC_DEFUN(GNUPG_CHECK_FAQPROG,
95 [ AC_MSG_CHECKING(for faqprog.pl)
96 if faqprog.pl -V 2>/dev/null | grep '^faqprog.pl ' >/dev/null 2>&1; then
103 AC_MSG_RESULT($working_faqprog)
105 AM_CONDITIONAL(WORKING_FAQPROG, test "$working_faqprog" = "yes" )
107 if test $working_faqprog = no; then
110 *** It seems that the faqprog.pl program is not installed.
111 *** Unless you do not change the source of the FAQs it is not required.
112 *** The working version of this utility should be available at:
113 *** ftp://ftp.gnupg.org/pub/gcrypt/contrib/faqprog.pl
120 dnl GNUPG_CHECK_ENDIAN
121 dnl define either LITTLE_ENDIAN_HOST or BIG_ENDIAN_HOST
123 define(GNUPG_CHECK_ENDIAN,
124 [ if test "$cross_compiling" = yes; then
125 AC_MSG_WARN(cross compiling; assuming little endianess)
127 AC_MSG_CHECKING(endianess)
128 AC_CACHE_VAL(gnupg_cv_c_endian,
129 [ gnupg_cv_c_endian=unknown
130 # See if sys/param.h defines the BYTE_ORDER macro.
131 AC_TRY_COMPILE([#include <sys/types.h>
132 #include <sys/param.h>], [
133 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
135 #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
136 AC_TRY_COMPILE([#include <sys/types.h>
137 #include <sys/param.h>], [
138 #if BYTE_ORDER != BIG_ENDIAN
140 #endif], gnupg_cv_c_endian=big, gnupg_cv_c_endian=little)])
141 if test "$gnupg_cv_c_endian" = unknown; then
142 AC_TRY_RUN([main () {
143 /* Are we little or big endian? From Harbison&Steele. */
147 char c[sizeof (long)];
150 exit (u.c[sizeof (long) - 1] == 1);
152 gnupg_cv_c_endian=little,
153 gnupg_cv_c_endian=big,
154 gnupg_cv_c_endian=little
158 AC_MSG_RESULT([$gnupg_cv_c_endian])
159 if test "$gnupg_cv_c_endian" = little; then
160 AC_DEFINE(LITTLE_ENDIAN_HOST,1,
161 [Defined if the host has little endian byte ordering])
163 AC_DEFINE(BIG_ENDIAN_HOST,1,
164 [Defined if the host has big endian byte ordering])
168 dnl GNUPG_CHECK_CACHE
170 define(GNUPG_CHECK_CACHE,
171 [ AC_MSG_CHECKING(cached information)
172 gnupg_hostcheck="$target"
173 AC_CACHE_VAL(gnupg_cv_hostcheck, [ gnupg_cv_hostcheck="$gnupg_hostcheck" ])
174 if test "$gnupg_cv_hostcheck" != "$gnupg_hostcheck"; then
175 AC_MSG_RESULT(changed)
176 AC_MSG_WARN(config.cache exists!)
177 AC_MSG_ERROR(you must do 'make distclean' first to compile for
178 different target or different parameters.)
185 ######################################################################
186 # Check for -fPIC etc (taken from libtool)
187 # This sets CFLAGS_PIC to the required flags
188 # NO_PIC to yes if it is not possible to
190 ######################################################################
193 define(GNUPG_CHECK_PIC,
194 [ AC_MSG_CHECKING(for option to create PIC)
197 if test "$cross_compiling" = yes; then
198 AC_MSG_RESULT(assume none)
200 if test "$GCC" = yes; then
205 # All rs/6000 code is PIC
206 # but is there any non-rs/6000 AIX platform?
214 # PIC (with -KPIC) is the default.
218 # FIXME - pic_flag is probably required for
219 # hppa*-osf* and i860-osf*
226 solaris2* | solaris7* )
241 rs6000 | powerpc | powerpcle)
242 # Yippee! All RS/6000 and PowerPC code is position-independent.
247 if test "$NO_PIC" = yes; then
248 AC_MSG_RESULT(not possible)
250 if test -z "$CFLAGS_PIC"; then
253 AC_MSG_RESULT($CFLAGS_PIC)
260 ######################################################################
261 # Check for export-dynamic flag
262 # This sets CFLAGS_EXPORTDYNAMIC to the required flags
263 ######################################################################
264 dnl GNUPG_CHECK_EXPORTDYNAMIC
266 define(GNUPG_CHECK_EXPORTDYNAMIC,
267 [ AC_MSG_CHECKING(how to specify -export-dynamic)
268 if test "$cross_compiling" = yes; then
269 AC_MSG_RESULT(assume none)
270 CFLAGS_EXPORTDYNAMIC=""
272 AC_CACHE_VAL(gnupg_cv_export_dynamic,[
273 if AC_TRY_COMMAND([${CC-cc} $CFLAGS -Wl,--version 2>&1 |
274 grep "GNU ld" >/dev/null]); then
276 gnupg_cv_export_dynamic="-Wl,-export-dynamic"
280 gnupg_cv_export_dynamic="-Wl,-E"
283 gnupg_cv_export_dynamic=""
288 AC_MSG_RESULT($gnupg_cv_export_dynamic)
289 CFLAGS_EXPORTDYNAMIC="$gnupg_cv_export_dynamic"
293 #####################################################################
294 # Check for SysV IPC (from GIMP)
295 # And see whether we have a SHM_LOCK (FreeBSD does not have it).
296 #####################################################################
299 define(GNUPG_CHECK_IPC,
300 [ AC_CHECK_HEADERS(sys/ipc.h sys/shm.h)
301 if test "$ac_cv_header_sys_shm_h" = "yes"; then
302 AC_MSG_CHECKING(whether IPC_RMID allowes subsequent attaches)
303 AC_CACHE_VAL(gnupg_cv_ipc_rmid_deferred_release,
305 #include <sys/types.h>
312 id = shmget (IPC_PRIVATE, 4, IPC_CREAT | 0777);
315 shmaddr = shmat (id, 0, 0);
316 shmctl (id, IPC_RMID, 0);
317 if ((char*) shmat (id, 0, 0) == (char*) -1)
327 gnupg_cv_ipc_rmid_deferred_release="yes",
328 gnupg_cv_ipc_rmid_deferred_release="no",
329 gnupg_cv_ipc_rmid_deferred_release="assume-no")
331 if test "$gnupg_cv_ipc_rmid_deferred_release" = "yes"; then
332 AC_DEFINE(IPC_RMID_DEFERRED_RELEASE,1,
333 [Defined if we can do a deferred shm release])
336 if test "$gnupg_cv_ipc_rmid_deferred_release" = "no"; then
339 AC_MSG_RESULT([assuming no])
343 AC_MSG_CHECKING(whether SHM_LOCK is available)
344 AC_CACHE_VAL(gnupg_cv_ipc_have_shm_lock,
345 AC_TRY_COMPILE([#include <sys/types.h>
347 #include <sys/shm.h>],[
349 shmctl(shm_id, SHM_LOCK, 0);
351 gnupg_cv_ipc_have_shm_lock="yes",
352 gnupg_cv_ipc_have_shm_lock="no"
355 if test "$gnupg_cv_ipc_have_shm_lock" = "yes"; then
356 AC_DEFINE(IPC_HAVE_SHM_LOCK,1,
357 [Defined if a SysV shared memory supports the LOCK flag])
366 ######################################################################
367 # Check whether mlock is broken (hpux 10.20 raises a SIGBUS if mlock
368 # is not called from uid 0 (not tested whether uid 0 works)
369 # For DECs Tru64 we have also to check whether mlock is in librt
370 # mlock is there a macro using memlk()
371 ######################################################################
372 dnl GNUPG_CHECK_MLOCK
374 define(GNUPG_CHECK_MLOCK,
375 [ AC_CHECK_FUNCS(mlock)
376 if test "$ac_cv_func_mlock" = "no"; then
377 AC_CHECK_HEADERS(sys/mman.h)
378 if test "$ac_cv_header_sys_mman_h" = "yes"; then
380 AC_CHECK_LIB(rt, memlk)
381 AC_CACHE_CHECK([whether mlock is in sys/mman.h],
382 gnupg_cv_mlock_is_in_sys_mman,
385 #ifdef HAVE_SYS_MMAN_H
386 #include <sys/mman.h>
391 /* glibc defines this for functions which it implements
392 * to always fail with ENOSYS. Some functions are actually
393 * named something starting with __ and the normal name
395 #if defined (__stub_mlock) || defined (__stub___mlock)
402 gnupg_cv_mlock_is_in_sys_mman=yes,
403 gnupg_cv_mlock_is_in_sys_mman=no)])
404 if test "$gnupg_cv_mlock_is_in_sys_mman" = "yes"; then
405 AC_DEFINE(HAVE_MLOCK,1,
406 [Defined if the system supports an mlock() call])
410 if test "$ac_cv_func_mlock" = "yes"; then
411 AC_MSG_CHECKING(whether mlock is broken)
412 AC_CACHE_VAL(gnupg_cv_have_broken_mlock,
417 #include <sys/mman.h>
418 #include <sys/types.h>
425 long int pgsize = getpagesize();
427 pool = malloc( 4096 + pgsize );
430 pool += (pgsize - ((long int)pool % pgsize));
432 err = mlock( pool, 4096 );
433 if( !err || errno == EPERM )
440 gnupg_cv_have_broken_mlock="no",
441 gnupg_cv_have_broken_mlock="yes",
442 gnupg_cv_have_broken_mlock="assume-no"
445 if test "$gnupg_cv_have_broken_mlock" = "yes"; then
446 AC_DEFINE(HAVE_BROKEN_MLOCK,1,
447 [Defined if the mlock() call does not work])
450 if test "$gnupg_cv_have_broken_mlock" = "no"; then
453 AC_MSG_RESULT(assuming no)
461 ################################################################
462 # GNUPG_PROG_NM - find the path to a BSD-compatible name lister
463 ################################################################
464 AC_DEFUN(GNUPG_PROG_NM,
465 [AC_MSG_CHECKING([for BSD-compatible nm])
466 AC_CACHE_VAL(ac_cv_path_NM,
467 [if test -n "$NM"; then
468 # Let the user override the test.
471 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
472 for ac_dir in /usr/ucb /usr/ccs/bin $PATH /bin; do
473 test -z "$ac_dir" && ac_dir=.
474 if test -f $ac_dir/nm; then
475 # Check to see if the nm accepts a BSD-compat flag.
476 # Adding the `sed 1q' prevents false positives on HP-UX, which says:
477 # nm: unknown option "B" ignored
478 if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
479 ac_cv_path_NM="$ac_dir/nm -B"
480 elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
481 ac_cv_path_NM="$ac_dir/nm -p"
483 ac_cv_path_NM="$ac_dir/nm"
489 test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
496 # GNUPG_SYS_NM_PARSE - Check for command ro grab the raw symbol name followed
497 # by C symbol name from nm.
498 AC_DEFUN(GNUPG_SYS_NM_PARSE,
499 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
500 AC_REQUIRE([GNUPG_PROG_NM])dnl
501 # Check for command to grab the raw symbol name followed by C symbol from nm.
502 AC_MSG_CHECKING([command to parse $NM output])
503 AC_CACHE_VAL(ac_cv_sys_global_symbol_pipe,
504 [# These are sane defaults that work on at least a few old systems.
505 # {They come from Ultrix. What could be older than Ultrix?!! ;)}
508 # Character class describing NM global symbol codes.
509 ac_symcode='[BCDEGRSTU]'
511 # Regexp to match symbols that can be accessed directly from C.
512 ac_sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
514 # Transform the above into a raw symbol and a C symbol.
517 # Define system-specific variables.
522 freebsd* | netbsd* | openbsd* | bsdi* | sunos* | cygwin32* | mingw32*)
523 ac_sympat='_\([_A-Za-z][_A-Za-z0-9]*\)'
527 # Cannot use undefined symbols on IRIX because inlined functions mess us up.
528 ac_symcode='[BCDEGRST]'
535 # If we're using GNU nm, then use its standard symbol codes.
536 if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then
537 ac_symcode='[ABCDGISTUW]'
541 cygwin32* | mingw32*)
542 # We do not want undefined symbols on cygwin32. The user must
543 # arrange to define them via -l arguments.
544 ac_symcode='[ABCDGISTW]'
549 # Write the raw and C identifiers.
550 ac_cv_sys_global_symbol_pipe="sed -n -e 's/^.* $ac_symcode $ac_sympat$/$ac_symxfrm/p'"
552 # Check to see that the pipe works correctly.
554 cat > conftest.$ac_ext <<EOF
559 void nm_test_func(){}
563 int main(){nm_test_var='a';nm_test_func;return 0;}
565 if AC_TRY_EVAL(ac_compile); then
566 # Now try to grab the symbols.
568 if AC_TRY_EVAL(NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
570 # Try sorting and uniquifying the output.
571 if sort "$ac_nlist" | uniq > "$ac_nlist"T; then
572 mv -f "$ac_nlist"T "$ac_nlist"
573 ac_wcout=`wc "$ac_nlist" 2>/dev/null`
575 ac_count=`echo "X$ac_wcout" | sed -e 's,^X,,' -e 's/^[ ]*\([0-9][0-9]*\).*$/\1/'`
577 (test "$ac_count" -ge 0) 2>/dev/null || ac_count=-1
583 # Make sure that we snagged all the symbols we need.
584 if egrep ' nm_test_var$' "$ac_nlist" >/dev/null; then
585 if egrep ' nm_test_func$' "$ac_nlist" >/dev/null; then
586 cat <<EOF > conftest.c
592 # Now generate the symbol file.
593 sed 's/^.* \(.*\)$/extern char \1;/' < "$ac_nlist" >> conftest.c
595 cat <<EOF >> conftest.c
596 #if defined (__STDC__) && __STDC__
597 # define __ptr_t void *
599 # define __ptr_t char *
602 /* The number of symbols in dld_preloaded_symbols, -1 if unsorted. */
603 int dld_preloaded_symbol_count = $ac_count;
605 /* The mapping between symbol names and symbols. */
611 dld_preloaded_symbols[] =
615 sed 's/^\(.*\) \(.*\)$/ {"\1", (__ptr_t) \&\2},/' < "$ac_nlist" >> conftest.c
616 cat <<\EOF >> conftest.c
624 # Now try linking the two files.
625 mv conftest.$ac_objext conftestm.$ac_objext
627 ac_save_CFLAGS="$CFLAGS"
628 LIBS="conftestm.$ac_objext"
629 CFLAGS="$CFLAGS$no_builtin_flag"
630 if AC_TRY_EVAL(ac_link) && test -s conftest; then
633 echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD()
634 cat conftest.c >&AS_MESSAGE_LOG_FD()
637 CFLAGS="$ac_save_CFLAGS"
639 echo "cannot find nm_test_func in $ac_nlist" >&AS_MESSAGE_LOG_FD()
642 echo "cannot find nm_test_var in $ac_nlist" >&AS_MESSAGE_LOG_FD()
645 echo "cannot run $ac_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD()
648 echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD()
649 cat conftest.c >&AS_MESSAGE_LOG_FD()
653 # Do not use the global_symbol_pipe unless it works.
654 test "$ac_pipe_works" = yes || ac_cv_sys_global_symbol_pipe=
658 if test -z "$ac_cv_sys_global_symbol_pipe"; then
661 AC_MSG_RESULT($ac_result)
664 # GNUPG_SYS_LIBTOOL_CYGWIN32 - find tools needed on cygwin32
665 AC_DEFUN(GNUPG_SYS_LIBTOOL_CYGWIN32,
666 [AC_CHECK_TOOL(DLLTOOL, dlltool, false)
667 AC_CHECK_TOOL(AS, as, false)
670 # GNUPG_SYS_SYMBOL_UNDERSCORE - does the compiler prefix global symbols
671 # with an underscore?
672 AC_DEFUN(GNUPG_SYS_SYMBOL_UNDERSCORE,
675 i386-emx-os2 | i[3456]86-pc-os2*emx | i386-pc-msdosdjgpp)
676 ac_cv_sys_symbol_underscore=yes
679 if test "$cross_compiling" = yes; then
680 ac_cv_sys_symbol_underscore=yes
687 if test "$tmp_do_check" = "yes"; then
688 AC_REQUIRE([GNUPG_PROG_NM])dnl
689 AC_REQUIRE([GNUPG_SYS_NM_PARSE])dnl
690 AC_MSG_CHECKING([for _ prefix in compiled symbols])
691 AC_CACHE_VAL(ac_cv_sys_symbol_underscore,
692 [ac_cv_sys_symbol_underscore=no
693 cat > conftest.$ac_ext <<EOF
694 void nm_test_func(){}
695 int main(){nm_test_func;return 0;}
697 if AC_TRY_EVAL(ac_compile); then
698 # Now try to grab the symbols.
700 if AC_TRY_EVAL(NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
701 # See whether the symbols have a leading underscore.
702 if egrep '^_nm_test_func' "$ac_nlist" >/dev/null; then
703 ac_cv_sys_symbol_underscore=yes
705 if egrep '^nm_test_func ' "$ac_nlist" >/dev/null; then
708 echo "configure: cannot find nm_test_func in $ac_nlist" >&AS_MESSAGE_LOG_FD()
712 echo "configure: cannot run $ac_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD()
715 echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD()
716 cat conftest.c >&AS_MESSAGE_LOG_FD()
721 AC_MSG_CHECKING([for _ prefix in compiled symbols])
723 AC_MSG_RESULT($ac_cv_sys_symbol_underscore)
724 if test x$ac_cv_sys_symbol_underscore = xyes; then
725 AC_DEFINE(WITH_SYMBOL_UNDERSCORE,1,
726 [define if compiled symbols have a leading underscore])
731 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
733 AC_DEFUN(GNUPG_FUNC_MKDIR_TAKES_ONE_ARG,
734 [AC_CHECK_HEADERS(sys/stat.h unistd.h direct.h)
735 AC_CACHE_CHECK([if mkdir takes one argument], gnupg_cv_mkdir_takes_one_arg,
737 #include <sys/types.h>
738 #ifdef HAVE_SYS_STAT_H
739 # include <sys/stat.h>
746 #endif], [mkdir ("foo", 0);],
747 gnupg_cv_mkdir_takes_one_arg=no, gnupg_cv_mkdir_takes_one_arg=yes)])
748 if test $gnupg_cv_mkdir_takes_one_arg = yes ; then
749 AC_DEFINE(MKDIR_TAKES_ONE_ARG,1,
750 [Defined if mkdir() does not take permission flags])
755 dnl GPH_PROG_DB2ANY()
756 dnl Check whether we have the needed Docbook tools
757 dnl and issue a warning if this is not the case.
759 dnl This test defines these variables for substitution:
760 dnl DB2ANY - script used to render Docbook
764 AC_DEFUN(GPH_PROG_DB2ANY,
765 [ AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
767 if $ac_aux_dir/db2any --systemcheck; then
769 DB2ANY=`cd $ac_aux_dir && pwd`/db2any
774 *** It seems that the Docbook environment is not installed as required.
775 *** We will try to build everything, but if you either touch some files
776 *** or use a bogus make tool, you may run into problems.
777 *** Docbook is normally only needed to build the documentation.
778 *** To further investigate the problem you can run the command
779 *** $ac_aux_dir/db2any --systemcheck --verbose
783 AM_CONDITIONAL(WORKING_DB2ANY, test "$working_db2any" != yes )