2004-09-14 Marcus Brinkmann <marcus@g10code.de>
[gpgme.git] / acinclude.m4
1 dnl Macros to configure GPGME
2 dnl Copyright (C) 2004 g10 Code GmbH
3 dnl
4 dnl This file is part of GPGME.
5 dnl
6 dnl GPGME 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.
10 dnl 
11 dnl GPGME 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, write to the Free Software
18 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19
20 dnl GNUPG_FIX_HDR_VERSION(FILE, NAME)
21 dnl   Make the version number stored in NAME in the header file FILE the
22 dnl   same as the one here.  This is easier than to have a .in file just
23 dnl   for one substitution.
24 dnl   We must use a temp file in the current directory because make
25 dnl   distcheck installs all sourcefiles RO.
26 dnl   (wk 2001-12-18)
27 AC_DEFUN(GNUPG_FIX_HDR_VERSION,
28   [ sed "s/^#define $2 \".*/#define $2 \"$VERSION\"/" $srcdir/$1 > fixhdr.tmp
29     if cmp -s $srcdir/$1 fixhdr.tmp 2>/dev/null; then
30         rm -f fixhdr.tmp
31     else
32         rm -f $srcdir/$1
33         if mv fixhdr.tmp $srcdir/$1 ; then
34             :
35         else
36             AC_MSG_ERROR([[
37 ***
38 *** Failed to fix the version string macro $2 in $1.
39 *** The old file has been saved as fixhdr.tmp
40 ***]])
41         fi
42         AC_MSG_WARN([fixed the $2 macro in $1])
43     fi
44   ])
45
46 dnl GNUPG_CHECK_VA_COPY()
47 dnl   Do some check on how to implement va_copy.
48 dnl   May define MUST_COPY_VA_BY_VAL.
49 dnl   Actual test code taken from glib-1.1.
50 AC_DEFUN(GNUPG_CHECK_VA_COPY,
51 [ AC_MSG_CHECKING(whether va_lists must be copied by value)
52   AC_CACHE_VAL(gnupg_cv_must_copy_va_byval,[
53     gnupg_cv_must_copy_va_byval=no
54     AC_TRY_RUN([
55        #include <stdarg.h>
56        void f (int i, ...)
57        {
58           va_list args1, args2;
59           va_start (args1, i);
60           args2 = args1;
61           if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
62             exit (1);
63           va_end (args1);
64           va_end (args2);
65        }
66       
67        int main()
68        {
69           f (0, 42);
70             return 0;
71        }
72     ],gnupg_cv_must_copy_va_byval=yes)
73   ])
74   if test "$gnupg_cv_must_copy_va_byval" = yes; then
75      AC_DEFINE(MUST_COPY_VA_BYVAL,1,[used to implement the va_copy macro])
76   fi
77   AC_MSG_RESULT($gnupg_cv_must_copy_va_byval)
78 ])