libcrypto: add support for SOURCE_DATE_EPOCH

Use SOURCE_DATE_EPOCH for build date if present.

issue #5255
This commit is contained in:
Sebastian Sumpf 2024-06-25 10:27:12 +02:00 committed by Norman Feske
parent cfe27e07de
commit eb656bf40c

View File

@ -651,13 +651,23 @@ CC_OPT_ec/curve448/scalar += $(CURVE448_INCLUDES)
#
$(SRC_C:.c=.o): buildinf.h
# Taken from https://reproducible-builds.org/docs/source-date-epoch
DATE_FMT = +%Y-%m-%d
ifdef SOURCE_DATE_EPOCH
BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || \
date -u -r "$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || \
date -u "$(DATE_FMT)")
else
BUILD_DATE ?= $(shell date "$(DATE_FMT)")
endif
# Rules taken from FreeBSDs libcrypto/Makefile
buildinf.h:
$(VERBOSE)( \
echo "#ifndef MK1MF_BUILD" ;\
echo "/* auto-generated by libcrypto.mk for crypto/cversion.c */" ;\
echo "/* auto-generated by libcrypto.mk for crypto/cversion.c */" ;\
echo "#define PLATFORM \"Genode-$(TARGET_CPUARCH)\"" ;\
echo "#define DATE \"built on: $(shell date --rfc-email)\"" ;\
echo "#define DATE \"built on: $(BUILD_DATE)\"" ;\
echo "static const char compiler_flags[] = \"<undefined>\";" ;\
echo "#endif" ;\
) > $@