[BUILD] centralize version and date into one file for each

The version does not appear anymore in the Makefiles nor in
the include files. It was a nightmare to maintain. Now there
is a VERSION file which contains the major version, a VERDATE
file which contains the date for this version and a SUBVERS
file which may contain a sub-version.

A "make version" target has been added to all makefiles to
check the version. The GNU Makefile also has an update-version
target to update those files. This should never be used.

It is still possible to override those values by specifying
them in the equivalent make variables. By default, the GNU
makefile tries to detect a GIT repository and always uses the
version and date from the current repository. This can be
disabled by setting IGNOREGIT to a non-void value.
diff --git a/Makefile.bsd b/Makefile.bsd
index 892cdb2..f4ff4f2 100644
--- a/Makefile.bsd
+++ b/Makefile.bsd
@@ -7,8 +7,6 @@
 #   make TARGET=freebsd CPU=i686 DLMALLOC_SRC=/usr/local/src/dlmalloc.c \
 #        OPT_OBJS=src/dlmalloc.o
 
-VERSION := 1.3.12
-
 # Select target OS. TARGET must match a system for which COPTS and LIBS are
 # correctly defined below.
 TARGET = openbsd
@@ -87,10 +85,17 @@
 REGEX_OPTS=$(COPTS.$(REGEX))
 CPU_OPTS=$(COPTS.$(CPU))
 
-COPTS=-Iinclude $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE)
-LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
+VERSION != cat VERSION 2>/dev/null || touch VERSION
+SUBVERS != cat SUBVERS 2>/dev/null || touch SUBVERS
+VERDATE != cat VERDATE 2>/dev/null || touch VERDATE
 
-CFLAGS = -Wall $(COPTS) $(DEBUG)
+VER_OPTS := -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\" \
+            -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
+
+COPTS   = -Iinclude $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) \
+          $(SMALL_OPTS) $(VER_OPTS) $(DEFINE)
+LIBS    = $(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
+CFLAGS  = -Wall $(COPTS) $(DEBUG)
 LDFLAGS = -g
 
 OBJS = src/haproxy.o src/sessionhash.o src/base64.o \
@@ -118,3 +123,8 @@
 	rm -f *.[oas] src/*.[oas] core haproxy test
 	for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;done
 	rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION) nohup.out gmon.out
+
+version:
+	@echo "VERSION: $(VERSION)"
+	@echo "SUBVERS: $(SUBVERS)"
+	@echo "VERDATE: $(VERDATE)"