1SUMMARY = "The GPL Ghostscript PostScript/PDF interpreter"
2DESCRIPTION = "Ghostscript is used for PostScript/PDF preview and printing.  Usually as \
3a back-end to a program such as ghostview, it can display PostScript and PDF \
4documents in an X11 environment. \
5\
6Furthermore, it can render PostScript and PDF files as graphics to be printed \
7on non-PostScript printers. Supported printers include common \
8dot-matrix, inkjet and laser models. \
9"
10HOMEPAGE = "http://www.ghostscript.com"
11SECTION = "console/utils"
12
13LICENSE = "AGPL-3.0-or-later"
14LIC_FILES_CHKSUM = "file://LICENSE;md5=f98ffa763e50cded76f49bce73aade16"
15
16DEPENDS = "tiff jpeg fontconfig cups libpng freetype zlib"
17
18UPSTREAM_CHECK_URI = "https://github.com/ArtifexSoftware/ghostpdl-downloads/releases"
19UPSTREAM_CHECK_REGEX = "(?P<pver>\d+(\.\d+)+)\.tar"
20
21def gs_verdir(v):
22    return "".join(v.split("."))
23
24
25SRC_URI = "https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs${@gs_verdir("${PV}")}/${BPN}-${PV}.tar.gz \
26           file://ghostscript-9.16-Werror-return-type.patch \
27           file://avoid-host-contamination.patch \
28           "
29
30SRC_URI[sha256sum] = "6f2bc61023469fcf7c7c2d7f1bdd75b75f2b41836aa1d5e641396246d4abbb59"
31
32PACKAGECONFIG ??= ""
33PACKAGECONFIG[gtk] = "--enable-gtk,--disable-gtk,gtk+3"
34PACKAGECONFIG[libidn] = "--with-libidn,--without-libidn,libidn"
35PACKAGECONFIG[libpaper] = "--with-libpaper,--without-libpaper,libpaper"
36PACKAGECONFIG[x11] = "--with-x --x-includes=${STAGING_INCDIR} --x-libraries=${STAGING_LIBDIR}, \
37                      --without-x, virtual/libx11 libxext libxt"
38
39EXTRA_OECONF = "--with-jbig2dec \
40                --with-fontpath=${datadir}/fonts \
41                CUPSCONFIG="${STAGING_BINDIR_CROSS}/cups-config" \
42                PKGCONFIG=pkg-config \
43                "
44
45EXTRA_OECONF:append:mipsarcho32 = " --with-large_color_index=0"
46
47EXTRA_OECONF:append:armv7a = "${@bb.utils.contains('TUNE_FEATURES','neon','',' --disable-neon',d)}"
48EXTRA_OECONF:append:armv7ve = "${@bb.utils.contains('TUNE_FEATURES','neon','',' --disable-neon',d)}"
49
50# Uses autoconf but not automake, can't do out-of-tree
51inherit autotools-brokensep pkgconfig
52
53# Prune the source tree of libraries that we're using our packaging of, so that
54# ghostscript can't link to them. Can't prune zlib as that's needed for the
55# native tools.
56prune_sources() {
57    rm -rf ${S}/jpeg/ ${S}/libpng/ ${S}/tiff/ ${S}/expat/ ${S}/freetype/ ${S}/cups/lib
58}
59do_unpack[postfuncs] += "prune_sources"
60
61do_install:append () {
62    oe_runmake DESTDIR=${D} install-so
63    oe_runmake DESTDIR=${D} install-data
64    cp -r ${S}/Resource ${D}${datadir}/ghostscript/${PV}/
65    cp -r ${S}/iccprofiles ${D}${datadir}/ghostscript/${PV}/
66}
67
68# ghostscript does not supports "arc"
69COMPATIBLE_HOST = "^(?!arc).*"
70
71# some entries in NVD uses gpl_ghostscript
72CVE_PRODUCT = "ghostscript gpl_ghostscript"
73
74CVE_STATUS[CVE-2023-38560] = "not-applicable-config: PCL isn't part of the Ghostscript release"
75CVE_STATUS[CVE-2023-38559] = "cpe-incorrect: Issue only appears in versions before 10.02.0"
76