lammps-20150210.ebuild 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. # Copyright 1999-2015 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. inherit eutils flag-o-matic fortran-2 multilib
  5. convert_month() {
  6. case $1 in
  7. 01) echo Jan
  8. ;;
  9. 02) echo Feb
  10. ;;
  11. 03) echo Mar
  12. ;;
  13. 04) echo Apr
  14. ;;
  15. 05) echo May
  16. ;;
  17. 06) echo Jun
  18. ;;
  19. 07) echo Jul
  20. ;;
  21. 08) echo Aug
  22. ;;
  23. 09) echo Sep
  24. ;;
  25. 10) echo Oct
  26. ;;
  27. 11) echo Nov
  28. ;;
  29. 12) echo Dec
  30. ;;
  31. *) echo unknown
  32. ;;
  33. esac
  34. }
  35. MY_P=${PN}-$((10#${PV:6:2}))$(convert_month ${PV:4:2})${PV:2:2}
  36. DESCRIPTION="Large-scale Atomic/Molecular Massively Parallel Simulator"
  37. HOMEPAGE="http://lammps.sandia.gov/"
  38. SRC_URI="http://lammps.sandia.gov/tars/${MY_P}.tar.gz"
  39. LICENSE="GPL-2"
  40. SLOT="0"
  41. KEYWORDS="amd64 x86"
  42. IUSE="doc examples gzip lammps-memalign mpi static-libs"
  43. DEPEND="
  44. mpi? (
  45. virtual/blas
  46. virtual/lapack
  47. virtual/mpi
  48. )
  49. sci-libs/voro++
  50. "
  51. RDEPEND="${DEPEND}"
  52. S="${WORKDIR}/${MY_P}"
  53. lmp_emake() {
  54. local LAMMPS_INCLUDEFLAGS
  55. LAMMPS_INCLUDEFLAGS="$(usex gzip '-DLAMMPS_GZIP' '')"
  56. LAMMPS_INCLUDEFLAGS+="$(usex lammps-memalign ' -DLAMMPS_MEMALIGN' '')"
  57. # The lammps makefile uses CC to indicate the C++ compiler.
  58. emake \
  59. ARCHIVE=$(tc-getAR) \
  60. CC=$(usex mpi "mpic++" "$(tc-getCXX)") \
  61. F90=$(usex mpi "mpif90" "$(tc-getFC)") \
  62. LINK=$(usex mpi "mpic++" "$(tc-getCXX)") \
  63. CCFLAGS="${CXXFLAGS}" \
  64. F90FLAGS="${FCFLAGS}" \
  65. LINKFLAGS="${LDFLAGS}" \
  66. LMP_INC="${LAMMPS_INCLUDEFLAGS}" \
  67. MPI_INC=$(usex mpi '' "-I../STUBS") \
  68. MPI_PATH=$(usex mpi '' '-L../STUBS') \
  69. MPI_LIB=$(usex mpi '' '-lmpi_stubs') \
  70. user-atc_SYSLIB="$(usex mpi "$($(tc-getPKG_CONFIG) --libs blas) $($(tc-getPKG_CONFIG) --libs lapack)" '')"\
  71. "$@"
  72. }
  73. src_prepare() {
  74. # Fix inconsistent use of SHFLAGS.
  75. sed -i \
  76. -e 's:voronoi_SYSINC\s\+=.*$:voronoi_SYSINC = -I/usr/include/voro++:' \
  77. -e 's:voronoi_SYSPATH\s\+=.*$:voronoi_SYSPATH =:' \
  78. lib/voronoi/Makefile.lammps || die
  79. # Fix missing .so name.
  80. sed -i \
  81. -e 's:SHLIBFLAGS\s\+=\s\+:SHLIBFLAGS = -Wl,-soname,liblammps.so.0 :' \
  82. src/MAKE/Makefile.serial || die
  83. # Fix makefile in tools.
  84. sed -i \
  85. -e 's:g++:$(CXX) $(CXXFLAGS):' \
  86. -e 's:gcc:$(CC) $(CCFLAGS):' \
  87. -e 's:ifort:$(FC) $(FCFLAGS):' \
  88. tools/Makefile || die
  89. }
  90. src_compile() {
  91. # Prepare compiler flags.
  92. append-cxxflags -fPIC -I../../src
  93. append-fflags -fPIC
  94. # Compile stubs for serial version.
  95. use mpi || lmp_emake -C src stubs
  96. # Build packages
  97. emake -C src yes-asphere
  98. emake -C src yes-body
  99. emake -C src yes-class2
  100. emake -C src yes-colloid
  101. emake -C src yes-dipole
  102. emake -C src yes-fld
  103. #emake -C src yes-gpu
  104. emake -C src yes-granular
  105. # Need OpenKIM external dependency.
  106. #emake -C src yes-kim
  107. # Need Kokkos external dependency.
  108. #emake -C src yes-kokkos
  109. emake -C src yes-kspace
  110. emake -C src yes-manybody
  111. emake -C src yes-mc
  112. lmp_emake -C src yes-meam
  113. lmp_emake -j1 -C lib/meam -f Makefile.gfortran
  114. emake -C src yes-misc
  115. emake -C src yes-molecule
  116. #emake -C src yes-mpiio
  117. emake -C src yes-opt
  118. emake -C src yes-peri
  119. emake -C src yes-poems
  120. lmp_emake -C lib/poems -f Makefile.g++
  121. emake -C src yes-reax
  122. lmp_emake -j1 -C lib/reax -f Makefile.gfortran
  123. emake -C src yes-replica
  124. emake -C src yes-rigid
  125. emake -C src yes-shock
  126. emake -C src yes-snap
  127. emake -C src yes-srd
  128. emake -C src yes-voronoi
  129. emake -C src yes-xtc
  130. emake -C src yes-user-eff
  131. emake -C src yes-user-fep
  132. use mpi && emake -C src yes-user-lb
  133. emake -C src yes-user-phonon
  134. emake -C src yes-user-sph
  135. if use mpi; then
  136. emake -C src yes-user-atc
  137. lmp_emake -C lib/atc -f Makefile.g++
  138. fi
  139. if use static-libs; then
  140. # Build static library.
  141. lmp_emake -C src makelib
  142. lmp_emake -C src -f Makefile.lib serial
  143. fi
  144. # Build shared library.
  145. lmp_emake -C src makeshlib
  146. lmp_emake -C src -f Makefile.shlib serial
  147. # Compile main executable.
  148. lmp_emake -C src serial
  149. # Compile tools.
  150. emake -C tools binary2txt chain micelle2d data2xmovie
  151. }
  152. src_install() {
  153. use static-libs && newlib.a src/liblammps_serial.a liblammps.a
  154. newlib.so src/liblammps_serial.so liblammps.so.0.0.0
  155. dosym liblammps.so.0.0.0 /usr/$(get_libdir)/liblammps.so
  156. dosym liblammps.so.0.0.0 /usr/$(get_libdir)/liblammps.so.0
  157. newbin src/lmp_serial lmp
  158. dobin tools/binary2txt
  159. # Don't forget to add header files of optional packages as they are added
  160. # to this ebuild. There may also be .mod files from Fortran based
  161. # packages.
  162. insinto "/usr/include/${PN}"
  163. doins -r src/*.h lib/meam/*.mod
  164. local LAMMPS_POTENTIALS="usr/share/${PN}/potentials"
  165. insinto "/${LAMMPS_POTENTIALS}"
  166. doins potentials/*
  167. echo "LAMMPS_POTENTIALS=${EROOT}${LAMMPS_POTENTIALS}" > 99lammps
  168. doenvd 99lammps
  169. if use examples; then
  170. local LAMMPS_EXAMPLES="/usr/share/${PN}/examples"
  171. insinto "${LAMMPS_EXAMPLES}"
  172. doins -r examples/*
  173. fi
  174. dodoc README
  175. if use doc; then
  176. dodoc doc/Manual.pdf
  177. dohtml -r doc/*
  178. fi
  179. }