compiler: separate argument parser and improve it

Notable change: only generate a single target
(the last instance of the -g option).