xref: /netbsd-src/external/bsd/am-utils/dist/m4/macros/expand_cpp_hex.m4 (revision a53f50b9b44dc9467ccc9c464999b1d1c509cb0c)
1dnl ######################################################################
2dnl Expand the value of a CPP macro into a printable hex 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_HEX],
7[
8# we are looking for a regexp of a string
9AC_EGREP_CPP(0x,
10[$1]
11$2,
12value="notfound"
13AC_TRY_RUN(
14[
15[$1]
16main(argc)
17int argc;
18{
19#ifdef $2
20if (argc > 1)
21  printf("0x%x", $2);
22exit(0);
23#else
24# error no such option $2
25#endif
26exit(1);
27}], value=`./conftest dummy 2>>config.log`, value="notfound", value="notfound")
28,
29value="notfound"
30)
31if test "$value" = notfound
32then
33  :
34  $4
35else
36  :
37  $3
38fi
39])
40dnl ======================================================================
41