summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 2b3405dccfd53333dd7078f790bf336003ea2a50 (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
# Maintainer: Butui Hu <hot123tea123@gmail.com>

_pkgname=ITK
pkgname=(itk python-itk)
pkgver=5.4.0
pkgrel=2
pkgdesc='An open-source, cross-platform library that provides developers with an extensive suite of software tools for image analysis'
arch=('x86_64')
url='https://www.itk.org'
license=('Apache-2.0')
depends=(
  double-conversion
  dcmtk
  eigen
  expat
  fftw
  gcc-libs
  gdcm
  glibc
  hdf5
  intel-oneapi-mkl
  libjpeg-turbo
  libpng
  libtiff.so
  zlib
)
makedepends=(
  castxml
  cmake
  gcc13
  git
  gtest
  subversion
  swig
)
options=(!emptydirs !lto)
source=("${_pkgname}-${pkgver}.tar.gz::https://github.com/InsightSoftwareConsortium/ITK/archive/refs/tags/v${pkgver}.tar.gz"
)
sha512sums=('3a98ececf258aac545f094dd3e97918c93cc82bc623ddf793c4bf0162ab06c83fbfd4d08130bdec6e617bda85dd17225488bc1394bc91b17f1232126a5d990db')

get_pyver() {
  python -c 'import sys; print(str(sys.version_info[0]) + "." + str(sys.version_info[1]))'
}

prepare() {
  # quick fix for building with swig < 4.3.0
  find ${_pkgname}-${pkgver} -type f -exec sed -i "s/SWIG_Py_DECREF/Py_DECREF/g" {} \;
  find ${_pkgname}-${pkgver} -type f -exec sed -i "s/SWIG_Py_INCREF/Py_INCREF/g" {} \;
}

build() {
# we build the default modules by default
# you could add additional modules by setting -DModule_<NAME>=ON
  cmake_opts=(
    -DBUILD_SHARED_LIBS=ON
    -DBUILD_TESTING=OFF
    -DCMAKE_BUILD_TYPE=Release
    -DCMAKE_CXX_COMPILER=g++-13
    -DCMAKE_C_COMPILER=gcc-13
    -DCMAKE_INSTALL_PREFIX=/usr
    -DCMAKE_SKIP_INSTALL_RPATH=ON
    -DCMAKE_SKIP_RPATH=ON
    -DITK_BUILD_DEFAULT_MODULES=ON
    -DITK_LEGACY_REMOVE=ON
    -DITK_USE_MKL=ON
    -DITK_USE_SYSTEM_CASTXML=ON
    -DITK_USE_SYSTEM_DCMTK=ON
    -DITK_USE_SYSTEM_DOUBLECONVERSION=ON
    -DITK_USE_SYSTEM_EIGEN=ON
    -DITK_USE_SYSTEM_EXPAT=ON
    -DITK_USE_SYSTEM_FFTW=ON
    -DITK_USE_SYSTEM_GDCM=ON
    -DITK_USE_SYSTEM_GOOGLETEST=OFF
    -DITK_USE_SYSTEM_HDF5=ON
    -DITK_USE_SYSTEM_JPEG=ON
    -DITK_USE_SYSTEM_MINC=OFF
    -DITK_USE_SYSTEM_PNG=ON
    -DITK_USE_SYSTEM_SWIG=ON
    -DITK_USE_SYSTEM_TIFF=ON
    -DITK_USE_SYSTEM_VXL=OFF
    -DITK_USE_SYSTEM_ZLIB=ON
    -DITK_WRAP_IMAGE_DIMS="2;3;4"
    -DITK_WRAP_PYTHON=ON
    -DITK_WRAP_complex_double=ON
    -DITK_WRAP_complex_float=ON
    -DITK_WRAP_covariant_vector_double=ON
    -DITK_WRAP_covariant_vector_float=ON
    -DITK_WRAP_double=ON
    -DITK_WRAP_float=ON
    -DITK_WRAP_rgb_unsigned_char=ON
    -DITK_WRAP_rgb_unsigned_short=ON
    -DITK_WRAP_rgb_unsigned_short=ON
    -DITK_WRAP_rgba_unsigned_char=ON
    -DITK_WRAP_rgba_unsigned_short=ON
    -DITK_WRAP_rgba_unsigned_short=ON
    -DITK_WRAP_signed_char=ON
    -DITK_WRAP_signed_long_long=ON
    -DITK_WRAP_signed_short=ON
    -DITK_WRAP_unsigned_char=ON
    -DITK_WRAP_unsigned_long_long=ON
    -DITK_WRAP_unsigned_short=ON
    -DITK_WRAP_vector_double=ON
    -DModule_GenericLabelInterpolator=ON \
    -DModule_ITKIODCMTK=ON \
    -DModule_ITKIOTransformMINC=ON \
    -DModule_ITKReview=ON \
    -DModule_MorphologicalContourInterpolation=ON
    -DModule_SimpleITKFilters=ON \
    -DPY_SITE_PACKAGES_PATH=/usr/lib/python$(get_pyver)/site-packages
)

  cmake -B "build" -S "${srcdir}/${_pkgname}-${pkgver}" \
    ${cmake_opts[@]} \
    -DITK_USE_GPU=OFF
  make -C "${srcdir}/build"
}

package_itk() {
  make -C "${srcdir}/build" DESTDIR="${pkgdir}" install
  rm -rf "${pkgdir}/usr/lib/python$(get_pyver)"
}

package_python-itk() {
  pkgdesc="${pkgdesc} (Python binding)"
  depends+=(
    itk
    python-numpy
    python-xarray
  )

  make -C "${srcdir}/build" DESTDIR="${srcdir}/dist" install
  install -dm755 "${pkgdir}/usr/lib"
  cp -a "${srcdir}/dist/usr/lib/python$(get_pyver)" "${pkgdir}/usr/lib"
  python -O -m compileall "${pkgdir}/usr/lib"
}
# vim:set ts=2 sw=2 et: