aboutsummaryrefslogtreecommitdiffstats
path: root/community/hdf5/APKBUILD
blob: 77c2f71ad29e91a8bf4c8bea382b45236ee98ad2 (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
# Contributor: Isaac Dunham <ibid.ag@gmail.com>
# Maintainer: Holger Jaekel <holger.jaekel@gmx.de>
#
# HDF5 depends on zlib and provides a C interface by default.
# Optionally, it can be built with szip (which has limitations on
# commercial use and thus is non-free), MPI, and C++ and Fortran bindings.
# C++ and Fortran bindings may not be thread-safe:
# building either and passing --enable-threadsafe is unsupported.
# Additionally, the 'high-level' bindings are incompatible with threadsafe
# builds, due to inadequate locking.

pkgname=hdf5
pkgver=1.12.1
pkgrel=2
pkgdesc="HDF5 is a data model, library, and file format for storing and managing data"
url="https://www.hdfgroup.org/solutions/hdf5/"
arch="all"
license="custom"
options="!check" # test suite takes a very long time
depends_dev="zlib-dev"
makedepends="cmake $depends_dev gfortran libaec-dev perl"
subpackages="$pkgname-fortran $pkgname-static $pkgname-doc $pkgname-dev"
source="https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-${pkgver%.*}/hdf5-$pkgver/src/hdf5-$pkgver.tar.bz2"

# Optional dependency java-jdk is not available on riscv64
_with_java=""
_enable_java=""
case "$CARCH" in
	riscv64) ;;
	*)
		makedepends="$makedepends java-jdk"
		subpackages="$subpackages java-$pkgname:java"
		_with_java="-DHDF5_BUILD_JAVA=ON -DJAVA_HOME=/usr/lib/jvm/default-jvm"
		_enable_java="--enable-java"
		;;
esac

# secfixes:
#   1.12.1-r0:
#     - CVE-2018-11206
#     - CVE-2018-13869
#     - CVE-2018-13870
#     - CVE-2018-14033
#     - CVE-2018-14460
#     - CVE-2018-17435
#     - CVE-2019-9151
#     - CVE-2020-10811

prepare() {
	default_prepare

	update_config_sub
	update_config_guess
}

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	export PATH=/usr/lib/jvm/default-jvm/bin:$PATH

	# Crazy workaround: run CMake to generate pkg-config file
	# 2nd workaround: cmake creates the file pac_Cconftest.out in the current
	# directory, but checks if it is successfully created in the build dir.
	# So the current directory must be build.
	mkdir build && cd build
	cmake \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
		-DCMAKE_C_FLAGS="$CFLAGS" \
		-DHDF5_BUILD_HL_LIB=ON \
		-DHDF5_BUILD_CPP_LIB=ON \
		-DHDF5_BUILD_FORTRAN=ON \
		$_with_java \
		-DHDF5_ENABLE_Z_LIB_SUPPORT=ON \
		-DHDF5_ENABLE_SZIP_SUPPORT=OFF \
		-DHDF5_ENABLE_SZIP_ENCODING=OFF \
		-DDEFAULT_API_VERSION=v18 \
		${CMAKE_CROSSOPTS} ..
	cd $builddir

	# But don’t build with it, it’s quite broken
	./configure \
		--prefix=/usr \
		--docdir=/usr/share/doc/hdf5/ \
		--with-examplesdir='${prefix}/share/doc/hdf5/examples' \
		--enable-static \
		--disable-sharedlib-rpath \
		--enable-build-mode=production \
		--enable-hl \
		--enable-cxx \
		--enable-fortran \
		$_enable_java \
		--with-pic \
		--with-zlib \
		--without-szlib \
		--with-default-api-version=v18
	make
}

check() {
	# Without this, checks are failing with messages like
	# "error while loading shared libraries: libhdf5.so.101: cannot open shared object file: No such file or directory"
	export LD_LIBRARY_PATH="$srcdir"/$pkgname-${pkgver/_/-}/src/.libs/
	export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$srcdir"/$pkgname-${pkgver/_/-}/c++/src/.libs/
	export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$srcdir"/$pkgname-${pkgver/_/-}/fortran/src/.libs/
	export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$srcdir"/$pkgname-${pkgver/_/-}/hl/src/.libs/
	export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$srcdir"/$pkgname-${pkgver/_/-}/hl/c++/src/.libs/
	export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$srcdir"/$pkgname-${pkgver/_/-}/hl/fortran/src/.libs/
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm0644 COPYING "$pkgdir"/usr/share/licenses/"$pkgname"/COPYING

	# Install pkg-config files from CMake tree
	install -Dm644 build/CMakeFiles/hdf5*.pc -t "${pkgdir}"/usr/lib/pkgconfig/
}

fortran() {
	pkgdesc="Fortran bindings for HDF5 library"
	amove usr/lib/libhdf5*fortran.so.*
}

java() {
	pkgdesc="Java bindings for HDF5 library"
	mkdir -p "$subpkgdir"/usr/share/java/
	mkdir -p "$subpkgdir"/usr/lib/jni/
	mv "$pkgdir"/usr/lib/jarhdf5-$pkgver.jar "$subpkgdir"/usr/share/java/
	ln -s jarhdf5-$pkgver.jar "$subpkgdir"/usr/share/java/jarhdf5.jar
	mv "$pkgdir"/usr/lib/libhdf5_java.so "$subpkgdir"/usr/lib/jni/
}

sha512sums="
158a067ee284ccb9e2c4db12e9d37cf187d90d9ef1bed7a6303e2c3a2fd216d7b13a46c5f46018b097511281c4246156b6f917633ca88872f10f0ad04be285fd  hdf5-1.12.1.tar.bz2
"