libtiff: Merge branch 'consistently_update_TIFF-version_from_configure-ac' into 'master'

From 432a3b64ad0a393448cb44d727b5a0dd8f22eb5f Mon Sep 17 00:00:00 2001
From: Su Laus <[EMAIL REDACTED]>
Date: Sun, 3 Sep 2023 18:11:13 +0000
Subject: [PATCH] Update CMake and autoconf scripts to consistently update
 LibTIFF version defines and references in various files when version
 definition in configure.ac has been changed.

- Move in tiffvers.h from .\libtiff source directory to .\libtiff  build directory.
- Remove unused version information from tif_config.h
- With every CMake build the version defines (e.g. 4.5.1) within tiffvers.h are consistently updated from configure.ac. The version release-date is taken from file RELEASE-DATE.
- The files VERSION and RELEASE-DATE are only updated with a special CMake target build: cmake --build . --target tiff_release.

- For autotools, version information is updated from configure.ac with ./autogen.sh. LIBTIFF_RELEASE_DATE is taken form file RELEASE-DATE.
- ./configure generates tiffvers.h with the cached version information and LIBTIFF_RELEASE_DATE.
- "make release" updates tiffvers.h and VERSION file with cached version info and RELEASE-DATE file and tiffves.h with the current date.
---
 CMakeLists.txt                                | 10 +++++--
 HOWTO-RELEASE                                 |  8 ++++--
 Makefile.am                                   |  8 ++++--
 cmake/AutotoolsVersion.cmake                  |  6 ++++
 cmake/Release.cmake                           | 28 +++++++++++++++----
 cmake/ReleaseScript.cmake                     | 16 +++++++++--
 configure.ac                                  | 10 +++++--
 libtiff/CMakeLists.txt                        |  6 +++-
 libtiff/Makefile.am                           |  1 +
 libtiff/tif_config.h.cmake.in                 |  9 ------
 libtiff/tif_config.h.in                       |  9 ------
 libtiff/tif_win32_versioninfo.rc              |  5 ++--
 libtiff/{tiffvers.h => tiffvers.h.cmake.in}   | 16 +++++++----
 libtiff/tiffvers.h.in                         | 16 +++++++----
 tools/tif_tools_versioninfo.rc                |  5 ++--
 .../tif_tools-unsupported_versioninfo.rc      |  5 ++--
 16 files changed, 101 insertions(+), 57 deletions(-)
 rename libtiff/{tiffvers.h => tiffvers.h.cmake.in} (57%)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 184f7863..cdd54950 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,9 +35,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
 # Read version information from configure.ac.
 include(AutotoolsVersion)
 message(STATUS "Building tiff version ${LIBTIFF_VERSION_FULL}")
-message(STATUS "libtiff library version ${SO_VERSION}")
-string(TIMESTAMP BUILD_DATE "%Y%m%d")
-message(STATUS "libtiff build date: ${BUILD_DATE}")
 
 # Project definition
 set(CMAKE_C_STANDARD 99)
@@ -167,6 +164,13 @@ include(PkgConfig)
 message(STATUS "")
 message(STATUS "Libtiff is now configured for ${CMAKE_SYSTEM}")
 message(STATUS "")
+if (NOT LIBTIFF_RELEASE_VERSION STREQUAL LIBTIFF_VERSION_FULL)
+  message(STATUS "  Libtiff release version      ${LIBTIFF_RELEASE_VERSION} is not equal to build version!")
+endif()
+message(STATUS "  Libtiff build version:       ${LIBTIFF_VERSION_FULL}")
+message(STATUS "  Libtiff library version:     ${SO_VERSION}")
+message(STATUS "  Libtiff release date:        ${LIBTIFF_RELEASE_DATE}")
+message(STATUS "")
 message(STATUS "  Installation directory:             ${prefix}")
 message(STATUS "  Documentation directory:            ${LIBTIFF_DOCDIR}")
 message(STATUS "  C compiler:                         ${CMAKE_C_COMPILER}")
diff --git a/HOWTO-RELEASE b/HOWTO-RELEASE
index 7d46abe3..3821faad 100644
--- a/HOWTO-RELEASE
+++ b/HOWTO-RELEASE
@@ -100,11 +100,13 @@ Notes on releasing.
 
      make release
 
