summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 29e730312b99bee6eeea44df4b13187fe7aa5ce1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# Maintainer: Daniel Bermond < yahoo-com: danielbermond >

# NOTE (1):
# DPS (Display PostScript) feature is obsolete and thus not enabled.
# For more information about DPS being obsolete please visit:
# http://www.x.org/releases/X11R7.7/doc/xorg-docs/graphics/dps.html

# NOTE (2):
# change font directories bellow to match yours:
#   - deJaVu and GhostScript font directories provided bellow are
#     the default ones
#   - Windows font directory provided bellow is set according to
#     the example in Arch Linux Wiki
#   - this Windows font directory example is for people that
#     copy/link fonts from a Windows installation. If you prefer,
#     you can choose an AUR package that provides the Windows fonts
#     as described in the Wiki and change the directory accordingly.

_dejavu_font_dir='/usr/share/fonts/TTF'
_gs_font_dir='/usr/share/fonts/gsfonts'
_urw_font_dir='/usr/share/fonts/gsfonts'
_windows_font_dir='/usr/share/fonts/WindowsFonts'
_1st_apple_font_dir='/usr/share/fonts/TTF'
_2nd_apple_font_dir='/usr/share/fonts/Type1'
_commit='2678d86a95653ec81760f0466a03d9efbf7f831d'
_qdepth='32'

pkgbase=imagemagick-full
pkgname=('libmagick-full' 'imagemagick-full' 'imagemagick-full-doc')
pkgver=7.0.7.32
pkgrel=1
arch=('i686' 'x86_64')
pkgdesc="An image viewing/manipulation program (Q${_qdepth} HDRI with all libs and features)"
url='http://www.imagemagick.org/'
license=('custom')
depends=(
    # official repositories:
        'libltdl' 'lcms2' 'fontconfig' 'libxext' 'liblqr' 'libraqm' 'libpng' 'libxml2'
        'ghostscript' 'gsfonts' 'ttf-dejavu' 'libraw' 'librsvg' 'libwebp' 'libwmf'
        'ocl-icd' 'openexr' 'openjpeg2' 'pango'
        'jemalloc' 'bzip2' 'libx11' 'libsm' 'libice' 'libxt' 'zlib' 'fftw' 'djvulibre'
        'freetype2' 'graphviz' 'jbigkit' 'libjpeg-turbo' 'xz' 'libtiff'
    # AUR:
        'libumem-git' 'autotrace-nomagick' 'flif' 'libfpx' 'libheif'
)
makedepends=('git' 'perl' 'opencl-headers' 'chrpath' 'glu' 'ghostpcl' 'ghostxps')
source=("${pkgbase}-git"::"git+https://github.com/ImageMagick/ImageMagick.git#commit=${_commit}"
        'arch-fonts.diff')
sha256sums=('SKIP'
            'a85b744c61b1b563743ecb7c7adad999d7ed9a8af816650e3ab9321b2b102e73')

prepare() {
    cd "${pkgbase}-git"
    
    # fix for 'sh: gitversion.sh: command not found' during autoreconf
    sed -i 's|(gitversion|(./gitversion|' configure.ac
    
    # fix up typemaps to match Arch Linux packages, where possible
    patch -Np1 -i "${srcdir}/arch-fonts.diff"
}

build() {
    cd "${pkgbase}-git"
    
    export CFLAGS="${CFLAGS} -I/usr/include/FLIF"
    
    autoreconf -fis
    
    ./configure \
        --prefix='/usr' \
        --sysconfdir='/etc' \
        --enable-openmp \
        --enable-opencl \
        --enable-largefile \
        --enable-static='no' \
        --enable-shared='yes' \
        --enable-fast-install='yes' \
        --disable-delegate-build \
        --enable-cipher \
        --enable-hdri \
        --enable-hugepages \
        --enable-docs \
        --with-threads \
        --with-modules \
        --with-quantum-depth="${_qdepth}" \
        --with-magick-plus-plus \
        --with-perl \
        --with-perl-options='INSTALLDIRS=vendor' \
        --with-jemalloc \
        --with-umem \
        --with-bzlib \
        --with-x \
        --with-zlib \
        --with-autotrace \
        --without-dps \
        --with-fftw \
        --with-flif \
        --with-fpx \
        --with-djvu \
        --with-fontconfig \
        --with-freetype \
        --with-raqm \
        --with-gslib \
        --with-gvc \
        --with-heic \
        --with-jbig \
        --with-jpeg \
        --with-lcms \
        --with-openjp2 \
        --with-lqr \
        --with-lzma \
        --with-openexr \
        --with-pango \
        --with-png \
        --with-raw \
        --with-rsvg \
        --with-tiff \
        --with-webp \
        --with-wmf \
        --with-xml \
        --with-dejavu-font-dir="$_dejavu_font_dir" \
        --with-gs-font-dir="$_gs_font_dir" \
        --with-urw-base35-font-dir="$_urw_font_dir" \
        --with-windows-font-dir="$_windows_font_dir" \
        --with-apple-font-dir="$_1st_apple_font_dir" \
        --with-fontpath="$_2nd_apple_font_dir" \
        PSDelegate='/usr/bin/gs' \
        XPSDelegate='/usr/bin/gxps' \
        PCLDelegate='/usr/bin/gpcl6' \
            
    make
}

