Hopefully last changes for building with MSC.
[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 it
7 dnl under the terms of the GNU Lesser General Public License as
8 dnl published by the Free Software Foundation; either version 2.1 of the
9 dnl License, or (at your option) any later version.
10 dnl 
11 dnl GPGME is distributed in the hope that it will be useful, but WITHOUT
12 dnl ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 dnl or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
14 dnl Public License for more details.
15 dnl 
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
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     if test "$cross_compiling" = yes; then
54       gnupg_cv_must_copy_va_byval=no
55     else
56       gnupg_cv_must_copy_va_byval=no
57       AC_TRY_RUN([
58        #include <stdarg.h>
59        void f (int i, ...)
60        {
61           va_list args1, args2;
62           va_start (args1, i);
63           args2 = args1;
64           if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
65             exit (1);
66           va_end (args1);
67           va_end (args2);
68        }
69       
70        int main()
71        {
72           f (0, 42);
73             return 0;
74        }
75       ],gnupg_cv_must_copy_va_byval=yes)
76     fi
77   ])
78   if test "$gnupg_cv_must_copy_va_byval" = yes; then
79      AC_DEFINE(MUST_COPY_VA_BYVAL,1,[used to implement the va_copy macro])
80   fi
81   if test "$cross_compiling" = yes; then
82     AC_MSG_RESULT(assuming $gnupg_cv_must_copy_va_byval)
83   else
84     AC_MSG_RESULT($gnupg_cv_must_copy_va_byval)
85   fi
86 ])