diff options
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/libjpeg-turbo')
4 files changed, 251 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/libjpeg-turbo/0001-Compile-transupp.c-as-part-of-the-library.patch b/nixpkgs/pkgs/development/libraries/libjpeg-turbo/0001-Compile-transupp.c-as-part-of-the-library.patch new file mode 100644 index 000000000000..775315018064 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/libjpeg-turbo/0001-Compile-transupp.c-as-part-of-the-library.patch @@ -0,0 +1,34 @@ +From 6442d11617f95d13e2a371bd3e01f5082a9c356d Mon Sep 17 00:00:00 2001 +From: Las <las@protonmail.ch> +Date: Sun, 3 Jan 2021 18:35:37 +0000 +Subject: [PATCH] Compile transupp.c as part of the library + +--- + CMakeLists.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index adb0ca45..46fc16dd 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -581,7 +581,7 @@ set(JPEG_SOURCES ${JPEG12_SOURCES} jcapimin.c jchuff.c jcicc.c jcinit.c + jclhuff.c jcmarker.c jcmaster.c jcomapi.c jcparam.c jcphuff.c jctrans.c + jdapimin.c jdatadst.c jdatasrc.c jdhuff.c jdicc.c jdinput.c jdlhuff.c + jdmarker.c jdmaster.c jdphuff.c jdtrans.c jerror.c jfdctflt.c jmemmgr.c +- jmemnobs.c jpeg_nbits.c) ++ jmemnobs.c jpeg_nbits.c transupp.c) + + if(WITH_ARITH_ENC OR WITH_ARITH_DEC) + set(JPEG_SOURCES ${JPEG_SOURCES} jaricom.c) +@@ -1803,7 +1803,7 @@ install(EXPORT ${CMAKE_PROJECT_NAME}Targets + + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jconfig.h + ${CMAKE_CURRENT_SOURCE_DIR}/jerror.h ${CMAKE_CURRENT_SOURCE_DIR}/jmorecfg.h +- ${CMAKE_CURRENT_SOURCE_DIR}/jpeglib.h ++ ${CMAKE_CURRENT_SOURCE_DIR}/jpeglib.h ${CMAKE_CURRENT_SOURCE_DIR}/transupp.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + + include(cmakescripts/BuildPackages.cmake) +-- +2.43.0 + diff --git a/nixpkgs/pkgs/development/libraries/libjpeg-turbo/0002-Make-exported-symbols-in-transupp.c-weak.patch b/nixpkgs/pkgs/development/libraries/libjpeg-turbo/0002-Make-exported-symbols-in-transupp.c-weak.patch new file mode 100644 index 000000000000..fc23b776312a --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/libjpeg-turbo/0002-Make-exported-symbols-in-transupp.c-weak.patch @@ -0,0 +1,81 @@ +From 6442d11617f95d13e2a371bd3e01f5082a9c356d Mon Sep 17 00:00:00 2001 +From: Las <las@protonmail.ch> +Date: Sun, 3 Jan 2021 18:35:37 +0000 +Subject: [PATCH] Make exported symbols in transupp.c weak + +The exported symbols are made weak to not conflict with users +of the library that already vendor this functionality. +--- + transupp.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/transupp.c b/transupp.c +index 34fbb371..c0ade5a9 100644 +--- a/transupp.c ++++ b/transupp.c +@@ -1388,7 +1388,7 @@ jt_read_integer(const char **strptr, JDIMENSION *result) + * This code is loosely based on XParseGeometry from the X11 distribution. + */ + +-GLOBAL(boolean) ++GLOBAL(boolean) __attribute__((weak)) + jtransform_parse_crop_spec(jpeg_transform_info *info, const char *spec) + { + info->crop = FALSE; +@@ -1488,7 +1488,7 @@ trim_bottom_edge(jpeg_transform_info *info, JDIMENSION full_height) + * and transformation is not perfect. Otherwise returns TRUE. + */ + +-GLOBAL(boolean) ++GLOBAL(boolean) __attribute__((weak)) + jtransform_request_workspace(j_decompress_ptr srcinfo, + jpeg_transform_info *info) + { +@@ -2035,7 +2035,7 @@ adjust_exif_parameters(JOCTET *data, unsigned int length, JDIMENSION new_width, + * to jpeg_write_coefficients(). + */ + +-GLOBAL(jvirt_barray_ptr *) ++GLOBAL(jvirt_barray_ptr *) __attribute__((weak)) + jtransform_adjust_parameters(j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + jvirt_barray_ptr *src_coef_arrays, + jpeg_transform_info *info) +@@ -2154,7 +2154,7 @@ jtransform_adjust_parameters(j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + * Note that some transformations will modify the source data arrays! + */ + +-GLOBAL(void) ++GLOBAL(void) __attribute__((weak)) + jtransform_execute_transform(j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + jvirt_barray_ptr *src_coef_arrays, + jpeg_transform_info *info) +@@ -2266,7 +2266,7 @@ jtransform_execute_transform(j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + * (may use custom action then) + */ + +-GLOBAL(boolean) ++GLOBAL(boolean) __attribute__((weak)) + jtransform_perfect_transform(JDIMENSION image_width, JDIMENSION image_height, + int MCU_width, int MCU_height, + JXFORM_CODE transform) +@@ -2305,7 +2305,7 @@ jtransform_perfect_transform(JDIMENSION image_width, JDIMENSION image_height, + * This must be called before jpeg_read_header() to have the desired effect. + */ + +-GLOBAL(void) ++GLOBAL(void) __attribute__((weak)) + jcopy_markers_setup(j_decompress_ptr srcinfo, JCOPY_OPTION option) + { + #ifdef SAVE_MARKERS_SUPPORTED +@@ -2337,7 +2337,7 @@ jcopy_markers_setup(j_decompress_ptr srcinfo, JCOPY_OPTION option) + * JFIF APP0 or Adobe APP14 markers if selected. + */ + +-GLOBAL(void) ++GLOBAL(void) __attribute__((weak)) + jcopy_markers_execute(j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JCOPY_OPTION option) + { +-- +2.43.0 + diff --git a/nixpkgs/pkgs/development/libraries/libjpeg-turbo/default.nix b/nixpkgs/pkgs/development/libraries/libjpeg-turbo/default.nix new file mode 100644 index 000000000000..a34a60b11bf1 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/libjpeg-turbo/default.nix @@ -0,0 +1,117 @@ +{ lib +, stdenv +, fetchFromGitHub +, fetchpatch +, cmake +, nasm +, openjdk +, enableJava ? false # whether to build the java wrapper +, enableJpeg7 ? false # whether to build libjpeg with v7 compatibility +, enableJpeg8 ? false # whether to build libjpeg with v8 compatibility +, enableStatic ? stdenv.hostPlatform.isStatic +, enableShared ? !stdenv.hostPlatform.isStatic + +# for passthru.tests +, dvgrab +, epeg +, freeimage +, gd +, graphicsmagick +, imagemagick +, imlib2 +, jhead +, libjxl +, mjpegtools +, opencv +, python3 +, vips +, testers +}: + +assert !(enableJpeg7 && enableJpeg8); # pick only one or none, not both + +stdenv.mkDerivation (finalAttrs: { + + pname = "libjpeg-turbo"; + version = "3.0.2"; + + src = fetchFromGitHub { + owner = "libjpeg-turbo"; + repo = "libjpeg-turbo"; + rev = finalAttrs.version; + hash = "sha256-xHjd0WHN50b75wdWPHUwfmJGsiWKmj+zA59UwakIo74="; + }; + + patches = [ + (fetchpatch { + name = "CMAKE_CROSSCOMPILING_EMULATOR=env-fix.patch"; + url = "https://github.com/libjpeg-turbo/libjpeg-turbo/compare/36c51dd3eb60ebde3ca77d3cfa7df3422f1aaaf1..b6ee1016abbc55116304ad396cf88aa19391e10a.patch"; + hash = "sha256-dNwXicvZEsG02TBaM5nYMlZ+VczT/Dfx6ZM/6huZpwE="; + }) + + # This is needed by freeimage + ./0001-Compile-transupp.c-as-part-of-the-library.patch + ] ++ lib.optionals (!stdenv.hostPlatform.isMinGW) [ + ./0002-Make-exported-symbols-in-transupp.c-weak.patch + ] ++ lib.optionals stdenv.hostPlatform.isMinGW [ + ./mingw-boolean.patch + ]; + + outputs = [ "bin" "dev" "dev_private" "out" "man" "doc" ]; + + postFixup = '' + moveToOutput include/transupp.h $dev_private + ''; + + nativeBuildInputs = [ + cmake + nasm + ] ++ lib.optionals enableJava [ + openjdk + ]; + + cmakeFlags = [ + "-DENABLE_STATIC=${if enableStatic then "1" else "0"}" + "-DENABLE_SHARED=${if enableShared then "1" else "0"}" + ] ++ lib.optionals enableJava [ + "-DWITH_JAVA=1" + ] ++ lib.optionals enableJpeg7 [ + "-DWITH_JPEG7=1" + ] ++ lib.optionals enableJpeg8 [ + "-DWITH_JPEG8=1" + ] ++ lib.optionals stdenv.hostPlatform.isRiscV [ + # https://github.com/libjpeg-turbo/libjpeg-turbo/issues/428 + # https://github.com/libjpeg-turbo/libjpeg-turbo/commit/88bf1d16786c74f76f2e4f6ec2873d092f577c75 + "-DFLOATTEST=fp-contract" + ]; + + doInstallCheck = true; + installCheckTarget = "test"; + + passthru.tests = { + inherit + dvgrab + epeg + freeimage + gd + graphicsmagick + imagemagick + imlib2 + jhead + libjxl + mjpegtools + opencv + vips; + inherit (python3.pkgs) pillow imread pyturbojpeg; + pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; + }; + + meta = with lib; { + homepage = "https://libjpeg-turbo.org/"; + description = "A faster (using SIMD) libjpeg implementation"; + license = licenses.ijg; # and some parts under other BSD-style licenses + pkgConfigModules = [ "libjpeg" "libturbojpeg" ]; + maintainers = with maintainers; [ vcunat colemickens kamadorueda ]; + platforms = platforms.all; + }; +}) diff --git a/nixpkgs/pkgs/development/libraries/libjpeg-turbo/mingw-boolean.patch b/nixpkgs/pkgs/development/libraries/libjpeg-turbo/mingw-boolean.patch new file mode 100644 index 000000000000..9b9483d63987 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/libjpeg-turbo/mingw-boolean.patch @@ -0,0 +1,19 @@ +Ported to updated libjpeg-turbo from +https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-libjpeg-turbo/jpeg-typedefs.patch +--- a/jmorecfg.h 2012-02-10 06:47:55 +0300 ++++ b/jmorecfg.h 2012-05-03 10:29:13 +0400 +@@ -224,7 +224,13 @@ + * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. + */ + +-#ifndef HAVE_BOOLEAN ++#if defined(_WIN32) && !defined(HAVE_BOOLEAN) ++#ifndef __RPCNDR_H__ ++typedef unsigned char boolean; ++#endif ++#define HAVE_BOOLEAN ++#endif ++#if !defined(HAVE_BOOLEAN) && !defined(__RPCNDR_H__) + typedef int boolean; + #endif + #ifndef FALSE /* in case these macros already exist */ |