cbfstool: Rework to use getopt style parameters

- Adding more and more optional and non-optional parameters
  bloated cbfstool and made the code hard to read with a lot
  of parsing in the actual cbfs handling functions. This change
  switches over to use getopt style options for everything but
  command and cbfs file name.
- This allows us to simplify the coreboot Makefiles a bit
- Also, add guards to include files
- Fix some 80+ character lines
- Add more detailed error reporting
- Free memory we're allocating

Signed-off-by: Stefan Reinauer <reinauer@google.com>
Change-Id: Ia9137942deb8d26bbb30068e6de72466afe9b0a7
Reviewed-on: http://review.coreboot.org/1800
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
diff --git a/util/cbfstool/cbfs-mkstage.c b/util/cbfstool/cbfs-mkstage.c
index 6b80a37..55c81c6 100644
--- a/util/cbfstool/cbfs-mkstage.c
+++ b/util/cbfstool/cbfs-mkstage.c
@@ -31,7 +31,7 @@
 #include "common.h"
 #include "cbfs.h"
 
-unsigned int idemp(unsigned int x)
+static unsigned int idemp(unsigned int x)
 {
 	return x;
 }
@@ -123,7 +123,8 @@
 	}
 
 	if (data_end <= data_start) {
-		fprintf(stderr, "E: data ends before it starts. Make sure the ELF file is correct and resides in ROM space.\n");
+		fprintf(stderr, "E: data ends before it starts. Make sure the "
+			"ELF file is correct and resides in ROM space.\n");
 		exit(1);
 	}
 
@@ -175,6 +176,8 @@
 	compress(buffer, data_end - data_start,
 		 (char *)(out + sizeof(struct cbfs_stage)), (int *)&stage->len);
 
+	free(buffer);
+
 	*output = out;
 
 	if (*location)