# -*- 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

name                plumed
PortGroup           mpi 1.0
PortGroup           linear_algebra 1.0
PortGroup           debug 1.0

version             @_VERSION_@
revision            @_REVISION_@
categories          science

# Most of the PLUMED code is L-GPL3. However, PLUMED containts
# molfile plugins from VMD that are released with a BSD-like license
# http://www.ks.uiuc.edu/Research/vmd/plugins/molfile/
license             LGPL-3 BSD
maintainers         {gmail.com:giovanni.bussi @GiovanniBussi} openmaintainer
description         PLUMED is a plugin for molecular dynamics
long_description    PLUMED is a plugin for molecular dynamics that can be used \
                    in combination with popular molecular dynamics codes to perform biased simulations. \
                    Additionally, it can be used as a standalone tool to analyze trajectories.

platforms           darwin

homepage            http://www.plumed.org/

@_FETCH_@

### This is required so that patch made with "git format-patch" work correctly
# patch.pre_args -p1
### In case patches from github should be included to fix behavior on macports one should
### - put patch files (as obtained with git format-patch) in files/ directory
### - list their name here:
# patchfiles file1 \
#            file2
### etc

# Disable additional features.
# --disable-doc:          Do not create documentation, and avoid searching for Doxygen.
# --disable-libsearch:    Avoid searching libraries using their default names.
#                         This forces the libraries names to be explicitly passed (e.g. "-lz").
#                         It has the advantage that during compilation from source it does not
#                         link packages that are not explicitely required.
# --disable-static-patch: Avoid a number of tests that are only required when linking plumed
#                         statically to an MD code.
# --disable-mpi:          Do not search for MPI compiler (replaced when enabling mpi, see below)
configure.args-append \
               --disable-doc \
               --disable-libsearch \
               --disable-static-patch \
               --disable-mpi 

# Hardcode path for libplumedKernel.dylib.
# This allows to patch MD codes using the --runtime option but using as
# default kernel the installed one. In this way, MacPorts users
# can just use patched MD codes with the installed plumed or replace it
# by setting PLUMED_KERNEL at runtime
configure.cppflags-append "-D__PLUMED_DEFAULT_KERNEL=${prefix}/lib/libplumedKernel.dylib"

compilers.choose    cc cxx
mpi.setup

# To enable mpi, replace a configure flag
if {[mpi_variant_isset]} {
  configure.args-replace --disable-mpi --enable-mpi
}

# Libraries.
# Library names are specified here to make sure that
# only requested packages are linked.
configure.ldflags-append -lmatheval -lxdrfile -lz -lgsl
depends_lib-append port:libmatheval port:xdrfile port:zlib port:gsl

# This variant enables optional modules in PLUMED.
variant allmodules description {Enable all optional modules} {
  configure.args-append --enable-modules=all
}

# Link lapack/blas libraries
pre-configure {
  # commands should be included in a pre-configure block to access tcl variables
  configure.ldflags-append ${linalglib}
}

