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

github.setup            avrdudes avr-libc 2_2_0 avr-libc- -release
version                 [string map {_ .} ${github.version}]
revision                0
checksums               rmd160  0bbc8a2e1c2fc152814d1662b36f8d299806f9ad \
                        sha256  0718efd4f54278877da65a0b203b402073b30e04dfea988e6f2a8835ad071d35 \
                        size    8398941

categories              cross
maintainers             nomaintainer
supported_archs         noarch
license                 BSD

description             C library for the AVR microcontroller.
long_description        AVR Libc is a Free Software project whose goal is \
                        to provide a high quality C library for use with \
                        GCC on Atmel AVR microcontrollers.

# installs deliberately files outside regular tree:
destroot.violate_mtree  yes

homepage                https://avrdudes.github.io/avr-libc/
github.tarball_from     releases
distname                ${name}-${version}
use_bzip2               yes

depends_lib             port:avr-gcc

configure.args          --host=avr --build=`./config.guess`
configure.cc            avr-gcc

depends_build-append    port:automake
post-patch {
    # Update config.guess and config.sub to be able to build on arm64. This also
    # allows x86_64 to be detected properly (instead of as i386), although that
    # problem did not impair the build on x86_64.
    set automake_dirs [glob -directory ${prefix}/share automake-*]
    set automake_dir [lindex [lsort -command vercmp $automake_dirs] end]
    copy -force ${automake_dir}/config.guess ${automake_dir}/config.sub \
        ${worksrcpath}
}
