# Copyright 2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit toolchain-funcs eutils cmake-utils DESCRIPTION="NLM Insight Segmentation and Registration Toolkit" HOMEPAGE="http://www.itk.org" SRC_URI="mirror://sourceforge/itk/InsightToolkit-${PV}.tar.gz" LICENSE="BSD" SLOT="0" KEYWORDS="~amd64" IUSE="debug doc examples fftw shared patented test oldpython optreg python review" RDEPEND="sys-libs/zlib fftw? ( sci-libs/fftw ) media-libs/jpeg media-libs/libpng media-libs/tiff" DEPEND="${RDEPEND} >=dev-util/cmake-2.6 python? ( >=dev-util/cableswig-3.18.0 >=dev-lang/python-2.5 ) oldpython? ( >=dev-util/cableswig-3.18.0 >=dev-lang/python-2.5 ) " MY_PN=InsightToolkit S="${WORKDIR}/${MY_PN}-${PV}" pkg_setup() { # optreg is part of the review package if use optreg && ! use review; then die "USE=optreg requires USE=review to be set" fi if use python && use oldpython; then die "Must only enable one type of python bindings" fi if use oldpython; then ewarn "Warning: python bindings will be installed in a nonstandard path" fi } src_unpack() { unpack ${A} cd "${S}" epatch "${FILESDIR}/itk-3.18.0-png14.patch" epatch "${FILESDIR}/itk-numpy-3.16.0-detection.patch" } src_compile() { local CMAKE_VARIABLES="" CMAKE_VARIABLES="${CMAKE_VARIABLES} -DCMAKE_INSTALL_PREFIX:PATH=/usr" #these are currently turned off be default CMAKE_VARIABLES="${CMAKE_VARIABLES} -DWRAP_ITK_JAVA:BOOL=OFF" CMAKE_VARIABLES="${CMAKE_VARIABLES} -DWRAP_ITK_TCL:BOOL=OFF" mycmakeargs+=( $(cmake-utils_use fftw USE_FFTWD) $(cmake-utils_use fftw USE_FFTWF) $(cmake-utils_use oldpython ITK_CSWIG_PYTHON) $(cmake-utils_use python USE_WRAP_ITK WRAP_ITK_PYTHON) $(cmake-utils_use examples BUILD_EXAMPLES) $(cmake-utils_use patented ITK_USE_PATENTED) $(cmake-utils_use shared BUILD_SHARED_LIBS) $(cmake-utils_use test BUILD_TESTING) $(cmake-utils_use review ITK_USE_REVIEW) $(cmake-utils_use optreg ITK_USE_OPTIMIZED_REGISTRATION_METHODS) ) # Give us an optimised release build if use debug; then CMAKE_VARIABLES="${CMAKE_VARIABLES} -DCMAKE_BUILD_TYPE:STRING=RELWITHDEBINFO" else CMAKE_VARIABLES="${CMAKE_VARIABLES} -DCMAKE_BUILD_TYPE:STRING=RELEASE" fi # Use the system libraries for these CMAKE_VARIABLES="${CMAKE_VARIABLES} -DITK_USE_SYSTEM_JPEG:BOOL=ON" CMAKE_VARIABLES="${CMAKE_VARIABLES} -DITK_USE_SYSTEM_PNG:BOOL=ON" CMAKE_VARIABLES="${CMAKE_VARIABLES} -DITK_USE_SYSTEM_TIFF:BOOL=ON" CMAKE_VARIABLES="${CMAKE_VARIABLES} -DITK_USE_SYSTEM_ZLIB:BOOL=ON" echo -n "cmake_vars:" echo ${CMAKE_VARIABLES} # Run CMake twice to configure properly with CMake 2.2.x cmake ${CMAKE_VARIABLES} . && cmake ${CMAKE_VARIABLES} . \ || die "cmake configuration failed" #when wrapping with cableswig is enabled, paallel builds break if use python; then emake -j1 || die "emake failed" else emake || die "emake failed" fi } src_install() { cd "${S}" make DESTDIR="${D}" install || die "make install failed" # install the documentation if use doc; then mv README.html README-Overview.html dodoc "${S}"/README-Overview.html dodoc "${S}"/Documentation/DeveloperList.txt \ "${S}"/Documentation/InsightDeveloperStart.doc \ "${S}"/Documentation/InsightDeveloperStart.pdf \ "${S}"/Documentation/README.html \ "${S}"/Documentation/Style.pdf \ "${S}"/Documentation/itk.ico docinto Doxygen dodoc "${S}"/Documentation/Doxygen/*.dox \ "${S}"/Documentation/Doxygen/*.html \ "${S}"/Documentation/Doxygen/*.css docinto Art dodoc "${S}"/Documentation/Art/*gif \ "${S}"/Documentation/Art/*jpg \ "${S}"/Documentation/Art/*psd \ "${S}"/Documentation/Art/*xpm fi # install the examples if use examples; then # Copy Example sources rm -rf $(find "${S}/Examples" -type d -a -name "CMakeFiles") \; || \ die "Failed remove build files" # remove CVS directories from examples folder rm -rf $(find "${D}"/usr/share/"${MY_PN}"/examples -type d -name CVS ) ||\ die "Failed to remove CVS folders" dodir /usr/share/${MY_PN}/examples || \ die "Failed to create examples directory" cp -pPR "${S}/Examples" "${D}/usr/share/${MY_PN}/examples/src" || \ die "Failed to copy example files" # copy binary examples cp -pPR "${S}/bin" "${D}/usr/share/${MY_PN}/examples" || \ die "Failed to copy binary example files" rm -rf "${D}"/usr/share/"${MY_PN}"/examples/bin/*.so || \ die "Failed to remove libraries from examples directory" # fix examples permissions find "${D}/usr/share/${MY_PN}/examples/src" -type d -exec \ chmod 0755 {} \; || \ die "Failed to fix example directories permissions" find "${D}/usr/share/${MY_PN}/examples/src" -type f -exec \ chmod 0644 {} \; || \ die "Failed to fix example files permissions" fi LDPATH="/usr/lib/InsightToolkit" echo "LDPATH=${LDPATH}" > $T/40${PN} echo "ITK_DATA_ROOT=/usr/share/${PN}/data" >> ${T}/40${PN} doenvd "${T}/40${PN}" } pkg_postinst() { if use patented; then ewarn "Using patented code in ITK may require a license." ewarn "For more information, please read:" ewarn "http://www.itk.org/HTML/Copyright.htm" ewarn "http://www.itk.org/Wiki/ITK_Patent_Bazaar" fi }