scotch-6.0.4-r2.ebuild 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. # Copyright 1999-2017 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 ~arm ~ppc64 ~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. epatch "${FILESDIR}"/${P}-flex-2.6.3-fix.patch
  46. use int64 && append-cflags -DIDXSIZE64
  47. if use threads; then
  48. append-cflags "-DSCOTCH_PTHREAD_NUMBER=$(nproc)"
  49. else
  50. append-cflags "-DSCOTCH_PTHREAD_NUMBER=1"
  51. sed -i \
  52. -e 's/ -DSCOTCH_PTHREAD//' \
  53. src/Make.inc/Makefile.inc.i686_pc_linux3 || die
  54. fi
  55. sed -e "s/gcc/$(tc-getCC)/" \
  56. -e "s/-O3/${CFLAGS} -pthread/" \
  57. -e "s/ ar/ $(tc-getAR)/" \
  58. -e "s/ranlib/$(tc-getRANLIB)/" \
  59. -e "s/LDFLAGS/LIBS/" \
  60. src/Make.inc/Makefile.inc.i686_pc_linux3 > src/Makefile.inc || die
  61. }
  62. src_compile() {
  63. emake -C src CLIBFLAGS=-fPIC scotch esmumps
  64. static_to_shared lib/libscotcherr.a
  65. static_to_shared lib/libscotcherrexit.a
  66. static_to_shared lib/libscotch.a -Llib -lz -lm -lrt -lpthread -lscotcherr
  67. static_to_shared lib/libesmumps.a -Llib -lscotch
  68. static_to_shared lib/libscotchmetis.a -Llib -lscotch
  69. if use mpi; then
  70. emake -C src CLIBFLAGS=-fPIC ptscotch ptesmumps
  71. export LINK=mpicc
  72. static_to_shared lib/libptscotcherr.a
  73. static_to_shared lib/libptscotcherrexit.a
  74. static_to_shared lib/libptscotch.a -Llib -lscotch -lptscotcherr -lz -lm -lrt
  75. static_to_shared lib/libptesmumps.a -Llib -lscotch -lptscotch
  76. static_to_shared lib/libptscotchparmetis.a -Llib -lscotch -lptscotch
  77. fi
  78. if use static-libs; then
  79. emake -C src clean
  80. emake -C src
  81. use mpi && emake -C src ptscotch
  82. fi
  83. }
  84. src_test() {
  85. LD_LIBRARY_PATH="${S}/lib" emake -C src check
  86. }
  87. src_install() {
  88. dolib.so lib/lib*$(get_libname)*
  89. use static-libs && dolib.a lib/*.a
  90. #install metis headers into a subdir
  91. #to allow usage of real metis and scotch
  92. #in the same code
  93. insinto /usr/include/scotch/metis
  94. doins include/*metis*
  95. rm include/*metis*
  96. insinto /usr/include/scotch
  97. doins include/*
  98. cat <<-EOF > scotchmetis.pc
  99. prefix=${EPREFIX}/usr
  100. libdir=\${prefix}/$(get_libdir)
  101. includedir=\${prefix}/include
  102. Name: scotchmetis
  103. Description: ${DESCRIPTION}
  104. Version: ${PV}
  105. URL: ${HOMEPAGE}
  106. Libs: -L\${libdir} -lscotchmetis -lscotcherr -lscotch
  107. Private: -lm -lz -lrt
  108. Cflags: -I\${includedir}/scotch/metis
  109. EOF
  110. insinto /usr/$(get_libdir)/pkgconfig
  111. doins scotchmetis.pc
  112. # not sure it is actually a full replacement of metis
  113. #alternatives_for metis scotch 0 \
  114. # /usr/$(get_libdir)/pkgconfig/metis.pc scotchmetis.pc
  115. if use mpi; then
  116. cat <<-EOF > ptscotchparmetis.pc
  117. prefix=${EPREFIX}/usr
  118. libdir=\${prefix}/$(get_libdir)
  119. includedir=\${prefix}/include
  120. Name: ptscotchparmetis
  121. Description: ${DESCRIPTION}
  122. Version: ${PV}
  123. URL: ${HOMEPAGE}
  124. Libs: -L\${libdir} -lptscotchparmetis -lptscotcherr -lptscotch
  125. Private: -lm -lz -lrt
  126. Cflags: -I\${includedir}/scotch/metis
  127. Requires: scotchmetis
  128. EOF
  129. insinto /usr/$(get_libdir)/pkgconfig
  130. doins ptscotchparmetis.pc
  131. # not sure it is actually a full replacement of parmetis
  132. #alternatives_for metis-mpi ptscotch 0 \
  133. # /usr/$(get_libdir)/pkgconfig/metis-mpi.pc ptscotchparmetis.pc
  134. fi
  135. dodoc README.txt
  136. if use tools; then
  137. local b m
  138. pushd bin > /dev/null
  139. for b in *; do
  140. newbin ${b} scotch_${b}
  141. done
  142. popd > /dev/null
  143. pushd man/man1 > /dev/null
  144. for m in *; do
  145. newman ${m} scotch_${m}
  146. done
  147. popd > /dev/null
  148. fi
  149. use doc && dodoc doc/*.pdf
  150. }