2020-10-22 21:04:04 +02:00
|
|
|
{ config, stdenv, lib, fetchurl, pkg-config, zlib, expat, openssl, autoconf
|
2018-09-04 18:50:15 +02:00
|
|
|
, libjpeg, libpng, libtiff, freetype, fontconfig, libpaper, jbig2dec
|
2021-11-04 13:48:57 +01:00
|
|
|
, libiconv, ijs, lcms2, fetchpatch, callPackage, bash, buildPackages
|
2021-11-04 23:11:37 +01:00
|
|
|
, cupsSupport ? config.ghostscript.cups or (!stdenv.isDarwin), cups
|
|
|
|
, x11Support ? cupsSupport, xlibsWrapper # with CUPS, X11 only adds very little
|
2005-08-30 15:50:14 +02:00
|
|
|
}:
|
|
|
|
|
2015-07-26 15:50:59 +02:00
|
|
|
let
|
|
|
|
fonts = stdenv.mkDerivation {
|
|
|
|
name = "ghostscript-fonts";
|
|
|
|
|
|
|
|
srcs = [
|
|
|
|
(fetchurl {
|
|
|
|
url = "mirror://sourceforge/gs-fonts/ghostscript-fonts-std-8.11.tar.gz";
|
|
|
|
sha256 = "00f4l10xd826kak51wsmaz69szzm2wp8a41jasr4jblz25bg7dhf";
|
|
|
|
})
|
|
|
|
(fetchurl {
|
|
|
|
url = "mirror://gnu/ghostscript/gnu-gs-fonts-other-6.0.tar.gz";
|
|
|
|
sha256 = "1cxaah3r52qq152bbkiyj2f7dx1rf38vsihlhjmrvzlr8v6cqil1";
|
|
|
|
})
|
|
|
|
# ... add other fonts here
|
|
|
|
];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir "$out"
|
|
|
|
mv -v * "$out/"
|
|
|
|
'';
|
|
|
|
};
|
2005-04-29 15:23:15 +02:00
|
|
|
|
2015-07-26 15:50:59 +02:00
|
|
|
in
|
2014-11-05 03:26:53 +01:00
|
|
|
stdenv.mkDerivation rec {
|
2022-02-22 20:13:24 +01:00
|
|
|
pname = "ghostscript${lib.optionalString (x11Support) "-with-X"}";
|
2022-01-09 02:01:38 +01:00
|
|
|
version = "9.55.0";
|
2011-05-24 17:35:38 +02:00
|
|
|
|
2014-11-05 03:26:53 +01:00
|
|
|
src = fetchurl {
|
2022-02-22 20:13:24 +01:00
|
|
|
url = "https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs9${lib.versions.minor version}${lib.versions.patch version}/ghostscript-${version}.tar.xz";
|
2022-01-09 02:01:38 +01:00
|
|
|
sha512 = "27g72152mlwlalg232jxdhaf3ykgmqwi2pccbkwfygql1h9iz40plfbwbs1n0fkvm4zwzg5r9cr8g7w2dxih4jldiidv7rflxdy1is2";
|
2011-05-24 17:35:38 +02:00
|
|
|
};
|
|
|
|
|
2018-09-04 18:50:15 +02:00
|
|
|
patches = [
|
2020-08-24 01:52:41 +02:00
|
|
|
(fetchpatch {
|
2022-01-09 02:01:38 +01:00
|
|
|
name = "fix-non-vendored-lcms2-typo.patch";
|
|
|
|
url = "https://github.com/ArtifexSoftware/ghostpdl/commit/830afae5454dea3bff903869d82022306890a96c.patch";
|
|
|
|
sha256 = "1w9yspsgxyabvrw9ld6pv6pb7708c44ihjqvag7qqh9v1lhm48j0";
|
2021-09-11 06:11:19 +02:00
|
|
|
})
|
2018-09-04 18:50:15 +02:00
|
|
|
./urw-font-files.patch
|
|
|
|
./doc-no-ref.diff
|
|
|
|
];
|
|
|
|
|
2017-07-11 10:53:41 +02:00
|
|
|
outputs = [ "out" "man" "doc" ];
|
2005-04-29 15:23:15 +02:00
|
|
|
|
2013-09-26 17:00:12 +02:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2021-11-04 13:48:57 +01:00
|
|
|
depsBuildBuild = [
|
|
|
|
buildPackages.stdenv.cc
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ pkg-config autoconf zlib ]
|
|
|
|
++ lib.optional cupsSupport cups;
|
|
|
|
|
2021-11-04 23:11:37 +01:00
|
|
|
buildInputs = [
|
|
|
|
zlib expat openssl
|
|
|
|
libjpeg libpng libtiff freetype fontconfig libpaper jbig2dec
|
|
|
|
libiconv ijs lcms2 bash
|
|
|
|
]
|
|
|
|
++ lib.optional x11Support xlibsWrapper
|
|
|
|
++ lib.optional cupsSupport cups
|
|
|
|
;
|
2012-01-03 18:50:10 +01:00
|
|
|
|
2015-07-26 15:50:59 +02:00
|
|
|
preConfigure = ''
|
2021-11-04 13:48:57 +01:00
|
|
|
# https://ghostscript.com/doc/current/Make.htm
|
|
|
|
export CCAUX=$CC_FOR_BUILD
|
|
|
|
${lib.optionalString cupsSupport ''export CUPSCONFIG="${cups.dev}/bin/cups-config"''}
|
|
|
|
|
2016-01-13 17:47:07 +01:00
|
|
|
# requires in-tree (heavily patched) openjpeg
|
2019-03-11 00:07:18 +01:00
|
|
|
rm -rf jpeg libpng zlib jasper expat tiff lcms2mt jbig2dec freetype cups/libs ijs
|
2015-07-26 15:50:59 +02:00
|
|
|
|
|
|
|
sed "s@if ( test -f \$(INCLUDE)[^ ]* )@if ( true )@; s@INCLUDE=/usr/include@INCLUDE=/no-such-path@" -i base/unix-aux.mak
|
2016-04-16 19:50:01 +02:00
|
|
|
sed "s@^ZLIBDIR=.*@ZLIBDIR=${zlib.dev}/include@" -i configure.ac
|
2016-01-13 17:47:07 +01:00
|
|
|
|
|
|
|
autoconf
|
2015-07-26 15:50:59 +02:00
|
|
|
'';
|
|
|
|
|
2019-11-20 09:21:30 +01:00
|
|
|
configureFlags = [
|
|
|
|
"--with-system-libtiff"
|
|
|
|
"--enable-dynamic"
|
2022-01-09 02:01:38 +01:00
|
|
|
"--without-tesseract"
|
2019-11-20 09:21:30 +01:00
|
|
|
]
|
|
|
|
++ lib.optional x11Support "--with-x"
|
|
|
|
++ lib.optionals cupsSupport [
|
|
|
|
"--enable-cups"
|
|
|
|
];
|
2008-07-17 21:37:18 +02:00
|
|
|
|
2021-09-11 20:07:58 +02:00
|
|
|
# make check does nothing useful
|
|
|
|
doCheck = false;
|
2012-01-03 18:50:10 +01:00
|
|
|
|
2015-07-26 15:50:59 +02:00
|
|
|
# don't build/install statically linked bin/gs
|
2016-02-02 14:52:03 +01:00
|
|
|
buildFlags = [ "so" ];
|
|
|
|
installTargets = [ "soinstall" ];
|
2014-11-05 03:26:53 +01:00
|
|
|
|
2012-01-03 18:50:10 +01:00
|
|
|
postInstall = ''
|
2015-07-26 15:50:59 +02:00
|
|
|
ln -s gsc "$out"/bin/gs
|
|
|
|
|
2016-02-02 14:52:03 +01:00
|
|
|
cp -r Resource "$out/share/ghostscript/${version}"
|
|
|
|
|
2015-07-26 15:50:59 +02:00
|
|
|
ln -s "${fonts}" "$out/share/ghostscript/fonts"
|
2021-01-15 14:21:58 +01:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
2017-02-16 19:32:39 +01:00
|
|
|
for file in $out/lib/*.dylib* ; do
|
|
|
|
install_name_tool -id "$file" $file
|
|
|
|
done
|
2012-01-03 18:50:10 +01:00
|
|
|
'';
|
2014-11-05 03:26:53 +01:00
|
|
|
|
2020-11-24 10:46:19 +01:00
|
|
|
# dynamic library name only contains maj.min, eg. '9.53'
|
|
|
|
dylib_version = lib.versions.majorMinor version;
|
2016-02-02 14:52:03 +01:00
|
|
|
preFixup = lib.optionalString stdenv.isDarwin ''
|
2020-11-24 10:46:19 +01:00
|
|
|
install_name_tool -change libgs.dylib.$dylib_version $out/lib/libgs.dylib.$dylib_version $out/bin/gs
|
|
|
|
'';
|
|
|
|
|
|
|
|
# validate dynamic linkage
|
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
|
|
runHook preInstallCheck
|
|
|
|
|
|
|
|
$out/bin/gs --version
|
2021-09-11 20:07:58 +02:00
|
|
|
pushd examples
|
|
|
|
for f in *.{ps,eps,pdf}; do
|
|
|
|
echo "Rendering $f"
|
|
|
|
$out/bin/gs \
|
|
|
|
-dNOPAUSE \
|
|
|
|
-dBATCH \
|
|
|
|
-sDEVICE=bitcmyk \
|
|
|
|
-sOutputFile=/dev/null \
|
|
|
|
-r600 \
|
|
|
|
-dBufferSpace=100000 \
|
|
|
|
$f
|
|
|
|
done
|
|
|
|
popd # examples
|
2020-11-24 10:46:19 +01:00
|
|
|
|
|
|
|
runHook postInstallCheck
|
2016-01-05 16:04:33 +01:00
|
|
|
'';
|
|
|
|
|
2021-09-12 14:13:19 +02:00
|
|
|
passthru.tests.test-corpus-render = callPackage ./test-corpus-render.nix {};
|
|
|
|
|
2014-11-05 03:26:53 +01:00
|
|
|
meta = {
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "https://www.ghostscript.com/";
|
2014-11-05 03:26:53 +01:00
|
|
|
description = "PostScript interpreter (mainline version)";
|
|
|
|
longDescription = ''
|
|
|
|
Ghostscript is the name of a set of tools that provides (i) an
|
|
|
|
interpreter for the PostScript language and the PDF file format,
|
|
|
|
(ii) a set of C procedures (the Ghostscript library) that
|
|
|
|
implement the graphics capabilities that appear as primitive
|
|
|
|
operations in the PostScript language, and (iii) a wide variety
|
|
|
|
of output drivers for various file formats and printers.
|
|
|
|
'';
|
2021-01-15 14:21:58 +01:00
|
|
|
license = lib.licenses.agpl3;
|
|
|
|
platforms = lib.platforms.all;
|
|
|
|
maintainers = [ lib.maintainers.viric ];
|
2021-10-11 08:03:44 +02:00
|
|
|
mainProgram = "gs";
|
2014-11-05 03:26:53 +01:00
|
|
|
};
|
2005-04-29 15:23:15 +02:00
|
|
|
}
|