From: Willy Tarreau Date: Sun, 9 Sep 2007 21:31:11 +0000 (+0200) Subject: [BUILD] centralize version and date into one file for each X-Git-Tag: v1.3.13~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec69256382ecafb4fb8aa0c684fbda3c9a1b5be3;p=thirdparty%2Fhaproxy.git [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 b/Makefile index d607e5cdf0..ba9a01156c 100644 --- 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 diff --git a/Makefile.bsd b/Makefile.bsd index 892cdb288a..f4ff4f2b6d 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 @@ 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)" diff --git a/Makefile.osx b/Makefile.osx index a920f98d9d..1c24e777e2 100644 --- a/Makefile.osx +++ b/Makefile.osx @@ -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 index 0000000000..8b13789179 --- /dev/null +++ b/SUBVERS @@ -0,0 +1 @@ + diff --git a/VERDATE b/VERDATE new file mode 100644 index 0000000000..70d00fb0c1 --- /dev/null +++ b/VERDATE @@ -0,0 +1 @@ +2007/06/17 diff --git a/VERSION b/VERSION new file mode 100644 index 0000000000..90a7f6029b --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.3.12 diff --git a/include/common/version.h b/include/common/version.h index 8022244bae..c9f5f16c6a 100644 --- a/include/common/version.h +++ b/include/common/version.h @@ -57,13 +57,13 @@ #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 */