Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Show commit id in version for git builds.

  • Loading branch information...
commit a1311277703c96b7caa45573d0b857f17b3a937b 1 parent a88d9c7
@DarthGandalf DarthGandalf authored
View
18 Makefile.in
@@ -27,16 +27,18 @@ INSTALL := @INSTALL@
INSTALL_PROGRAM := @INSTALL_PROGRAM@
INSTALL_SCRIPT := @INSTALL_SCRIPT@
INSTALL_DATA := @INSTALL_DATA@
+GIT := @GIT@
+SED := @SED@
LIB_SRCS := ZNCString.cpp Csocket.cpp znc.cpp IRCNetwork.cpp User.cpp IRCSock.cpp \
Client.cpp Chan.cpp Nick.cpp Server.cpp Modules.cpp MD5.cpp Buffer.cpp Utils.cpp \
FileUtils.cpp HTTPSock.cpp Template.cpp ClientCommand.cpp Socket.cpp SHA256.cpp \
- WebModules.cpp Listener.cpp Config.cpp ZNCDebug.cpp
+ WebModules.cpp Listener.cpp Config.cpp ZNCDebug.cpp version.cpp
LIB_SRCS := $(addprefix src/,$(LIB_SRCS))
BIN_SRCS := src/main.cpp
LIB_OBJS := $(patsubst %cpp,%o,$(LIB_SRCS))
BIN_OBJS := $(patsubst %cpp,%o,$(BIN_SRCS))
-CLEAN := znc src/*.o core core.*
+CLEAN := znc src/*.o core core.* .version_extra
DISTCLEAN := Makefile config.log config.status znc-buildmod .depend \
modules/.depend modules/Makefile man/Makefile znc.pc znc-uninstalled.pc
@@ -55,7 +57,7 @@ E=@\#
C=
endif
-.PHONY: all man modules clean distclean install
+.PHONY: all man modules clean distclean install version_extra_recompile
.SECONDARY:
all: znc man modules $(LIBZNC)
@@ -98,6 +100,16 @@ src/%.o: src/%.cpp Makefile
$(E) Building core object $*...
$(Q)$(CXX) $(CXXFLAGS) -c -o $@ $< -MD -MF .depend/$*.dep -MT $@
+ifneq "$(GIT)" ""
+# If git-describe differs from .version_extra, add a phony target to dependencies, forcing version.o to be recompiled
+# znc-0.200-430-g80acaa7 -> -DVERSION_EXTRA="\"-git-430-80acaa7\""
+src/version.o: src/version.cpp Makefile $(shell if [ x`cat .version_extra 2> /dev/null` != x`$(GIT) --git-dir=$(srcdir)/.git describe 2> /dev/null` ]; then echo version_extra_recompile; fi)
+ @mkdir -p .depend src
+ $(E) Building core object version...
+ $(Q)$(CXX) $(shell $(GIT) --git-dir=$(srcdir)/.git describe 2> /dev/null | $(SED) 's/.*-\([0123456789][0123456789]*\)-g\(.*\)/-DVERSION_EXTRA="\\"-git-\1-\2\\""/') $(CXXFLAGS) -c -o $@ $< -MD -MF .depend/version.dep -MT $@
+ -$(Q)$(GIT) --git-dir=$(srcdir)/.git describe > .version_extra 2> /dev/null
+endif
+
install: znc $(LIBZNC)
test -d $(DESTDIR)$(bindir) || $(INSTALL) -d $(DESTDIR)$(bindir)
test -d $(DESTDIR)$(includedir)/znc || $(INSTALL) -d $(DESTDIR)$(includedir)/znc
View
1  configure.ac
@@ -35,6 +35,7 @@ AC_PROG_SED
AC_CANONICAL_HOST
AC_SYS_LARGEFILE
ZNC_VISIBILITY
+AC_PATH_PROG([GIT], [git])
appendLib () {
if test "$LIBS" != ""; then
View
12 include/znc/main.h
@@ -10,17 +10,7 @@
#define _MAIN_H
#include <znc/zncconfig.h>
-
-// The following defines are for #if comparison (preprocessor only likes ints)
-#define VERSION_MAJOR 0
-#define VERSION_MINOR 207
-// This one is for display purpose
-#define VERSION (VERSION_MAJOR + VERSION_MINOR / 1000.0)
-
-// You can add -DVERSION_EXTRA="stuff" to your CXXFLAGS!
-#ifndef VERSION_EXTRA
-#define VERSION_EXTRA ""
-#endif
+#include <znc/version.h>
#define NOTHING (void)0
View
13 include/znc/version.h
@@ -0,0 +1,13 @@
+#ifndef _VERSION_H
+#define _VERSION_H
+
+// The following defines are for #if comparison (preprocessor only likes ints)
+#define VERSION_MAJOR 0
+#define VERSION_MINOR 207
+// This one is for display purpose
+#define VERSION (VERSION_MAJOR + VERSION_MINOR / 1000.0)
+
+// You can add -DVERSION_EXTRA="stuff" to your CXXFLAGS!
+extern const char* ZNC_VERSION_EXTRA;
+
+#endif
View
2  modules/modperl/module.h
@@ -175,7 +175,7 @@ inline double GetVersion() {
}
inline CString GetVersionExtra() {
- return VERSION_EXTRA;
+ return ZNC_VERSION_EXTRA;
}
#if HAVE_VISIBILITY
#pragma GCC visibility pop
View
2  modules/modpython/module.h
@@ -215,7 +215,7 @@ inline double GetVersion() {
}
inline CString GetVersionExtra() {
- return VERSION_EXTRA;
+ return ZNC_VERSION_EXTRA;
}
class MCString_iter {
View
8 src/version.cpp
@@ -0,0 +1,8 @@
+#include <znc/version.h>
+
+#ifdef VERSION_EXTRA
+const char* ZNC_VERSION_EXTRA = VERSION_EXTRA;
+#else
+const char* ZNC_VERSION_EXTRA = "";
+#endif
+
View
4 src/znc.cpp
@@ -72,7 +72,7 @@ CZNC::~CZNC() {
CString CZNC::GetVersion() {
char szBuf[128];
- snprintf(szBuf, sizeof(szBuf), "%1.3f"VERSION_EXTRA, VERSION);
+ snprintf(szBuf, sizeof(szBuf), "%1.3f%s", VERSION, ZNC_VERSION_EXTRA);
// If snprintf overflows (which I doubt), we want to be on the safe side
szBuf[sizeof(szBuf) - 1] = '\0';
@@ -87,7 +87,7 @@ CString CZNC::GetTag(bool bIncludeVersion, bool bHTML) {
}
char szBuf[128];
- snprintf(szBuf, sizeof(szBuf), "ZNC %1.3f"VERSION_EXTRA" - ", VERSION);
+ snprintf(szBuf, sizeof(szBuf), "ZNC %1.3f%s - ", VERSION, ZNC_VERSION_EXTRA);
// If snprintf overflows (which I doubt), we want to be on the safe side
szBuf[sizeof(szBuf) - 1] = '\0';
Please sign in to comment.
Something went wrong with that request. Please try again.