Makefiles: Change link sequence for better compatibility.

Some compilers need the link flags to be last on the command line.