7 , enableJava ? false # whether to build the java wrapper
8 , enableJpeg7 ? false # whether to build libjpeg with v7 compatibility
9 , enableJpeg8 ? false # whether to build libjpeg with v8 compatibility
10 , enableStatic ? stdenv.hostPlatform.isStatic
11 , enableShared ? !stdenv.hostPlatform.isStatic
30 assert !(enableJpeg7 && enableJpeg8); # pick only one or none, not both
32 stdenv.mkDerivation (finalAttrs: {
34 pname = "libjpeg-turbo";
37 src = fetchFromGitHub {
38 owner = "libjpeg-turbo";
39 repo = "libjpeg-turbo";
40 rev = finalAttrs.version;
41 sha256 = "sha256-96SBBZp+/4WkXLvHKSPItNi5WuzdVccI/ZcbJOFjYYk=";
44 # This is needed by freeimage
45 patches = [ ./0001-Compile-transupp.c-as-part-of-the-library.patch ]
46 ++ lib.optional stdenv.hostPlatform.isMinGW
47 ./mingw-boolean.patch;
49 outputs = [ "bin" "dev" "dev_private" "out" "man" "doc" ];
52 moveToOutput include/transupp.h $dev_private
58 ] ++ lib.optionals enableJava [
63 "-DENABLE_STATIC=${if enableStatic then "1" else "0"}"
64 "-DENABLE_SHARED=${if enableShared then "1" else "0"}"
65 ] ++ lib.optionals enableJava [
67 ] ++ lib.optionals enableJpeg7 [
69 ] ++ lib.optionals enableJpeg8 [
71 ] ++ lib.optionals stdenv.hostPlatform.isRiscV [
72 # https://github.com/libjpeg-turbo/libjpeg-turbo/issues/428
73 # https://github.com/libjpeg-turbo/libjpeg-turbo/commit/88bf1d16786c74f76f2e4f6ec2873d092f577c75
74 "-DFLOATTEST=fp-contract"
77 doInstallCheck = true;
78 installCheckTarget = "test";
94 inherit (python3.pkgs) pillow imread pyturbojpeg;
95 pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
99 homepage = "https://libjpeg-turbo.org/";
100 description = "A faster (using SIMD) libjpeg implementation";
101 license = licenses.ijg; # and some parts under other BSD-style licenses
102 pkgConfigModules = [ "libjpeg" "libturbojpeg" ];
103 maintainers = with maintainers; [ vcunat colemickens kamadorueda ];
104 platforms = platforms.all;