@@ -683,3 +683,76 @@ AC_DEFUN([JDKOPT_ALLOW_ABSOLUTE_PATHS_IN_OUTPUT],
683683
684684 AC_SUBST ( ALLOW_ABSOLUTE_PATHS_IN_OUTPUT )
685685] )
686+
687+ # ###############################################################################
688+ #
689+ # Check and set options related to reproducible builds.
690+ #
691+ AC_DEFUN_ONCE ( [ JDKOPT_SETUP_REPRODUCIBLE_BUILD] ,
692+ [
693+ AC_ARG_WITH ( [ source-date] , [ AS_HELP_STRING ( [ --with-source-date] ,
694+ [ how to set SOURCE_DATE_EPOCH ('updated', 'current', 'version' a timestamp or an ISO-8601 date) @<:@ updated@:>@ ] ) ] ,
695+ [ with_source_date_present=true] , [ with_source_date_present=false] )
696+
697+ AC_MSG_CHECKING ( [ what source date to use] )
698+
699+ if test "x$with_source_date" = xyes; then
700+ AC_MSG_ERROR ( [ --with-source-date must have a value] )
701+ elif test "x$with_source_date" = xupdated || test "x$with_source_date" = x; then
702+ # Tell the makefiles to update at each build
703+ SOURCE_DATE=updated
704+ AC_MSG_RESULT ( [ determined at build time, from 'updated'] )
705+ elif test "x$with_source_date" = xcurrent; then
706+ # Set the current time
707+ SOURCE_DATE=$($DATE +"%s")
708+ AC_MSG_RESULT ( [ $SOURCE_DATE, from 'current'] )
709+ elif test "x$with_source_date" = xversion; then
710+ # Use the date from version-numbers
711+ UTIL_GET_EPOCH_TIMESTAMP(SOURCE_DATE, $DEFAULT_VERSION_DATE)
712+ if test "x$SOURCE_DATE" = x; then
713+ AC_MSG_RESULT ( [ unavailable] )
714+ AC_MSG_ERROR ( [ Cannot convert DEFAULT_VERSION_DATE to timestamp] )
715+ fi
716+ AC_MSG_RESULT ( [ $SOURCE_DATE, from 'version'] )
717+ else
718+ # It's a timestamp, an ISO-8601 date, or an invalid string
719+ # Additional [ ] needed to keep m4 from mangling shell constructs.
720+ if [ [ [ "$with_source_date" =~ ^[ 0-9] [ 0-9] *$ ] ] ] ; then
721+ SOURCE_DATE=$with_source_date
722+ AC_MSG_RESULT ( [ $SOURCE_DATE, from timestamp on command line] )
723+ else
724+ UTIL_GET_EPOCH_TIMESTAMP(SOURCE_DATE, $with_source_date)
725+ if test "x$SOURCE_DATE" != x; then
726+ AC_MSG_RESULT ( [ $SOURCE_DATE, from ISO-8601 date on command line] )
727+ else
728+ AC_MSG_RESULT ( [ unavailable] )
729+ AC_MSG_ERROR ( [ Cannot parse date string "$with_source_date"] )
730+ fi
731+ fi
732+ fi
733+
734+ REPRODUCIBLE_BUILD_DEFAULT=$with_source_date_present
735+
736+ if test "x$OPENJDK_BUILD_OS" = xwindows && \
737+ test "x$ALLOW_ABSOLUTE_PATHS_IN_OUTPUT" = xfalse; then
738+ # To support banning absolute paths on Windows, we must use the -pathmap
739+ # method, which requires reproducible builds.
740+ REPRODUCIBLE_BUILD_DEFAULT=true
741+ fi
742+
743+ UTIL_ARG_ENABLE(NAME: reproducible-build, DEFAULT: $REPRODUCIBLE_BUILD_DEFAULT,
744+ RESULT: ENABLE_REPRODUCIBLE_BUILD,
745+ DESC: [ enable reproducible builds (not yet fully functional)] ,
746+ DEFAULT_DESC: [ enabled if --with-source-date is given or on Windows without absolute paths] )
747+
748+ if test "x$OPENJDK_BUILD_OS" = xwindows && \
749+ test "x$ALLOW_ABSOLUTE_PATHS_IN_OUTPUT" = xfalse && \
750+ test "x$ENABLE_REPRODUCIBLE_BUILD" = xfalse; then
751+ AC_MSG_NOTICE ( [ On Windows it is not possible to combine --disable-reproducible-builds] )
752+ AC_MSG_NOTICE ( [ with --disable-absolute-paths-in-output.] )
753+ AC_MSG_ERROR ( [ Cannot continue] )
754+ fi
755+
756+ AC_SUBST ( SOURCE_DATE )
757+ AC_SUBST ( ENABLE_REPRODUCIBLE_BUILD )
758+ ] )
0 commit comments