PKGBUILD 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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
  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')
  19. optdepends=(
  20. 'python2: build python wrapping'
  21. 'ruby'
  22. 'tcl: build tcl wrapping (currently not supported)'
  23. 'perl: build perl wrapping (currently not supported)'
  24. 'java-runtime: build java 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=("${_pkgbase}::git+https://github.com/InsightSoftwareConsortium/ITK#tag=v${pkgver}${pkgrel}"
  32. "SimpleITKFilters::git+file://${startdir}/Modules/SimpleITKFilters"
  33. "disable_remote_git.diff")
  34. sha512sums=('SKIP'
  35. 'SKIP'
  36. '021a162cf37eee24535d52d9b5a137d6722653f8ff4a5c7feade7b6b3ee71a74e6af1191384891d3f572136a08e8381e04137291b1a745a51f80d26f19d7a033')
  37. provides=(python-itk="${pkgver}" itk="${pkgver}")
  38. conflicts=(python-itk itk)
  39. function _get_cores_func() {
  40. # Not CPU, but cores. Hopefully, the machine has enough
  41. # memory for that
  42. local _ncores
  43. _ncores=$(grep -m 1 'cpu cores' /proc/cpuinfo |
  44. cut -f2 -d":" | tr -d "[:space:]")
  45. # Try to use MAKEFLAGS, otherwise, _ncores
  46. _nproc_make="${MAKEFLAGS:-$_ncores}"
  47. _nproc_make="${_comp_nproc##*-j}"
  48. _nproc_make="${_comp_nproc%%[[:space:]]*}"
  49. _nproc_make="${_comp_nproc##*[[:space:]]}"
  50. }
  51. prepare() {
  52. cd "${srcdir}"
  53. _basedir="${srcdir}"/"${_pkgbase}"
  54. patch -d "${_basedir}" -p0 \
  55. -i "${srcdir}"/disable_remote_git.diff
  56. }
  57. build() {
  58. cd "${srcdir}"
  59. _build_dir="${srcdir}"/"${_pkgbase}"/build
  60. _confopts=(
  61. -S "${srcdir}"/"${_pkgbase}"
  62. -B "${_build_dir}"
  63. -DCMAKE_INSTALL_PREFIX:FILEPATH=/usr
  64. -DCMAKE_BUILD_TYPE:STRING=Release
  65. -DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF
  66. --log-level="NOTICE"
  67. -DCMAKE_CXX_FLAGS:STRING="-std=c++14 ${CXXFLAGS}"
  68. -DCMAKE_C_FLAGS:STRING="${CFLAGS}"
  69. -DITK_CXX_OPTIMIZATION_FLAGS:STRING="${COPTFLAGS}"
  70. -DITK_C_OPTIMIZATION_FLAGS:STRING="${COPTFLAGS}"
  71. -DCMAKE_SKIP_INSTALL_RPATH:BOOL=ON
  72. -G Ninja
  73. # -DCMAKE_BUILD_PARALLEL_LEVEL="${_nproc_make}"
  74. -DBUILD_TESTING:BOOL=OFF
  75. -DBUILD_EXAMPLES:BOOL=OFF
  76. -DITK_BUILD_DOCUMENTATION:BOOL=OFF
  77. -DITK_BUILD_DEFAULT_MODULES:BOOL=ON
  78. # Python
  79. -DITK_WRAP_PYTHON:BOOL=ON
  80. -DITK_USE_SYSTEM_SWIG:BOOL=ON
  81. -DITK_USE_SYSTEM_CASTXML:BOOL=ON
  82. -DITK_LEGACY_SILENT:BOOL=ON
  83. -DBUILD_SHARED_LIBS:BOOL=ON
  84. -DITK_USE_SYSTEM_LIBRARIES:BOOL=ON
  85. -DITK_USE_SYSTEM_JPEG:BOOL=ON
  86. -DITK_USE_SYSTEM_PNG:BOOL=ON
  87. -DITK_USE_SYSTEM_ZLIB:BOOL=ON
  88. -DITK_USE_SYSTEM_TIFF:BOOL=ON
  89. -DITK_USE_SYSTEM_GDCM:BOOL=ON
  90. -DITK_USE_SYSTEM_EXPAT:BOOL=ON
  91. -DITK_USE_SYSTEM_FFTW:BOOL=ON
  92. -DITK_USE_SYSTEM_HDF5:BOOL=ON
  93. -DITK_USE_64BITS_IDS:BOOL=ON
  94. -DITK_WRAP_IMAGE_DIMS:STRING="2;3;4"
  95. -DITK_WRAP_VECTOR_COMPONENTS:STRING="2;3;4"
  96. -DITK_WRAP_float:BOOL=ON
  97. -DITK_WRAP_vector_float:BOOL=ON
  98. # generates a compile_commands.json
  99. -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON
  100. )
  101. cmake "${_confopts[@]}" 1>/dev/null
  102. _get_cores_func
  103. # Persist after error
  104. local _f=1 _try_i=0 _max_try=20
  105. while [[ ! "${_f}" == "0" ]] && \
  106. [[ "${_i}" -lt "${_max_try}" ]]; do
  107. _f=0
  108. samu -j"${_nproc_make}" -C "${_build_dir}" ||
  109. _f=$? # catch error
  110. _try_i="$(( ${_i} + 1 ))" # counter
  111. sleep 3; # pause (to kill manually)
  112. done
  113. }
  114. package() {
  115. _build_dir="${srcdir}"/"${_pkgbase}"/build
  116. cd "${_build_dir}"
  117. _get_cores_func;
  118. DESTDIR="${pkgdir}" samu -C "${_build_dir}" \
  119. -j"${_nproc_make}" install 1>/dev/null
  120. # Based on AUR's itk-git package
  121. # (quick fix for
  122. # https://github.com/InsightSoftwareConsortium/ITK/issues/2960)
  123. install -dm755 "${pkgdir}"/usr/lib
  124. _pycmd='print("%s.%s" % (sys.version_info[:2]))'
  125. _pyver=$(python -c "import sys; ${_pycmd}")
  126. find "${pkgdir}" -type d -name "python${_pyver}" \
  127. -print0 -quit | xargs -0 mv -vt "${pkgdir}/usr/lib"
  128. python -O -m compileall "${pkgdir}/usr/lib" 1>/dev/null
  129. }