diff --git a/Recipe b/Recipe index 379f9b6b..952373f2 100644 --- a/Recipe +++ b/Recipe @@ -134,6 +134,18 @@ # ------------------------------------------------------------ # Additional text added verbatim to each individual Makefile. +!cflags am version -DSOURCE_COMMIT=\"`git rev-parse HEAD 2>/dev/null`\" +!begin am +BUILT_SOURCES = empty.h +CLEANFILES = empty.h +empty.h: $(allsources) + echo '/* Empty file touched by automake makefile to force rebuild of version.o */' >$@ + +!end +!begin >empty.h +/* Empty file touched by automake makefile to force rebuild of version.o */ +!end + !begin vc vars CFLAGS = $(CFLAGS) /DHAS_GSSAPI !end diff --git a/version.c b/version.c index 231c1a75..59e9ca75 100644 --- a/version.c +++ b/version.c @@ -8,6 +8,10 @@ * to do here is to drop it into variables of the right names. */ +#ifdef SOURCE_COMMIT +#include "empty.h" +#endif + #include "version.h" const char ver[] = TEXTVER; diff --git a/version.h b/version.h index a9fab692..26242ad6 100644 --- a/version.h +++ b/version.h @@ -11,4 +11,25 @@ #define TEXTVER "Unidentified build" #define SSHVER "PuTTY-Unidentified-Local-Build" #define BINARY_VERSION 0,0,0,0 + +#ifndef SOURCE_COMMIT +/* + * git commit id from which this build was made. This is defined by + * Buildscr for official builds - both source archives and prebuilt + * binaries - in the course of overwriting this file as described + * above. But we put it here under ifdef, so that it can also be + * passed in on the command line for Unix local development builds, + * which I treat specially because Unix developers - e.g. me - are + * quite likely to run 'make install' straight out of their dev + * directory so as to use the bleeding-edge code for day-to-day + * running. + * + * Windows doesn't really need the same treatment, because the easiest + * way to install a build properly on Windows is to run the installer, + * and the easiest way to do that is to run Buildscr, which will + * populate this field its own way. It's only the Unix automake build + * where you might go straight from local 'make' to 'make install' + * without going through Buildscr. + */ #define SOURCE_COMMIT "unavailable" +#endif