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