Advertisement
Guest User

openmodelica-1.13.2.ebuild

a guest
Oct 23rd, 2019
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 11.51 KB | None | 0 0
  1. # Copyright 1999-2018 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3.  
  4. EAPI=6
  5.  
  6. inherit autotools check-reqs desktop flag-o-matic toolchain-funcs git-r3 llvm xdg-utils
  7. # https://devmanual.gentoo.org/eclass-reference/ebuild/index.html
  8. # https://devmanual.gentoo.org/eclass-reference/autotools.eclass/index.html
  9. # https://devmanual.gentoo.org/eclass-reference/cmake-utils.eclass/index.html
  10. # https://devmanual.gentoo.org/eclass-reference/desktop.eclass/index.html
  11. # https://devmanual.gentoo.org/eclass-reference/git-r3.eclass/index.html
  12. # https://devmanual.gentoo.org/eclass-reference/llvm.eclass/index.html
  13. # https://devmanual.gentoo.org/eclass-reference/toolchain-funcs.eclass/index.html
  14. # https://devmanual.gentoo.org/eclass-reference/flag-o-matic.eclass/index.html
  15.  
  16. DESCRIPTION="A multi-physics modeling and simulation environment"
  17. HOMEPAGE="https://www.openmodelica.org/"
  18. OMLIBFILENAME="openmodelicalibraries_20181220-190606"
  19. SRC_URI="https://build.openmodelica.org/libraries/${OMLIBFILENAME}.tar.xz"
  20. EGIT_REPO_URI="https://github.com/OpenModelica/OpenModelica"
  21. #EGIT_REPO_URI="/home/vince/src/openmodelica/OpenModelica-repo"
  22. EGIT_TAG="v1.13.2"
  23.  
  24. IUSE="clang doc cppruntime hdf5 hwloc om_all om_optim om_shellterminal sundials test"
  25.  
  26. # from OpenModelica/Readme.md :
  27. # clang -> compile with clang/clang++  . HIGHLY RECCOMMENDED
  28. # cppruntime -> use dev-libs/boost
  29. # hdf5 -> use HDF5 data library. Doesn't do much...
  30. # hwloc -> queries the number of hardware CPU cores instead of logical CPU cores
  31. # om_all -> build all libraries instead of only core ones (configure --with-omlibrary=core,all,no )
  32. # om_optim -> build OMOptim tool. pull in Java JDK instead of JRE. configure for  CORBA_TARGETS="OMOptim-omoptim"
  33. # om_shellterminal -> build the shell for use inside a terminal
  34. # sundials -> adds more numerical solvers to the simulation runtime
  35. # dev-lang/perl[ithreads] -> used for test
  36.  
  37. # from OpenModelica/configure :
  38. #Optional Packages:
  39. #  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  40. #  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  41. #  --with-ombuilddir=build       (where build files are generated; OPENMODELICAHOME)
  42. #  --with-openmodelicahome=OPENMODELICAHOME|PREFIX    (Find OPENMODELICAHOME - the directory where all OpenModelica dependencies are installed.)
  43. #  --with-cppruntime       (build the optional cppruntime simulation libraries)
  44. #  --with-omlibrary=core,all,no       (which libraries to build; default is core; the libraries used by the testsuite)
  45. #  --with-MICO=DIR                  use mico corba installed in DIR (or use mico-config)
  46. #  --with-omniORB=DIR               use omniORB installed in DIR (recommended CORBA implementation)
  47.  
  48. #./configure --with-omniORB=/path/to/omniORB (if you want omc to use omniORB corba)
  49. #./configure --with-CORBA=/path/to/mico (if you want omc to use mico corba)
  50. #./configure --without-CORBA            (if you want omc to use sockets)
  51.  
  52.  
  53. LICENSE="GPL-3"
  54. SLOT="0"
  55. KEYWORDS="~amd64"
  56.  
  57. RDEPEND="test? ( dev-lang/perl[ithreads] )"
  58. DEPEND="${RDEPEND}
  59.    sys-libs/glibc
  60.    dev-vcs/git
  61.    dev-libs/expat
  62.    dev-util/cmake
  63.    dev-games/openscenegraph
  64.    dev-qt/qtcore
  65.    dev-qt/qtgui
  66.    dev-qt/qtwebkit
  67.    dev-qt/qtopengl
  68.    sci-libs/lapack-reference
  69.    sci-libs/blas-reference
  70.    sci-mathematics/lpsolve
  71.    clang? ( sys-devel/clang )
  72.    cppruntime? ( dev-libs/boost )
  73.    hdf5? ( sci-libs/hdf5 )
  74.    hwloc? ( sys-apps/hwloc )
  75.    om_optim? ( dev-java/oracle-jdk-bin net-misc/omniORB )
  76.    !om_optim? ( dev-java/oracle-jre-bin )
  77.    om_shellterminal? ( sys-libs/ncurses sys-libs/readline )"
  78.     # sundials? ( sci-libs/sundials )
  79.     # please note that unfortunately, OpenModelica builds against older versions of sundials, shipped
  80.     # with its sources. See https://trac.openmodelica.org/OpenModelica/ticket/3933
  81.    
  82. pkg_pretend()
  83. {
  84. # Final size of build directory: 5813108 KiB (5.5 GiB)
  85. # Final size of installed tree:  1998612 KiB (1.9 GiB)
  86.     CHECKREQS_DISK_BUILD="6G"
  87.     check-reqs_pkg_setup
  88. }
  89.    
  90. src_unpack() {
  91.         EGIT_CHECKOUT_DIR=${WORKDIR}/${P}
  92.         einfo "Cloning from github..."
  93.         #git-r3_fetch
  94.         git clone "${EGIT_REPO_URI}" "${EGIT_CHECKOUT_DIR}"
  95.         einfo "Checking out from github..."
  96.         #git-r3_checkout
  97.         cd "${EGIT_CHECKOUT_DIR}"
  98.         git checkout "${EGIT_TAG}"
  99.         einfo "Fixing repo URIs..."
  100.         sed -i 's,../,https://github.com/OpenModelica/,g' .gitmodules
  101.        
  102.         # avoid unnecessary sources:
  103.         if ! use doc ; then
  104.              [[ `git config --get submodule.doc.active` = "true" ]] && git config --replace submodule.doc.active false
  105.         fi    
  106.         if ! use test ; then
  107.              [[ `git config --get submodule.testsuite.active` = "true" ]] && git config --replace submodule.testsuite.active false
  108.         fi    
  109.         if ! use om_optim ; then
  110.             [[ `git config --get submodule.OMOptim.active` = "true" ]] && git config --replace submodule.OMOptim.active false
  111.         fi
  112.        
  113.         # cloning repos of libraries often raises fatal errors "Could not resolve github.com"
  114.         # this probably occurs due to proxy settings. In order to avoid the problem,
  115.         # we just skip the clone and download the souces via tarball...
  116.         [[ `git config --get submodule.libraries.active` = "true" ]] && git config --replace submodule.libraries.active false
  117.        
  118.         # sync submodules:
  119.         git submodule sync --recursive
  120.         git submodule update --init --recursive
  121.         einfo "Checkout completed."
  122.         GITVER=`git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'`
  123.         elog "Working with ${PN}-${GITVER}..."
  124.  
  125.         unpack ${A}
  126. }
  127.  
  128. src_prepare() {
  129.     # https://trac.openmodelica.org/OpenModelica/ticket/5409
  130.     eapply --binary "${FILESDIR}/paradiseo-cmake.patch"
  131.     # https://openmodelica.org/forum/default-topic/2574-openmodelica-incompatible-with-sundials-3
  132.     # https://trac.openmodelica.org/OpenModelica/ticket/3933
  133.     eapply --binary "${FILESDIR}/sundials-cmake.patch"
  134.     eapply_user
  135. }
  136.  
  137. src_configure() {
  138.     local myconf
  139.  
  140.     if use clang && ! tc-is-clang ; then
  141.         # Force clang
  142.         einfo "Enforcing the use of clang due to USE=clang ..."
  143.         CC=${CHOST}-clang
  144.         CXX=${CHOST}-clang++
  145.         strip-unsupported-flags
  146.     elif ! use clang && ! tc-is-gcc ; then
  147.         # Force gcc
  148.         einfo "Enforcing the use of gcc due to USE=-clang ..."
  149.         CC=${CHOST}-gcc
  150.         CXX=${CHOST}-g++
  151.         strip-unsupported-flags
  152.     fi
  153.  
  154.     # pass a variable to OMCompiler configure script. configure expects omc binary in PATH,
  155.     # but tipically omc is not installed yet.
  156.     myconf="--with-omc=${WORKDIR}/${PF}/build/bin"
  157.    
  158.     # pass a variable to OMPlot configure script:
  159.     myconf="${myconf} --with-ombuilddir=${WORKDIR}/${PF}/build"
  160.    
  161.     # The following code can be uncommented when fetching libraries via GIT:
  162.     # configure to build all libraries or core only:
  163.     #if use om_all ; then
  164.     #    myconf="${myconf} --with-omlibrary=all"
  165.     #else
  166.     #    myconf="${myconf} --with-omlibrary=core"
  167.     #fi
  168.     myconf="${myconf} --without-omlibrary" # libraries will be installed from tarball
  169.    
  170.     if use cppruntime ; then
  171.         myconf="${myconf} --with-cppruntime --with-cppruntime-args=BUILDTYPE=Release,PARALLEL_OUTPUT,RUNTIME_PROFILING,FMU_SUNDIALS"
  172.     fi
  173.    
  174.     llvm_pkg_setup
  175.     eautoconf
  176.  
  177.     if [[ -x ${ECONF_SOURCE:-.}/configure ]] ; then
  178.         econf \
  179.                 $(use_with om_optim omniORB) \
  180.                 ${myconf}
  181.     fi
  182. }
  183.  
  184. src_compile() {
  185.     einfo "Copying libraries..."
  186.     mkdir -p ${WORKDIR}/${PF}/build/lib/omlibrary
  187.     cp -ar  ${OMLIBFILENAME}/libraries/* ${WORKDIR}/${PF}/build/lib/omlibrary/
  188.     einfo "Compile phase started."
  189.     if [ -f Makefile ] || [ -f makefile ]; then
  190.         #emake
  191.         # using -j1 (sorry!) because OMCompiler makefile cannot handle parallel compilation, and will fail:
  192.             # /tmp/portage/sci-physics/openmodelica-1.13.2/work/openmodelica-1.13.2/build/bin/omc: error while loading shared libraries: libzmq.so.5.1.3: cannot open shared object file: No such file or directory
  193.             # make[6]: *** [Makefile:78: OpenModelicaBootstrappingHeader.h] Error 1
  194.             # make[5]: *** [Makefile.common:90: runtime-depends] Error 2
  195.             # make[4]: *** [Makefile.common:72: bootstrap-from-tarball] Error 2
  196.             # make[4]: Leaving directory '/tmp/portage/sci-physics/openmodelica-1.13.2/work/openmodelica-1.13.2/OMCompiler/Compiler/boot'
  197.             # make[3]: *** [Makefile.common:14: all] Error 2
  198.             # make[3]: Leaving directory '/tmp/portage/sci-physics/openmodelica-1.13.2/work/openmodelica-1.13.2/OMCompiler/Compiler/boot'
  199.             # make[2]: *** [Makefile:97: omc-bootstrapped] Error 2
  200.             # make[2]: Leaving directory '/tmp/portage/sci-physics/openmodelica-1.13.2/work/openmodelica-1.13.2/OMCompiler'
  201.             # make[1]: *** [Makefile.common:216: all-runtimeCPPinstall] Error 2
  202.             # make[1]: Leaving directory '/tmp/portage/sci-physics/openmodelica-1.13.2/work/openmodelica-1.13.2/OMCompiler'
  203.             # make: *** [Makefile:9: omc] Error 2
  204.         emake -j1
  205.     fi
  206. }
  207.  
  208. src_test() {
  209.         if use test ; then
  210.             cd testsuite/partest && ./runtests.pl
  211.         fi
  212. }
  213.  
  214. src_install() {
  215.     if [[ -f Makefile ]] || [[ -f GNUmakefile ]] || [[ -f makefile ]] ; then
  216.         emake DESTDIR="${D}" install
  217.     fi
  218.     einstalldocs
  219.    
  220.     doicon "OMEdit/OMEdit/OMEditGUI/Resources/icons/omedit.ico" "OMNotebook/OMNotebook/OMNotebookGUI/Resources/OMNotebook_icon.ico" "OMOptim/OMOptim/GUI/Resources/omoptim.ico" "OMShell/OMShell/OMShellGUI/Resources/omshell.ico" "OMPlot/OMPlot/OMPlotGUI/Resources/icons/omplot.ico"
  221.     doicon -s scalable "OMEdit/OMEdit/OMEditGUI/Resources/icons/omedit.png" "OMNotebook/OMNotebook/OMNotebookGUI/Resources/OMNotebook_icon.svg" "OMShell/OMShell/OMShellGUI/Resources/omshell-large.svg" "OMPlot/OMPlot/OMPlotGUI/Resources/icons/omplot.png"
  222.     #make_desktop_entry OMEdit "OpenModelica Connection Editor" "/usr/share/icons/scalable/apps/omedit.png" "Science"
  223.     #make_desktop_entry OMNotebook "OpenModelica Notebook" "/usr/share/icons/scalable/apps/OMNotebook_icon.svg" "Science"
  224.     #make_desktop_entry OMShell "OpenModelica Shell" "/usr/share/icons/scalable/apps/omshell-large.svg" "Science"
  225.     make_desktop_entry OMEdit "OpenModelica Connection Editor" "omedit" "Science"
  226.     make_desktop_entry OMNotebook "OpenModelica Notebook" "OMNotebook_icon" "Science"
  227.     make_desktop_entry OMShell "OpenModelica Shell" "omshell-large" "Science"
  228. }
  229.  
  230. pkg_preinst()
  231. {
  232.     return
  233. }
  234.  
  235. pkg_postinst() {
  236.     echo "${ROOT}usr/lib64/${CHOST}/omc" > /etc/ld.so.conf.d/openmodelica.conf
  237.     if use sundials ; then
  238.         # sundials libraries should be simbolically linked:
  239.         for S_LIB in "${ROOT}usr/lib64/${CHOST}/omc/libsundials_cvode.so.1" \
  240.                              "${ROOT}usr/lib64/${CHOST}/omc/libsundials_ida.so.2" \
  241.                              "${ROOT}usr/lib64/${CHOST}/omc/libsundials_kinsol.so.1" \
  242.                              "${ROOT}usr/lib64/${CHOST}/omc/libsundials_cvodes.so.2" \
  243.                              "${ROOT}usr/lib64/${CHOST}/omc/libsundials_idas.so.0" \
  244.                              "${ROOT}usr/lib64/${CHOST}/omc/libsundials_arkode.so.1" \
  245.                              "${ROOT}usr/lib64/${CHOST}/omc/libsundials_nvecserial.so.0"
  246.         do
  247.             if [[ -f $S_LIB ]] ; then
  248.                 einfo "Fixing $S_LIB..."
  249.                 rm $S_LIB
  250.                 ln -s "$S_LIB.0.0" "$S_LIB"
  251.             fi
  252.         done
  253.     fi
  254.     ldconfig
  255.    
  256.     xdg_desktop_database_update
  257.     xdg_icon_cache_update  
  258. }
  259.  
  260. pkg_postrm() {
  261.     xdg_desktop_database_update
  262.     xdg_icon_cache_update
  263. }
  264.  
  265. pkg_info() {
  266.     OMCver=`"${ROOT}"/usr/bin/omc --version`
  267.     echo "Compiler: ${OMCver}"
  268. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement