ax_check_sign.m4 (2104B)
1 # =========================================================================== 2 # https://www.gnu.org/software/autoconf-archive/ax_check_sign.html 3 # =========================================================================== 4 # 5 # SYNOPSIS 6 # 7 # AX_CHECK_SIGN (TYPE, [ACTION-IF-SIGNED], [ACTION-IF-UNSIGNED], [INCLUDES]) 8 # 9 # DESCRIPTION 10 # 11 # Checks whether TYPE is signed or not. If no INCLUDES are specified, the 12 # default includes are used. If ACTION-IF-SIGNED is given, it is 13 # additional shell code to execute when the type is signed. If 14 # ACTION-IF-UNSIGNED is given, it is executed when the type is unsigned. 15 # 16 # This macro assumes that the type exists. Therefore the existence of the 17 # type should be checked before calling this macro. For example: 18 # 19 # AC_CHECK_HEADERS([wchar.h]) 20 # AC_CHECK_TYPE([wchar_t],,[ AC_MSG_ERROR([Type wchar_t not found.]) ]) 21 # AX_CHECK_SIGN([wchar_t], 22 # [ AC_DEFINE(WCHAR_T_SIGNED, 1, [Define if wchar_t is signed]) ], 23 # [ AC_DEFINE(WCHAR_T_UNSIGNED, 1, [Define if wchar_t is unsigned]) ], [ 24 # #ifdef HAVE_WCHAR_H 25 # #include <wchar.h> 26 # #endif 27 # ]) 28 # 29 # LICENSE 30 # 31 # Copyright (c) 2008 Ville Laurikari <vl@iki.fi> 32 # 33 # Copying and distribution of this file, with or without modification, are 34 # permitted in any medium without royalty provided the copyright notice 35 # and this notice are preserved. This file is offered as-is, without any 36 # warranty. 37 38 #serial 6 39 40 AU_ALIAS([VL_CHECK_SIGN], [AX_CHECK_SIGN]) 41 AC_DEFUN([AX_CHECK_SIGN], [ 42 typename=`echo $1 | sed "s/@<:@^a-zA-Z0-9_@:>@/_/g"` 43 AC_CACHE_CHECK([whether $1 is signed], ax_cv_decl_${typename}_signed, [ 44 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$4]], 45 [[ int foo @<:@ 1 - 2 * !((($1) -1) < 0) @:>@ ]])], 46 [ eval "ax_cv_decl_${typename}_signed=\"yes\"" ], 47 [ eval "ax_cv_decl_${typename}_signed=\"no\"" ])]) 48 symbolname=`echo $1 | sed "s/@<:@^a-zA-Z0-9_@:>@/_/g" | tr "a-z" "A-Z"` 49 if eval "test \"\${ax_cv_decl_${typename}_signed}\" = \"yes\""; then 50 $2 51 elif eval "test \"\${ax_cv_decl_${typename}_signed}\" = \"no\""; then 52 $3 53 fi 54 ])dnl