From 38f67894cdece5880317434823b56eb33f58fecf 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
This copies the same logic as used by CMake.
---
configure.ac | 2 ++
test/Makefile.am | 13 +++++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 7b295fa1..1ae5573c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -163,6 +163,8 @@ AC_SUBST(tiff_libs_private)
tiff_requires_private=
AC_SUBST(tiff_requires_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 6df12122..2da13dbf 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -67,12 +67,16 @@ 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
if TIFF_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 test_directory \
- testtypes test_signed_tags $(JPEG_DEPENDENT_CHECK_PROG)
+ defer_strile_loading defer_strile_writing test_directory \
+ testtypes test_signed_tags $(JPEG_DEPENDENT_CHECK_PROG) $(STATIC_CHECK_PROGS)
endif
# Test scripts to execute
@@ -226,8 +230,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