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 hash = "sha256-ZNqhOfZtWcMv10VWIUxn7MSy4KhW/jBrgC1tUFKczqs=";
45 # This is needed by freeimage
46 ./0001-Compile-transupp.c-as-part-of-the-library.patch
47 ] ++ lib.optionals (!stdenv.hostPlatform.isMinGW) [
48 ./0002-Make-exported-symbols-in-transupp.c-weak.patch
49 ] ++ lib.optionals stdenv.hostPlatform.isMinGW [
53 outputs = [ "bin" "dev" "dev_private" "out" "man" "doc" ];
56 moveToOutput include/transupp.h $dev_private
62 ] ++ lib.optionals enableJava [
67 "-DENABLE_STATIC=${if enableStatic then "1" else "0"}"
68 "-DENABLE_SHARED=${if enableShared then "1" else "0"}"
69 ] ++ lib.optionals enableJava [
71 ] ++ lib.optionals enableJpeg7 [
73 ] ++ lib.optionals enableJpeg8 [
75 ] ++ lib.optionals stdenv.hostPlatform.isRiscV [
76 # https://github.com/libjpeg-turbo/libjpeg-turbo/issues/428
77 # https://github.com/libjpeg-turbo/libjpeg-turbo/commit/88bf1d16786c74f76f2e4f6ec2873d092f577c75
78 "-DFLOATTEST=fp-contract"
81 doInstallCheck = true;
82 installCheckTarget = "test";
97 inherit (python3.pkgs) pillow imread pyturbojpeg;
98 pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
102 homepage = "https://libjpeg-turbo.org/";
103 description = "Faster (using SIMD) libjpeg implementation";
104 license = licenses.ijg; # and some parts under other BSD-style licenses
105 pkgConfigModules = [ "libjpeg" "libturbojpeg" ];
106 maintainers = with maintainers; [ vcunat colemickens kamadorueda ];
107 platforms = platforms.all;