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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20 dnl GNUPG_CHECK_TYPEDEF(TYPE, HAVE_NAME)
21 dnl Check whether a typedef exists and create a #define $2 if it exists
23 AC_DEFUN([GNUPG_CHECK_TYPEDEF],
24 [ AC_MSG_CHECKING(for $1 typedef)
25 AC_CACHE_VAL(gnupg_cv_typedef_$1,
26 [AC_TRY_COMPILE([#define _GNU_SOURCE 1
28 #include <sys/types.h>], [
31 ], gnupg_cv_typedef_$1=yes, gnupg_cv_typedef_$1=no )])
32 AC_MSG_RESULT($gnupg_cv_typedef_$1)
33 if test "$gnupg_cv_typedef_$1" = yes; then
34 AC_DEFINE($2,1,[Defined if a `]$1[' is typedef'd])
39 dnl GNUPG_CHECK_GNUMAKE
41 AC_DEFUN([GNUPG_CHECK_GNUMAKE],
43 if ${MAKE-make} --version 2>/dev/null | grep '^GNU ' >/dev/null 2>&1; then
48 *** It seems that you are not using GNU make. Some make tools have serious
49 *** flaws and you may not be able to build this software at all. Before you
50 *** complain, please try GNU make: GNU make is easy to build and available
51 *** at all GNU archives. It is always available from ftp.gnu.org:/gnu/make.
56 dnl GNUPG_CHECK_FAQPROG
58 AC_DEFUN([GNUPG_CHECK_FAQPROG],
59 [ AC_MSG_CHECKING(for faqprog.pl)
60 if faqprog.pl -V 2>/dev/null | grep '^faqprog.pl ' >/dev/null 2>&1; then
67 AC_MSG_RESULT($working_faqprog)
69 AM_CONDITIONAL(WORKING_FAQPROG, test "$working_faqprog" = "yes" )
71 dnl if test $working_faqprog = no; then
74 dnl *** It seems that the faqprog.pl program is not installed;
75 dnl *** however it is only needed if you want to change the FAQ.
76 dnl *** (faqprog.pl should be available at:
77 dnl *** ftp://ftp.gnupg.org/gcrypt/contrib/faqprog.pl )
78 dnl *** No need to worry about this warning.
83 dnl GNUPG_CHECK_DOCBOOK_TO_TEXI
85 AC_DEFUN([GNUPG_CHECK_DOCBOOK_TO_TEXI],
87 AC_CHECK_PROG(DOCBOOK_TO_TEXI, docbook2texi, yes, no)
88 AC_MSG_CHECKING(for sgml to texi tools)
90 if test "$ac_cv_prog_DOCBOOK_TO_TEXI" = yes; then
91 if sgml2xml -v /dev/null 2>&1 | grep 'SP version' >/dev/null 2>&1 ; then
92 working_sgmltotexi=yes
95 AC_MSG_RESULT($working_sgmltotexi)
96 AM_CONDITIONAL(HAVE_DOCBOOK_TO_TEXI, test "$working_sgmltotexi" = "yes" )
101 dnl GNUPG_CHECK_ENDIAN
102 dnl define either LITTLE_ENDIAN_HOST or BIG_ENDIAN_HOST
104 AC_DEFUN([GNUPG_CHECK_ENDIAN],
106 tmp_assumed_endian=big
107 if test "$cross_compiling" = yes; then
110 tmp_assumed_endian=little
115 AC_MSG_WARN(cross compiling; assuming $tmp_assumed_endian endianess)
117 AC_MSG_CHECKING(endianess)
118 AC_CACHE_VAL(gnupg_cv_c_endian,
119 [ gnupg_cv_c_endian=unknown
120 # See if sys/param.h defines the BYTE_ORDER macro.
121 AC_TRY_COMPILE([#include <sys/types.h>
122 #include <sys/param.h>], [
123 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
125 #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
126 AC_TRY_COMPILE([#include <sys/types.h>
127 #include <sys/param.h>], [
128 #if BYTE_ORDER != BIG_ENDIAN
130 #endif], gnupg_cv_c_endian=big, gnupg_cv_c_endian=little)])
131 if test "$gnupg_cv_c_endian" = unknown; then
132 AC_TRY_RUN([main () {
133 /* Are we little or big endian? From Harbison&Steele. */
137 char c[sizeof (long)];
140 exit (u.c[sizeof (long) - 1] == 1);
142 gnupg_cv_c_endian=little,
143 gnupg_cv_c_endian=big,
144 gnupg_cv_c_endian=$tmp_assumed_endian
148 AC_MSG_RESULT([$gnupg_cv_c_endian])
149 if test "$gnupg_cv_c_endian" = little; then
150 AC_DEFINE(LITTLE_ENDIAN_HOST,1,
151 [Defined if the host has little endian byte ordering])
153 AC_DEFINE(BIG_ENDIAN_HOST,1,
154 [Defined if the host has big endian byte ordering])
161 # GNUPG_BUILD_PROGRAM(NAME,DEFAULT)
162 # Add a --enable-NAME option to configure an set the
163 # shell variable build_NAME either to "yes" or "no". DEFAULT must
164 # either be "yes" or "no" and decided on the default value for
165 # build_NAME and whether --enable-NAME or --disable-NAME is shown with
167 AC_DEFUN([GNUPG_BUILD_PROGRAM],
170 AC_ARG_ENABLE([$1], AC_HELP_STRING([--disable-$1],
171 [do not build the $1 program]),
172 build_$1=$enableval, build_$1=$2)
174 AC_ARG_ENABLE([$1], AC_HELP_STRING([--enable-$1],
175 [build the $1 program]),
176 build_$1=$enableval, build_$1=$2)
182 AC_MSG_ERROR([only yes or no allowed for feature --enable-$1])
189 # GNUPG_PTH_VERSION_CHECK(REQUIRED)
191 # If the version is sufficient, HAVE_PTH will be set to yes.
193 # Taken form the m4 macros which come with Pth
194 AC_DEFUN([GNUPG_PTH_VERSION_CHECK],
196 _pth_version=`$PTH_CONFIG --version | awk 'NR==1 {print [$]3}'`
197 _req_version="ifelse([$1],,1.2.0,$1)"
199 AC_MSG_CHECKING(for PTH - version >= $_req_version)
200 for _var in _pth_version _req_version; do
201 eval "_val=\"\$${_var}\""
202 _major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\1/'`
203 _minor=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\2/'`
204 _rtype=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\3/'`
205 _micro=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\4/'`
211 _hex=`echo dummy | awk '{ printf("%d%02d%1d%02d", major, minor, rtype, micro); }' \
212 "major=$_major" "minor=$_minor" "rtype=$_rtype" "micro=$_micro"`
213 eval "${_var}_hex=\"\$_hex\""
216 if test ".$_pth_version_hex" != .; then
217 if test ".$_req_version_hex" != .; then
218 if test $_pth_version_hex -ge $_req_version_hex; then
223 if test $have_pth = yes; then
225 AC_MSG_CHECKING([whether PTH installation is sane])
226 AC_CACHE_VAL(gnupg_cv_pth_is_sane,[
227 _gnupg_pth_save_cflags=$CFLAGS
228 _gnupg_pth_save_ldflags=$LDFLAGS
229 _gnupg_pth_save_libs=$LIBS
230 CFLAGS="$CFLAGS `$PTH_CONFIG --cflags`"
231 LDFLAGS="$LDFLAGS `$PTH_CONFIG --ldflags`"
232 LIBS="$LIBS `$PTH_CONFIG --libs`"
233 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pth.h>
236 gnupg_cv_pth_is_sane=yes,
237 gnupg_cv_pth_is_sane=no)
238 CFLAGS=$_gnupg_pth_save_cflags
239 LDFLAGS=$_gnupg_pth_save_ldflags
240 LIBS=$_gnupg_pth_save_libs
242 if test $gnupg_cv_pth_is_sane != yes; then
245 AC_MSG_RESULT($gnupg_cv_pth_is_sane)
254 # Check whether mlock is broken (hpux 10.20 raises a SIGBUS if mlock
255 # is not called from uid 0 (not tested whether uid 0 works)
256 # For DECs Tru64 we have also to check whether mlock is in librt
257 # mlock is there a macro using memlk()
258 dnl GNUPG_CHECK_MLOCK
260 AC_DEFUN([GNUPG_CHECK_MLOCK],
261 [ AC_CHECK_FUNCS(mlock)
262 if test "$ac_cv_func_mlock" = "no"; then
263 AC_CHECK_HEADERS(sys/mman.h)
264 if test "$ac_cv_header_sys_mman_h" = "yes"; then
266 AC_CHECK_LIB(rt, memlk)
267 AC_CACHE_CHECK([whether mlock is in sys/mman.h],
268 gnupg_cv_mlock_is_in_sys_mman,
271 #ifdef HAVE_SYS_MMAN_H
272 #include <sys/mman.h>
277 /* glibc defines this for functions which it implements
278 * to always fail with ENOSYS. Some functions are actually
279 * named something starting with __ and the normal name
281 #if defined (__stub_mlock) || defined (__stub___mlock)
288 gnupg_cv_mlock_is_in_sys_mman=yes,
289 gnupg_cv_mlock_is_in_sys_mman=no)])
290 if test "$gnupg_cv_mlock_is_in_sys_mman" = "yes"; then
291 AC_DEFINE(HAVE_MLOCK,1,
292 [Defined if the system supports an mlock() call])
296 if test "$ac_cv_func_mlock" = "yes"; then
297 AC_MSG_CHECKING(whether mlock is broken)
298 AC_CACHE_VAL(gnupg_cv_have_broken_mlock,
303 #include <sys/mman.h>
304 #include <sys/types.h>
311 long int pgsize = getpagesize();
313 pool = malloc( 4096 + pgsize );
316 pool += (pgsize - ((long int)pool % pgsize));
318 err = mlock( pool, 4096 );
319 if( !err || errno == EPERM )
326 gnupg_cv_have_broken_mlock="no",
327 gnupg_cv_have_broken_mlock="yes",
328 gnupg_cv_have_broken_mlock="assume-no"
331 if test "$gnupg_cv_have_broken_mlock" = "yes"; then
332 AC_DEFINE(HAVE_BROKEN_MLOCK,1,
333 [Defined if the mlock() call does not work])
335 AC_CHECK_FUNCS(plock)
337 if test "$gnupg_cv_have_broken_mlock" = "no"; then
340 AC_MSG_RESULT(assuming no)
348 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
350 AC_DEFUN([GNUPG_FUNC_MKDIR_TAKES_ONE_ARG],
351 [AC_CHECK_HEADERS(sys/stat.h unistd.h direct.h)
352 AC_CACHE_CHECK([if mkdir takes one argument], gnupg_cv_mkdir_takes_one_arg,
354 #include <sys/types.h>
355 #ifdef HAVE_SYS_STAT_H
356 # include <sys/stat.h>
363 #endif], [mkdir ("foo", 0);],
364 gnupg_cv_mkdir_takes_one_arg=no, gnupg_cv_mkdir_takes_one_arg=yes)])
365 if test $gnupg_cv_mkdir_takes_one_arg = yes ; then
366 AC_DEFINE(MKDIR_TAKES_ONE_ARG,1,
367 [Defined if mkdir() does not take permission flags])