fix bashisms in configure
[m6w6/ext-psi] / m4 / psi_const.m4
1 # psi_add_str_const(name, value)
2 # Add a pre-defined string constant to $PSI_CONSTS
3 psi_add_str_const() {
4 grep -q "\"psi\\\\\\\\$1\"" $PSI_CONSTS \
5 || cat >>$PSI_CONSTS <<EOF
6 {PSI_T_STRING, "string", "psi\\$1", $2, PSI_T_QUOTED_STRING},
7 EOF
8 }
9
10 # psi_add_int_const(name, value)
11 # Add a pre-defined int constant to $PSI_CONSTS
12 psi_add_int_const() {
13 grep -q "\"psi\\\\\\\\$1\"" $PSI_CONSTS \
14 || cat >>$PSI_CONSTS <<EOF
15 {PSI_T_INT, "int", "psi\\$1", "$2", PSI_T_NUMBER},
16 EOF
17 }
18
19 dnl PSI_CONST(const name, type)
20 dnl Check the value of a str/int constant and add it to the list of pre-defined
21 dnl constants.
22 AC_DEFUN(PSI_CONST, [
23 AC_CACHE_CHECK(value of $1, psi_cv_const_$1, [
24 psi_const_val=
25 case $2 in
26 str*)
27 if test "$cross_compiling" = "yes"
28 then
29 AC_TRY_CPP(PSI_INCLUDES $1, psi_const_val=`eval "$ac_try|tail -n1"`, psi_const_val=)
30 else
31 PSI_COMPUTE_STR(psi_const_val, $1, PSI_INCLUDES)
32 fi
33 ;;
34 int)
35 AC_COMPUTE_INT(psi_const_val, $1, PSI_INCLUDES)
36 ;;
37 esac
38 psi_cv_const_$1=$psi_const_val
39 ])
40 if test "$psi_cv_const_$1"
41 then
42 case $2 in
43 str*)
44 psi_add_str_const "$1" "$psi_cv_const_$1"
45 ;;
46 int)
47 psi_add_int_const "$1" "$psi_cv_const_$1"
48 ;;
49 esac
50 fi
51 ])