Implement --enable-debug configure option.

Fixes #3254