Get the ROOT version number from a Makefile

Hello,

I would like to know if it is possible to access (and check) the ROOT version through some environment variable from a makefile.

It is fairly easy to do this within the code itself with preprocessor directives, e.g.

#if ROOT_VERSION_CODE > ROOT_VERSION(6,20,04)
#include "TFITS.h"
#endif

I was wandering if there is some bash environment variable corresponding to ROOT_VERSION_CODE.

The only thing I had worked out so far is to store the output of root-config --version in a variable

ROOTVERSION = `root-config --version`

(alternatively the file $ROOTSYS/build/version_number contains the same number but is available only if you have built ROOT, not in pre-compiled binaries.)

Both cases will return a string with . and / separators, e.g. 6.20/04 which will be very difficult to parse in bash in order to apply a numerical check on it.

Any suggestion?

Many thanks!

ROOTVERSION=`root-config --version | tr -c -d [:digit:]`
1 Like

You can also see how we do it in the Reference Guide Makefile

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.