Fix custom 'basepath' handling.
Add automatic `main` option setting when possible.

The `main` option is automatically set only when there is no ambiguity: when there is only one source file.
Update tests.
Update .gitignore