Using autoconf/automake how does one find the GCC version on the system?
To get the python version installed you’d use AM_PATH_PYTHON, and then the PYTHON_VERSION variable would be available. Is there something similar for the GCC version?
(Also, is it possible to get the major, minor and patch level of gcc?)
A quick search reveals the ax_gcc_version macro which should give you the
GCC_VERSIONvariable.Unfortunately, that macro depends on
AX_GCC_OPTIONwhich has recently been deprecated in favour of ofAX_*_CHECK_FLAG.This mailing list post suggests a patch for
ax_gcc_versionwhich amounts to:I have not tested this, but it looks sensible.
Once you have the version string in
GCC_VERSION, you can manually split the string to get the major, minor and patch versions. Here’s a simple-minded solution: