Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake, pkg-config 2, libdeflate, libpng, libtiff, zlib, lcms2, jpylyzer 3, jpipLibSupport ? false # JPIP library & executables 4, jpipServerSupport ? false, curl, fcgi # JPIP Server 5, jdk 6, poppler 7}: 8 9let 10 mkFlag = optSet: flag: "-D${flag}=${if optSet then "ON" else "OFF"}"; 11in 12 13stdenv.mkDerivation rec { 14 pname = "openjpeg"; 15 version = "2.5.0"; 16 17 src = fetchFromGitHub { 18 owner = "uclouvain"; 19 repo = "openjpeg"; 20 rev = "v${version}"; 21 sha256 = "sha256-/0o3Fl6/jx5zu854TCqMyOz/8mnEyEC9lpZ6ij/tbHc="; 22 }; 23 24 outputs = [ "out" "dev" ]; 25 26 patches = [ 27 # modernise cmake files, also fixes them for multiple outputs 28 (fetchpatch { 29 url = "https://github.com/uclouvain/openjpeg/pull/1424.patch"; 30 sha256 = "sha256-CxVRt1u4HVOMUjWiZ2plmZC29t/zshCpSY+N4Wlrlvg="; 31 }) 32 # fix cmake files cross compilation 33 (fetchpatch { 34 url = "https://github.com/uclouvain/openjpeg/commit/c6ceb84c221b5094f1e8a4c0c247dee3fb5074e8.patch"; 35 sha256 = "sha256-gBUtmO/7RwSWEl7rc8HGr8gNtvNFdhjEwm0Dd51p5O8="; 36 }) 37 ]; 38 39 cmakeFlags = [ 40 "-DCMAKE_INSTALL_NAME_DIR=\${CMAKE_INSTALL_PREFIX}/lib" 41 "-DBUILD_SHARED_LIBS=ON" 42 "-DBUILD_CODEC=ON" 43 "-DBUILD_THIRDPARTY=OFF" 44 (mkFlag jpipLibSupport "BUILD_JPIP") 45 (mkFlag jpipServerSupport "BUILD_JPIP_SERVER") 46 "-DBUILD_VIEWER=OFF" 47 "-DBUILD_JAVA=OFF" 48 (mkFlag doCheck "BUILD_TESTING") 49 ]; 50 51 nativeBuildInputs = [ cmake pkg-config ]; 52 53 buildInputs = [ libpng libtiff zlib lcms2 ] 54 ++ lib.optionals jpipServerSupport [ curl fcgi ] 55 ++ lib.optional (jpipLibSupport) jdk; 56 57 doCheck = (!stdenv.isAarch64 && !stdenv.hostPlatform.isPower64); # tests fail on aarch64-linux and powerpc64 58 nativeCheckInputs = [ jpylyzer ]; 59 checkPhase = '' 60 substituteInPlace ../tools/ctest_scripts/travis-ci.cmake \ 61 --replace "JPYLYZER_EXECUTABLE=" "JPYLYZER_EXECUTABLE=\"$(command -v jpylyzer)\" # " 62 OPJ_SOURCE_DIR=.. ctest -S ../tools/ctest_scripts/travis-ci.cmake 63 ''; 64 65 passthru = { 66 incDir = "openjpeg-${lib.versions.majorMinor version}"; 67 tests = { 68 inherit poppler; 69 }; 70 }; 71 72 meta = with lib; { 73 description = "Open-source JPEG 2000 codec written in C language"; 74 homepage = "https://www.openjpeg.org/"; 75 license = licenses.bsd2; 76 maintainers = with maintainers; [ codyopel ]; 77 platforms = platforms.all; 78 changelog = "https://github.com/uclouvain/openjpeg/blob/v${version}/CHANGELOG.md"; 79 }; 80}