Fix build scripts.

Attempt #2.
Fixes in autogen.sh related scripts.