# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           linear_algebra 1.0

name                mbdyn
version             1.7.3
revision            0

categories          science
license             GPL-2.1
maintainers         {mps @Schamschula} openmaintainer
description         MBDyn is the first and one of the few full-featured free* general \
                    purpose Multibody Dynamics analysis software.
long_description    {*}${description}
homepage            https://www.mbdyn.org
master_sites        https://github.com/mmorandi/MBDyn-web/raw/main/userfiles/downloads/

checksums           rmd160  d4d4371936071a9d965f752660b5ba8f4ddcadcc \
                    sha256  3cf05cd1cb14c1af3d987aac119b6ecf0d835bc1aee06bc4cf7cc5a245c1f36d \
                    size    3108007

compiler.require_fortran    yes

depends_build       port:pkgconfig

depends_lib         port:gcc15 \
                    port:GiNaC \
                    port:metis \
                    port:SuiteSparse

patchfiles          patch-libraries-libmbwrap-kluwrap.h.diff \
                    patch-libraries-libmbwrap-umfpackwrap.h.diff

# Fix build with metis
# see: https://www.freelists.org/post/mbdyn-users/Successful-build-of-MBDyn-from-source-on-a-Mac
patchfiles-append   patch-libraries-libmbwrap-metiswrap.cc.diff

configure.args      --with-blas=blas \
                    --with-ginac=yes \
                    --with-mpi=no \
                    --with-metis=yes

# workaround for Type mismatch in argument 't' at (1); passed REAL(4) to INTEGER(4)
# See FreeBSD Makefile
configure.env       FFLAGS=-fallow-argument-mismatch             
