libtiff: use an exported symbols list for mac.

From faff88b66fbca0dfedc73216f1992a7069cf36fb Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sat, 21 Oct 2023 23:33:32 +0300
Subject: [PATCH] use an exported symbols list for mac.

---
 configure.ac           |   9 +++
 libtiff/CMakeLists.txt |   7 +-
 libtiff/Makefile.am    |   3 +
 libtiff/libtiff.exp    | 178 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 196 insertions(+), 1 deletion(-)
 create mode 100644 libtiff/libtiff.exp

diff --git a/configure.ac b/configure.ac
index 1f8f7c12..2cb308ff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -143,7 +143,16 @@ EOF
   LDFLAGS="$save_LDFLAGS"
   AC_MSG_RESULT($have_ld_version_script)
 fi
+case "$host" in
+    *-*-darwin*)
+        have_darwin_exports=yes
+        have_ld_version_script=no
+        ;;
+   *)   have_darwin_exports=no
+        ;;
+esac
 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
+AM_CONDITIONAL(HAVE_DARWIN_EXPORTS, test "$have_darwin_exports" = "yes")
 
 
 dnl Tests for Windows
diff --git a/libtiff/CMakeLists.txt b/libtiff/CMakeLists.txt
index 0c1607ae..e485d509 100644
--- a/libtiff/CMakeLists.txt
+++ b/libtiff/CMakeLists.txt
@@ -129,7 +129,12 @@ if(NOT CYGWIN)
     # seems to be the default.
     set_target_properties(tiff PROPERTIES VERSION ${SO_VERSION})
 endif()
-if(HAVE_LD_VERSION_SCRIPT)
+if(WIN32)
+# Windows links with libtiff.def, nothing else needed.
+elseif(APPLE)
+  set_target_properties(tiff PROPERTIES LINK_FLAGS
+                        "-Wl,-exported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libtiff.exp")
+elseif(HAVE_LD_VERSION_SCRIPT)
   set_target_properties(tiff PROPERTIES LINK_FLAGS
                         "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libtiff.map")
 endif()
diff --git a/libtiff/Makefile.am b/libtiff/Makefile.am
index 14a250a5..d94ff637 100644
--- a/libtiff/Makefile.am
+++ b/libtiff/Makefile.am
@@ -128,6 +128,9 @@ endif
 if HAVE_LD_VERSION_SCRIPT
 libtiff_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libtiff.map
 endif
+if HAVE_DARWIN_EXPORTS
+libtiff_la_LDFLAGS += -Wl,-exported_symbols_list,$(srcdir)/libtiff.exp
+endif
 libtiff_la_LIBADD = $(LIBPORT)
 
 libtiffxx_la_LDFLAGS = \
