Use LIBDIR, BINDIR, and SHAREDIR environment variables. Fixes Bug #1184432