Make CFG_LIBDIR configurable. Fixes #5223