Fixed buffer overflow when generating filenames.

Fixed Makefile so libstdc++ and libgcc are now statically linked.
Fixed regular expression for filenames that have dots before the
extension.