[MINOR] store the build options to report with -vv

Sometimes it is useful to find out how a given binary version was
built. The build compiler and options are now provided for this,
and it's possible to get them with the -vv option.
diff --git a/Makefile b/Makefile
index aa523cd..25c460f 100644
--- a/Makefile
+++ b/Makefile
@@ -245,6 +245,11 @@
 %.o:	%.c
 	$(CC) $(CFLAGS) -c -o $@ $<
 
+src/haproxy.o:	src/haproxy.c
+	$(CC) $(CFLAGS) -DBUILD_TARGET='"$(TARGET)"' -DBUILD_CC='"$(CC)"' \
+	                -DBUILD_CPU='"$(CPU)"' -DBUILD_REGEX='"$(REGEX)"' \
+	                -DBUILD_OPTS='"$(COPTS)"' -c -o $@ $<
+
 src/dlmalloc.o: $(DLMALLOC_SRC)
 	$(CC) $(CFLAGS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $<
 
diff --git a/Makefile.bsd b/Makefile.bsd
index d85ae00..d05ad55 100644
--- a/Makefile.bsd
+++ b/Makefile.bsd
@@ -119,6 +119,11 @@
 .c.o:
 	$(CC) $(CFLAGS) -c -o $@ $>
 
+src/haproxy.o: src/haproxy.c
+	$(CC) $(CFLAGS) -DBUILD_TARGET='"$(TARGET)"' -DBUILD_CC='"$(CC)"' \
+	                -DBUILD_CPU='"$(CPU)"' -DBUILD_REGEX='"$(REGEX)"' \
+	                -DBUILD_OPTS='"$(COPTS)"' -c -o $@ $>
+
 src/dlmalloc.o: $(DLMALLOC_SRC)
 	$(CC) $(CFLAGS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $>
 
diff --git a/Makefile.osx b/Makefile.osx
index 586d449..f2469bc 100644
--- a/Makefile.osx
+++ b/Makefile.osx
@@ -116,6 +116,11 @@
 .c.o:
 	$(CC) $(CFLAGS) -c -o $@ $<
 
+src/haproxy.o: src/haproxy.c
+	$(CC) $(CFLAGS) -DBUILD_TARGET='"$(TARGET)"' -DBUILD_CC='"$(CC)"' \
+	                -DBUILD_CPU='"$(CPU)"' -DBUILD_REGEX='"$(REGEX)"' \
+	                -DBUILD_OPTS='"$(COPTS)"' -c -o $@ $<
+
 src/dlmalloc.o: $(DLMALLOC_SRC)
 	$(CC) $(CFLAGS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $<
 
diff --git a/src/haproxy.c b/src/haproxy.c
index 791f64b..887c162 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -171,6 +171,27 @@
 	printf("Copyright 2000-2007 Willy Tarreau <w@1wt.eu>\n\n");
 }
 
+void display_build_opts()
+{
+	printf("Build options :"
+#ifdef BUILD_TARGET
+	       "\n  TARGET = " BUILD_TARGET
+#endif
+#ifdef BUILD_CPU
+	       "\n  CPU    = " BUILD_CPU
+#endif
+#ifdef BUILD_REGEX
+	       "\n  REGEX  = " BUILD_REGEX
+#endif
+#ifdef BUILD_CC
+	       "\n  CC     = " BUILD_CC
+#endif
+#ifdef BUILD_OPTS
+	       "\n  COPTS  = " BUILD_OPTS
+#endif
+	       "\n\n");
+}
+
 /*
  * This function prints the command line usage and exits
  */
@@ -181,7 +202,7 @@
 		"Usage : %s -f <cfgfile> [ -vdV"
 		"D ] [ -n <maxconn> ] [ -N <maxpconn> ]\n"
 		"        [ -p <pidfile> ] [ -m <max megs> ]\n"
-		"        -v displays version\n"
+		"        -v displays version ; -vv shows known build options.\n"
 		"        -d enters debug mode ; -db only disables background mode.\n"
 		"        -V enters verbose mode (disables quiet mode)\n"
 		"        -D goes daemon ; implies -q\n"
@@ -432,6 +453,8 @@
 			/* 1 arg */
 			if (*flag == 'v') {
 				display_version();
+				if (flag[1] == 'v')  /* -vv */
+					display_build_opts();
 				exit(0);
 			}
 #if defined(ENABLE_EPOLL)