From: Etienne Dechamps Date: Sun, 29 Jun 2014 13:57:42 +0000 (+0100) Subject: Regenerate build date and time every time tinc is built. X-Git-Tag: release-1.1pre11~85 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=aec82bb1c94af6d3142cdef0c51f42f38e9be3e0;p=tinc Regenerate build date and time every time tinc is built. This prevents the date and time shown in version information from getting stale because of partial builds. With these changes, date and time information is written to a dedicated object file that gets rebuilt every time make is run, even if there are no changes. --- diff --git a/src/Makefile.am b/src/Makefile.am index 1a84098e..c48e3fdd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,6 +2,9 @@ sbin_PROGRAMS = tincd tinc sptps_test sptps_keypair +## Make sure version.c is always rebuilt +.PHONY: version.c + if LINUX sbin_PROGRAMS += sptps_speed endif @@ -88,6 +91,7 @@ tincd_SOURCES = \ tincd.c \ utils.c utils.h \ xalloc.h \ + version.c version.h \ $(ed25519_SOURCES) \ $(chacha_poly1305_SOURCES) @@ -106,6 +110,7 @@ tinc_SOURCES = \ tincctl.c tincctl.h \ top.c top.h \ utils.c utils.h \ + version.c version.h \ $(ed25519_SOURCES) \ $(chacha_poly1305_SOURCES) diff --git a/src/process.c b/src/process.c index 98f4d33a..15120aca 100644 --- a/src/process.c +++ b/src/process.c @@ -34,6 +34,7 @@ #include "subnet.h" #include "utils.h" #include "xalloc.h" +#include "version.h" /* If zero, don't detach from the terminal. */ bool do_detach = true; @@ -223,7 +224,7 @@ bool detach(void) { openlogger(identname, use_logfile?LOGMODE_FILE:(do_detach?LOGMODE_SYSLOG:LOGMODE_STDERR)); logger(DEBUG_ALWAYS, LOG_NOTICE, "tincd %s (%s %s) starting, debug level %d", - VERSION, __DATE__, __TIME__, debug_level); + VERSION, BUILD_DATE, BUILD_TIME, debug_level); return true; } diff --git a/src/tincctl.c b/src/tincctl.c index 18fc05ac..fc21d42a 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -38,6 +38,7 @@ #include "utils.h" #include "tincctl.h" #include "top.h" +#include "version.h" #ifndef MSG_NOSIGNAL #define MSG_NOSIGNAL 0 @@ -85,7 +86,7 @@ static struct option const long_options[] = { static void version(void) { printf("%s version %s (built %s %s, protocol %d.%d)\n", PACKAGE, - VERSION, __DATE__, __TIME__, PROT_MAJOR, PROT_MINOR); + VERSION, BUILD_DATE, BUILD_TIME, PROT_MAJOR, PROT_MINOR); printf("Copyright (C) 1998-2012 Ivo Timmermans, Guus Sliepen and others.\n" "See the AUTHORS file for a complete list.\n\n" "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" diff --git a/src/tincd.c b/src/tincd.c index 87c0b7d1..30a56782 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -57,6 +57,7 @@ #include "protocol.h" #include "utils.h" #include "xalloc.h" +#include "version.h" /* If nonzero, display usage information and exit. */ static bool show_help = false; @@ -319,7 +320,7 @@ int main(int argc, char **argv) { if(show_version) { printf("%s version %s (built %s %s, protocol %d.%d)\n", PACKAGE, - VERSION, __DATE__, __TIME__, PROT_MAJOR, PROT_MINOR); + VERSION, BUILD_DATE, BUILD_TIME, PROT_MAJOR, PROT_MINOR); printf("Copyright (C) 1998-2014 Ivo Timmermans, Guus Sliepen and others.\n" "See the AUTHORS file for a complete list.\n\n" "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" diff --git a/src/version.c b/src/version.c new file mode 100644 index 00000000..fc62c8a3 --- /dev/null +++ b/src/version.c @@ -0,0 +1,24 @@ +/* + version.c -- version information + Copyright (C) 2014 Etienne Dechamps + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "version.h" + +/* This file is always rebuilt (even if there are no changes) so that the following is updated */ +const char* const BUILD_DATE = __DATE__; +const char* const BUILD_TIME = __TIME__; diff --git a/src/version.h b/src/version.h new file mode 100644 index 00000000..d3e4a1f2 --- /dev/null +++ b/src/version.h @@ -0,0 +1,26 @@ +/* + version.h -- header for version.c + Copyright (C) 2014 Etienne Dechamps + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __TINC_VERSION_H__ +#define __TINC_VERSION_H__ + +extern const char* const BUILD_DATE; +extern const char* const BUILD_TIME; + +#endif /* __TINC_VERSION_H__ */