diff --git a/include/host-build.mk b/include/host-build.mk index 235caaa6fbe8fc..246f248e26eecf 100644 --- a/include/host-build.mk +++ b/include/host-build.mk @@ -67,6 +67,10 @@ HOST_CONFIGURE_ARGS = \ --localstatedir=$(HOST_BUILD_PREFIX)/var \ --sbindir=$(HOST_BUILD_PREFIX)/bin +ifneq ($(YEAR_2038),y) + HOST_CONFIGURE_ARGS += --disable-year2038 +endif + HOST_MAKE_VARS = \ CFLAGS="$(HOST_CFLAGS)" \ CPPFLAGS="$(HOST_CPPFLAGS)" \ diff --git a/rules.mk b/rules.mk index 66297565cbab34..91ed9b2085a049 100644 --- a/rules.mk +++ b/rules.mk @@ -26,6 +26,7 @@ qstrip=$(strip $(subst ",,$(1))) empty:= space:= $(empty) $(empty) comma:=, +pound:=\# merge=$(subst $(space),,$(1)) confvar=$(shell echo '$(foreach v,$(1),$(v)=$(subst ','\'',$($(v))))' | $(MKHASH) md5) strip_last=$(patsubst %.$(lastword $(subst .,$(space),$(1))),%,$(1)) @@ -378,6 +379,19 @@ define shexport export $(call shvar,$(1))=$$(call $(1)) endef +# Test support for 64-bit time with C code from largefile.m4 provided by GNU Gnulib +# the value is 'y' when successful and '' otherwise +define YEAR_2038 +$(shell \ + mkdir -p $(TMP_DIR); \ + echo '$(pound) include ' > $(TMP_DIR)/year2038.c; \ + echo '$(pound) define LARGE_TIME_T ((time_t) (((time_t) 1 << 30) - 1 + 3 * ((time_t) 1 << 30)))' >> $(TMP_DIR)/year2038.c; \ + echo 'int verify_time_t_range[(LARGE_TIME_T / 65537 == 65535 && LARGE_TIME_T % 65537 == 0) ? 1 : -1];' >> $(TMP_DIR)/year2038.c; \ + echo 'int main (void) {return 0;}' >> $(TMP_DIR)/year2038.c; \ + $(HOSTCC) $(TMP_DIR)/year2038.c -o /dev/null 2>/dev/null && echo y && rm -f $(TMP_DIR)/year2038.c || rm -f $(TMP_DIR)/year2038.c; \ +) +endef + # Execute commands under flock # $(1) => The shell expression. # $(2) => The lock name. If not given, the global lock will be used.