aboutsummaryrefslogtreecommitdiffstats
path: root/community/gdal/APKBUILD
blob: d9f5b81ca1a974cc78e44e968c7bc5486f581b94 (plain) (blame)
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
# Contributor: Trevor R.H. Clarke <trevor@notcows.com>
# Maintainer: Holger Jaekel <holger.jaekel@gmx.de>
pkgname=gdal
pkgver=3.4.1
pkgrel=0
pkgdesc="A translator library for raster and vector geospatial data formats"
url="https://gdal.org/"
arch="all"
license="MIT"
depends_dev="gdal"
makedepends="
	armadillo-dev
	cfitsio-dev
	charls-dev
	chrpath
	curl-dev
	expat-dev
	freexl-dev
	geos-dev
	giflib-dev
	hdf5-dev
	json-c-dev
	kealib-dev
	libdap-dev
	libdeflate-dev
	libheif-dev
	libpng-dev
	libwebp-dev
	libxml2-dev
	linux-headers
	mariadb-dev
	ogdi-dev
	openexr-dev
	openjpeg-dev
	poppler-dev
	libpq-dev
	proj-dev
	py3-numpy
	py3-numpy-dev
	py3-setuptools
	python3-dev
	qhull-dev
	libspatialite-dev
	sqlite-dev
	swig
	tiff-dev
	unixodbc-dev
	xerces-c-dev
	zlib-dev
	zstd-dev
	"
checkdepends="
	pytest
	"
subpackages="
	$pkgname-static
	$pkgname-dev
	py3-$pkgname:_py3
	$pkgname-tools
	"

source="
	https://github.com/OSGeo/gdal/releases/download/v$pkgver/gdal-$pkgver.tar.gz
	10-atoll.patch
	20-userfaultfd-detection.patch
	"

# Optional dependency netcdf-dev is not available on s390x
case "$CARCH" in
	s390x) ;;
	*) makedepends="$makedepends netcdf-dev" ;;
esac

# Optional dependency librasterlite2-dev is only available on x86 and x86_64
_with_librasterlite2="no"
case "$CARCH" in
	x86|x86_64)
		makedepends="$makedepends librasterlite2-dev"
		_with_librasterlite2="yes"
		;;
esac

# Optional dependency java-jdk is not available on riscv64
_with_java=""
case "$CARCH" in
	riscv64)
		_with_java="no"
		;;
	*)
		makedepends="$makedepends apache-ant java-jdk"
		subpackages="$subpackages java-$pkgname:_java"
		_with_java="--with-java=/usr/lib/jvm/default-jvm"
		;;
esac

build() {
	CPPFLAGS="$CPPFLAGS -I/usr/include/mysql/server -I/usr/include/tirpc" ./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--with-cfitsio=/usr \
		--with-armadillo=yes \
		--with-spatialite=yes \
		--with-rasterlite2=$_with_librasterlite2 \
		--with-cpp14 \
		--with-dods-root=/usr \
		--with-poppler \
		$_with_java \
		--with-mysql
	make

	cd "$builddir/swig/python"
	python3 setup.py build

	if [ "$_with_java" != "no" ]; then
		cd "$builddir/swig/java"
		make
	fi
}

package() {
	make DESTDIR="$pkgdir" install
	chmod -x "$pkgdir"/usr/include/*.h
}

_py3() {
	pkgdesc="$pkgdesc (Python3 bindings)"
	depends="py3-numpy"

	mkdir -p "$subpkgdir"/usr/lib/
	cd "$builddir"/swig/python
	python3 setup.py install --prefix=/usr --root="$subpkgdir"
	rm -rf "${subpkgdir:?}"/usr/bin
}

_java() {
	pkgdesc="$pkgdesc (Java bindings)"
	cd "$builddir"/swig/java
	make

	mkdir -p "$subpkgdir/usr/lib" "$subpkgdir/usr/share/java/"
	chrpath -d .libs/*.so*
	mv .libs/*.so* "$subpkgdir/usr/lib"
	cp gdal.jar "$subpkgdir/usr/share/java/gdal-$pkgver.jar"
	cd "$subpkgdir/usr/share/java/"
	ln -s gdal-$pkgver.jar gdal.jar
}

tools() {
	pkgdesc="$pkgdesc (command line utilities)"
	depends="py3-$pkgname"

	cd "$builddir"/swig/python/gdal-utils
	chmod a+x scripts/*

	install -d "$subpkgdir/usr/bin"
	install -m755 scripts/*.py "$subpkgdir/usr/bin/"

	for b in "$pkgdir"/usr/bin/*; do
		amove usr/bin/"$(basename $b)"
	done
}

check() {
	# TODO: https://trac.osgeo.org/gdal/wiki/TestingNotes

	apps/gdal-config --version | grep "$pkgver"

	# confirms MBTiles support
	apps/gdal_translate --formats | grep "MBTiles -raster,vector- (rw+v): MBTiles"

	# confirms PostgreSQL/PostGIS support
	apps/ogr2ogr --formats | grep "PostgreSQL -vector- (rw+): PostgreSQL/PostGIS"

}
sha512sums="
dcfd5f5ceac633838db2a92af6f6eb1c9fca55216885f071c7d8df8fc119aa800b2854c6e5ae84cdeea531e7e61296ad4378d798107c19d80d2ba4e1094299bf  gdal-3.4.1.tar.gz
63ab07b2de79a5ff95c7a33bd7b431fd4f3d0407cfc9d47df55eaff858064a9869b241bae7d93b4b86fc2995d65cb2bed3e3767659ed9a6d92e00771910cf72c  10-atoll.patch
15d8c25f1fdbb050ffa4082e16c7f506a50dd2827d947b663e532876c9d303982b6effb10c2eff50323aab867f5e48215736679d6a5b92f0e2266a09ad5aac53  20-userfaultfd-detection.patch
"