]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUILD] centralize version and date into one file for each
authorWilly Tarreau <w@1wt.eu>
Sun, 9 Sep 2007 21:31:11 +0000 (23:31 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 9 Sep 2007 21:31:11 +0000 (23:31 +0200)
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.

Makefile
Makefile.bsd
Makefile.osx
SUBVERS [new file with mode: 0644]
VERDATE [new file with mode: 0644]
VERSION [new file with mode: 0644]
include/common/version.h

index d607e5cdf0d9b529484c08613f05daeb15d1ea58..ba9a01156c3f6c4659a795a9de113d7a82b812c2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -113,19 +113,24 @@ DEFINE = -DTPROXY
 # Now let's determine the version, sub-version and release date.
 # If we're in the GIT tree, we can use the last commit's version and date.
 ifeq ($(IGNOREGIT),)
-VERSION := $(shell [ -d .git/. ] && ref=`git-describe --tags 2>/dev/null` && ref=$${ref%-g*} && echo "$${ref\#v}" )
-endif
-
+VERSION := $(shell [ -d .git/. ] && ref=`(git-describe --tags) 2>/dev/null` && ref=$${ref%-g*} && echo "$${ref\#v}")
 ifneq ($(VERSION),)
 # OK git is there and works.
 SUBVERS := $(shell comms=`git-log --no-merges v$(VERSION).. 2>/dev/null |grep -c ^commit `; [ $$comms -gt 0 ] && echo "-$$comms" )
 VERDATE := $(shell date +%Y/%m/%d -d "`git-log HEAD^.. 2>/dev/null | grep -m 1 ^Date: | cut -f2- -d: | cut -f1 -d+`" )
-else
+endif
+endif
+
 # Otherwise, use the hard-coded version of last tag, number of changes
 # since last tag, and release date.
-VERSION := 1.3.12
-SUBVERS := 
-VERDATE := 2007/06/17
+ifeq ($(VERSION),)
+VERSION := $(shell cat VERSION 2>/dev/null || touch VERSION)
+endif
+ifeq ($(SUBVERS),)
+SUBVERS := $(shell cat SUBVERS 2>/dev/null || touch SUBVERS)
+endif
+ifeq ($(VERDATE),)
+VERDATE := $(shell cat VERDATE 2>/dev/null || touch VERDATE)
 endif
 
 #### build options
@@ -256,3 +261,19 @@ tar:       clean
 
 git-tar: clean
        git-tar-tree HEAD haproxy-$(VERSION) | gzip -9 > haproxy-$(VERSION)$(SUBVERS).tar.gz
+
+version:
+       @echo "VERSION: $(VERSION)"
+       @echo "SUBVERS: $(SUBVERS)"
+       @echo "VERDATE: $(VERDATE)"
+
+# never use this one if you don't know what it is used for.
+update-version:
+       @echo "Ready to update the following versions :"
+       @echo "VERSION: $(VERSION)"
+       @echo "SUBVERS: $(SUBVERS)"
+       @echo "VERDATE: $(VERDATE)"
+       @echo "Press [ENTER] to continue or Ctrl-C to abort now.";read
+       echo "$(VERSION)" > VERSION
+       echo "$(SUBVERS)" > SUBVERS
+       echo "$(VERDATE)" > VERDATE
index 892cdb288a76c0da3df14dd73e0a977f28448b9d..f4ff4f2b6d5e3b0e9b46adfe79a4b52ae36d301e 100644 (file)
@@ -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 @@ TARGET_OPTS=$(COPTS.$(TARGET))
 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
+
+VER_OPTS := -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\" \
+            -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
 
-CFLAGS = -Wall $(COPTS) $(DEBUG)
+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 @@ clean:
        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)"
index a920f98d9d9642160b66ae233ad31a1d33bb9bcb..1c24e777e29030b79ff44835c5e1509bccdaedcc 100644 (file)
@@ -7,8 +7,6 @@
 #   make 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 = generic
@@ -84,10 +82,17 @@ TARGET_OPTS=$(COPTS.$(TARGET))
 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
+
+VER_OPTS := -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\" \
+            -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
 
-CFLAGS = -Wall $(COPTS) $(DEBUG) -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386
+COPTS   = -Iinclude $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) \
+          $(SMALL_OPTS) $(VER_OPTS) $(DEFINE)
+LIBS    = $(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
+CFLAGS  = -Wall $(COPTS) $(DEBUG) -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386
 LDFLAGS = -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386
 
 OBJS = src/haproxy.o src/sessionhash.o src/base64.o \
@@ -115,3 +120,8 @@ clean:
        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)"
diff --git a/SUBVERS b/SUBVERS
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
+++ b/SUBVERS
@@ -0,0 +1 @@
+
diff --git a/VERDATE b/VERDATE
new file mode 100644 (file)
index 0000000..70d00fb
--- /dev/null
+++ b/VERDATE
@@ -0,0 +1 @@
+2007/06/17
diff --git a/VERSION b/VERSION
new file mode 100644 (file)
index 0000000..90a7f60
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+1.3.12
index 8022244bae412294e6403f19299c2a3c7cd73915..c9f5f16c6aa8e88277c2bdf31f7668b8b8382a4e 100644 (file)
 #ifdef CONFIG_HAPROXY_VERSION
 #define HAPROXY_VERSION CONFIG_HAPROXY_VERSION
 #else
-#define HAPROXY_VERSION "1.3.12"
+#error "Must define CONFIG_HAPROXY_VERSION"
 #endif
 
 #ifdef CONFIG_HAPROXY_DATE
 #define HAPROXY_DATE    CONFIG_HAPROXY_DATE
 #else
-#define HAPROXY_DATE    "2007/06/17"
+#error "Must define CONFIG_HAPROXY_DATE"
 #endif
 
 #endif /* _COMMON_VERSION_H */