# Create jmods in the support dir and then move them into place to keep the
# module path in $(IMAGES_OUTPUTDIR)/jmods valid at all times.
+# strip-nondeterminism requires the same timestamp as
+# dh_strip_nondeterminism uses, so we determine this first.
+# Fall back to the original behavior if the tools are missing for backports
+DSN_TIMESTAMP := $(shell perl -MDebian::Debhelper::Dh_Lib -e 'print get_source_date_epoch()' 2>/dev/null)
+ifneq (,$(DSN_TIMESTAMP))
+ ifneq (,$(wildcard /bin/strip-nondeterminism /usr/bin/strip-nondeterminism))
+ use_strip_ndt = yes
+ endif
+endif
$(eval $(call SetupExecute, create_$(JMOD_FILE), \
WARN := Creating $(INTERIM_MSG)$(JMOD_FILE), \
DEPS := $(DEPS), \
--module-path $(JMODS_DIR) $(JMOD_FLAGS) \
$(JMOD_SOURCE_DATE) \
$(JMODS_SUPPORT_DIR)/$(JMOD_FILE), \
- POST_COMMAND := $(MV) $(JMODS_SUPPORT_DIR)/$(JMOD_FILE) $(JMODS_DIR)/$(JMOD_FILE), \
+ POST_COMMAND := $(if $(use_strip_ndt),strip-nondeterminism --timestamp $(DSN_TIMESTAMP) $(JMODS_SUPPORT_DIR)/$(JMOD_FILE) && )$(MV) $(JMODS_SUPPORT_DIR)/$(JMOD_FILE) $(JMODS_DIR)/$(JMOD_FILE), \
))
TARGETS += $(create_$(JMOD_FILE))