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
|
2023-10-09 19:29:22 +00:00
|
|
|
, testers
|
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
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
pname = "libjpeg-turbo";
|
2023-05-24 13:37:59 +00:00
|
|
|
version = "2.1.5.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-10-16 20:44:37 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "libjpeg-turbo";
|
|
|
|
repo = "libjpeg-turbo";
|
2023-10-09 19:29:22 +00:00
|
|
|
rev = finalAttrs.version;
|
2023-05-24 13:37:59 +00:00
|
|
|
sha256 = "sha256-96SBBZp+/4WkXLvHKSPItNi5WuzdVccI/ZcbJOFjYYk=";
|
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 ]
|
2023-10-09 19:29:22 +00:00
|
|
|
++ lib.optional stdenv.hostPlatform.isMinGW
|
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;
|
2023-10-09 19:29:22 +00:00
|
|
|
pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
|
2022-08-21 13:32:41 +00:00
|
|
|
};
|
|
|
|
|
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
|
2023-10-09 19:29:22 +00:00
|
|
|
pkgConfigModules = [ "libjpeg" "libturbojpeg" ];
|
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;
|
|
|
|
};
|
2023-10-09 19:29:22 +00:00
|
|
|
})
|