I am trying to use autoconf to check the version of gfortran used to compile my code. How to get the version number safely in a portable way?
The easiest way would be to simply use gfortran -dumpversion
, but I read that there is some problems with this approach (on my machine for example, it does not return the patchlevel number). The option -dumpfullversion
I found in the documentation does not seem to be implemented (I get a fatal error).
Instead, I am trying to use gfortran --version
or gfortran -v
. My first attempt is the following:
GFORTRAN_VERSION=`gfortran -v 2>&1 | $AWK 'END { print }' | $AWK '{ print $3 }'`
where $AWK
contains the awk-type program found by AC_PROG_AWK
. It works perfectly on all the linux machines I have tested. However, it does not look reasonable to assume that gfortran -v
will always return the version number in the third position of the last line of its output. For instance, will this approach work on MacOS or Windows?
Any advice would be very welcome, thank you very much in advance!