-   This will update "RELEASE-DATE", "VERSION", and libtiff/tiffvers.h
-   in the source tree.
+   This will update "RELEASE-DATE", "VERSION" in the source tree, 
+   and libtiff/tiffvers.h in the build tree.
 
 12. In the source tree, verify that the version info in RELEASE-DATE,
-   VERSION and libtiff/tiffvers.h is right.
+    VERSION is right.
+    In the build tree, verify that the version info in
+    libtiff/tiffvers.h is right.
 
 13. In the build tree do
 
diff --git a/Makefile.am b/Makefile.am
index 0b2276d9..80f6341a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -62,10 +62,14 @@ distcheck-hook:
 
 SUBDIRS = port libtiff tools build contrib test doc tools/unsupported
 
+
+NEW_LIBTIFF_RELEASE_DATE=$(shell date +"%Y%m%d")
+
 release:
-	(rm -f $(top_srcdir)/RELEASE-DATE && echo $(LIBTIFF_RELEASE_DATE) > $(top_srcdir)/RELEASE-DATE)
+	@(echo --- Setting release date to $(NEW_LIBTIFF_RELEASE_DATE) and release version to $(LIBTIFF_VERSION) ---)
+	(rm -f $(top_srcdir)/RELEASE-DATE && echo $(NEW_LIBTIFF_RELEASE_DATE) > $(top_srcdir)/RELEASE-DATE)
 	(rm -f $(top_srcdir)/VERSION && echo $(LIBTIFF_VERSION) > $(top_srcdir)/VERSION)
-	(rm -f $(top_srcdir)/libtiff/tiffvers.h && sed 's,LIBTIFF_VERSION,$(LIBTIFF_VERSION),;s,LIBTIFF_RELEASE_DATE,$(LIBTIFF_RELEASE_DATE),;s,LIBTIFF_MAJOR_VERSION,$(LIBTIFF_MAJOR_VERSION),;s,LIBTIFF_MINOR_VERSION,$(LIBTIFF_MINOR_VERSION),;s,LIBTIFF_MICRO_VERSION,$(LIBTIFF_MICRO_VERSION),' $(top_srcdir)/libtiff/tiffvers.h.in > $(top_srcdir)/libtiff/tiffvers.h)
+	(rm -f $(top_builddir)/libtiff/tiffvers.h && sed 's,LIBTIFF_VERSION,$(LIBTIFF_VERSION),;s,LIBTIFF_RELEASE_DATE,$(NEW_LIBTIFF_RELEASE_DATE),;s,LIBTIFF_MAJOR_VERSION,$(LIBTIFF_MAJOR_VERSION),;s,LIBTIFF_MINOR_VERSION,$(LIBTIFF_MINOR_VERSION),;s,LIBTIFF_MICRO_VERSION,$(LIBTIFF_MICRO_VERSION),' $(top_srcdir)/libtiff/tiffvers.h.in > $(top_builddir)/libtiff/tiffvers.h && sed -i 's,@,,g' $(top_builddir)/libtiff/tiffvers.h)
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libtiff-4.pc
diff --git a/cmake/AutotoolsVersion.cmake b/cmake/AutotoolsVersion.cmake
index 0f660878..f93f5cf0 100644
--- a/cmake/AutotoolsVersion.cmake
+++ b/cmake/AutotoolsVersion.cmake
@@ -40,6 +40,12 @@ endforeach()
 set(LIBTIFF_VERSION "${LIBTIFF_MAJOR_VERSION}.${LIBTIFF_MINOR_VERSION}.${LIBTIFF_MICRO_VERSION}")
 set(LIBTIFF_VERSION_FULL "${LIBTIFF_VERSION}${LIBTIFF_ALPHA_VERSION}")
 
+# Get release version from file VERSION
+FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" LIBTIFF_RELEASE_VERSION)
+
+# Package date - get it from file RELEASE-DATE
+FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/RELEASE-DATE" LIBTIFF_RELEASE_DATE)
+
 # Convert the libtool version variables to proper major and minor versions
 math(EXPR SO_MAJOR "${LIBTIFF_CURRENT} - ${LIBTIFF_AGE}")
 set(SO_MINOR "${LIBTIFF_AGE}")
