Remove hard-coded getopt and improve Makefile