1 # Copyright 1999-2018 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit eapi7-ver eutils flag-o-matic libtool perl-functions toolchain-funcs multilib
8 MY_P=ImageMagick-$(ver_rs 3 '-')
10 DESCRIPTION="A collection of tools and libraries for many image formats"
11 HOMEPAGE="https://www.imagemagick.org/"
12 SRC_URI="mirror://${PN}/${MY_P}.tar.xz"
16 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~x64-solaris ~x86-solaris"
17 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 RESTRICT="perl? ( userpriv )"
23 bzip2? ( app-arch/bzip2 )
24 corefonts? ( media-fonts/corefonts )
25 djvu? ( app-text/djvu )
26 fftw? ( sci-libs/fftw:3.0 )
27 fontconfig? ( media-libs/fontconfig )
28 fpx? ( >=media-libs/libfpx-1.3.0-r1 )
29 graphviz? ( media-gfx/graphviz )
30 heif? ( media-libs/libheif:= )
31 jbig? ( >=media-libs/jbigkit-2:= )
32 jpeg? ( virtual/jpeg:0 )
33 jpeg2k? ( >=media-libs/openjpeg-2.1.0:2 )
34 lcms? ( media-libs/lcms:2= )
35 lqr? ( media-libs/liblqr )
36 opencl? ( virtual/opencl )
37 openexr? ( media-libs/openexr:0= )
38 pango? ( x11-libs/pango )
39 perl? ( >=dev-lang/perl-5.8.8:0= )
40 png? ( media-libs/libpng:0= )
41 postscript? ( app-text/ghostscript-gpl )
42 raw? ( media-libs/libraw:= )
43 svg? ( gnome-base/librsvg )
44 tiff? ( media-libs/tiff:0= )
47 >=media-libs/freetype-2
49 webp? ( media-libs/libwebp:0= )
50 wmf? ( media-libs/libwmf )
57 xml? ( dev-libs/libxml2:= )
58 lzma? ( app-arch/xz-utils )
59 zlib? ( sys-libs/zlib:= )"
61 !media-gfx/graphicsmagick[imagemagick]
63 X? ( x11-base/xorg-proto )"
65 REQUIRED_USE="corefonts? ( truetype )
68 S="${WORKDIR}/${MY_P}"
73 # Apply hardening #664236
74 cp "${FILESDIR}"/policy-hardening.snippet "${S}" || die
75 sed -i -e '/^<policymap>$/ {
76 r policy-hardening.snippet
79 config/policy.xml || \
80 die "Failed to apply hardening of policy.xml"
81 einfo "policy.xml hardened"
83 elibtoolize # for Darwin modules
85 # For testsuite, see https://bugs.gentoo.org/show_bug.cgi?id=500580#c3
86 local mesa_cards ati_cards nvidia_cards render_cards
88 ati_cards=$(echo -n /dev/ati/card* | sed 's/ /:/g')
89 if test -n "${ati_cards}"; then
90 addpredict "${ati_cards}"
92 mesa_cards=$(echo -n /dev/dri/card* | sed 's/ /:/g')
93 if test -n "${mesa_cards}"; then
94 addpredict "${mesa_cards}"
96 nvidia_cards=$(echo -n /dev/nvidia** | sed 's/ /:/g')
97 if test -n "${nvidia_cards}"; then
98 addpredict "${nvidia_cards}"
100 render_cards=$(echo -n /dev/dri/renderD128* | sed 's/ /:/g')
101 if test -n "${render_cards}"; then
102 addpredict "${render_cards}"
105 addpredict /dev/nvidiactl
114 use openmp && { tc-has-openmp && openmp=enable; }
116 use perl && perl_check_env
118 [[ ${CHOST} == *-solaris* ]] && append-ldflags -lnsl -lsocket
121 $(use_enable static-libs static)
126 --with-quantum-depth=${depth}
127 $(use_with cxx magick-plus-plus)
129 --with-perl-options='INSTALLDIRS=vendor'
130 --with-gs-font-dir="${EPREFIX}"/usr/share/fonts/urw-fonts
131 $(use_with bzip2 bzlib)
135 $(use_with postscript dps)
137 --with-dejavu-font-dir="${EPREFIX}"/usr/share/fonts/dejavu
140 $(use_with fontconfig)
141 $(use_with truetype freetype)
142 $(use_with postscript gslib)
143 $(use_with graphviz gvc)
144 $(use_with heif heic)
147 $(use_with jpeg2k openjp2)
158 $(use_with corefonts windows-font-dir "${EPREFIX}"/usr/share/fonts/corefonts)
162 --with-gcc-arch=no-automagic
164 CONFIG_SHELL=$(type -P bash) econf "${myeconfargs[@]}"
168 # Install default (unrestricted) policy in $HOME for test suite #664238
169 local _im_local_config_home="${HOME}/.config/ImageMagick"
170 mkdir -p "${_im_local_config_home}" || \
171 die "Failed to create IM config dir in '${_im_local_config_home}'"
172 cp "${FILESDIR}"/policy.test.xml "${_im_local_config_home}/policy.xml" || \
173 die "Failed to install default blank policy.xml in '${_im_local_config_home}'"
175 local im_command= IM_COMMANDS=()
176 IM_COMMANDS+=( "magick -version" ) # Verify that we are using version we just built
177 IM_COMMANDS+=( "magick -list policy" ) # Verify that policy.xml is used
178 IM_COMMANDS+=( "emake check" ) # Run tests
180 for im_command in "${IM_COMMANDS[@]}"; do
187 # Ensure documentation installation files and paths with each release!
190 DOCUMENTATION_PATH="${EPREFIX}"/usr/share/doc/${PF}/html \
193 rm -f "${ED%/}"/usr/share/doc/${PF}/html/{ChangeLog,LICENSE,NEWS.txt}
194 dodoc {AUTHORS,README}.txt ChangeLog
197 find "${ED}" -type f -name perllocal.pod -exec rm -f {} +
198 find "${ED}" -depth -mindepth 1 -type d -empty -exec rm -rf {} +
201 find "${ED}" -name '*.la' -exec sed -i -e "/^dependency_libs/s:=.*:='':" {} +
204 cat <<-EOF > "${T}"/99${PN}
205 SANDBOX_PREDICT="/dev/nvidiactl:/dev/nvidia-uvm:/dev/ati/card:/dev/dri/card:/dev/dri/renderD128"
208 insinto /etc/sandbox.d
209 doins "${T}"/99${PN} #472766
212 insinto /usr/share/${PN}
217 local _show_policy_xml_notice=
219 if [[ -z "${REPLACING_VERSIONS}" ]]; then
220 # This is a new installation
221 _show_policy_xml_notice=yes
224 for v in ${REPLACING_VERSIONS}; do
225 if ! ver_test "${v}" -gt "6.9.10.10-r2"; then
227 _show_policy_xml_notice=yes
229 # Show this elog only once
235 if [[ -n "${_show_policy_xml_notice}" ]]; then
236 elog "For security reasons, a policy.xml file was installed in /etc/ImageMagick-6"
237 elog "which will prevent the usage of the following coders by default:"