The OS X version of grep doesn't support -P (--perl-regexp). It was breaking the building.
Solved by slightly changing the RegExp and using -E (--extended-regexp).
In RH based systems, libraries are distributed in two separate packages for each version. One contains the precompiled code, while the second one contains the related development files such as headers, etc. (marked as "-devel").
The previous auto-detection was marking the libraries as installed even if their "-devel" part was missing, generating compilation errors.
This should mark libraries as installed only if their "-devel" part is installed.