# -*- 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                       cmake 1.1
PortGroup                       github 1.0
PortGroup                       muniversal 1.1

github.setup                    ampl asl 2f5d9de248c53a3063bba23af2013cd3db768bf8
version                         20240106
revision                        0

categories                      math
maintainers                     nomaintainer

license                         BSD

description                     ASL is A Modeling Language for Mathematical Programming (AMPL) Solver Library
long_description                {*}${description}.

checksums                       rmd160  5556051b6addff78eff4d69c53e45bf4e898e28b \
                                sha256  79c7ffa64f686231cf75b008df48a8dc3d176326c0d1563c7f78911cd51d2579 \
                                size    1615712
github.tarball_from             archive

configure.args-append           -DBUILD_SHARED_LIBS=ON \
                                -DBUILD_CPP=ON

variant threads description {builds multithreaded libraries, compiled using OpenMP switches} {
    compiler.openmp_version     2.5

    if {[string match *clang* ${configure.compiler}]} {
        depends_lib-append      port:libomp

        configure.cflags-append -I${prefix}/include/libomp
        configure.ldflags-append \
                                -L${prefix}/lib/libomp -lomp
    } elseif {[string match *gcc* ${configure.compiler}]} {
        # The build fails to add needed flags automatically:
        # https://github.com/ampl/asl/issues/17
        configure.cflags-append -fopenmp
        configure.ldflags-append \
                                -fopenmp
    }

    configure.args-append       -DBUILD_MT_LIBS=ON
}

# cc1: error: unrecognized command line option "-Wno-unused-result"
# arith.h: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘byte’
compiler.blacklist-append       *gcc-4.0 *gcc-4.2

# PowerPC support should be enabled manually
if {${build_arch} in [list ppc ppc64]} {
    configure.args-append       -Dppc_support=ON
}

default_variants-append         +threads
