summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 4e430efc8c4b3d8acbc96e0097708afd8f16cef4 (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
# Contributor: Andrew Sun <adsun701 at gmail dot com>

pkgname=mingw-w64-libgeotiff
pkgver=1.7.1
pkgrel=1
pkgdesc="A TIFF based interchange format for georeferenced raster imagery (mingw-w64)"
arch=('any')
url="https://trac.osgeo.org/geotiff/"
license=('custom')
depends=('mingw-w64-libtiff' 'mingw-w64-proj' 'mingw-w64-libjpeg-turbo')
makedepends=('mingw-w64-configure')
options=('!buildflags' 'staticlibs' '!strip')
source=("http://download.osgeo.org/geotiff/libgeotiff/libgeotiff-${pkgver}.tar.gz"
        "libgeotiff_buildsys.patch")
sha256sums=('05ab1347aaa471fc97347d8d4269ff0c00f30fa666d956baba37948ec87e55d6'
            'fb7e213559f779905c913389ad715e3aaf849c0e8c8ef72df86d1ca313d9393b')

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

prepare() {
  cd ${srcdir}/libgeotiff-${pkgver}
  patch -p1 -i ../libgeotiff_buildsys.patch
  
  # fix wrongly encoded files from tarball
  for f in $(find . -type f); do
    if file $f | grep -q ISO-8859 ; then
      iconv -f ISO-8859-1 -t UTF-8 $f > ${f}.tmp && \
        mv -f ${f}.tmp $f
    fi
    if file $f | grep -q CRLF ; then
      sed -i -e 's|\r$||g' $f
    fi
  done
  
  ./autogen.sh
}

build() {
  cd ${srcdir}/libgeotiff-${pkgver}
  for _arch in ${_architectures}; do
    mkdir -p build-${_arch} && pushd build-${_arch}
    ${_arch}-configure \
      --with-proj \
      --with-jpeg \
      --with-zip \
      ..

    # FIXME: out-of-source build fails
    # cp ../*.h libxtiff
    # cp ../libxtiff/*.h libxtiff
    # cp ../*.inc bin

#     ${_arch}-cmake -DCMAKE_BUILD_TYPE=Release \
#       -DGEOTIFF_CSV_DATA_DIR=$PWD/../csv \
#       -DGEOTIFF_DATA_SUBDIR=share \
#       -DGEOTIFF_BIN_SUBDIR=bin \
#       ..
    make
    popd
  done
}

package() {
  for _arch in ${_architectures}; do
    cd "${srcdir}/libgeotiff-${pkgver}/build-${_arch}"
    make DESTDIR="${pkgdir}" install
    
    mkdir -p "${pkgdir}"/usr/${_arch}/lib/pkgconfig/

cat > ${pkgdir}/usr/${_arch}/lib/pkgconfig/libgeotiff.pc <<EOF
prefix=/usr/${_arch}
exec_prefix=\${prefix}
libdir=\${prefix}/lib
includedir=\${prefix}/include
Name: libgeotiff
Description: GeoTIFF file format library
Version: ${pkgver}
Libs: -L\${libdir} -lgeotiff
Cflags: -I\${includedir}
EOF
    
    rm -rf "${pkgdir}"/usr/${_arch}/share
    find "${pkgdir}/usr/${_arch}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
    ${_arch}-strip --strip-unneeded "${pkgdir}/usr/${_arch}/bin/"*.exe
    ${_arch}-strip --strip-unneeded "${pkgdir}/usr/${_arch}/bin/"*.dll
    ${_arch}-strip -g "${pkgdir}/usr/${_arch}/lib/"*.a
  done
}