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