dev-qt/qtx11extras: stable 5.14.2 for ppc, bug #719732
[gentoo.git] / media-gfx / imagemagick / imagemagick-6.9.11.9.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="6"
5
6 inherit eapi7-ver eutils flag-o-matic libtool perl-functions toolchain-funcs multilib
7
8 MY_PV="$(ver_rs 3 '-')"
9 MY_P="ImageMagick-${MY_PV}"
10
11 DESCRIPTION="A collection of tools and libraries for many image formats"
12 HOMEPAGE="https://www.imagemagick.org/"
13 SRC_URI="mirror://imagemagick/${MY_P}.tar.xz"
14
15 LICENSE="imagemagick"
16 SLOT="0/6.9.11"
17 KEYWORDS="~alpha amd64 arm hppa ~ia64 ~mips ppc ppc64 ~s390 sparc x86 ~ppc-aix ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~x64-solaris ~x86-solaris"
18 IUSE="bzip2 corefonts +cxx djvu fftw fontconfig fpx graphviz hdri heif jbig jpeg jpeg2k lcms lqr lzma opencl openexr openmp pango perl png postscript q32 q8 raw static-libs svg test tiff truetype webp wmf X xml zlib"
19
20 REQUIRED_USE="corefonts? ( truetype )
21         test? ( corefonts )"
22
23 RESTRICT="perl? ( userpriv )
24         !test? ( test )"
25
26 RDEPEND="
27         dev-libs/libltdl:0
28         bzip2? ( app-arch/bzip2 )
29         corefonts? ( media-fonts/corefonts )
30         djvu? ( app-text/djvu )
31         fftw? ( sci-libs/fftw:3.0 )
32         fontconfig? ( media-libs/fontconfig )
33         fpx? ( >=media-libs/libfpx-1.3.0-r1 )
34         graphviz? ( media-gfx/graphviz )
35         heif? ( media-libs/libheif:= )
36         jbig? ( >=media-libs/jbigkit-2:= )
37         jpeg? ( virtual/jpeg:0 )
38         jpeg2k? ( >=media-libs/openjpeg-2.1.0:2 )
39         lcms? ( media-libs/lcms:2= )
40         lqr? ( media-libs/liblqr )
41         opencl? ( virtual/opencl )
42         openexr? ( media-libs/openexr:0= )
43         pango? ( x11-libs/pango )
44         perl? ( >=dev-lang/perl-5.8.8:0= )
45         png? ( media-libs/libpng:0= )
46         postscript? ( app-text/ghostscript-gpl )
47         raw? ( media-libs/libraw:= )
48         svg? (
49                 gnome-base/librsvg
50                 media-gfx/potrace
51                 )
52         tiff? ( media-libs/tiff:0= )
53         truetype? (
54                 media-fonts/urw-fonts
55                 >=media-libs/freetype-2
56                 )
57         webp? ( media-libs/libwebp:0= )
58         wmf? ( media-libs/libwmf )
59         X? (
60                 x11-libs/libICE
61                 x11-libs/libSM
62                 x11-libs/libXext
63                 x11-libs/libXt
64                 )
65         xml? ( dev-libs/libxml2:= )
66         lzma? ( app-arch/xz-utils )
67         zlib? ( sys-libs/zlib:= )"
68 DEPEND="${RDEPEND}
69         !media-gfx/graphicsmagick[imagemagick]
70         virtual/pkgconfig
71         X? ( x11-base/xorg-proto )"
72
73 S="${WORKDIR}/${MY_P}"
74 #S="${WORKDIR}/ImageMagick6-${MY_PV}"
75
76 src_prepare() {
77         default
78
79         # Apply hardening #664236
80         cp "${FILESDIR}"/policy-hardening.snippet "${S}" || die
81         sed -i -e '/^<policymap>$/ {
82                         r policy-hardening.snippet
83                         d
84                 }' \
85                 config/policy.xml || \
86                 die "Failed to apply hardening of policy.xml"
87         einfo "policy.xml hardened"
88
89         elibtoolize # for Darwin modules
90
91         # For testsuite, see https://bugs.gentoo.org/show_bug.cgi?id=500580#c3
92         local mesa_cards ati_cards nvidia_cards render_cards
93         shopt -s nullglob
94         ati_cards=$(echo -n /dev/ati/card* | sed 's/ /:/g')
95         if test -n "${ati_cards}"; then
96                 addpredict "${ati_cards}"
97         fi
98         mesa_cards=$(echo -n /dev/dri/card* | sed 's/ /:/g')
99         if test -n "${mesa_cards}"; then
100                 addpredict "${mesa_cards}"
101         fi
102         nvidia_cards=$(echo -n /dev/nvidia** | sed 's/ /:/g')
103         if test -n "${nvidia_cards}"; then
104                 addpredict "${nvidia_cards}"
105         fi
106         render_cards=$(echo -n /dev/dri/renderD128* | sed 's/ /:/g')
107         if test -n "${render_cards}"; then
108                 addpredict "${render_cards}"
109         fi
110         shopt -u nullglob
111         addpredict /dev/nvidiactl
112 }
113
114 src_configure() {
115         local depth=16
116         use q8 && depth=8
117         use q32 && depth=32
118
119         local openmp=disable
120         use openmp && { tc-has-openmp && openmp=enable; }
121
122         use perl && perl_check_env
123
124         [[ ${CHOST} == *-solaris* ]] && append-ldflags -lnsl -lsocket
125
126         local myeconfargs=(
127                 $(use_enable static-libs static)
128                 $(use_enable hdri)
129                 $(use_enable opencl)
130                 --with-threads
131                 --with-modules
132                 --with-quantum-depth=${depth}
133                 $(use_with cxx magick-plus-plus)
134                 $(use_with perl)
135                 --with-perl-options='INSTALLDIRS=vendor'
136                 --with-gs-font-dir="${EPREFIX}"/usr/share/fonts/urw-fonts
137                 $(use_with bzip2 bzlib)
138                 $(use_with X x)
139                 $(use_with zlib)
140                 --without-autotrace
141                 $(use_with postscript dps)
142                 $(use_with djvu)
143                 --with-dejavu-font-dir="${EPREFIX}"/usr/share/fonts/dejavu
144                 $(use_with fftw)
145                 $(use_with fpx)
146                 $(use_with fontconfig)
147                 $(use_with truetype freetype)
148                 $(use_with postscript gslib)
149                 $(use_with graphviz gvc)
150                 $(use_with heif heic)
151                 $(use_with jbig)
152                 $(use_with jpeg)
153                 $(use_with jpeg2k openjp2)
154                 $(use_with lcms)
155                 $(use_with lqr)
156                 $(use_with lzma)
157                 $(use_with openexr)
158                 $(use_with pango)
159                 $(use_with png)
160                 $(use_with raw)
161                 $(use_with svg rsvg)
162                 $(use_with tiff)
163                 $(use_with webp)
164                 $(use_with corefonts windows-font-dir "${EPREFIX}"/usr/share/fonts/corefonts)
165                 $(use_with wmf)
166                 $(use_with xml)
167                 --${openmp}-openmp
168                 --with-gcc-arch=no-automagic
169         )
170         CONFIG_SHELL=$(type -P bash) econf "${myeconfargs[@]}"
171 }
172
173 src_test() {
174         # Install default (unrestricted) policy in $HOME for test suite #664238
175         local _im_local_config_home="${HOME}/.config/ImageMagick"
176         mkdir -p "${_im_local_config_home}" || \
177                 die "Failed to create IM config dir in '${_im_local_config_home}'"
178         cp "${FILESDIR}"/policy.test.xml "${_im_local_config_home}/policy.xml" || \
179                 die "Failed to install default blank policy.xml in '${_im_local_config_home}'"
180
181         local im_command= IM_COMMANDS=()
182         IM_COMMANDS+=( "identify -version | grep -q -- \"${MY_PV}\"" ) # Verify that we are using version we just built
183         IM_COMMANDS+=( "identify -list policy" ) # Verify that policy.xml is used
184         IM_COMMANDS+=( "emake check" ) # Run tests
185
186         for im_command in "${IM_COMMANDS[@]}"; do
187                 eval "${S}"/magick.sh \
188                         ${im_command} || \
189                         die "Failed to run \"${im_command}\""
190         done
191 }
192
193 src_install() {
194         # Ensure documentation installation files and paths with each release!
195         emake \
196                 DESTDIR="${D}" \
197                 DOCUMENTATION_PATH="${EPREFIX}"/usr/share/doc/${PF}/html \
198                 install
199
200         rm -f "${ED%/}"/usr/share/doc/${PF}/html/{ChangeLog,LICENSE,NEWS.txt}
201         dodoc {AUTHORS,README}.txt ChangeLog
202
203         if use perl; then
204                 find "${ED}" -type f -name perllocal.pod -exec rm -f {} +
205                 find "${ED}" -depth -mindepth 1 -type d -empty -exec rm -rf {} +
206         fi
207
208         find "${ED}" -name '*.la' -exec sed -i -e "/^dependency_libs/s:=.*:='':" {} +
209         # .la files in parent are not needed, keep plugin .la files
210         rm "${ED}"/usr/$(get_libdir)/*.la || die
211
212         if use opencl; then
213                 cat <<-EOF > "${T}"/99${PN}
214                 SANDBOX_PREDICT="/dev/nvidiactl:/dev/nvidia-uvm:/dev/ati/card:/dev/dri/card:/dev/dri/renderD128"
215                 EOF
216
217                 insinto /etc/sandbox.d
218                 doins "${T}"/99${PN} #472766
219         fi
220
221         insinto /usr/share/${PN}
222         doins config/*icm
223 }
224
225 pkg_postinst() {
226         local _show_policy_xml_notice=
227
228         if [[ -z "${REPLACING_VERSIONS}" ]]; then
229                 # This is a new installation
230                 _show_policy_xml_notice=yes
231         else
232                 local v
233                 for v in ${REPLACING_VERSIONS}; do
234                         if ! ver_test "${v}" -gt "6.9.10.10-r2"; then
235                                 # This is an upgrade
236                                 _show_policy_xml_notice=yes
237
238                                 # Show this elog only once
239                                 break
240                         fi
241                 done
242         fi
243
244         if [[ -n "${_show_policy_xml_notice}" ]]; then
245                 elog "For security reasons, a policy.xml file was installed in /etc/ImageMagick-6"
246                 elog "which will prevent the usage of the following coders by default:"
247                 elog ""
248                 elog "  - PS"
249                 elog "  - PS2"
250                 elog "  - PS3"
251                 elog "  - EPS"
252                 elog "  - PDF"
253                 elog "  - XPS"
254         fi
255 }