1dnl @synopsis AX_CHECK_SIGN (TYPE, [ACTION-IF-SIGNED], [ACTION-IF-UNSIGNED], [INCLUDES])
2dnl
3dnl Checks whether TYPE is signed or not.  If no INCLUDES are specified,
4dnl the default includes are used.  If ACTION-IF-SIGNED is given, it is
5dnl additional shell code to execute when the type is signed.  If
6dnl ACTION-IF-UNSIGNED is given, it is executed when the type is unsigned.
7dnl
8dnl This macro assumes that the type exists.  Therefore the existence of
9dnl the type should be checked before calling this macro.  For example:
10dnl
11dnl   AC_CHECK_HEADERS([wchar.h])
12dnl   AC_CHECK_TYPE([wchar_t],,[ AC_MSG_ERROR([Type wchar_t not found.]) ])
13dnl   AX_CHECK_SIGN([wchar_t],
14dnl     [ AC_DEFINE(WCHAR_T_SIGNED, 1, [Define if wchar_t is signed]) ],
15dnl     [ AC_DEFINE(WCHAR_T_UNSIGNED, 1, [Define if wchar_t is unsigned]) ], [
16dnl   #ifdef HAVE_WCHAR_H
17dnl   #include <wchar.h>
18dnl   #endif
19dnl   ])
20dnl
21dnl @version 1.1
22dnl @author Ville Laurikari <vl@iki.fi>
23AC_DEFUN([AX_CHECK_SIGN], [
24 typename=`echo $1 | sed "s/@<:@^a-zA-Z0-9_@:>@/_/g"`
25 AC_CACHE_CHECK([whether $1 is signed], ax_cv_decl_${typename}_signed, [
26   AC_COMPILE_IFELSE(
27     [ AC_LANG_PROGRAM([$4],
28         [ int foo @<:@ 1 - 2 * !((($1) -1) < 0) @:>@ ])],
29     [ eval "ax_cv_decl_${typename}_signed=\"yes\"" ],
30     [ eval "ax_cv_decl_${typename}_signed=\"no\"" ])])
31 symbolname=`echo $1 | sed "s/@<:@^a-zA-Z0-9_@:>@/_/g" | tr "@<:@a-z@:>@" "@<:@A-Z@:>@"`
32 if eval "test \"\${ax_cv_decl_${typename}_signed}\" = \"yes\""; then
33   true
34   $2
35 elif eval "test \"\${ax_cv_decl_${typename}_signed}\" = \"no\""; then
36   true
37   $3
38 fi
39])dnl
40