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
29 assert !(enableJpeg7 && enableJpeg8); # pick only one or none, not both
31 stdenv.mkDerivation rec {
33 pname = "libjpeg-turbo";
36 src = fetchFromGitHub {
37 owner = "libjpeg-turbo";
38 repo = "libjpeg-turbo";
40 sha256 = "sha256-1NRoVIL3zXX1D6iOf2FCrwBEcDW7TYFbdIbCTjY1m8Q=";
43 # This is needed by freeimage
44 patches = [ ./0001-Compile-transupp.c-as-part-of-the-library.patch ]
45 ++ lib.optional (stdenv.hostPlatform.libc or null == "msvcrt")
46 ./mingw-boolean.patch;
48 outputs = [ "bin" "dev" "dev_private" "out" "man" "doc" ];
51 moveToOutput include/transupp.h $dev_private
57 ] ++ lib.optionals enableJava [
62 "-DENABLE_STATIC=${if enableStatic then "1" else "0"}"
63 "-DENABLE_SHARED=${if enableShared then "1" else "0"}"
64 ] ++ lib.optionals enableJava [
66 ] ++ lib.optionals enableJpeg7 [
68 ] ++ lib.optionals enableJpeg8 [
70 ] ++ lib.optionals stdenv.hostPlatform.isRiscV [
71 # https://github.com/libjpeg-turbo/libjpeg-turbo/issues/428
72 # https://github.com/libjpeg-turbo/libjpeg-turbo/commit/88bf1d16786c74f76f2e4f6ec2873d092f577c75
73 "-DFLOATTEST=fp-contract"
76 doInstallCheck = true;
77 installCheckTarget = "test";
93 inherit (python3.pkgs) pillow imread pyturbojpeg;
97 homepage = "https://libjpeg-turbo.org/";
98 description = "A faster (using SIMD) libjpeg implementation";
99 license = licenses.ijg; # and some parts under other BSD-style licenses
100 maintainers = with maintainers; [ vcunat colemickens kamadorueda ];
101 platforms = platforms.all;