diff --git a/cmake/Release.cmake b/cmake/Release.cmake
index 5deba03d..b6b754f9 100644
--- a/cmake/Release.cmake
+++ b/cmake/Release.cmake
@@ -22,10 +22,26 @@
 # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
 # OF THIS SOFTWARE.
 
-
+# Add target tiff_release to update the version information in the root files
+# VERSION and RELEASE-DATE.
 add_custom_target(tiff_release
-        COMMAND ${CMAKE_COMMAND}
-        "-DSOURCE_DIR:PATH=${PROJECT_SOURCE_DIR}"
-        "-DLIBTIFF_VERSION=${PROJECT_VERSION}"
-        -P "${CMAKE_CURRENT_LIST_DIR}/ReleaseScript.cmake"
-        COMMENT "Releasing ${PROJECT_NAME} ${PROJECT_VERSION}")
+    COMMAND ${CMAKE_COMMAND}
+    "-DSOURCE_DIR:PATH=${PROJECT_SOURCE_DIR}"
+    "-DLIBTIFF_VERSION=${PROJECT_VERSION}"
+    "-DLIBTIFF_BASIC_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}"
+    "-DLIBTIFF_BASIC_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}"
+    -P "${CMAKE_CURRENT_LIST_DIR}/ReleaseScript.cmake"
+    COMMENT "Releasing ${PROJECT_NAME} ${PROJECT_VERSION} ...")
+
+# Version information is taken from configure.ac
+# Note: Single command "cmake --build . --target tiff_release"
+#       does not work correctly, because version information is taken from CMakeCache.txt,
+#       which is not updated by cmake --build.
+#       Therefore, force CMake re-configure if configure.ac has changed.
+#       By the way, release-date and VERSION will not change but only when --targt tiff_release is called.
+set_property(
+    DIRECTORY
+    APPEND
+    PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/configure.ac
+)
+
diff --git a/cmake/ReleaseScript.cmake b/cmake/ReleaseScript.cmake
index 31cdbfe3..90cfaf65 100644
--- a/cmake/ReleaseScript.cmake
+++ b/cmake/ReleaseScript.cmake
@@ -22,11 +22,21 @@
 # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
 # OF THIS SOFTWARE.
 
+# Update release date to current date
 string(TIMESTAMP LIBTIFF_RELEASE_DATE "%Y%m%d")
 
+# Update version information in all relevant files
 message(STATUS "Setting release version to ${LIBTIFF_VERSION}")
 message(STATUS "Setting release date to ${LIBTIFF_RELEASE_DATE}")
 
-configure_file("${SOURCE_DIR}/libtiff/tiffvers.h.cmake.in"
-        "${SOURCE_DIR}/libtiff/tiffvers.h"
-        @ONLY)
+# Only needed here, for manual build of target tiff_release
+# because otherwise tiffvers.h is generated when building all targets.
+configure_file(${LIBTIFF_BASIC_SOURCE_DIR}/libtiff/tiffvers.h.cmake.in
+               ${LIBTIFF_BASIC_BINARY_DIR}/libtiff/tiffvers.h
+               @ONLY)
+
+# Write version information and release date to root files.
+FILE(WRITE ${LIBTIFF_BASIC_SOURCE_DIR}/VERSION "${LIBTIFF_VERSION}" \n) 
+FILE(WRITE ${LIBTIFF_BASIC_SOURCE_DIR}/RELEASE-DATE "${LIBTIFF_RELEASE_DATE}" \n)
+message(STATUS "Files tiffvers.h, VERSION and RELEASE-DATE updated.")
+
diff --git a/configure.ac b/configure.ac
index dad8457e..8556239e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,8 +44,9 @@ LIBTIFF_MINOR_VERSION=5
 LIBTIFF_MICRO_VERSION=1
 LIBTIFF_ALPHA_VERSION=
 LIBTIFF_VERSION=$LIBTIFF_MAJOR_VERSION.$LIBTIFF_MINOR_VERSION.$LIBTIFF_MICRO_VERSION$LIBTIFF_ALPHA_VERSION
-dnl This will be used with the 'make release' target
-LIBTIFF_RELEASE_DATE=`date +"%Y%m%d"`
+dnl This (LIBTIFF_RELEASE_DATE) is used to set the #define TIFFLIB_VERSION in tiffvers.h.
+LIBTIFF_RELEASE_DATE=$(cat ${srcdir}/RELEASE-DATE)
+
 
 dnl Libtool library revision control info
 dnl See the libtool documentation under the heading "Libtool's versioning