diff --git a/libtiff/libtiff.exp b/libtiff/libtiff.exp
new file mode 100644
index 00000000..dac3e4db
--- /dev/null
+++ b/libtiff/libtiff.exp
@@ -0,0 +1,178 @@
+_TIFFAccessTagMethods
+_TIFFCIELabToRGBInit
+_TIFFCIELabToXYZ
+_TIFFCheckTile
+_TIFFCheckpointDirectory
+_TIFFCleanup
+_TIFFClientOpen
+_TIFFClientdata
+_TIFFClose
+_TIFFComputeStrip
+_TIFFComputeTile
+_TIFFCreateCustomDirectory
+_TIFFCreateDirectory
+_TIFFCreateEXIFDirectory
+_TIFFCreateGPSDirectory
+_TIFFCurrentDirOffset
+_TIFFCurrentDirectory
+_TIFFCurrentRow
+_TIFFCurrentStrip
+_TIFFCurrentTile
+_TIFFDataWidth
+_TIFFDefaultStripSize
+_TIFFDefaultTileSize
+_TIFFDeferStrileArrayWriting
+_TIFFError
+_TIFFErrorExt
+_TIFFFdOpen
+_TIFFFieldDataType
+_TIFFFieldName
+_TIFFFieldPassCount
+_TIFFFieldReadCount
+_TIFFFieldTag
+_TIFFFieldWithName
+_TIFFFieldWithTag
+_TIFFFieldWriteCount
+_TIFFFileName
+_TIFFFileno
+_TIFFFindCODEC
+_TIFFFindField
+_TIFFFlush
+_TIFFFlushData
+_TIFFForceStrileArrayWriting
+_TIFFFreeDirectory
+_TIFFGetBitRevTable
+_TIFFGetClientInfo
+_TIFFGetCloseProc
+_TIFFGetConfiguredCODECs
+_TIFFGetField
+_TIFFGetFieldDefaulted
+_TIFFGetMapFileProc
+_TIFFGetMode
+_TIFFGetReadProc
+_TIFFGetSeekProc
+_TIFFGetSizeProc
+_TIFFGetStrileByteCount
+_TIFFGetStrileByteCountWithErr
+_TIFFGetStrileOffset
+_TIFFGetStrileOffsetWithErr
+_TIFFGetTagListCount
+_TIFFGetTagListEntry
+_TIFFGetUnmapFileProc
+_TIFFGetVersion
+_TIFFGetWriteProc
+_TIFFIsBigEndian
+_TIFFIsByteSwapped
+_TIFFIsCODECConfigured
+_TIFFIsMSB2LSB
+_TIFFIsTiled
+_TIFFIsUpSampled
+_TIFFLastDirectory
+_TIFFMergeFieldInfo
+_TIFFNumberOfDirectories
+_TIFFNumberOfStrips
+_TIFFNumberOfTiles
+_TIFFOpen
+_TIFFPrintDirectory
+_TIFFRGBAImageBegin
+_TIFFRGBAImageEnd
+_TIFFRGBAImageGet
+_TIFFRGBAImageOK
+_TIFFRasterScanlineSize
+_TIFFRasterScanlineSize64
+_TIFFRawStripSize
+_TIFFRawStripSize64
+_TIFFReadBufferSetup
+_TIFFReadCustomDirectory
+_TIFFReadDirectory
+_TIFFReadEXIFDirectory
+_TIFFReadGPSDirectory
+_TIFFReadEncodedStrip
+_TIFFReadEncodedTile
+_TIFFReadFromUserBuffer
+_TIFFReadRGBAImage
+_TIFFReadRGBAImageOriented
+_TIFFReadRGBAStrip
+_TIFFReadRGBAStripExt
+_TIFFReadRGBATile
+_TIFFReadRGBATileExt
+_TIFFReadRawStrip
+_TIFFReadRawTile
+_TIFFReadScanline
+_TIFFReadTile
+_TIFFRegisterCODEC
+_TIFFReverseBits
+_TIFFRewriteDirectory
+_TIFFScanlineSize
+_TIFFScanlineSize64
+_TIFFSetClientInfo
+_TIFFSetClientdata
+_TIFFSetCompressionScheme
+_TIFFSetDirectory
+_TIFFSetErrorHandler
+_TIFFSetErrorHandlerExt
+_TIFFSetField
+_TIFFSetFileName
+_TIFFSetFileno
+_TIFFSetMode
+_TIFFSetSubDirectory
+_TIFFSetTagExtender
+_TIFFSetWarningHandler
+_TIFFSetWarningHandlerExt
+_TIFFSetWriteOffset
+_TIFFSetupStrips
+_TIFFStripSize
+_TIFFStripSize64
+_TIFFSwabArrayOfDouble
+_TIFFSwabArrayOfFloat
+_TIFFSwabArrayOfLong
+_TIFFSwabArrayOfLong8
+_TIFFSwabArrayOfShort
+_TIFFSwabArrayOfTriples
+_TIFFSwabDouble
+_TIFFSwabFloat
+_TIFFSwabLong
+_TIFFSwabLong8
+_TIFFSwabShort
+_TIFFTileRowSize
+_TIFFTileRowSize64
+_TIFFTileSize
+_TIFFTileSize64
+_TIFFUnRegisterCODEC
+_TIFFUnlinkDirectory
+_TIFFUnsetField
+_TIFFVGetField
+_TIFFVGetFieldDefaulted
+_TIFFVSetField
+_TIFFVStripSize
+_TIFFVStripSize64
+_TIFFVTileSize
+_TIFFVTileSize64
+_TIFFWarning
+_TIFFWarningExt
+_TIFFWriteBufferSetup
+_TIFFWriteCheck
+_TIFFWriteCustomDirectory
+_TIFFWriteDirectory
+_TIFFWriteEncodedStrip
+_TIFFWriteEncodedTile
+_TIFFWriteRawStrip
+_TIFFWriteRawTile
+_TIFFWriteScanline
+_TIFFWriteTile
+_TIFFXYZToRGB
+_TIFFYCbCrToRGBInit
+_TIFFYCbCrtoRGB
+__TIFFCheckMalloc
+__TIFFCheckRealloc
+__TIFFRewriteField
+__TIFFfree
+__TIFFmalloc
+__TIFFmemcmp
+__TIFFmemcpy
+__TIFFmemset
+__TIFFrealloc
+__TIFFMultiply32
+__TIFFMultiply64
+__TIFFGetExifFields
+__TIFFGetGpsFields