PKGBUILD 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. # Maintainer: Chris <christopher.r.mullins g-mail>
  2. # Contributor: geosam <samuelmesa@linuxmail.org>
  3. # Contributor: Andrzej Giniewicz <gginiu@gmail.com>
  4. # Contributor: Thomas Dziedzic < gostrc at gmail >
  5. # Contributor: joel schaerer <joel.schaerer@laposte.net>
  6. _pkgbase=insight-toolkit
  7. pkgname="${_pkgbase}"
  8. pkgver=5.3
  9. pkgrel=rc03.tubetk_fem_c++14
  10. _pkgdesc="Cross-platform system that provides developers"
  11. _pkgdesc="${_pkgdesc} with an extensive suite of software"
  12. _pkgdesc="${_pkgdesc} tools for image analysis"
  13. pkgdesc="${_pkgdesc}"
  14. arch=('i686' 'x86_64')
  15. url='http://www.itk.org/'
  16. license=('APACHE')
  17. depends=('fftw' 'libjpeg-turbo' 'libpng' 'zlib' 'libtiff'
  18. 'gdcm' 'expat' 'hdf5' 'gtest' 'eigen' 'jre-openjdk'
  19. 'jre-openjdk-headless')
  20. optdepends=(
  21. 'python2: build python wrapping'
  22. 'ruby'
  23. 'tcl: build tcl wrapping (currently not supported)'
  24. 'perl: build perl wrapping (currently not supported)'
  25. 'swig: generate python wrappers'
  26. 'pcre: for wrapping'
  27. 'castxml-git: for wrapping and docs'
  28. 'clang: for swig'
  29. 'castxml-git: for ITK')
  30. makedepends=('cmake' 'git' 'castxml' "samurai")
  31. source=("insight-toolkit::git+https://github.com/InsightSoftwareConsortium/ITK#tag=v${pkgver}rc03"
  32. "disable_remote_git.diff"
  33. "libdl_fix.diff"
  34. "SimpleITKFilters::git+https://github.com/InsightSoftwareConsortium/ITKSimpleITKFilters.git"
  35. "IsotropicWavelets::git+https://github.com/InsightSoftwareConsortium/ITKIsotropicWavelets.git"
  36. "LabelErodeDilate::git+https://github.com/InsightSoftwareConsortium/ITKLabelErodeDilate.git"
  37. "Montage::git+https://github.com/InsightSoftwareConsortium/ITKMontage.git"
  38. "MorphologicalContourInterpolation::git+https://github.com/KitwareMedical/ITKMorphologicalContourInterpolation.git"
  39. "MultipleImageIterator::git+https://github.com/KitwareMedical/MultipleImageIterator.git"
  40. "PhaseSymmetry::git+https://github.com/KitwareMedical/ITKPhaseSymmetry.git"
  41. "Strain::git+https://github.com/KitwareMedical/ITKStrain.git"
  42. "TubeTK::git+https://github.com/InsightSoftwareConsortium/ITKTubeTK.git#tag=v1.0.0"
  43. "TwoProjectionRegistration::git+https://github.com/InsightSoftwareConsortium/ITKTwoProjectionRegistration.git"
  44. "MinimalPathExtraction::git+https://github.com/InsightSoftwareConsortium/ITKMinimalPathExtraction.git"
  45. )
  46. sha512sums=('SKIP'
  47. 'c5338b5919e818e3719c1273e865ecd2a1673f71df29a0cc13b02dbdc3b7dc293eb61935f45ea4a51e12ab01584f79cbd55ae426d214c21e4ad80e6ba4aefa4d'
  48. '972ba667ac65849f18f93d6e29003d2f02218dedc4d37cbaefe63fd587ee0fcf9aa1b0e2195b338b7a4c3943620263100b86202d255019beacdf99be50cfc511'
  49. 'SKIP'
  50. 'SKIP'
  51. 'SKIP'
  52. 'SKIP'
  53. 'SKIP'
  54. 'SKIP'
  55. 'SKIP'
  56. 'SKIP'
  57. 'SKIP'
  58. 'SKIP'
  59. 'SKIP')
  60. provides=(python-itk="${pkgver}" itk="${pkgver}")
  61. conflicts=(python-itk itk)
  62. backup=(etc/ld.so.conf.d/insight-toolkit.conf)
  63. function _get_cores_func() {
  64. # Not CPU, but cores. Hopefully, the machine has enough
  65. # memory for that
  66. local _ncores
  67. _ncores=$(grep -m 1 'cpu cores' /proc/cpuinfo |
  68. cut -f2 -d":" | tr -d "[:space:]")
  69. # Try to use MAKEFLAGS, otherwise, _ncores
  70. _nproc_make="${MAKEFLAGS:-$_ncores}"
  71. _nproc_make="${_nproc_make##*-j}"
  72. _nproc_make="${_nproc_make%%[[:space:]]*}"
  73. _nproc_make="${_nproc_make##*[[:space:]]}"
  74. }
  75. prepare() {
  76. cd "${srcdir}"
  77. _basedir="${srcdir}"/"${_pkgbase}"
  78. patch -d "${_basedir}" -p0 \
  79. -i "${srcdir}"/disable_remote_git.diff
  80. patch -d "${srcdir}" -p0 -i "${srcdir}"/libdl_fix.diff
  81. }
  82. build() {
  83. cd "${srcdir}"
  84. _build_dir="${srcdir}"/"${_pkgbase}"/build
  85. _confopts=(
  86. -S "${srcdir}"/"${_pkgbase}"
  87. -B "${_build_dir}"
  88. -DCMAKE_INSTALL_PREFIX:FILEPATH=/usr
  89. -DCMAKE_BUILD_TYPE:STRING=Release
  90. -DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF
  91. --log-level="NOTICE"
  92. -DCMAKE_CXX_FLAGS:STRING="-std=c++14 ${CXXFLAGS}"
  93. -DCMAKE_C_FLAGS:STRING="${CFLAGS}"
  94. -DITK_CXX_OPTIMIZATION_FLAGS:STRING="${COPTFLAGS}"
  95. -DITK_C_OPTIMIZATION_FLAGS:STRING="${COPTFLAGS}"
  96. -DCMAKE_SKIP_INSTALL_RPATH:BOOL=ON
  97. -G Ninja
  98. # -G "Unix Makefiles"
  99. # -DCMAKE_BUILD_PARALLEL_LEVEL="${_nproc_make}"
  100. -DBUILD_TESTING:BOOL=OFF
  101. -DBUILD_EXAMPLES:BOOL=OFF
  102. -DITK_BUILD_DOCUMENTATION:BOOL=OFF
  103. -DITK_BUILD_DEFAULT_MODULES:BOOL=ON
  104. # Python
  105. -DITK_WRAP_PYTHON:BOOL=ON
  106. -DITK_USE_SYSTEM_SWIG:BOOL=ON
  107. -DITK_USE_SYSTEM_CASTXML:BOOL=ON
  108. -DITK_LEGACY_SILENT:BOOL=ON
  109. -DBUILD_SHARED_LIBS:BOOL=ON
  110. -DITK_USE_SYSTEM_LIBRARIES:BOOL=ON
  111. -DITK_USE_SYSTEM_JPEG:BOOL=ON
  112. -DITK_USE_SYSTEM_PNG:BOOL=ON
  113. -DITK_USE_SYSTEM_ZLIB:BOOL=ON
  114. -DITK_USE_SYSTEM_TIFF:BOOL=ON
  115. -DITK_USE_SYSTEM_GDCM:BOOL=ON
  116. -DITK_USE_SYSTEM_EXPAT:BOOL=ON
  117. -DITK_USE_SYSTEM_FFTW:BOOL=ON
  118. -DITK_USE_SYSTEM_HDF5:BOOL=ON
  119. -DITK_USE_64BITS_IDS:BOOL=ON
  120. -DITK_WRAP_IMAGE_DIMS:STRING="2;3;4"
  121. -DITK_WRAP_VECTOR_COMPONENTS:STRING="2;3;4"
  122. -DITK_WRAP_float:BOOL=ON
  123. -DITK_WRAP_vector_float:BOOL=ON
  124. # generates a compile_commands.json
  125. -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON
  126. # Reconstruction of 3D from 2D slices
  127. -DModule_Montage:BOOL=ON
  128. # Interpolate contours
  129. -DModule_MorphologicalContourInterpolation:BOOL=ON
  130. # Facilitate working on multiple images
  131. -DModule_MultipleImageIterator:BOOL=ON
  132. # Separate material phases?
  133. -DModule_PhaseSymmetry:BOOL=ON
  134. -DModule_IsotropicWavelets:BOOL=OFF # Not working
  135. # Improving segmentation of circles
  136. -DModule_LabelErodeDilate:BOOL=ON
  137. # Compute strain from displacement or transformation
  138. -DModule_Strain:BOOL=ON
  139. # From 2D slices to 3D registration
  140. -DModule_TwoProjectionRegistration:BOOL=ON
  141. # segmentation, registration, and analysis of tubes
  142. -DModule_TubeTK:BOOL=ON
  143. # TubeTK requires MinimalPathExtraction module enabled
  144. -DModule_MinimalPathExtraction:BOOL=ON
  145. # Finite Element
  146. -DModule_ITKFEM:BOOL=ON
  147. -DModule_ITKFEMRegistration:BOOL=ON
  148. # -DModule_FixedPointInverseDisplacementField:BOOL=ON
  149. # -DModule_IOOpenSlide:BOOL=OFF #
  150. # -DModule_IOTransformDCMTK:BOOL=OFF
  151. # -DITKVideoBridgeOpenCV
  152. # -DITKVideoBridgeVXL
  153. )
  154. printf "INFO: Running CMake...\n"
  155. cmake "${_confopts[@]}"
  156. printf "INFO: ... CMake done\n"
  157. printf "INFO: Cleaning TubeTK...\n"
  158. # Fixing TubeTK
  159. # The next commands should go in prepare(), but `cmake'
  160. # should be in build(), and the files only exist after
  161. # `cmake'.
  162. # find "${srcdir}" -type f -regex '.*\.\(supp\|cxx\|txt\|ninja\|make\|so\.1\)' -exec grep --color -nH --null -e 'libdl[^[:space:];]*\.\(so\|a\)[[:digit:].]*' \{\} +
  163. sed -i "s%libdl[^[:space:];]*\.so[[:digit:].]*%libdl.so.2%g" "${_build_dir}"/build.ninja
  164. # Get rid of triaged MinimalPathExtraction.h
  165. rm -fr "${srcdir}/${pkgname}"/Modules/Remote/TubeTK/include/MinimalPathExtractionExport.h
  166. printf "INFO: ... cleaning TubeTK, done\n"
  167. _get_cores_func
  168. # Persist after error
  169. local _f=1 _try_i=0 _max_try=20
  170. while [[ "${_i}" -lt "${_max_try}" ]] && [[ ! "${_f}" == "0" ]]; do
  171. _f=0
  172. # make -s -j4 -C "${_build_dir}" -f "${_build_dir}"/Makefile ||
  173. samu -j4 -C "${_build_dir}" -f "${_build_dir}"/build.ninja ||
  174. _f=$? # catch error
  175. _try_i="$(( ${_i} + 1 ))" # counter
  176. sleep 3; # pause (to kill manually)
  177. done
  178. }
  179. package() {
  180. _build_dir="${srcdir}"/"${_pkgbase}"/build
  181. cd "${_build_dir}"
  182. _get_cores_func;
  183. # DESTDIR="${pkgdir}" make -C "${_build_dir}" \
  184. DESTDIR="${pkgdir}" samu -C "${_build_dir}" -f "${_build_dir}"/build.ninja \
  185. -j4 install 1>/dev/null
  186. # Based on AUR's itk-git package
  187. # (quick fix for
  188. # https://github.com/InsightSoftwareConsortium/ITK/issues/2960)
  189. install -dm755 "${pkgdir}"/usr/lib
  190. _pycmd='print("%s.%s" % (sys.version_info[:2]))'
  191. _pyver=$(python -c "import sys; ${_pycmd}")
  192. find "${pkgdir}" -type d -name "python${_pyver}" \
  193. -print0 -quit | xargs -0 mv -vt "${pkgdir}/usr/lib"
  194. python -O -m compileall "${pkgdir}/usr/lib" 1>/dev/null
  195. # Find required java libraries and add it to /etc/profile.d/
  196. # Skipping RPATH allows that the packager system's may
  197. # be different from the installer's system, but it also
  198. # implies having the path to some libraries in the
  199. # right place. For some reason libjawt.so,
  200. # libawt_xawt.so and libjvm.so are not immediately
  201. # found, so we create entries in /etc/profile.d/ with
  202. # insight-toolkit.sh.
  203. mkdir "${pkgdir}"/etc/profile.d/
  204. echo 'export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/jvm/default/lib:/usr/lib/jvm/default/lib/server"' > "${pkgdir}"/etc/profile.d/insight-toolkit.sh
  205. }