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.
I agree that it does deviate from the established style, however I would like to recommend that the current style be switched to this style.
Reasons for this are that it is
-Much easier to read
-Less likely to get the syntax wrong
-Less susceptible to the various ways things can interact/change when using shells/pipes
-Spawns less processes

If we can agree on changing the style, then I would like to make another patch changing the rest of the sed commands (only those that are actually only a simple string replacement though) into string replacements.

I'd say this style is also more modern, but reasearch into what shells support this seems to indicate that most shells have backported this feature ~10 years ago, even busybox it appears. Minix's default shell possibly does not support this though, but I saw other existing syntax that minix would likely not work with anyways.