nixpkgs/pkgs/applications/misc/mupdf/default.nix

74 lines
2.3 KiB
Nix
Raw Normal View History

{ stdenv, fetchurl, fetchpatch, pkgconfig, zlib, freetype, libjpeg, jbig2dec, openjpeg
, libX11, libXext }:
stdenv.mkDerivation rec {
2014-10-06 00:33:55 +04:00
version = "1.6";
name = "mupdf-${version}";
src = fetchurl {
2012-10-04 10:37:54 +04:00
url = "http://mupdf.com/download/archive/${name}-source.tar.gz";
2014-10-06 00:33:55 +04:00
sha256 = "0qx51rj6alzcagcixm59rvdpm54w6syrwr4184v439jh14ryw4wq";
};
buildInputs = [ pkgconfig zlib freetype libjpeg jbig2dec openjpeg libX11 libXext ];
enableParallelBuilding = true;
2014-05-17 16:14:42 +04:00
my_soname = "libmupdf.so.1.3";
my_soname_js_none = "libmupdf-js-none.so.1.3";
preBuild = ''
2014-05-17 16:14:07 +04:00
export makeFlags="prefix=$out build=release XCFLAGS=-fpic"
2012-10-04 10:37:54 +04:00
export NIX_CFLAGS_COMPILE=" $NIX_CFLAGS_COMPILE -I$(echo ${openjpeg}/include/openjpeg-*) "
2014-05-17 16:14:42 +04:00
# Copied from Gentoo ebuild
rm -rf thirdparty
sed -e "\$a\$(MUPDF_LIB): \$(MUPDF_JS_NONE_LIB)" \
-e "\$a\\\t\$(QUIET_LINK) \$(CC) \$(LDFLAGS) --shared -Wl,-soname -Wl,${my_soname} -Wl,--no-undefined -o \$@ \$^ \$(MUPDF_JS_NONE_LIB) \$(LIBS)" \
-e "/^MUPDF_LIB :=/s:=.*:= \$(OUT)/${my_soname}:" \
-e "\$a\$(MUPDF_JS_NONE_LIB):" \
-e "\$a\\\t\$(QUIET_LINK) \$(CC) \$(LDFLAGS) --shared -Wl,-soname -Wl,${my_soname_js_none} -Wl,--no-undefined -o \$@ \$^ \$(LIBS)" \
-e "/^MUPDF_JS_NONE_LIB :=/s:=.*:= \$(OUT)/${my_soname_js_none}:" \
-i Makefile
sed -e "s/libopenjpeg1/libopenjp2/" -i Makerules
'';
postInstall = ''
2014-05-17 16:14:42 +04:00
ln -s ${my_soname} $out/lib/libmupdf.so
mkdir -p "$out/lib/pkgconfig"
cat >"$out/lib/pkgconfig/mupdf.pc" <<EOF
prefix=$out
libdir=$out/lib
includedir=$out/include
Name: mupdf
Description: Library for rendering PDF documents
Requires: freetype2 libopenjp2 libcrypto
Version: 1.3
Libs: -L$out/lib -lmupdf
Cflags: -I$out/include
EOF
mkdir -p $out/share/applications
cat > $out/share/applications/mupdf.desktop <<EOF
[Desktop Entry]
Type=Application
Version=1.0
Name=mupdf
Comment=PDF viewer
Exec=$out/bin/mupdf-x11
Terminal=false
EOF
'';
meta = {
homepage = http://mupdf.com/;
2014-04-03 08:55:17 +04:00
repositories.git = git://git.ghostscript.com/mupdf.git;
description = "Lightweight PDF viewer and toolkit written in portable C";
license = stdenv.lib.licenses.gpl3Plus;
maintainers = with stdenv.lib.maintainers; [ viric ];
platforms = with stdenv.lib.platforms; linux;
inherit version;
};
}