CNFS_CMD = ../build-scripts/create_element_defs.pl
TIMESTAMP_FILE = conftime.h
+TIMESTAMP_FORMAT = %Y-%m-%d %H:%M
+
+# use SOURCE_DATE_EPOCH, or else last Git commit date, or else current date
+SOURCE_DATE_EPOCH ?= $(shell test -d ../.git && test `git ls-files -m | wc -l` -eq 0 && git show -s --format=%ct || date +%s)
+
+# get source date string from either GNU / Linux or BSD / Mac OS X style "date"
+SOURCE_DATE_STRING := $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(TIMESTAMP_FORMAT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(TIMESTAMP_FORMAT)" 2>/dev/null || date -u "+$(TIMESTAMP_FORMAT)")
LIBGAME_DIR = libgame
LIBGAME = $(LIBGAME_DIR)/libgame.a
conf_mus.h: conf_mus.c $(CNFS_CMD)
@$(MAKE) auto-conf
-# $(TIMESTAMP_FILE): $(SRCS) $(LIBGAME) $(GAME_EM) $(GAME_SP)
$(TIMESTAMP_FILE): $(SRCS) $(RNDLIBS)
- @date '+"%Y-%m-%d %H:%M"' \
- | sed -e 's/^/#define COMPILE_DATE_STRING /' \
+ @echo '#define SOURCE_DATE_STRING "$(SOURCE_DATE_STRING)"' \
> $(TIMESTAMP_FILE)
$(ICON):
#include "conftime.h"
-char *getCompileDateString()
+char *getSourceDateString()
{
- return COMPILE_DATE_STRING;
+ return SOURCE_DATE_STRING;
}
char *getProgramTitleString()
#ifdef DEBUG
window_title_string = checked_malloc(strlen(getProgramInitString()) + 20 +
- strlen(getCompileDateString()) + 2 + 1);
+ strlen(getSourceDateString()) + 2 + 1);
sprintf(window_title_string, "%s (%d %%) [%s]",
getProgramInitString(), video.window_scaling_percent,
- getCompileDateString());
+ getSourceDateString());
#else
window_title_string = checked_malloc(strlen(getProgramInitString()) + 20);
#ifdef DEBUG
window_title_string = checked_malloc(strlen(getProgramInitString()) + 1 +
- strlen(getCompileDateString()) + 2 + 1);
+ strlen(getSourceDateString()) + 2 + 1);
sprintf(window_title_string, "%s [%s]",
- getProgramInitString(), getCompileDateString());
+ getProgramInitString(), getSourceDateString());
#else
window_title_string = checked_malloc(strlen(getProgramInitString()) + 1);
#include "main.h"
-char *getCompileDateString(void);
+char *getSourceDateString(void);
char *getProgramTitleString(void);
char *getProgramVersionString(void);
char *getProgramInitString(void);
DrawTextF(xstart2, ystart2, font_text, TARGET_STRING);
ystart2 += ystep;
- DrawTextF(xstart1, ystart2, font_header, "Compile time");
- DrawTextF(xstart2, ystart2, font_text, getCompileDateString());
+ DrawTextF(xstart1, ystart2, font_header, "Source date");
+ DrawTextF(xstart2, ystart2, font_text, getSourceDateString());
ystart2 += 3 * ystep;
DrawTextF(xstart1, ystart2, font_header, "Library");