@@ -1183,6 +1184,7 @@ AC_CONFIG_FILES([Makefile \
 		 doc/Makefile \
 		 libtiff-4.pc \
 		 libtiff/Makefile \
+		 libtiff/tiffvers.h \
 		 port/Makefile \
 		 test/Makefile \
 		 tools/Makefile \
@@ -1196,6 +1198,10 @@ dnl ---------------------------------------------------------------------------
 LOC_MSG()
 LOC_MSG([Libtiff is now configured for ${host}])
 LOC_MSG()
+LOC_MSG([  Libtiff build version:              ${LIBTIFF_VERSION}])
+LOC_MSG([  Libtiff library version:            ${LIBTIFF_VERSION_INFO}])
+LOC_MSG([  Libtiff release date:               ${LIBTIFF_RELEASE_DATE}])
+LOC_MSG()
 LOC_MSG([  Installation directory:             ${prefix}])
 LOC_MSG([  Documentation directory:            ${LIBTIFF_DOCDIR}])
 LOC_MSG([  C compiler:                         ${CC} ${CFLAGS}])
diff --git a/libtiff/CMakeLists.txt b/libtiff/CMakeLists.txt
index 5d2a29ca..9c8024e8 100755
--- a/libtiff/CMakeLists.txt
+++ b/libtiff/CMakeLists.txt
@@ -23,17 +23,21 @@
 # OF THIS SOFTWARE.
 
 # Generate headers
+# and update configuration settings and package / version information.
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tif_config.h.cmake.in
                ${CMAKE_CURRENT_BINARY_DIR}/tif_config.h
                @ONLY)
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tiffconf.h.cmake.in
                ${CMAKE_CURRENT_BINARY_DIR}/tiffconf.h
                @ONLY)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tiffvers.h.cmake.in
