2023-04-11 21:53:17 +00:00
|
|
|
{ config
|
|
|
|
, stdenv
|
|
|
|
, lib
|
|
|
|
, fetchurl
|
|
|
|
, pkg-config
|
|
|
|
, zlib
|
|
|
|
, expat
|
|
|
|
, openssl
|
|
|
|
, autoconf
|
|
|
|
, libjpeg
|
|
|
|
, libpng
|
|
|
|
, libtiff
|
|
|
|
, freetype
|
|
|
|
, fontconfig
|
|
|
|
, libpaper
|
|
|
|
, jbig2dec
|
|
|
|
, libiconv
|
|
|
|
, ijs
|
|
|
|
, lcms2
|
|
|
|
, callPackage
|
|
|
|
, bash
|
|
|
|
, buildPackages
|
|
|
|
, openjpeg
|
|
|
|
, cupsSupport ? config.ghostscript.cups or (!stdenv.isDarwin)
|
|
|
|
, cups
|
|
|
|
, x11Support ? cupsSupport
|
|
|
|
, xorg # with CUPS, X11 only adds very little
|
|
|
|
, dynamicDrivers ? true
|
2005-08-30 13:50:14 +00:00
|
|
|
}:
|
|
|
|
|
2015-07-26 13:50:59 +00: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 13:23:15 +00:00
|
|
|
|
2015-07-26 13:50:59 +00:00
|
|
|
in
|
2014-11-05 02:26:53 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2022-02-22 19:13:24 +00:00
|
|
|
pname = "ghostscript${lib.optionalString (x11Support) "-with-X"}";
|
2023-04-11 21:53:17 +00:00
|
|
|
version = "10.01.1";
|
2011-05-24 15:35:38 +00:00
|
|
|
|
2014-11-05 02:26:53 +00:00
|
|
|
src = fetchurl {
|
2023-04-11 21:53:17 +00:00
|
|
|
url = "https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs${lib.replaceStrings ["."] [""] version}/ghostscript-${version}.tar.xz";
|
|
|
|
hash = "sha512-2US+norvaNEXbWTEDbb6htVdDJ4wBH8hR8AoBqthz+msLLANTlshj/PFHMbtR87/4brE3Z1MwXYLeXTzDGwnNQ==";
|
2011-05-24 15:35:38 +00:00
|
|
|
};
|
|
|
|
|
2018-09-04 16:50:15 +00:00
|
|
|
patches = [
|
|
|
|
./urw-font-files.patch
|
|
|
|
./doc-no-ref.diff
|
|
|
|
];
|
|
|
|
|
2017-07-11 08:53:41 +00:00
|
|
|
outputs = [ "out" "man" "doc" ];
|
2005-04-29 13:23:15 +00:00
|
|
|
|
2013-09-26 15:00:12 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2021-11-04 12:48:57 +00:00
|
|
|
depsBuildBuild = [
|
|
|
|
buildPackages.stdenv.cc
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ pkg-config autoconf zlib ]
|
|
|
|
++ lib.optional cupsSupport cups;
|
|
|
|
|
2021-11-04 22:11:37 +00:00
|
|
|
buildInputs = [
|
|
|
|
zlib expat openssl
|
|
|
|
libjpeg libpng libtiff freetype fontconfig libpaper jbig2dec
|
2022-04-21 11:54:14 +00:00
|
|
|
libiconv ijs lcms2 bash openjpeg
|
2021-11-04 22:11:37 +00:00
|
|
|
]
|
2022-10-04 18:58:14 +00:00
|
|
|
++ lib.optionals x11Support [ xorg.libICE xorg.libX11 xorg.libXext xorg.libXt ]
|
2021-11-04 22:11:37 +00:00
|
|
|
++ lib.optional cupsSupport cups
|
|
|
|
;
|
2012-01-03 17:50:10 +00:00
|
|
|
|
2015-07-26 13:50:59 +00:00
|
|
|
preConfigure = ''
|
2021-11-04 12:48:57 +00:00
|
|
|
# https://ghostscript.com/doc/current/Make.htm
|
|
|
|
export CCAUX=$CC_FOR_BUILD
|
|
|
|
${lib.optionalString cupsSupport ''export CUPSCONFIG="${cups.dev}/bin/cups-config"''}
|
|
|
|
|
2022-04-21 11:54:14 +00:00
|
|
|
rm -rf jpeg libpng zlib jasper expat tiff lcms2mt jbig2dec freetype cups/libs ijs openjpeg
|
2015-07-26 13:50:59 +00: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 17:50:01 +00:00
|
|
|
sed "s@^ZLIBDIR=.*@ZLIBDIR=${zlib.dev}/include@" -i configure.ac
|
2016-01-13 16:47:07 +00:00
|
|
|
|
|
|
|
autoconf
|
2015-07-26 13:50:59 +00:00
|
|
|
'';
|
|
|
|
|
2019-11-20 08:21:30 +00:00
|
|
|
configureFlags = [
|
|
|
|
"--with-system-libtiff"
|
2022-01-09 01:01:38 +00:00
|
|
|
"--without-tesseract"
|
2023-04-11 21:53:17 +00:00
|
|
|
] ++ lib.optionals dynamicDrivers [
|
|
|
|
"--enable-dynamic"
|
|
|
|
"--disable-hidden-visibility"
|
|
|
|
] ++ lib.optional x11Support [
|
|
|
|
"--with-x"
|
|
|
|
] ++ lib.optionals cupsSupport [
|
2019-11-20 08:21:30 +00:00
|
|
|
"--enable-cups"
|
|
|
|
];
|
2008-07-17 19:37:18 +00:00
|
|
|
|
2021-09-11 18:07:58 +00:00
|
|
|
# make check does nothing useful
|
|
|
|
doCheck = false;
|
2012-01-03 17:50:10 +00:00
|
|
|
|
2015-07-26 13:50:59 +00:00
|
|
|
# don't build/install statically linked bin/gs
|
2016-02-02 13:52:03 +00:00
|
|
|
buildFlags = [ "so" ];
|
|
|
|
installTargets = [ "soinstall" ];
|
2014-11-05 02:26:53 +00:00
|
|
|
|
2012-01-03 17:50:10 +00:00
|
|
|
postInstall = ''
|
2015-07-26 13:50:59 +00:00
|
|
|
ln -s gsc "$out"/bin/gs
|
|
|
|
|
2016-02-02 13:52:03 +00:00
|
|
|
cp -r Resource "$out/share/ghostscript/${version}"
|
|
|
|
|
2015-07-26 13:50:59 +00:00
|
|
|
ln -s "${fonts}" "$out/share/ghostscript/fonts"
|
2021-01-15 13:21:58 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
2017-02-16 18:32:39 +00:00
|
|
|
for file in $out/lib/*.dylib* ; do
|
|
|
|
install_name_tool -id "$file" $file
|
|
|
|
done
|
2012-01-03 17:50:10 +00:00
|
|
|
'';
|
2014-11-05 02:26:53 +00:00
|
|
|
|
2020-11-24 09:46:19 +00:00
|
|
|
# dynamic library name only contains maj.min, eg. '9.53'
|
|
|
|
dylib_version = lib.versions.majorMinor version;
|
2016-02-02 13:52:03 +00:00
|
|
|
preFixup = lib.optionalString stdenv.isDarwin ''
|
2020-11-24 09:46:19 +00: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 18:07:58 +00: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 09:46:19 +00:00
|
|
|
|
|
|
|
runHook postInstallCheck
|
2016-01-05 15:04:33 +00:00
|
|
|
'';
|
|
|
|
|
2021-09-12 12:13:19 +00:00
|
|
|
passthru.tests.test-corpus-render = callPackage ./test-corpus-render.nix {};
|
|
|
|
|
2014-11-05 02:26:53 +00:00
|
|
|
meta = {
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://www.ghostscript.com/";
|
2014-11-05 02:26:53 +00: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 13:21:58 +00:00
|
|
|
license = lib.licenses.agpl3;
|
|
|
|
platforms = lib.platforms.all;
|
|
|
|
maintainers = [ lib.maintainers.viric ];
|
2021-10-11 06:03:44 +00:00
|
|
|
mainProgram = "gs";
|
2014-11-05 02:26:53 +00:00
|
|
|
};
|
2005-04-29 13:23:15 +00:00
|
|
|
}
|