Configure script refactoring of module handling

-Fixes a few errors in the code that might only trigger in corner cases
-Reorders some code to avoid having to duplicate code, and then forgetting to consider it when adding new code
-Reduces spawning of external processes
-Improves modules listing at the end of configure

The resulting makefiles are almost identical, except that BUILD_SHARED_MODULE_OBJS is reordered to match SHARED_MODULE_OBJS, this should not have any effect on the compile.

PS: This requires that autoconf is run to regenerate the configure script itself.
While I agree it has no useful distiction for users, I dont believe it will be confusing them either.
And it can be informative to see core modules being compiled as well.
From a debugging point of view it can give important clues as to some of the logic having gone wrong (mostly from changes in configure.in of course), making them easy to spot.