+               ${CMAKE_CURRENT_BINARY_DIR}/tiffvers.h
+               @ONLY)
 
 set(tiff_public_HEADERS
         tiff.h
         tiffio.h
-        tiffvers.h
+        ${CMAKE_CURRENT_BINARY_DIR}/tiffvers.h
         ${CMAKE_CURRENT_BINARY_DIR}/tiffconf.h)
 
 set(tiff_private_HEADERS
diff --git a/libtiff/Makefile.am b/libtiff/Makefile.am
index 1d1a35d7..3d4ebcc5 100644
--- a/libtiff/Makefile.am
+++ b/libtiff/Makefile.am
@@ -32,6 +32,7 @@ EXTRA_DIST = \
 	libtiff.def \
 	libtiff.map \
 	libtiffxx.map \
+	tiffvers.h.cmake.in \
 	tif_config.h.cmake.in \
 	tiffconf.h.cmake.in \
 	tif_win32_versioninfo.rc
diff --git a/libtiff/tif_config.h.cmake.in b/libtiff/tif_config.h.cmake.in
index 9740a11f..400e5c07 100644
--- a/libtiff/tif_config.h.cmake.in
+++ b/libtiff/tif_config.h.cmake.in
@@ -82,18 +82,12 @@
 /* Define to the full name of this package. */
 #define PACKAGE_NAME "@PACKAGE_NAME@"
 
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "@PACKAGE_STRING@"
-
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "@PACKAGE_TARNAME@"
 
 /* Define to the home page for this package. */
 #define PACKAGE_URL "@PACKAGE_URL@"
 
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "@PACKAGE_VERSION@"
-
 /* Size of size_t */
 #define SIZEOF_SIZE_T @SIZEOF_SIZE_T@
 
@@ -106,9 +100,6 @@
 /* define to use win32 IO system */
 #cmakedefine USE_WIN32_FILEIO 1
 
-/* Version number of package */
-#define VERSION "@PACKAGE_VERSION@"
-
 /* Support WEBP compression */
 #cmakedefine WEBP_SUPPORT 1
 
diff --git a/libtiff/tif_config.h.in b/libtiff/tif_config.h.in
index cdf269a5..28da641a 100644
--- a/libtiff/tif_config.h.in
+++ b/libtiff/tif_config.h.in
@@ -85,18 +85,12 @@
 /* Define to the full name of this package. */
 #undef PACKAGE_NAME
 
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
 /* Define to the one symbol short name of this package. */
 #undef PACKAGE_TARNAME
 
 /* Define to the home page for this package. */
 #undef PACKAGE_URL
 
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
 /* The size of `size_t', as computed by sizeof. */
 #undef SIZEOF_SIZE_T
 
@@ -109,9 +103,6 @@
 /* define to use win32 IO system */
 #undef USE_WIN32_FILEIO
 
-/* Version number of package */
-#undef VERSION
-
 /* Support webp compression */
 #undef WEBP_SUPPORT
 
diff --git a/libtiff/tif_win32_versioninfo.rc b/libtiff/tif_win32_versioninfo.rc
index a5613f51..19188549 100644
--- a/libtiff/tif_win32_versioninfo.rc
+++ b/libtiff/tif_win32_versioninfo.rc
@@ -7,7 +7,6 @@
 #include <winver.h>
 
 #include "tiffvers.h"
-#include "tif_config.h"
 
 #ifdef _WIN32
 LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
@@ -33,12 +32,12 @@ BEGIN
         BEGIN
             VALUE "CompanyName", "libtiff project"
             VALUE "FileDescription", "TIFF Library"
-            VALUE "FileVersion", PACKAGE_VERSION
+            VALUE "FileVersion", TIFFLIB_VERSION_STR_MAJ_MIN_MIC
             VALUE "InternalName", "tiff.dll"
             VALUE "LegalCopyright", "See LICENCE.md"
             VALUE "OriginalFilename", "tiff.dll"
             VALUE "ProductName", "LibTIFF"
-            VALUE "ProductVersion", PACKAGE_VERSION
+            VALUE "ProductVersion", TIFFLIB_VERSION_STR_MAJ_MIN_MIC
             VALUE "WebPage", "https://libtiff.gitlab.io/libtiff/\0"
        END
     END
diff --git a/libtiff/tiffvers.h b/libtiff/tiffvers.h.cmake.in
similarity index 57%
rename from libtiff/tiffvers.h
rename to libtiff/tiffvers.h.cmake.in
index ed847760..28984998 100644
--- a/libtiff/tiffvers.h
+++ b/libtiff/tiffvers.h.cmake.in
@@ -1,9 +1,14 @@
+/* tiffvers.h version information is updated according to version information
+ * in configure.ac */
+
 /* clang-format off */
 
 /* clang-format disabled because FindTIFF.cmake is very sensitive to the
  * formatting of below line being a single line.
+ * Furthermore, configure_file variables of type "@VAR@" are
+ * modified by clang-format and won't be substituted by CMake.
  */
-#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.5.1\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
+#define TIFFLIB_VERSION_STR "LIBTIFF, Version @LIBTIFF_VERSION@\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
 /*
  * This define can be used in code that requires
  * compilation-related definitions specific to a
@@ -11,12 +16,13 @@
  * version checking should be done based on the
  * string returned by TIFFGetVersion.
  */
-#define TIFFLIB_VERSION 20230609
+#define TIFFLIB_VERSION @LIBTIFF_RELEASE_DATE@
 
 /* The following defines have been added in 4.5.0 */
-#define TIFFLIB_MAJOR_VERSION 4
-#define TIFFLIB_MINOR_VERSION 5
-#define TIFFLIB_MICRO_VERSION 1
+#define TIFFLIB_MAJOR_VERSION @LIBTIFF_MAJOR_VERSION@
+#define TIFFLIB_MINOR_VERSION @LIBTIFF_MINOR_VERSION@
+#define TIFFLIB_MICRO_VERSION @LIBTIFF_MICRO_VERSION@
+#define TIFFLIB_VERSION_STR_MAJ_MIN_MIC "@LIBTIFF_VERSION@"
 
 /* Macro added in 4.5.0. Returns TRUE if the current libtiff version is
  * greater or equal to major.minor.micro
diff --git a/libtiff/tiffvers.h.in b/libtiff/tiffvers.h.in
index b98851c0..28984998 100644
--- a/libtiff/tiffvers.h.in
+++ b/libtiff/tiffvers.h.in
@@ -1,9 +1,14 @@
+/* tiffvers.h version information is updated according to version information
+ * in configure.ac */
+
 /* clang-format off */
 
 /* clang-format disabled because FindTIFF.cmake is very sensitive to the
  * formatting of below line being a single line.
+ * Furthermore, configure_file variables of type "@VAR@" are
+ * modified by clang-format and won't be substituted by CMake.
  */
-#define TIFFLIB_VERSION_STR "LIBTIFF, Version LIBTIFF_VERSION\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
+#define TIFFLIB_VERSION_STR "LIBTIFF, Version @LIBTIFF_VERSION@\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
 /*
  * This define can be used in code that requires
  * compilation-related definitions specific to a
@@ -11,12 +16,13 @@
  * version checking should be done based on the
  * string returned by TIFFGetVersion.
  */
-#define TIFFLIB_VERSION LIBTIFF_RELEASE_DATE
+#define TIFFLIB_VERSION @LIBTIFF_RELEASE_DATE@
 
 /* The following defines have been added in 4.5.0 */
-#define TIFFLIB_MAJOR_VERSION LIBTIFF_MAJOR_VERSION
-#define TIFFLIB_MINOR_VERSION LIBTIFF_MINOR_VERSION
-#define TIFFLIB_MICRO_VERSION LIBTIFF_MICRO_VERSION
+#define TIFFLIB_MAJOR_VERSION @LIBTIFF_MAJOR_VERSION@
+#define TIFFLIB_MINOR_VERSION @LIBTIFF_MINOR_VERSION@
+#define TIFFLIB_MICRO_VERSION @LIBTIFF_MICRO_VERSION@
+#define TIFFLIB_VERSION_STR_MAJ_MIN_MIC "@LIBTIFF_VERSION@"
 
 /* Macro added in 4.5.0. Returns TRUE if the current libtiff version is
  * greater or equal to major.minor.micro
diff --git a/tools/tif_tools_versioninfo.rc b/tools/tif_tools_versioninfo.rc
index 6d560c3f..02f114a7 100644
--- a/tools/tif_tools_versioninfo.rc
+++ b/tools/tif_tools_versioninfo.rc
@@ -7,7 +7,6 @@
 #include <winver.h>
 
 #include "tiffvers.h"
-#include "tif_config.h"
 
 #ifdef _WIN32
 LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
@@ -33,12 +32,12 @@ BEGIN
         BEGIN
             VALUE "CompanyName", "libtiff project"
             VALUE "FileDescription", "TIFF Tools"
-            VALUE "FileVersion", PACKAGE_VERSION
+            VALUE "FileVersion", TIFFLIB_VERSION_STR_MAJ_MIN_MIC
             VALUE "InternalName", ""
             VALUE "LegalCopyright", "See LICENCE.md"
             VALUE "OriginalFilename", ""
             VALUE "ProductName", "LibTIFF"
-            VALUE "ProductVersion", PACKAGE_VERSION
+            VALUE "ProductVersion",  TIFFLIB_VERSION_STR_MAJ_MIN_MIC
             VALUE "WebPage", "https://libtiff.gitlab.io/libtiff/\0"
        END
     END
diff --git a/tools/unsupported/tif_tools-unsupported_versioninfo.rc b/tools/unsupported/tif_tools-unsupported_versioninfo.rc
index 377d9e65..a0466b38 100644
--- a/tools/unsupported/tif_tools-unsupported_versioninfo.rc
+++ b/tools/unsupported/tif_tools-unsupported_versioninfo.rc
@@ -7,7 +7,6 @@
 #include <winver.h>
 
 #include "tiffvers.h"
-#include "tif_config.h"
 
 #ifdef _WIN32
 LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
@@ -33,12 +32,12 @@ BEGIN
         BEGIN
             VALUE "CompanyName", "libtiff project"
             VALUE "FileDescription", "Unsupported TIFF Tools"
-            VALUE "FileVersion", PACKAGE_VERSION
+            VALUE "FileVersion", TIFFLIB_VERSION_STR_MAJ_MIN_MIC
             VALUE "InternalName", ""
             VALUE "LegalCopyright", "See LICENCE.md"
             VALUE "OriginalFilename", ""
             VALUE "ProductName", "LibTIFF"
-            VALUE "ProductVersion", PACKAGE_VERSION
+            VALUE "ProductVersion", TIFFLIB_VERSION_STR_MAJ_MIN_MIC
             VALUE "WebPage", "https://libtiff.gitlab.io/libtiff/\0"
        END
     END