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

_pkgname=ITK
pkgname=(itk python-itk)
pkgver=5.4.1
pkgrel=5
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=(
  dcmtk
  double-conversion
  eigen
  expat
  fftw
  gcc-libs
  gdcm
  glibc
  hdf5
  intel-oneapi-mkl
  libjpeg-turbo
  libpng
  libtiff.so
  # vxl
  zlib
)
makedepends=(
  castxml
  cmake
  gcc13
  git
#  gtest
  python
  subversion
  swig
)
options=(!emptydirs)
source=("${_pkgname}-${pkgver}.tar.gz::https://github.com/InsightSoftwareConsortium/ITK/archive/refs/tags/v${pkgver}.tar.gz"
)
sha512sums=('3b5ee32e75b6c13e94e97344affb085da459bd7157cc9dbd42cf9d156fb6d406cb047238309770a4aec6c02360e6660108988279f360994cc237f754ff058c42')

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
# set ITK_USE_SYSTEM_VXL=OFF due to conflicting file: /usr/lib/libvpl.so (owned by libvpl)
  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
    -DDO_NOT_BUILD_ITK_TEST_DRIVER=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
)

  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: