Bump to 2.4.3
[platform/upstream/gpg2.git] / acinclude.m4
1 dnl macros to configure gnupg
2 dnl Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
3 dnl
4 dnl This file is part of GnuPG.
5 dnl
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 3 of the License, or
9 dnl (at your option) any later version.
10 dnl
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.
15 dnl
16 dnl You should have received a copy of the GNU General Public License
17 dnl along with this program; if not, see <https://www.gnu.org/licenses/>.
18
19 dnl GNUPG_CHECK_TYPEDEF(TYPE, HAVE_NAME)
20 dnl Check whether a typedef exists and create a #define $2 if it exists
21 dnl
22 AC_DEFUN([GNUPG_CHECK_TYPEDEF],
23   [ AC_MSG_CHECKING(for $1 typedef)
24     AC_CACHE_VAL(gnupg_cv_typedef_$1,
25     [AC_TRY_COMPILE([#define _GNU_SOURCE 1
26     #include <stdlib.h>
27     #include <sys/types.h>], [
28     #undef $1
29     int a = sizeof($1);
30     ], gnupg_cv_typedef_$1=yes, gnupg_cv_typedef_$1=no )])
31     AC_MSG_RESULT($gnupg_cv_typedef_$1)
32     if test "$gnupg_cv_typedef_$1" = yes; then
33         AC_DEFINE($2,1,[Defined if a `]$1[' is typedef'd])
34     fi
35   ])
36
37
38 dnl GNUPG_CHECK_GNUMAKE
39 dnl
40 AC_DEFUN([GNUPG_CHECK_GNUMAKE],
41   [
42     if ${MAKE-make} --version 2>/dev/null | grep '^GNU ' >/dev/null 2>&1; then
43         :
44     else
45         AC_MSG_WARN([[
46 ***
47 *** It seems that you are not using GNU make.  Some make tools have serious
48 *** flaws and you may not be able to build this software at all. Before you
49 *** complain, please try GNU make:  GNU make is easy to build and available
50 *** at all GNU archives.  It is always available from ftp.gnu.org:/gnu/make.
51 ***]])
52     fi
53   ])
54
55
56 dnl GNUPG_CHECK_ENDIAN
57 dnl define either LITTLE_ENDIAN_HOST or BIG_ENDIAN_HOST
58 dnl
59 AC_DEFUN([GNUPG_CHECK_ENDIAN],
60   [
61     tmp_assumed_endian=big
62     tmp_assume_warn=""
63     if test "$cross_compiling" = yes; then
64       case "$host_cpu" in
65          i@<:@345678@:>@* )
66             tmp_assumed_endian=little
67             ;;
68          *)
69             ;;
70       esac
71     fi
72     AC_MSG_CHECKING(endianness)
73     AC_CACHE_VAL(gnupg_cv_c_endian,
74       [ gnupg_cv_c_endian=unknown
75         # See if sys/param.h defines the BYTE_ORDER macro.
76         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
77         #include <sys/param.h>]], [[
78         #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
79          bogus endian macros
80         #endif]])], [# It does; now see whether it defined to BIG_ENDIAN or not.
81         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
82         #include <sys/param.h>]], [[
83         #if BYTE_ORDER != BIG_ENDIAN
84          not big endian
85         #endif]])], gnupg_cv_c_endian=big, gnupg_cv_c_endian=little)])
86         if test "$gnupg_cv_c_endian" = unknown; then
87             AC_RUN_IFELSE([AC_LANG_SOURCE([[main () {
88               /* Are we little or big endian?  From Harbison&Steele.  */
89               union
90               {
91                 long l;
92                 char c[sizeof (long)];
93               } u;
94               u.l = 1;
95               exit (u.c[sizeof (long) - 1] == 1);
96               }]])],
97               gnupg_cv_c_endian=little,
98               gnupg_cv_c_endian=big,
99               gnupg_cv_c_endian=$tmp_assumed_endian
100               tmp_assumed_warn=" (assumed)"
101             )
102         fi
103       ])
104     AC_MSG_RESULT([${gnupg_cv_c_endian}${tmp_assumed_warn}])
105     if test "$gnupg_cv_c_endian" = little; then
106       AC_DEFINE(LITTLE_ENDIAN_HOST,1,
107                 [Defined if the host has little endian byte ordering])
108     else
109       AC_DEFINE(BIG_ENDIAN_HOST,1,
110                 [Defined if the host has big endian byte ordering])
111     fi
112   ])
113
114
115
116
117 # GNUPG_BUILD_PROGRAM(NAME,DEFAULT)
118 # Add a --enable-NAME option to configure an set the
119 # shell variable build_NAME either to "yes" or "no".  DEFAULT must
120 # either be "yes" or "no" and decided on the default value for
121 # build_NAME and whether --enable-NAME or --disable-NAME is shown with
122 # ./configure --help
123 AC_DEFUN([GNUPG_BUILD_PROGRAM],
124   [m4_define([my_build], [m4_bpatsubst(build_$1, [[^a-zA-Z0-9_]], [_])])
125    my_build=$2
126    m4_if([$2],[yes],[
127       AC_ARG_ENABLE([$1], AS_HELP_STRING([--disable-$1],
128                                          [do not build the $1 program]),
129                            my_build=$enableval, my_build=$2)
130     ],[
131       AC_ARG_ENABLE([$1], AS_HELP_STRING([--enable-$1],
132                                          [build the $1 program]),
133                            my_build=$enableval, my_build=$2)
134     ])
135    case "$my_build" in
136          no|yes)
137            ;;
138          *)
139            AC_MSG_ERROR([only yes or no allowed for feature --enable-$1])
140            ;;
141    esac
142    m4_undefine([my_build])
143   ])
144
145
146
147 # GNUPG_DISABLE_GPG_ALGO(NAME,DESCRIPTION)
148 #
149 # Add a --disable-gpg-NAME option and the corresponding ac_define
150 # GPG_USE_<NAME>.
151 AC_DEFUN([GNUPG_GPG_DISABLE_ALGO],
152   [AC_MSG_CHECKING([whether to enable the $2 for gpg])
153    AC_ARG_ENABLE([gpg-$1], AS_HELP_STRING([--disable-gpg-$1],
154                                           [disable the $2 algorithm in gpg]),
155                                           , enableval=yes)
156    AC_MSG_RESULT($enableval)
157    if test x"$enableval" = xyes ; then
158      AC_DEFINE(GPG_USE_[]m4_toupper($1), 1, [Define to support the $2])
159    fi
160   ])
161
162 # GNUPG_TIME_T_UNSIGNED
163 # Check whether time_t is unsigned
164 #
165 AC_DEFUN([GNUPG_TIME_T_UNSIGNED],
166   [ AC_CACHE_CHECK(whether time_t is unsigned, gnupg_cv_time_t_unsigned,
167      [AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY(
168        [AC_INCLUDES_DEFAULT([])
169 #if HAVE_SYS_TIME_H
170 # include <sys/time.h>
171 #else
172 # include <time.h>
173 #endif
174 ],
175        [((time_t)-1) < 0])],
176        gnupg_cv_time_t_unsigned=no, gnupg_cv_time_t_unsigned=yes)])
177     if test $gnupg_cv_time_t_unsigned = yes; then
178       AC_DEFINE(HAVE_UNSIGNED_TIME_T,1,[Defined if time_t is an unsigned type])
179     fi
180 ])# GNUPG_TIME_T_UNSIGNED