package_libmagick-full() {
    local _majorver="${pkgver%%.*}"
    local _etcdir="ImageMagick-${_majorver}"
    
    pkgdesc+=' (library)'
    backup=(etc/"$_etcdir"/{coder,colors,delegates,log,magic,mime,policy,quantization-table,thresholds,type,type-{dejavu,ghostscript}}.xml)
    options=('!emptydirs' 'libtool')
    provides=('libmagick'
              "libMagickCore-${pkgver%%.*}.Q${_qdepth}HDRI.so"
              "libMagickWand-${pkgver%%.*}.Q${_qdepth}HDRI.so"
                "libMagick++-${pkgver%%.*}.Q${_qdepth}HDRI.so")
    conflicts=('libmagick' 'libmagick-fftw' 'libmagick-no-hdri'
               'libmagick-git' 'libmagick-full-git')
    
    cd "${pkgbase}-git"
    make DESTDIR="$pkgdir" install
    
    rm -f "$pkgdir"/usr/lib/*.la
    
    install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
    install -D -m644 NOTICE  "${pkgdir}/usr/share/licenses/${pkgname}/NOTICE"
    
    rm -rf binpkg/* docpkg/*
    
    mkdir -p binpkg/usr/lib {binpkg,docpkg}/usr/share
    
    # split 'imagemagick'
    cd binpkg
    mv -f "${pkgdir}/usr/bin"       usr/
    mv -f "${pkgdir}/usr/lib/perl5" usr/lib/
    mv -f "${pkgdir}/usr/share/man" usr/share/
    
    # split docs
    cd "${srcdir}/${pkgbase}-git/docpkg"
    mv -f "${pkgdir}/usr/share/doc" usr/share/
    
    # security fix
    # https://www.imagemagick.org/discourse-server/viewtopic.php?f=4&t=29588
    # https://imagetragick.com/
    sed -i '65i\  \<policy domain="coder" rights="none" pattern="EPHEMERAL" />' "${pkgdir}/etc/${_etcdir}/policy.xml"
    sed -i '66i\  \<policy domain="coder" rights="none" pattern="URL" />'       "${pkgdir}/etc/${_etcdir}/policy.xml"
    sed -i '67i\  \<policy domain="coder" rights="none" pattern="HTTPS" />'     "${pkgdir}/etc/${_etcdir}/policy.xml"
    sed -i '68i\  \<policy domain="coder" rights="none" pattern="MVG" />'       "${pkgdir}/etc/${_etcdir}/policy.xml"
    sed -i '69i\  \<policy domain="coder" rights="none" pattern="MSL" />'       "${pkgdir}/etc/${_etcdir}/policy.xml"
    sed -i '70i\  \<policy domain="coder" rights="none" pattern="TEXT" />'      "${pkgdir}/etc/${_etcdir}/policy.xml"
    sed -i '71i\  \<policy domain="coder" rights="none" pattern="SHOW" />'      "${pkgdir}/etc/${_etcdir}/policy.xml"
    sed -i '72i\  \<policy domain="coder" rights="none" pattern="WIN" />'       "${pkgdir}/etc/${_etcdir}/policy.xml"
    sed -i '73i\  \<policy domain="coder" rights="none" pattern="PLT" />'       "${pkgdir}/etc/${_etcdir}/policy.xml"
}

package_imagemagick-full() {
    depends=("libmagick-full=${pkgver}-${pkgrel}" 'perl')
    optdepends=(
        # AUR:
            'imagemagick-full-doc: manual and API docs'
            'ttf-mac-fonts: for Apple fonts support'
    )
    options=('!emptydirs')
    provides=('imagemagick' 'imagemagick-fftw')
    conflicts=('imagemagick' 'imagemagick-fftw' 'imagemagick-no-hdri'
               'imagemagick-git' 'imagemagick-full-git')
    
    cd "${pkgbase}-git"
    
    mv -f binpkg/* "$pkgdir"
    
    find "${pkgdir}/usr/lib/perl5" -name '*.so' -exec chrpath -d {} +
    
    install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
    install -D -m644 NOTICE  "${pkgdir}/usr/share/licenses/${pkgname}/NOTICE"
}

package_imagemagick-full-doc() {
    pkgdesc+=' (manual and API docs)'
    arch=('any')
    depends=()
    provides=('imagemagick-doc')
    conflicts=('imagemagick-doc' 'imagemagick-git-doc' 'imagemagick-full-doc-git')
    
    cd "${pkgbase}-git"
    
    mv -f docpkg/* "$pkgdir"
    
    install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
    install -D -m644 NOTICE  "${pkgdir}/usr/share/licenses/${pkgname}/NOTICE"
}