scotch-6.0.4-r1.ebuild 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. inherit eutils toolchain-funcs versionator flag-o-matic multilib
  5. # use esmumps version to allow linking with mumps
  6. MYP="${PN}_${PV}_esmumps"
  7. # download id on gforge changes every goddamn release
  8. DID=34618
  9. SOVER=$(get_major_version)
  10. DESCRIPTION="Software for graph, mesh and hypergraph partitioning"
  11. HOMEPAGE="http://www.labri.u-bordeaux.fr/perso/pelegrin/scotch/"
  12. SRC_URI="http://gforge.inria.fr/frs/download.php/${DID}/${MYP}.tar.gz"
  13. LICENSE="CeCILL-2"
  14. SLOT="0/${SOVER}"
  15. KEYWORDS="~alpha ~amd64 ~x86 ~amd64-linux ~x86-linux"
  16. IUSE="doc int64 mpi static-libs tools threads"
  17. DEPEND="
  18. sys-libs/zlib
  19. mpi? ( virtual/mpi )"
  20. RDEPEND="${DEPEND}"
  21. S=${WORKDIR}/${P/-/_}
  22. static_to_shared() {
  23. local libstatic=${1}; shift
  24. local libname=$(basename ${libstatic%.a})
  25. local soname=${libname}$(get_libname ${SOVER})
  26. local libdir=$(dirname ${libstatic})
  27. einfo "Making ${soname} from ${libstatic}"
  28. if [[ ${CHOST} == *-darwin* ]] ; then
  29. ${LINK:-$(tc-getCC)} ${LDFLAGS} \
  30. -dynamiclib -install_name "${EPREFIX}"/usr/lib/"${soname}" \
  31. -Wl,-all_load -Wl,${libstatic} \
  32. "$@" -o ${libdir}/${soname} || die "${soname} failed"
  33. else
  34. ${LINK:-$(tc-getCC)} ${LDFLAGS} \
  35. -shared -Wl,-soname=${soname} \
  36. -Wl,--whole-archive ${libstatic} -Wl,--no-whole-archive \
  37. "$@" -o ${libdir}/${soname} || die "${soname} failed"
  38. [[ $(get_version_component_count) -gt 1 ]] && \
  39. ln -s ${soname} ${libdir}/${libname}$(get_libname $(get_major_version))
  40. ln -s ${soname} ${libdir}/${libname}$(get_libname)
  41. fi
  42. }
  43. src_prepare() {
  44. epatch "${FILESDIR}"/${P}-as-needed.patch
  45. use int64 && append-cflags -DIDXSIZE64
  46. if use threads; then
  47. append-cflags "-DSCOTCH_PTHREAD_NUMBER=$(nproc)"
  48. else
  49. append-cflags "-DSCOTCH_PTHREAD_NUMBER=1"
  50. sed -i \
  51. -e 's/ -DSCOTCH_PTHREAD//' \
  52. src/Make.inc/Makefile.inc.i686_pc_linux3 || die
  53. fi
  54. sed -e "s/gcc/$(tc-getCC)/" \
  55. -e "s/-O3/${CFLAGS} -pthread/" \
  56. -e "s/ ar/ $(tc-getAR)/" \
  57. -e "s/ranlib/$(tc-getRANLIB)/" \
  58. -e "s/LDFLAGS/LIBS/" \
  59. src/Make.inc/Makefile.inc.i686_pc_linux3 > src/Makefile.inc || die
  60. }
  61. src_compile() {
  62. emake -C src CLIBFLAGS=-fPIC scotch esmumps
  63. static_to_shared lib/libscotcherr.a
  64. static_to_shared lib/libscotcherrexit.a
  65. static_to_shared lib/libscotch.a -Llib -lz -lm -lrt -lpthread -lscotcherr
  66. static_to_shared lib/libesmumps.a -Llib -lscotch
  67. static_to_shared lib/libscotchmetis.a -Llib -lscotch
  68. if use mpi; then
  69. emake -C src CLIBFLAGS=-fPIC ptscotch ptesmumps
  70. export LINK=mpicc
  71. static_to_shared lib/libptscotcherr.a
  72. static_to_shared lib/libptscotcherrexit.a
  73. static_to_shared lib/libptscotch.a -Llib -lscotch -lptscotcherr -lz -lm -lrt
  74. static_to_shared lib/libptesmumps.a -Llib -lscotch -lptscotch
  75. static_to_shared lib/libptscotchparmetis.a -Llib -lscotch -lptscotch
  76. fi
  77. if use static-libs; then
  78. emake -C src clean
  79. emake -C src
  80. use mpi && emake -C src ptscotch
  81. fi
  82. }
  83. src_test() {
  84. LD_LIBRARY_PATH="${S}/lib" emake -C src check
  85. }
  86. src_install() {
  87. dolib.so lib/lib*$(get_libname)*
  88. use static-libs && dolib.a lib/*.a
  89. #install metis headers into a subdir
  90. #to allow usage of real metis and scotch
  91. #in the same code
  92. insinto /usr/include/scotch/metis
  93. doins include/*metis*
  94. rm include/*metis*
  95. insinto /usr/include/scotch
  96. doins include/*
  97. cat <<-EOF > scotchmetis.pc
  98. prefix=${EPREFIX}/usr
  99. libdir=\${prefix}/$(get_libdir)
  100. includedir=\${prefix}/include
  101. Name: scotchmetis
  102. Description: ${DESCRIPTION}
  103. Version: ${PV}
  104. URL: ${HOMEPAGE}
  105. Libs: -L\${libdir} -lscotchmetis -lscotcherr -lscotch
  106. Private: -lm -lz -lrt
  107. Cflags: -I\${includedir}/scotch/metis
  108. EOF
  109. insinto /usr/$(get_libdir)/pkgconfig
  110. doins scotchmetis.pc
  111. # not sure it is actually a full replacement of metis
  112. #alternatives_for metis scotch 0 \
  113. # /usr/$(get_libdir)/pkgconfig/metis.pc scotchmetis.pc
  114. if use mpi; then
  115. cat <<-EOF > ptscotchparmetis.pc
  116. prefix=${EPREFIX}/usr
  117. libdir=\${prefix}/$(get_libdir)
  118. includedir=\${prefix}/include
  119. Name: ptscotchparmetis
  120. Description: ${DESCRIPTION}
  121. Version: ${PV}
  122. URL: ${HOMEPAGE}
  123. Libs: -L\${libdir} -lptscotchparmetis -lptscotcherr -lptscotch
  124. Private: -lm -lz -lrt
  125. Cflags: -I\${includedir}/scotch/metis
  126. Requires: scotchmetis
  127. EOF
  128. insinto /usr/$(get_libdir)/pkgconfig
  129. doins ptscotchparmetis.pc
  130. # not sure it is actually a full replacement of parmetis
  131. #alternatives_for metis-mpi ptscotch 0 \
  132. # /usr/$(get_libdir)/pkgconfig/metis-mpi.pc ptscotchparmetis.pc
  133. fi
  134. dodoc README.txt
  135. if use tools; then
  136. local b m
  137. pushd bin > /dev/null
  138. for b in *; do
  139. newbin ${b} scotch_${b}
  140. done
  141. popd > /dev/null
  142. pushd man/man1 > /dev/null
  143. for m in *; do
  144. newman ${m} scotch_${m}
  145. done
  146. popd > /dev/null
  147. fi
  148. use doc && dodoc doc/*.pdf
  149. }