2002-04-05 Marcus Brinkmann <marcus@g10code.de>
[gpgme.git] / acinclude.m4
1 dnl Macros to configure gpgme
2
3 dnl GNUPG_FIX_HDR_VERSION(FILE, NAME)
4 dnl Make the version number in gcrypt/gcrypt.h the same as the one here.
5 dnl (this is easier than to have a .in file just for one substitution)
6 dnl We must use a temp file in the current directory because make distcheck 
7 dnl install all sourcefiles RO.
8 dnl (wk 2001-12-18)
9 AC_DEFUN(GNUPG_FIX_HDR_VERSION,
10   [ sed "s/^#define $2 \".*/#define $2 \"$VERSION\"/" $srcdir/$1 > fixhdr.tmp
11     if cmp -s $srcdir/$1 fixhdr.tmp 2>/dev/null; then
12         rm -f fixhdr.tmp
13     else
14         rm -f $srcdir/$1
15         if mv fixhdr.tmp $srcdir/$1 ; then
16             :
17         else
18             AC_MSG_ERROR([[
19 ***
20 *** Failed to fix the version string macro $2 in $1.
21 *** The old file has been saved as fixhdr.tmp
22 ***]])
23         fi
24         AC_MSG_WARN([fixed the $2 macro in $1])
25     fi
26   ])
27
28
29 dnl GNUPG_CHECK_TYPEDEF(TYPE, HAVE_NAME)
30 dnl Check whether a typedef exists and create a #define $2 if it exists
31 dnl
32 AC_DEFUN(GNUPG_CHECK_TYPEDEF,
33   [ AC_MSG_CHECKING(for $1 typedef)
34     AC_CACHE_VAL(gnupg_cv_typedef_$1,
35     [AC_TRY_COMPILE([#include <stdlib.h>
36     #include <sys/types.h>], [
37     #undef $1
38     int a = sizeof($1);
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, ,
43          [Define to 1 if $1 is defined in the <sys/types.h> header file.])
44     fi
45   ])