Use getopt_long() instead of getopt()

Also, respond properly to --help and --version as per GNU
coding standards.