File reproducible.patch of Package gromacs

commit 1dc7c3622e28e8ae49b63ceb7dd49ab6fca6ef07
Author: Bernhard M. Wiedemann <bwiedemann@suse.de>
Date:   Thu Aug 9 07:53:29 2018 +0200

    Allow to omit build system details from binaries
    
    This is auto-enabled when the SOURCE_DATE_EPOCH variable is set
    because that is already used by everyone doing reproducible builds
    It already fixes the cmake TIMESTAMP, so no change needed there.
    
    Change-Id: I8aa3d670aee90c60d30076923977e1a22d1496ba

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ef9be348b..4bdf4a862 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -201,6 +201,12 @@ gmx_add_cache_dependency(GMX_COOL_QUOTES BOOL "NOT GMX_FAHCORE" OFF)
 
 option(GMX_USE_OPENCL "Enable OpenCL acceleration" OFF)
 
+if($ENV{SOURCE_DATE_EPOCH})
+    set(GMX_REPRODUCIBLE_BUILD ON "Create reproducible binaries - suitable for distributions")
+else()
+    set(GMX_REPRODUCIBLE_BUILD OFF)
+endif()
+
 # Decide on GPU settings based on user-settings and GPU/CUDA
 # detection.  GCC 4.8 requires CUDA 6.0 (but we choose 6.5 for the
 # preliminary C++11 support), icc 15 requires CUDA 7.0, and VS2015
@@ -636,6 +642,9 @@ gmx_option_multichoice(
 mark_as_advanced(GMX_USE_RDTSCP)
 
 macro(gmx_check_rdtscp)
+    if (GMX_REPRODUCIBLE_BUILD)
+        message(FATAL_ERROR "For a reproducible build, you should not autodetect based on build system CPU. Use -DGMX_USE_RDTSCP=OFF")
+    endif()
     if (CPU_DETECTION_FEATURES MATCHES "rdtscp")
         set(HAVE_RDTSCP 1)
         set(RDTSCP_DETECTION_MESSAGE " - detected on the build host")
diff --git a/cmake/gmxDetectCpu.cmake b/cmake/gmxDetectCpu.cmake
index d5a8f12a2..87d10bad9 100644
--- a/cmake/gmxDetectCpu.cmake
+++ b/cmake/gmxDetectCpu.cmake
@@ -64,8 +64,10 @@ function(gmx_run_cpu_detection TYPE)
     set(OUTPUT_VAR "")
     # We need to execute the binary, so this only works if not
     # cross-compiling. However, note that we are NOT limited to x86.
-    if(CMAKE_CROSSCOMPILING)
-        # TODO Need we explain that we're not detecting because we are cross compiling?
+    if(CMAKE_CROSSCOMPILING OR GMX_REPRODUCIBLE_BUILD)
+        # we're not detecting because we are cross compiling
+        # or building distribution packages, meant to run on machines
+        # that are different from the build machine
     else()
         set(CPU_DETECTION_BINARY "${PROJECT_BINARY_DIR}/CMakeFiles/GmxDetectCpu${CMAKE_EXECUTABLE_SUFFIX}")
         if(NOT CPU_DETECTION_COMPILED)
diff --git a/cmake/gmxDetectSimd.cmake b/cmake/gmxDetectSimd.cmake
index bf348fc08..bd16141d1 100644
--- a/cmake/gmxDetectSimd.cmake
+++ b/cmake/gmxDetectSimd.cmake
@@ -140,6 +140,9 @@ endfunction()
 
 function(gmx_detect_simd _suggested_simd)
     if(GMX_SIMD STREQUAL "AUTO")
+        if(GMX_REPRODUCIBLE_BUILD)
+            message(FATAL_ERROR "For a reproducible build, you should not autodetect based on build system CPU. Use -DGMX_SIMD=")
+        endif()
         if(GMX_TARGET_BGQ)
             # BG/Q requires cross-compilation, so needs this
             # logic. While the qpx feature flag in cpuinfo works, it
diff --git a/cmake/gmxSetBuildInformation.cmake b/cmake/gmxSetBuildInformation.cmake
index 6d34b444c..870c63f6c 100644
--- a/cmake/gmxSetBuildInformation.cmake
+++ b/cmake/gmxSetBuildInformation.cmake
@@ -54,7 +54,7 @@ include(gmxDetectCpu)
 
 function(gmx_set_build_information)
     if(NOT BUILD_USER)
-        if(CMAKE_HOST_UNIX)
+        if(CMAKE_HOST_UNIX AND NOT GMX_REPRODUCIBLE_BUILD)
             execute_process( COMMAND whoami OUTPUT_VARIABLE TMP_USER OUTPUT_STRIP_TRAILING_WHITESPACE)
             execute_process( COMMAND hostname OUTPUT_VARIABLE TMP_HOSTNAME OUTPUT_STRIP_TRAILING_WHITESPACE)
         else()
@@ -72,7 +72,9 @@ function(gmx_set_build_information)
     endif()
 
     if(NOT BUILD_HOST)
-        if(CMAKE_HOST_UNIX)
+        if(GMX_REPRODUCIBLE_BUILD)
+            set(TMP_HOST "reproducible")
+        elseif(CMAKE_HOST_UNIX)
             execute_process( COMMAND uname -srm OUTPUT_VARIABLE TMP_HOST OUTPUT_STRIP_TRAILING_WHITESPACE)
         else()
             set(TMP_HOST "${CMAKE_HOST_SYSTEM} ${CMAKE_HOST_SYSTEM_PROCESSOR}")
@@ -85,6 +87,9 @@ function(gmx_set_build_information)
     if(CMAKE_CROSSCOMPILING)
         set(_reason ", cross-compiled")
     endif()
+    if(GMX_REPRODUCIBLE_BUILD)
+        set(_reason ", reproducible-build")
+    endif()
 
     # Run the cpu detection. If it produces an empty output, set a
     # local value in the parent scope with a suitable fallback (which
openSUSE Build Service is sponsored by