From 8b724434c37a12ea5ed23ba55339e3dc72d86d7d Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 19 Dec 2024 15:37:40 +0100 Subject: [PATCH 1/2] libtiff: switch back to CMake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since libwebp was switched to CMake, the .la files that told static builds which libraries had to be linked with libwebp are no longer generated, breaking static builds. By switching libtiff to CMake too, we can use the CMake files instead. (This is necessary, but not sufficient, for static builds to work — a further patch is required.) This was tried once before (in 96d50327bc59 ("libtiff: export private headers for freeimage")), and I reverted it (in 5df9305b60d5 ("libtiff: fix cross by switching back to autoconf")), because at the time, it broke cross compilation of libtiff. Things seem to have settled since then, and this now cross compiles correctly. Fixes: 909c49149371 ("libwebp: build with CMake") --- pkgs/by-name/li/libtiff/headers.patch | 16 ----------- pkgs/by-name/li/libtiff/package.nix | 22 +++++++------- pkgs/by-name/li/libtiff/rename-version.patch | 30 +++++++------------- 3 files changed, 23 insertions(+), 45 deletions(-) delete mode 100644 pkgs/by-name/li/libtiff/headers.patch diff --git a/pkgs/by-name/li/libtiff/headers.patch b/pkgs/by-name/li/libtiff/headers.patch deleted file mode 100644 index 933e06f32326..000000000000 --- a/pkgs/by-name/li/libtiff/headers.patch +++ /dev/null @@ -1,16 +0,0 @@ -export private headers for freeimage ---- i/libtiff/Makefile.am -+++ w/libtiff/Makefile.am -@@ -36,8 +36,12 @@ EXTRA_DIST = \ - tif_win32_versioninfo.rc - - libtiffinclude_HEADERS = \ -+ tif_config.h \ -+ tif_dir.h \ -+ tif_hash_set.h \ - tiff.h \ - tiffio.h \ -+ tiffiop.h \ - tiffvers.h - - if HAVE_CXX diff --git a/pkgs/by-name/li/libtiff/package.nix b/pkgs/by-name/li/libtiff/package.nix index 674369df1cd0..772afe696f25 100644 --- a/pkgs/by-name/li/libtiff/package.nix +++ b/pkgs/by-name/li/libtiff/package.nix @@ -5,7 +5,7 @@ fetchpatch, nix-update-script, - autoreconfHook, + cmake, pkg-config, sphinx, @@ -40,8 +40,6 @@ stdenv.mkDerivation (finalAttrs: { }; patches = [ - # FreeImage needs this patch - ./headers.patch # libc++abi 11 has an `#include `, this picks up files name # `version` in the project's include paths ./rename-version.patch @@ -61,16 +59,16 @@ stdenv.mkDerivation (finalAttrs: { ]; postFixup = '' - moveToOutput include/tif_config.h $dev_private - moveToOutput include/tif_dir.h $dev_private - moveToOutput include/tif_hash_set.h $dev_private - moveToOutput include/tiffiop.h $dev_private + mkdir -p $dev_private/include + mv -t $dev_private/include \ + libtiff/tif_config.h \ + ../libtiff/tif_dir.h \ + ../libtiff/tif_hash_set.h \ + ../libtiff/tiffiop.h ''; - # If you want to change to a different build system, please make - # sure cross-compilation works first! nativeBuildInputs = [ - autoreconfHook + cmake pkg-config sphinx ]; @@ -92,6 +90,10 @@ stdenv.mkDerivation (finalAttrs: { zstd ]; + cmakeFlags = [ + "-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON" + ]; + enableParallelBuilding = true; doCheck = true; diff --git a/pkgs/by-name/li/libtiff/rename-version.patch b/pkgs/by-name/li/libtiff/rename-version.patch index 04fa1bfc88c7..f5c9ec2811ca 100644 --- a/pkgs/by-name/li/libtiff/rename-version.patch +++ b/pkgs/by-name/li/libtiff/rename-version.patch @@ -1,21 +1,13 @@ -fix case-insensitive build ---- a/Makefile.am -+++ b/Makefile.am -@@ -34,7 +34,7 @@ docfiles = \ - README.md \ - RELEASE-DATE \ - TODO \ -- VERSION -+ VERSION.txt +diff --git a/cmake/AutotoolsVersion.cmake b/cmake/AutotoolsVersion.cmake +index f93f5cf0..fd33df59 100644 +--- a/cmake/AutotoolsVersion.cmake ++++ b/cmake/AutotoolsVersion.cmake +@@ -41,7 +41,7 @@ set(LIBTIFF_VERSION "${LIBTIFF_MAJOR_VERSION}.${LIBTIFF_MINOR_VERSION}.${LIBTIFF + set(LIBTIFF_VERSION_FULL "${LIBTIFF_VERSION}${LIBTIFF_ALPHA_VERSION}") - EXTRA_DIST = \ - placeholder.h \ -@@ -68,7 +68,7 @@ NEW_LIBTIFF_RELEASE_DATE=$(shell date +"%Y%m%d") - release: - @(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)/VERSION && echo $(LIBTIFF_VERSION) > $(top_srcdir)/VERSION.txt) - (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) + # Get release version from file VERSION +-FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" LIBTIFF_RELEASE_VERSION) ++FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt" LIBTIFF_RELEASE_VERSION) - pkgconfigdir = $(libdir)/pkgconfig + # Package date - get it from file RELEASE-DATE + FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/RELEASE-DATE" LIBTIFF_RELEASE_DATE) From f72ee0686dfa37018d76669764fb8794a7d501e4 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 19 Dec 2024 16:29:49 +0100 Subject: [PATCH 2/2] libtiff: fix static builds --- pkgs/by-name/li/libtiff/package.nix | 1 + pkgs/by-name/li/libtiff/static.patch | 36 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 pkgs/by-name/li/libtiff/static.patch diff --git a/pkgs/by-name/li/libtiff/package.nix b/pkgs/by-name/li/libtiff/package.nix index 772afe696f25..03564fced802 100644 --- a/pkgs/by-name/li/libtiff/package.nix +++ b/pkgs/by-name/li/libtiff/package.nix @@ -43,6 +43,7 @@ stdenv.mkDerivation (finalAttrs: { # libc++abi 11 has an `#include `, this picks up files name # `version` in the project's include paths ./rename-version.patch + ./static.patch ]; postPatch = '' diff --git a/pkgs/by-name/li/libtiff/static.patch b/pkgs/by-name/li/libtiff/static.patch new file mode 100644 index 000000000000..0eecc5d149b8 --- /dev/null +++ b/pkgs/by-name/li/libtiff/static.patch @@ -0,0 +1,36 @@ +From ed5fcc718075021fe670daee6dd426a5e12d6842 Mon Sep 17 00:00:00 2001 +From: Alyssa Ross +Date: Thu, 19 Dec 2024 16:51:51 +0100 +Subject: [PATCH] Fix name of Lerc package + +Lerc calls its CMake package "Lerc", not "LERC". This meant that, +even if building libtiff with -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON, +Lerc's CMake files wouldn't be used as intended. + +Link: https://gitlab.com/libtiff/libtiff/-/merge_requests/686 +--- + cmake/{FindLERC.cmake => FindLerc.cmake} | 0 + cmake/LERCCodec.cmake | 2 +- + 2 files changed, 1 insertion(+), 1 deletion(-) + rename cmake/{FindLERC.cmake => FindLerc.cmake} (100%) + +diff --git a/cmake/FindLERC.cmake b/cmake/FindLerc.cmake +similarity index 100% +rename from cmake/FindLERC.cmake +rename to cmake/FindLerc.cmake +diff --git a/cmake/LERCCodec.cmake b/cmake/LERCCodec.cmake +index 54504ca1..237f8d7e 100644 +--- a/cmake/LERCCodec.cmake ++++ b/cmake/LERCCodec.cmake +@@ -25,7 +25,7 @@ + + # libLerc + set(LERC_SUPPORT FALSE) +-find_package(LERC) ++find_package(Lerc) + option(lerc "use libLerc (required for LERC compression)" ${LERC_FOUND}) + if (lerc AND LERC_FOUND AND ZIP_SUPPORT) + set(LERC_SUPPORT TRUE) +-- +2.47.0 +