e0b67a36751726874e0b0f919755157e3592c891
[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
16 dnl PSI_CONST(const name, type)
17 dnl Check the value of a str/int constant and add it to the list of pre-defined
18 dnl constants.
19 AC_DEFUN(PSI_CONST, [
20 AC_CACHE_CHECK(value of $1, psi_cv_const_$1, [
21 psi_const_val=
22 case $2 in
23 str*)
24 if test "$cross_compiling" = "yes"
25 then
26 AC_TRY_CPP(PSI_INCLUDES $1, psi_const_val=`eval "$ac_try|tail -n1"`, psi_const_val=)
27 else
28 PSI_COMPUTE_STR(psi_const_val, $1, PSI_INCLUDES)
29 fi
30 ;;
31 int)
32 AC_COMPUTE_INT(psi_const_val, $1, PSI_INCLUDES)
33 ;;
34 esac
35 psi_cv_const_$1=$psi_const_val
36 ])
37 if test "$psi_cv_const_$1"
38 then
39 case $2 in
40 str*)
41 psi_add_str_const "$1" "$psi_cv_const_$1"
42 ;;
43 int)
44 psi_add_int_const "$1" "$psi_cv_const_$1"
45 ;;
46 esac
47 fi
48 ])