1 dnl macros to configure gnupg
2 dnl Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
4 dnl This file is part of GnuPG.
6 dnl GnuPG is free software; you can redistribute it and/or modify
7 dnl it under the terms of the GNU General Public License as published by
8 dnl the Free Software Foundation; either version 2 of the License, or
9 dnl (at your option) any later version.
11 dnl GnuPG is distributed in the hope that it will be useful,
12 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 dnl GNU General Public License for more details.
16 dnl You should have received a copy of the GNU General Public License
17 dnl along with this program; if not, write to the Free Software
18 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20 dnl GNUPG_MSG_PRINT(STRING)
23 define(GNUPG_MSG_PRINT,
24 [ echo $ac_n "$1"" $ac_c" 1>&AC_FD_MSG
28 dnl GNUPG_CHECK_TYPEDEF(TYPE, HAVE_NAME)
29 dnl Check whether a typedef exists and create a #define $2 if it exists
31 AC_DEFUN([GNUPG_CHECK_TYPEDEF],
32 [ AC_MSG_CHECKING(for $1 typedef)
33 AC_CACHE_VAL(gnupg_cv_typedef_$1,
34 [AC_TRY_COMPILE([#define _GNU_SOURCE 1
36 #include <sys/types.h>], [
39 ], gnupg_cv_typedef_$1=yes, gnupg_cv_typedef_$1=no )])
40 AC_MSG_RESULT($gnupg_cv_typedef_$1)
41 if test "$gnupg_cv_typedef_$1" = yes; then
42 AC_DEFINE($2,1,[Defined if a `]$1[' is typedef'd])
47 dnl GNUPG_CHECK_GNUMAKE
49 AC_DEFUN([GNUPG_CHECK_GNUMAKE],
51 if ${MAKE-make} --version 2>/dev/null | grep '^GNU ' >/dev/null 2>&1; then
56 *** It seems that you are not using GNU make. Some make tools have serious
57 *** flaws and you may not be able to build this software at all. Before you
58 *** complain, please try GNU make: GNU make is easy to build and available
59 *** at all GNU archives. It is always available from ftp.gnu.org:/gnu/make.
65 dnl GNUPG_CHECK_FAQPROG
67 AC_DEFUN([GNUPG_CHECK_FAQPROG],
68 [ AC_MSG_CHECKING(for faqprog.pl)
69 if faqprog.pl -V 2>/dev/null | grep '^faqprog.pl ' >/dev/null 2>&1; then
76 AC_MSG_RESULT($working_faqprog)
78 AM_CONDITIONAL(WORKING_FAQPROG, test "$working_faqprog" = "yes" )
80 dnl if test $working_faqprog = no; then
83 dnl *** It seems that the faqprog.pl program is not installed;
84 dnl *** however it is only needed if you want to change the FAQ.
85 dnl *** (faqprog.pl should be available at:
86 dnl *** ftp://ftp.gnupg.org/gcrypt/contrib/faqprog.pl )
87 dnl *** No need to worry about this warning.
92 dnl GNUPG_CHECK_DOCBOOK_TO_TEXI
94 AC_DEFUN([GNUPG_CHECK_DOCBOOK_TO_TEXI],
96 AC_CHECK_PROG(DOCBOOK_TO_TEXI, docbook2texi, yes, no)
97 AC_MSG_CHECKING(for sgml to texi tools)
99 if test "$ac_cv_prog_DOCBOOK_TO_TEXI" = yes; then
100 if sgml2xml -v /dev/null 2>&1 | grep 'SP version' >/dev/null 2>&1 ; then
101 working_sgmltotexi=yes
104 AC_MSG_RESULT($working_sgmltotexi)
105 AM_CONDITIONAL(HAVE_DOCBOOK_TO_TEXI, test "$working_sgmltotexi" = "yes" )
109 dnl GNUPG_CHECK_ENDIAN
110 dnl define either LITTLE_ENDIAN_HOST or BIG_ENDIAN_HOST
112 define([GNUPG_CHECK_ENDIAN],
114 tmp_assumed_endian=big
115 if test "$cross_compiling" = yes; then
118 tmp_assumed_endian=little
123 AC_MSG_WARN(cross compiling; assuming $tmp_assumed_endian endianess)
125 AC_MSG_CHECKING(endianess)
126 AC_CACHE_VAL(gnupg_cv_c_endian,
127 [ gnupg_cv_c_endian=unknown
128 # See if sys/param.h defines the BYTE_ORDER macro.
129 AC_TRY_COMPILE([#include <sys/types.h>
130 #include <sys/param.h>], [
131 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
133 #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
134 AC_TRY_COMPILE([#include <sys/types.h>
135 #include <sys/param.h>], [
136 #if BYTE_ORDER != BIG_ENDIAN
138 #endif], gnupg_cv_c_endian=big, gnupg_cv_c_endian=little)])
139 if test "$gnupg_cv_c_endian" = unknown; then
140 AC_TRY_RUN([main () {
141 /* Are we little or big endian? From Harbison&Steele. */
145 char c[sizeof (long)];
148 exit (u.c[sizeof (long) - 1] == 1);
150 gnupg_cv_c_endian=little,
151 gnupg_cv_c_endian=big,
152 gnupg_cv_c_endian=$tmp_assumed_endian
156 AC_MSG_RESULT([$gnupg_cv_c_endian])
157 if test "$gnupg_cv_c_endian" = little; then
158 AC_DEFINE(LITTLE_ENDIAN_HOST,1,
159 [Defined if the host has little endian byte ordering])
161 AC_DEFINE(BIG_ENDIAN_HOST,1,
162 [Defined if the host has big endian byte ordering])
166 dnl GNUPG_CHECK_CACHE
168 define(GNUPG_CHECK_CACHE,
169 [ AC_MSG_CHECKING(cached information)
170 gnupg_hostcheck="$target"
171 AC_CACHE_VAL(gnupg_cv_hostcheck, [ gnupg_cv_hostcheck="$gnupg_hostcheck" ])
172 if test "$gnupg_cv_hostcheck" != "$gnupg_hostcheck"; then
173 AC_MSG_RESULT(changed)
174 AC_MSG_WARN(config.cache exists!)
175 AC_MSG_ERROR(you must do 'make distclean' first to compile for
176 different target or different parameters.)
183 ######################################################################
184 # Check for -fPIC etc (taken from libtool)
185 # This sets CFLAGS_PIC to the required flags
186 # NO_PIC to yes if it is not possible to
188 ######################################################################
191 define(GNUPG_CHECK_PIC,
192 [ AC_MSG_CHECKING(for option to create PIC)
195 if test "$cross_compiling" = yes; then
196 AC_MSG_RESULT(assume none)
198 if test "$GCC" = yes; then
203 # All rs/6000 code is PIC
204 # but is there any non-rs/6000 AIX platform?
212 # PIC (with -KPIC) is the default.
216 # FIXME - pic_flag is probably required for
217 # hppa*-osf* and i860-osf*
224 solaris2* | solaris7* )
239 rs6000 | powerpc | powerpcle)
240 # Yippee! All RS/6000 and PowerPC code is position-independent.
245 if test "$NO_PIC" = yes; then
246 AC_MSG_RESULT(not possible)
248 if test -z "$CFLAGS_PIC"; then
251 AC_MSG_RESULT($CFLAGS_PIC)
258 ######################################################################
259 # Check for export-dynamic flag
260 # This sets CFLAGS_EXPORTDYNAMIC to the required flags
261 ######################################################################
262 dnl GNUPG_CHECK_EXPORTDYNAMIC
264 define(GNUPG_CHECK_EXPORTDYNAMIC,
265 [ AC_MSG_CHECKING(how to specify -export-dynamic)
266 if test "$cross_compiling" = yes; then
267 AC_MSG_RESULT(assume none)
268 CFLAGS_EXPORTDYNAMIC=""
270 AC_CACHE_VAL(gnupg_cv_export_dynamic,[
271 if AC_TRY_COMMAND([${CC-cc} $CFLAGS -Wl,--version 2>&1 |
272 grep "GNU ld" >/dev/null]); then
274 gnupg_cv_export_dynamic="-Wl,-export-dynamic"
278 gnupg_cv_export_dynamic="-Wl,-E"
281 gnupg_cv_export_dynamic=""
286 AC_MSG_RESULT($gnupg_cv_export_dynamic)
287 CFLAGS_EXPORTDYNAMIC="$gnupg_cv_export_dynamic"
291 #####################################################################
292 # Check for SysV IPC (from GIMP)
293 # And see whether we have a SHM_LOCK (FreeBSD does not have it).
294 #####################################################################
297 define(GNUPG_CHECK_IPC,
298 [ AC_CHECK_HEADERS(sys/ipc.h sys/shm.h)
299 if test "$ac_cv_header_sys_shm_h" = "yes"; then
300 AC_MSG_CHECKING(whether IPC_RMID allowes subsequent attaches)
301 AC_CACHE_VAL(gnupg_cv_ipc_rmid_deferred_release,
303 #include <sys/types.h>
310 id = shmget (IPC_PRIVATE, 4, IPC_CREAT | 0777);
313 shmaddr = shmat (id, 0, 0);
314 shmctl (id, IPC_RMID, 0);
315 if ((char*) shmat (id, 0, 0) == (char*) -1)
325 gnupg_cv_ipc_rmid_deferred_release="yes",
326 gnupg_cv_ipc_rmid_deferred_release="no",
327 gnupg_cv_ipc_rmid_deferred_release="assume-no")
329 if test "$gnupg_cv_ipc_rmid_deferred_release" = "yes"; then
330 AC_DEFINE(IPC_RMID_DEFERRED_RELEASE,1,
331 [Defined if we can do a deferred shm release])
334 if test "$gnupg_cv_ipc_rmid_deferred_release" = "no"; then
337 AC_MSG_RESULT([assuming no])
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>
345 #include <sys/shm.h>],[
347 shmctl(shm_id, SHM_LOCK, 0);
349 gnupg_cv_ipc_have_shm_lock="yes",
350 gnupg_cv_ipc_have_shm_lock="no"
353 if test "$gnupg_cv_ipc_have_shm_lock" = "yes"; then
354 AC_DEFINE(IPC_HAVE_SHM_LOCK,1,
355 [Defined if a SysV shared memory supports the LOCK flag])
364 ######################################################################
365 # Check whether mlock is broken (hpux 10.20 raises a SIGBUS if mlock
366 # is not called from uid 0 (not tested whether uid 0 works)
367 # For DECs Tru64 we have also to check whether mlock is in librt
368 # mlock is there a macro using memlk()
369 ######################################################################
370 dnl GNUPG_CHECK_MLOCK
372 define(GNUPG_CHECK_MLOCK,
373 [ AC_CHECK_FUNCS(mlock)
374 if test "$ac_cv_func_mlock" = "no"; then
375 AC_CHECK_HEADERS(sys/mman.h)
376 if test "$ac_cv_header_sys_mman_h" = "yes"; then
378 AC_CHECK_LIB(rt, memlk)
379 AC_CACHE_CHECK([whether mlock is in sys/mman.h],
380 gnupg_cv_mlock_is_in_sys_mman,
383 #ifdef HAVE_SYS_MMAN_H
384 #include <sys/mman.h>
389 /* glibc defines this for functions which it implements
390 * to always fail with ENOSYS. Some functions are actually
391 * named something starting with __ and the normal name
393 #if defined (__stub_mlock) || defined (__stub___mlock)
400 gnupg_cv_mlock_is_in_sys_mman=yes,
401 gnupg_cv_mlock_is_in_sys_mman=no)])
402 if test "$gnupg_cv_mlock_is_in_sys_mman" = "yes"; then
403 AC_DEFINE(HAVE_MLOCK,1,
404 [Defined if the system supports an mlock() call])
408 if test "$ac_cv_func_mlock" = "yes"; then
409 AC_MSG_CHECKING(whether mlock is broken)
410 AC_CACHE_VAL(gnupg_cv_have_broken_mlock,
415 #include <sys/mman.h>
416 #include <sys/types.h>
423 long int pgsize = getpagesize();
425 pool = malloc( 4096 + pgsize );
428 pool += (pgsize - ((long int)pool % pgsize));
430 err = mlock( pool, 4096 );
431 if( !err || errno == EPERM )
438 gnupg_cv_have_broken_mlock="no",
439 gnupg_cv_have_broken_mlock="yes",
440 gnupg_cv_have_broken_mlock="assume-no"
443 if test "$gnupg_cv_have_broken_mlock" = "yes"; then
444 AC_DEFINE(HAVE_BROKEN_MLOCK,1,
445 [Defined if the mlock() call does not work])
447 AC_CHECK_FUNCS(plock)
449 if test "$gnupg_cv_have_broken_mlock" = "no"; then
452 AC_MSG_RESULT(assuming no)
459 ################################################################
460 # GNUPG_PROG_NM - find the path to a BSD-compatible name lister
461 AC_DEFUN([GNUPG_PROG_NM],
462 [AC_MSG_CHECKING([for BSD-compatible nm])
463 AC_CACHE_VAL(ac_cv_path_NM,
464 [if test -n "$NM"; then
465 # Let the user override the test.
468 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
469 for ac_dir in /usr/ucb /usr/ccs/bin $PATH /bin; do
470 test -z "$ac_dir" && ac_dir=.
471 if test -f $ac_dir/nm; then
472 # Check to see if the nm accepts a BSD-compat flag.
473 # Adding the `sed 1q' prevents false positives on HP-UX, which says:
474 # nm: unknown option "B" ignored
475 if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
476 ac_cv_path_NM="$ac_dir/nm -B"
477 elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
478 ac_cv_path_NM="$ac_dir/nm -p"
480 ac_cv_path_NM="$ac_dir/nm"
486 test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
493 # GNUPG_SYS_NM_PARSE - Check for command ro grab the raw symbol name followed
494 # by C symbol name from nm.
495 AC_DEFUN([GNUPG_SYS_NM_PARSE],
496 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
497 AC_REQUIRE([GNUPG_PROG_NM])dnl
498 # Check for command to grab the raw symbol name followed by C symbol from nm.
499 AC_MSG_CHECKING([command to parse $NM output])
500 AC_CACHE_VAL(ac_cv_sys_global_symbol_pipe,
501 [# These are sane defaults that work on at least a few old systems.
502 # {They come from Ultrix. What could be older than Ultrix?!! ;)}
505 # Character class describing NM global symbol codes.
506 ac_symcode='[BCDEGRSTU]'
508 # Regexp to match symbols that can be accessed directly from C.
509 ac_sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
511 # Transform the above into a raw symbol and a C symbol.
514 # Define system-specific variables.
519 freebsd* | netbsd* | openbsd* | bsdi* | sunos* | cygwin32* | mingw32*)
520 ac_sympat='_\([_A-Za-z][_A-Za-z0-9]*\)'
524 # Cannot use undefined symbols on IRIX because inlined functions mess us up.
525 ac_symcode='[BCDEGRST]'
532 # If we're using GNU nm, then use its standard symbol codes.
533 if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then
534 ac_symcode='[ABCDGISTUW]'
538 cygwin32* | mingw32*)
539 # We do not want undefined symbols on cygwin32. The user must
540 # arrange to define them via -l arguments.
541 ac_symcode='[ABCDGISTW]'
546 # Write the raw and C identifiers.
547 ac_cv_sys_global_symbol_pipe="sed -n -e 's/^.* $ac_symcode $ac_sympat$/$ac_symxfrm/p'"
549 # Check to see that the pipe works correctly.
551 cat > conftest.$ac_ext <<EOF
556 void nm_test_func(){}
560 int main(){nm_test_var='a';nm_test_func;return 0;}
562 if AC_TRY_EVAL(ac_compile); then
563 # Now try to grab the symbols.
565 if AC_TRY_EVAL(NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
567 # Try sorting and uniquifying the output.
568 if sort "$ac_nlist" | uniq > "$ac_nlist"T; then
569 mv -f "$ac_nlist"T "$ac_nlist"
570 ac_wcout=`wc "$ac_nlist" 2>/dev/null`
572 ac_count=`echo "X$ac_wcout" | sed -e 's,^X,,' -e 's/^[ ]*\([0-9][0-9]*\).*$/\1/'`
574 (test "$ac_count" -ge 0) 2>/dev/null || ac_count=-1
580 # Make sure that we snagged all the symbols we need.
581 if egrep ' _?nm_test_var$' "$ac_nlist" >/dev/null; then
582 if egrep ' _?nm_test_func$' "$ac_nlist" >/dev/null; then
583 cat <<EOF > conftest.c
589 # Now generate the symbol file.
590 sed 's/^.* _\{0,1\}\(.*\)$/extern char \1;/' < "$ac_nlist" >> conftest.c
592 cat <<EOF >> conftest.c
593 #if defined (__STDC__) && __STDC__
594 # define __ptr_t void *
596 # define __ptr_t char *
599 /* The number of symbols in dld_preloaded_symbols, -1 if unsorted. */
600 int dld_preloaded_symbol_count = $ac_count;
602 /* The mapping between symbol names and symbols. */
608 dld_preloaded_symbols[] =
612 sed 's/^_\{0,1\}\(.*\) _\{0,1\}\(.*\)$/ {"\1", (__ptr_t) \&\2},/' < "$ac_nlist" >> conftest.c
613 cat <<\EOF >> conftest.c
621 # Now try linking the two files.
622 mv conftest.$ac_objext conftestm.$ac_objext
624 ac_save_CFLAGS="$CFLAGS"
625 LIBS="conftestm.$ac_objext"
626 CFLAGS="$CFLAGS$no_builtin_flag"
627 if AC_TRY_EVAL(ac_link) && test -s conftest; then
630 echo "configure: failed program was:" >&AC_FD_CC
631 cat conftest.c >&AC_FD_CC
634 CFLAGS="$ac_save_CFLAGS"
636 echo "cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
639 echo "cannot find nm_test_var in $ac_nlist" >&AC_FD_CC
642 echo "cannot run $ac_cv_sys_global_symbol_pipe" >&AC_FD_CC
645 echo "$progname: failed program was:" >&AC_FD_CC
646 cat conftest.c >&AC_FD_CC
650 # Do not use the global_symbol_pipe unless it works.
651 test "$ac_pipe_works" = yes || ac_cv_sys_global_symbol_pipe=
655 if test -z "$ac_cv_sys_global_symbol_pipe"; then
658 AC_MSG_RESULT($ac_result)
661 # GNUPG_SYS_LIBTOOL_CYGWIN32 - find tools needed on cygwin32
662 AC_DEFUN([GNUPG_SYS_LIBTOOL_CYGWIN32],
663 [AC_CHECK_TOOL(DLLTOOL, dlltool, false)
664 AC_CHECK_TOOL(AS, as, false)
667 # GNUPG_SYS_SYMBOL_UNDERSCORE - does the compiler prefix global symbols
668 # with an underscore?
669 AC_DEFUN([GNUPG_SYS_SYMBOL_UNDERSCORE],
672 i386-emx-os2 | i[3456]86-pc-os2*emx | i386-pc-msdosdjgpp)
673 ac_cv_sys_symbol_underscore=yes
676 if test "$cross_compiling" = yes; then
677 ac_cv_sys_symbol_underscore=yes
684 if test "$tmp_do_check" = "yes"; then
685 AC_REQUIRE([GNUPG_PROG_NM])dnl
686 AC_REQUIRE([GNUPG_SYS_NM_PARSE])dnl
687 AC_MSG_CHECKING([for _ prefix in compiled symbols])
688 AC_CACHE_VAL(ac_cv_sys_symbol_underscore,
689 [ac_cv_sys_symbol_underscore=no
690 cat > conftest.$ac_ext <<EOF
691 void nm_test_func(){}
692 int main(){nm_test_func;return 0;}
694 if AC_TRY_EVAL(ac_compile); then
695 # Now try to grab the symbols.
697 if AC_TRY_EVAL(NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
698 # See whether the symbols have a leading underscore.
699 if egrep '^_nm_test_func' "$ac_nlist" >/dev/null; then
700 ac_cv_sys_symbol_underscore=yes
702 if egrep '^nm_test_func ' "$ac_nlist" >/dev/null; then
705 echo "configure: cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
709 echo "configure: cannot run $ac_cv_sys_global_symbol_pipe" >&AC_FD_CC
712 echo "configure: failed program was:" >&AC_FD_CC
713 cat conftest.c >&AC_FD_CC
718 AC_MSG_CHECKING([for _ prefix in compiled symbols])
720 AC_MSG_RESULT($ac_cv_sys_symbol_underscore)
721 if test x$ac_cv_sys_symbol_underscore = xyes; then
722 AC_DEFINE(WITH_SYMBOL_UNDERSCORE,1,
723 [Defined if compiled symbols have a leading underscore])
728 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
730 AC_DEFUN([GNUPG_FUNC_MKDIR_TAKES_ONE_ARG],
731 [AC_CHECK_HEADERS(sys/stat.h unistd.h direct.h)
732 AC_CACHE_CHECK([if mkdir takes one argument], gnupg_cv_mkdir_takes_one_arg,
734 #include <sys/types.h>
735 #ifdef HAVE_SYS_STAT_H
736 # include <sys/stat.h>
743 #endif], [mkdir ("foo", 0);],
744 gnupg_cv_mkdir_takes_one_arg=no, gnupg_cv_mkdir_takes_one_arg=yes)])
745 if test $gnupg_cv_mkdir_takes_one_arg = yes ; then
746 AC_DEFINE(MKDIR_TAKES_ONE_ARG,1,
747 [Defined if mkdir() does not take permission flags])
751 # GNUPG_AC_INIT([PACKAGE, VERSION, [ISDEVEL], BUG-REPORT)
752 # ----------------------------------------
753 # Call AC_INIT with an additional argument to indicate a development
754 # version. If this is called ""svn", the global revision of the
755 # repository will be appended, so that a version. The variable
756 # SVN_REVISION will always be set. In case svn is not available 0
757 # will be used for the revision.
758 m4_define([GNUPG_AC_INIT],
760 m4_define(gnupg_ac_init_tmp, m4_esyscmd([echo -n $((svn info 2>/dev/null || \
761 echo 'Revision: 0') |sed -n '/^Revision:/ {s/[^0-9]//gp;q}')]))
762 SVN_REVISION="gnupg_ac_init_tmp[]"
763 AC_INIT([$1], [$2][]m4_ifval([$3],[-[$3][]gnupg_ac_init_tmp],[]), [$4])