1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit autotools multilib versionator flag-o-matic toolchain-funcs
8 DESCRIPTION="Ghostscript is an interpreter for the PostScript language and for PDF"
9 HOMEPAGE="http://ghostscript.com/"
12 PVM=$(get_version_component_range 1-2)
13 PVM_S=$(replace_all_version_separators "" ${PVM})
18 https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs${PVM_S}/${MY_P}.tar.xz
19 https://dev.gentoo.org/~dilfridge/distfiles/${P}-patchset-${MY_PATCHSET}.tar.xz
22 LICENSE="AGPL-3 CPL-1.0"
24 KEYWORDS="alpha amd64 arm ~arm64 ~hppa ia64 ~m68k ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
25 IUSE="cups dbus gtk l10n_de static-libs tiff unicode X"
30 >=media-libs/freetype-2.4.9:2=
32 >=media-libs/lcms-2.6:2
33 >=media-libs/libpng-1.6.2:0=
34 >=media-libs/openjpeg-2.1.0:2=
35 >=sys-libs/zlib-1.2.7:=
37 cups? ( >=net-print/cups-1.3.8 )
38 dbus? ( sys-apps/dbus )
39 gtk? ( || ( x11-libs/gtk+:3 x11-libs/gtk+:2 ) )
40 unicode? ( net-dns/libidn )
41 tiff? ( >=media-libs/tiff-4.0.1:0= )
42 X? ( x11-libs/libXt x11-libs/libXext )
45 DEPEND="${COMMON_DEPEND}
49 RDEPEND="${COMMON_DEPEND}
50 >=app-text/poppler-data-0.4.5-r1
51 >=media-fonts/urw-fonts-2.4.9
52 l10n_ja? ( media-fonts/kochi-substitute )
53 l10n_ko? ( media-fonts/baekmuk-fonts )
54 l10n_zh-CN? ( media-fonts/arphicfonts )
55 l10n_zh-TW? ( media-fonts/arphicfonts )
56 !!media-fonts/gnu-gs-fonts-std
57 !!media-fonts/gnu-gs-fonts-other
58 !<net-print/cups-filters-1.0.36-r2
61 S="${WORKDIR}/${MY_P}"
63 LANGS="ja ko zh-CN zh-TW"
64 for X in ${LANGS} ; do
65 IUSE="${IUSE} l10n_${X}"
71 # remove internal copies of various libraries
72 rm -rf "${S}"/cups/libs || die
73 rm -rf "${S}"/expat || die
74 rm -rf "${S}"/freetype || die
75 rm -rf "${S}"/jbig2dec || die
76 rm -rf "${S}"/jpeg{,xr} || die
77 rm -rf "${S}"/lcms{,2} || die
78 rm -rf "${S}"/libpng || die
79 rm -rf "${S}"/tiff || die
80 rm -rf "${S}"/zlib || die
81 rm -rf "${S}"/openjpeg || die
82 # remove internal CMaps (CMaps from poppler-data are used instead)
83 rm -rf "${S}"/Resource/CMap || die
85 # apply various patches, many borrowed from Fedora
86 # http://pkgs.fedoraproject.org/cgit/ghostscript.git
87 eapply "${WORKDIR}/patches/"*.patch
88 eapply "${FILESDIR}/imagewriter-gs.patch"
91 sed -i -e "s:\$(GSSOX)::" \
92 -e "s:.*\$(GSSOX_XENAME)$::" \
93 "${S}"/base/unix-dll.mak || die "sed failed"
96 # Force the include dirs to a neutral location.
98 -e "/^ZLIBDIR=/s:=.*:=${T}:" \
100 # Some files depend on zlib.h directly. Redirect them. #573248
101 # Also make sure to not define OPJ_STATIC to avoid linker errors due to
102 # hidden symbols (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=203327#c1)
104 -e '/^zlib_h/s:=.*:=:' \
105 -e 's|-DOPJ_STATIC ||' \
109 # put LDFLAGS after BINDIR, bug #383447
110 sed -i -e "s:\$\(gsdatadir\)/lib:@datarootdir@/ghostscript/${PVM}/$(get_libdir):" \
111 -e "s:exdir=.*:exdir=@datarootdir@/doc/${PF}/examples:" \
112 -e "s:docdir=.*:docdir=@datarootdir@/doc/${PF}/html:" \
113 -e "s:GS_DOCDIR=.*:GS_DOCDIR=@datarootdir@/doc/${PF}/html:" \
114 -e 's:-L$(BINDIR):& $(LDFLAGS):g' \
115 "${S}"/Makefile.in "${S}"/base/*.mak || die "sed failed"
118 # remove incorrect symlink, bug 590384
119 rm -f ijs/ltmain.sh || die
129 "${EPREFIX}"/usr/share/fonts/urw-fonts \
130 "${EPREFIX}"/usr/share/fonts/Type1 \
131 "${EPREFIX}"/usr/share/fonts \
132 "${EPREFIX}"/usr/share/poppler/cMap/Adobe-CNS1 \
133 "${EPREFIX}"/usr/share/poppler/cMap/Adobe-GB1 \
134 "${EPREFIX}"/usr/share/poppler/cMap/Adobe-Japan1 \
135 "${EPREFIX}"/usr/share/poppler/cMap/Adobe-Japan2 \
136 "${EPREFIX}"/usr/share/poppler/cMap/Adobe-Korea1
138 FONTPATH="$FONTPATH${FONTPATH:+:}${EPREFIX}$path"
141 PKGCONFIG=$(type -P $(tc-getPKG_CONFIG)) \
145 --enable-fontconfig \
147 --disable-compile-inits \
149 --with-fontpath="$FONTPATH" \
157 $(use_with cups pdftoraster) \
158 $(use_with unicode libidn) \
159 $(use_with tiff system-libtiff) \
165 $(use_enable static-libs static)
176 emake DESTDIR="${D}" install-so install
178 # move gsc to gs, bug #343447
179 # gsc collides with gambit, bug #253064
180 mv -f "${ED}"/usr/bin/{gsc,gs} || die
183 emake DESTDIR="${D}" install
185 # rename the original cidfmap to cidfmap.GS
186 mv "${ED}/usr/share/ghostscript/${PVM}/Resource/Init/cidfmap"{,.GS} || die
188 # install our own cidfmap to handle CJK fonts
189 insinto /usr/share/ghostscript/${PVM}/Resource/Init
191 "${WORKDIR}/fontmaps/CIDFnmap" \
192 "${WORKDIR}/fontmaps/cidfmap"
193 for X in ${LANGS} ; do
194 if use l10n_${X} ; then
195 doins "${WORKDIR}/fontmaps/cidfmap.${X/-/_}"
199 # install the CMaps from poppler-data properly, bug #409361
200 dosym ../../../poppler/cMaps "/usr/share/ghostscript/${PVM}/Resource/CMap"
202 use static-libs || find "${ED}" -name '*.la' -delete
204 if ! use l10n_de; then
205 rm -r "${ED}"/usr/share/man/de || die