summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 4c517418478a891a0d6fc438b8c61b7c4143ec32 (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
pkgname=mingw-w64-zlib
pkgver=1.2.12
pkgrel=1
pkgdesc="A compression/decompression Library (mingw-w64)"
arch=('any')
license=('custom:zlib')
depends=(mingw-w64-crt)
makedepends=(mingw-w64-gcc)
url="http://www.zlib.net/"
source=("http://zlib.net/zlib-${pkgver}.tar.gz")
options=(!strip !buildflags staticlibs)
sha256sums=('91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9')

_architectures="i686-w64-mingw32 x86_64-w64-mingw32"

build() {
  for _arch in ${_architectures}; do
    rm -rf "${srcdir}/build-${_arch}"
    cp -r "${srcdir}/zlib-${pkgver}" "${srcdir}/build-${_arch}"
    cd "${srcdir}/build-${_arch}"
    sed -ie "s,dllwrap,${_arch}-dllwrap," win32/Makefile.gcc
    ./configure --prefix=/usr/${_arch} -shared -static
    make -f win32/Makefile.gcc \
      CC=${_arch}-gcc \
      AR=${_arch}-ar \
      RC=${_arch}-windres \
      STRIP=${_arch}-strip \
      IMPLIB=libz.dll.a \
      CFLAGS="-Wp,-D_FORTIFY_SOURCE=2 -O2 -g -pipe -fno-plt -fexceptions --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fcf-protection"
  done
}

package () {
  for _arch in ${_architectures}; do
    cd "${srcdir}/build-${_arch}"
    install -d "${pkgdir}/usr/${_arch}/"{bin,include,lib}
    install -m644 -t "${pkgdir}/usr/${_arch}/include" zlib.h zconf.h
    install -m644 -t "${pkgdir}/usr/${_arch}/lib" libz.a libz.dll.a
    install -m755 -t "${pkgdir}/usr/${_arch}/bin" zlib1.dll

    install -d "${pkgdir}/usr/${_arch}/lib/pkgconfig"
    sed "s,@prefix@,/usr/${_arch},;s,@exec_prefix@,\${prefix},;s,@libdir@,\${exec_prefix}/lib,;s,@sharedlibdir@,\${libdir},;s,@includedir@,\${prefix}/include,;s,@VERSION@,$pkgver," < zlib.pc.in > "${pkgdir}/usr/${_arch}/lib/pkgconfig/zlib.pc"
    
    ${_arch}-strip -x -g "${pkgdir}/usr/${_arch}/bin/"*.dll
    ${_arch}-strip -g "${pkgdir}/usr/${_arch}/lib/"*.a
  done
}