8 enableJava ? false, # whether to build the java wrapper
9 enableJpeg7 ? false, # whether to build libjpeg with v7 compatibility
10 enableJpeg8 ? false, # whether to build libjpeg with v8 compatibility
11 enableStatic ? stdenv.hostPlatform.isStatic,
12 enableShared ? !stdenv.hostPlatform.isStatic,
31 assert !(enableJpeg7 && enableJpeg8); # pick only one or none, not both
33 stdenv.mkDerivation (finalAttrs: {
35 pname = "libjpeg-turbo";
38 src = fetchFromGitHub {
39 owner = "libjpeg-turbo";
40 repo = "libjpeg-turbo";
41 rev = finalAttrs.version;
42 hash = "sha256-ZNqhOfZtWcMv10VWIUxn7MSy4KhW/jBrgC1tUFKczqs=";
47 # This is needed by freeimage
48 ./0001-Compile-transupp.c-as-part-of-the-library.patch
50 ++ lib.optionals (!stdenv.hostPlatform.isMinGW) [
51 ./0002-Make-exported-symbols-in-transupp.c-weak.patch
53 ++ lib.optionals stdenv.hostPlatform.isMinGW [
67 moveToOutput include/transupp.h $dev_private
75 ++ lib.optionals enableJava [
81 "-DENABLE_STATIC=${if enableStatic then "1" else "0"}"
82 "-DENABLE_SHARED=${if enableShared then "1" else "0"}"
84 ++ lib.optionals enableJava [
87 ++ lib.optionals enableJpeg7 [
90 ++ lib.optionals enableJpeg8 [
93 ++ lib.optionals stdenv.hostPlatform.isRiscV [
94 # https://github.com/libjpeg-turbo/libjpeg-turbo/issues/428
95 # https://github.com/libjpeg-turbo/libjpeg-turbo/commit/88bf1d16786c74f76f2e4f6ec2873d092f577c75
96 "-DFLOATTEST=fp-contract"
99 doInstallCheck = true;
100 installCheckTarget = "test";
116 inherit (python3.pkgs) pillow imread pyturbojpeg;
117 pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
121 homepage = "https://libjpeg-turbo.org/";
122 description = "Faster (using SIMD) libjpeg implementation";
123 license = licenses.ijg; # and some parts under other BSD-style licenses
128 maintainers = with maintainers; [
132 platforms = platforms.all;