nixpkgs/pkgs/by-name/ph/phash/package.nix
benaryorg 4035c1ad05
phash: compilation fixes
This includes a patch already sent upstream that fixes compilation with Werror due to a lacking return, as well as adding a linker flag to include a threaded version of a library.
The fftw3_threads part stems from cimg requiring this apparently when linking the examples:

> test_texthash.cpp:(.text.startup+0x1c1): undefined reference to `fftw_init_threads'

I wouldn't know how to patch this upstream, however other packages in nixpkgs seem to provide the LDFLAGS too.

Signed-off-by: benaryorg <binary@benary.org>
2024-11-11 16:03:07 +00:00

43 lines
1.1 KiB
Nix

{ lib, stdenv, fetchFromGitHub, fetchpatch, pkg-config, cimg, imagemagick }:
stdenv.mkDerivation rec {
pname = "pHash";
version = "0.9.6";
buildInputs = [ cimg ];
# CImg.h calls to external binary `convert` from the `imagemagick` package
# at runtime
propagatedBuildInputs = [ imagemagick ];
nativeBuildInputs = [ pkg-config ];
configureFlags = ["--enable-video-hash=no" "--enable-audio-hash=no"];
postInstall = ''
cp ${cimg}/include/CImg.h $out/include/
'';
src = fetchFromGitHub {
owner = "clearscene";
repo = "pHash";
rev = version;
sha256 = "sha256-frISiZ89ei7XfI5F2nJJehfQZsk0Mlb4n91q/AiZ2vA=";
};
NIX_LDFLAGS = "-lfftw3_threads";
patches = [
# proper pthread return value (https://github.com/clearscene/pHash/pull/20)
./0001-proper-pthread-return-value.patch
];
meta = with lib; {
description = "Compute the perceptual hash of an image";
license = licenses.gpl3;
maintainers = [maintainers.imalsogreg];
platforms = platforms.all;
homepage = "http://www.phash.org";
downloadPage = "https://github.com/clearscene/pHash";
};
}