-
Notifications
You must be signed in to change notification settings - Fork 0
/
acinclude.m4
136 lines (120 loc) · 3.74 KB
/
acinclude.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
dnl ICE_ARG_WITH(PACKAGE, HELP-STRING, ACTION-IF-TRUE [, ACTION-IF-FALSE])
dnl This macro does the same thing as AC_ARG_WITH, but it also defines
dnl with_PACKAGE_arg and with_PACKAGE_sign to avoid complicated logic later.
dnl
AC_DEFUN([ICE_ARG_WITH], [
AC_ARG_WITH([$1], [$2], [
case "[${with_]patsubst([$1], -, _)}" in
[no)]
[with_]patsubst([$1], -, _)_sign=no
;;
[yes)]
[with_]patsubst([$1], -, _)_sign=yes
;;
[*)]
[with_]patsubst([$1], -, _)_arg="[${with_]patsubst([$1], -, _)}"
[with_]patsubst([$1], -, _)_sign=yes
;;
esac
$3
], [$4])])
dnl ICE_CXX_FLAG_ACCEPT(name,FLAG)
dnl checking whether the C++ accepts FLAG and add this flag to CXXFLAGS
dnl
AC_DEFUN([ICE_CXX_FLAG_ACCEPT], [
ice_save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$2 $CXXFLAGS"
AC_MSG_CHECKING(
[whether the C++ compiler ($CXX) accepts $1])
AC_TRY_COMPILE(, , [ice_tmp_result=yes],
[ice_tmp_result=no; CXXFLAGS=$ice_save_CXXFLAGS])
AC_MSG_RESULT([$]ice_tmp_result)
$1_ok=$ice_tmp_result
])
dnl ICE_PROG_CXX_LIGHT
dnl Checking for C in hope that it understands C++ too
dnl Useful for C++ programs which don't use C++ library at all
AC_DEFUN([ICE_PROG_CXX_LIGHT], [
AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([whether the C compiler ($CC) understands C++])
cat > conftest.C <<EOF
#ifdef __cplusplus
int main() {return 0;}
#else
bogus_command;
#endif
EOF
if AC_TRY_COMMAND(rm conftest; $CC -o conftest conftest.C; test -f ./conftest) >/dev/null 2>&1; then
ice_prog_gxx=yes
CXX=$CC
else
ice_prog_gxx=no
fi
AC_MSG_RESULT($ice_prog_gxx)
])
dnl ICE_EXPAND(variable[, value])
dnl Expands the value of variable.
dnl
AC_DEFUN([ICE_EXPAND], [
ice_stored_prefix="${prefix}"
test "${prefix}" = "NONE" && prefix="${ac_default_prefix}"
ice_stored_exec_prefix="${exec_prefix}"
test "${exec_prefix}" = "NONE" && exec_prefix="${prefix}"
$1=`eval echo \""ifelse($2,,[$]$1,$2)"\"`
ice_previous_value=''
until test "${ice_previous_value}" = "[$]{$1}"; do
ice_previous_value="[$]{$1}"
$1=`eval echo "[$]{$1}"`
done
prefix="${ice_stored_prefix}"
exec_prefix="${ice_stored_exec_prefix}"
])
dnl ICE_MSG_VALUE(label, variable)
dnl Prints the expanded value of variable prefixed by label.
dnl
AC_DEFUN([ICE_MSG_VALUE], [(
ICE_EXPAND(ice_value, [$]$2)
AC_MSG_RESULT([$1: $ice_value])
)])
dnl ICE_CHECK_NL_ITEM(nl-item,[if-found[, if-not-found]])
dnl Checks if nl_langinfo supports the requested locale dependent property.
dnl When nl-item is supported and if-found is not defined the shell variable
dnl have_$(nl_item) and the preprocessor macro HAVE_$(NL_ITEM) are set to
dnl yes/1. When nl-item is not supported and if-not-found is not defined
dnl have_$(nl_item) is set to no.
dnl
AC_DEFUN([ICE_CHECK_NL_ITEM], [
AC_MSG_CHECKING([whether nl_langinfo supports $1])
AC_TRY_COMPILE([
#include <langinfo.h>
#include <stdio.h>],
[ printf("%s\n", nl_langinfo($1));],
[ AC_MSG_RESULT(yes)
ifelse([$2],,
have_$1=yes
AC_DEFINE(HAVE_$1, 1, [define if nl_langinfo supports $1]),
[$2]) ],
[ AC_MSG_RESULT(no)
ifelse([$3],,have_$1=no,[$3]) ])
])
dnl ICE_CHECK_CONVERSION(from,to,result-if-cross-compiling[, extra-libs
dnl [, if-supported[, if-not-supported]]])
dnl Checks if iconv supports the requested conversion.
dnl
AC_DEFUN([ICE_CHECK_CONVERSION], [
AC_MSG_CHECKING([whether iconv converts from $1 to $2])
AC_TRY_RUN([
#include <iconv.h>
#include <locale.h>
int main() {
iconv_t cd;
setlocale(LC_ALL, "");
cd = iconv_open("$2", "$1");
iconv_close(cd);
return ((iconv_t) -1 == cd);
}],
[ AC_MSG_RESULT(yes); ifelse([$5],,,$5) ],
[ AC_MSG_RESULT(no); ifelse([$6],,,$6) ],
[ ifelse([$3],yes,
[ AC_MSG_RESULT([yes (cross)]); ifelse([$5],,,$5) ],
[ AC_MSG_RESULT([no (cross)]); ifelse([$6],,,$6) ])])])