Skip to content
Advertisement

How to print value of C macro in configure

I have configure.in script. I want to invoke configure ( after autoheader && autoconf ) and see value of PAGE_SHIFT macro from system header page_types.h. Something like this:

checking PAGE_SHIFT... 12

I’ve tried those:

1.

JavaScript

Result: macro PAGE_SHIFT was detected, but haven’t been printed

JavaScript

2.

JavaScript

Result: doesn’t work

JavaScript

3.

JavaScript

Result: works, but can’t be used with cross-compile

JavaScript
  1. method was suggested by Brett Hale

Autoconf will generate something like this:

JavaScript

Result: doesn’t work with kernel headers

JavaScript

Autoconf version: autoconf (GNU Autoconf) 2.69

Advertisement

Answer

I would recommend using the AC_COMPUTE_INT macro. e.g.,

JavaScript

Alternatively, you can replace the FAILURE macro with PAGE_SHIFT_VAL=0 and test that value for (0) if the error is recoverable.

Note that there’s nothing magical about the variable name PAGE_SHIFT_VAL, in this context; you can use another name. You still need the AC_SUBST if you want this value substituted in generated files, like config.h, or those listed in AC_CONFIG_FILES.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement