libtiff: build: Make rational2double static only for automake (13f29)

From 13f294c3d7837d630b3e9b08089752bc07b730e6 Mon Sep 17 00:00:00 2001
From: Roger Leigh <[EMAIL REDACTED]>
Date: Fri, 24 Jun 2022 12:57:54 +0100
Subject: [PATCH] build: Make rational2double static only for automake

(cherry picked from commit 38f67894cdece5880317434823b56eb33f58fecf)
---
 configure.ac     |  2 ++
 test/Makefile.am | 12 ++++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2cb308ff..cb862f2c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -169,6 +169,8 @@ AM_SILENT_RULES
 tiff_libs_private=
 AC_SUBST(tiff_libs_private)
 
+AM_CONDITIONAL(BUILD_STATIC, test "$enable_static" = "yes")
+
 dnl We don't need to add math library to all targets
 case "${host_os}" in
     cygwin* | mingw32* | beos* | darwin*)
diff --git a/test/Makefile.am b/test/Makefile.am
index 437503f1..2bb9a3d9 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -65,11 +65,14 @@ JPEG_DEPENDENT_CHECK_PROG=
 JPEG_DEPENDENT_TESTSCRIPTS=
 endif
 
+if BUILD_STATIC
+STATIC_CHECK_PROGS=rational_precision2double
+endif
+
 # Executable programs which need to be built in order to support tests
 check_PROGRAMS = \
 	ascii_tag long_tag short_tag strip_rw rewrite custom_dir custom_dir_EXIF_231 \
-	rational_precision2double defer_strile_loading defer_strile_writing testtypes \
-	$(JPEG_DEPENDENT_CHECK_PROG)
+	defer_strile_loading defer_strile_writing testtypes $(JPEG_DEPENDENT_CHECK_PROG) $(STATIC_CHECK_PROGS)
 
 # Test scripts to execute
 TESTSCRIPTS = \
@@ -218,8 +221,13 @@ raw_decode_SOURCES = raw_decode.c
 raw_decode_LDADD = $(LIBTIFF)
 custom_dir_SOURCES = custom_dir.c
 custom_dir_LDADD = $(LIBTIFF)
+
+if BUILD_STATIC
 rational_precision2double_SOURCES = rational_precision2double.c
 rational_precision2double_LDADD = $(LIBTIFF)
+rational_precision2double_LDFLAGS = -static
+endif
+
 custom_dir_EXIF_231_SOURCES = custom_dir_EXIF_231.c
 custom_dir_EXIF_231_LDADD = $(LIBTIFF)
 defer_strile_loading_SOURCES = defer_strile_loading.c