xref: /netbsd-src/external/bsd/am-utils/dist/m4/macros/expand_cpp_int.m4 (revision a53f50b9b44dc9467ccc9c464999b1d1c509cb0c)
1dnl ######################################################################
2dnl Expand the value of a CPP macro into a printable integer number.
3dnl Takes: header, macro, [action-if-found, [action-if-not-found]]
4dnl It runs the header through CPP looking for a match between the macro
5dnl and a string pattern, and if sucessful, it prints the string value out.
6AC_DEFUN([AMU_EXPAND_CPP_INT],
7[
8# we are looking for a regexp of an integer (must not start with 0 --- those
9# are octals).
10AC_EGREP_CPP(
11[[1-9]][[0-9]]*,
12[$1]
13$2,
14value="notfound"
15AC_TRY_RUN(
16[
17[$1]
18main(argc)
19int argc;
20{
21#ifdef $2
22if (argc > 1)
23  printf("%d", $2);
24exit(0);
25#else
26# error no such option $2
27#endif
28exit(1);
29}], value=`./conftest dummy 2>>config.log`, value="notfound", value="notfound")
30,
31value="notfound"
32)
33if test "$value" = notfound
34then
35  :
36  $4
37else
38  :
39  $3
40fi
41])
42dnl ======================================================================
43