2021-06-28 23:13:55 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, nasm
|
2021-03-09 03:18:52 +00:00
|
|
|
, openjdk
|
|
|
|
, enableJava ? false # whether to build the java wrapper
|
2021-06-28 23:13:55 +00:00
|
|
|
, enableJpeg7 ? false # whether to build libjpeg with v7 compatibility
|
|
|
|
, enableJpeg8 ? false # whether to build libjpeg with v8 compatibility
|
2021-01-05 17:05:55 +00:00
|
|
|
, enableStatic ? stdenv.hostPlatform.isStatic
|
|
|
|
, enableShared ? !stdenv.hostPlatform.isStatic
|
2022-08-21 13:32:41 +00:00
|
|
|
|
|
|
|
# for passthru.tests
|
|
|
|
, dvgrab
|
|
|
|
, epeg
|
|
|
|
, freeimage
|
|
|
|
, gd
|
|
|
|
, graphicsmagick
|
|
|
|
, imagemagick
|
|
|
|
, imlib2
|
|
|
|
, jhead
|
|
|
|
, libjxl
|
|
|
|
, mjpegtools
|
|
|
|
, opencv
|
|
|
|
, python3
|
|
|
|
, vips
|
2021-01-05 17:05:55 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
assert !(enableJpeg7 && enableJpeg8); # pick only one or none, not both
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
|
|
|
|
pname = "libjpeg-turbo";
|
2022-09-09 14:08:57 +00:00
|
|
|
version = "2.1.4";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-10-16 20:44:37 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "libjpeg-turbo";
|
|
|
|
repo = "libjpeg-turbo";
|
|
|
|
rev = version;
|
2022-09-09 14:08:57 +00:00
|
|
|
sha256 = "sha256-1NRoVIL3zXX1D6iOf2FCrwBEcDW7TYFbdIbCTjY1m8Q=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
# This is needed by freeimage
|
|
|
|
patches = [ ./0001-Compile-transupp.c-as-part-of-the-library.patch ]
|
|
|
|
++ lib.optional (stdenv.hostPlatform.libc or null == "msvcrt")
|
2021-06-28 23:13:55 +00:00
|
|
|
./mingw-boolean.patch;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
outputs = [ "bin" "dev" "dev_private" "out" "man" "doc" ];
|
|
|
|
|
|
|
|
postFixup = ''
|
|
|
|
moveToOutput include/transupp.h $dev_private
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
nasm
|
|
|
|
] ++ lib.optionals enableJava [
|
|
|
|
openjdk
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DENABLE_STATIC=${if enableStatic then "1" else "0"}"
|
2020-08-20 17:08:02 +00:00
|
|
|
"-DENABLE_SHARED=${if enableShared then "1" else "0"}"
|
2021-03-09 03:18:52 +00:00
|
|
|
] ++ lib.optionals enableJava [
|
|
|
|
"-DWITH_JAVA=1"
|
2021-06-28 23:13:55 +00:00
|
|
|
] ++ lib.optionals enableJpeg7 [
|
|
|
|
"-DWITH_JPEG7=1"
|
|
|
|
] ++ lib.optionals enableJpeg8 [
|
|
|
|
"-DWITH_JPEG8=1"
|
2021-06-01 10:57:12 +00:00
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isRiscV [
|
|
|
|
# https://github.com/libjpeg-turbo/libjpeg-turbo/issues/428
|
|
|
|
# https://github.com/libjpeg-turbo/libjpeg-turbo/commit/88bf1d16786c74f76f2e4f6ec2873d092f577c75
|
|
|
|
"-DFLOATTEST=fp-contract"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckTarget = "test";
|
|
|
|
|
2022-08-21 13:32:41 +00:00
|
|
|
passthru.tests = {
|
|
|
|
inherit
|
|
|
|
dvgrab
|
|
|
|
epeg
|
|
|
|
freeimage
|
|
|
|
gd
|
|
|
|
graphicsmagick
|
|
|
|
imagemagick
|
|
|
|
imlib2
|
|
|
|
jhead
|
|
|
|
libjxl
|
|
|
|
mjpegtools
|
|
|
|
opencv
|
|
|
|
vips;
|
|
|
|
inherit (python3.pkgs) pillow imread pyturbojpeg;
|
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-10-16 20:44:37 +00:00
|
|
|
homepage = "https://libjpeg-turbo.org/";
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "A faster (using SIMD) libjpeg implementation";
|
|
|
|
license = licenses.ijg; # and some parts under other BSD-style licenses
|
2021-06-28 23:13:55 +00:00
|
|
|
maintainers = with maintainers; [ vcunat colemickens kamadorueda ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
}
|