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

PortSystem      1.0
PortGroup       muniversal 1.0

name            gdb
version         7.9.1
revision        3
categories      devel
license         GPL-3+
maintainers     gmail.com:stuartwesterman openmaintainer
description     GDB: The GNU Project Debugger

long_description \
GDB, the GNU Project debugger, allows you to see what is going on 'inside' \
another program while it executes -- or what another program was doing at the \
moment it crashed.  GDB can do four main kinds of things (plus other things \
in support of these) to help you catch bugs in the act: \
    a) start your program, specifying anything that might affect its behavior, \
    b) make your program stop on specified conditions, \
    c) examine what has happened, when your program has stopped, \
    d) change things in your program, so you can experiment with correcting \
       the effects of one bug and go on to learn about another. \
The program being debugged can be written in Ada, C, C++, Objective-C, \
Pascal (and many other languages). Those programs might be executing on \
the same machine as GDB (native) or on another machine (remote). GDB \
can run on most popular UNIX and Microsoft Windows variants.

homepage        http://www.gnu.org/software/gdb/
platforms       darwin
supported_archs x86_64 i386

master_sites    gnu

checksums       rmd160  0dee316b422399512a8f604d169d217ba84ea2cc \
                sha256  4994ad986726ac4128a6f1bd8020cd672e9a92aa76b80736563ef992992764ef

# these dependencies are listed under depends_lib rather than depends_build
# because gdb will link with libraries they provide if installed.
# there may be more. See variable host_libs in configure.ac.
# port:guile should also be a dependency, but currently does not build universally. (#48767)

depends_lib     port:boehmgc \
                port:expat \
                port:gettext \
                port:libiconv \
                port:ncurses \
                port:zlib

configure.args \
    --infodir=${prefix}/share/info \
    --mandir=${prefix}/share/man \
    --with-docdir=${prefix}/share/doc \
    --without-guile \
    --program-prefix=g \
    --disable-werror

post-destroot {
    system "chgrp procmod ${destroot}${prefix}/bin/ggdb*"
    system "chmod g+s ${destroot}${prefix}/bin/ggdb*"

    foreach info [glob -tails -directory ${destroot}${prefix}/share/info g*] {
        move ${destroot}${prefix}/share/info/${info} ${destroot}${prefix}/share/info/g${info}
    }

    xinstall -m 755 -d ${destroot}${prefix}/libexec/gnubin
    foreach binary [glob -tails -directory ${destroot}${prefix}/bin g*] {
        ln -s ${prefix}/bin/${binary} ${destroot}${prefix}/libexec/gnubin/[string range $binary 1 end]
    }
}

set pythons_suffixes {27 34}

set pythons_ports {}
foreach s ${pythons_suffixes} {
    lappend pythons_ports python${s}
}

foreach s ${pythons_suffixes} {
    set p python${s}
    set v [string index ${s} 0].[string index ${s} 1]
    set i [lsearch -exact ${pythons_ports} ${p}]
    set c [lreplace ${pythons_ports} ${i} ${i}]
    eval [subst {
        variant ${p} description "Build GDB with Python ${v} Scripting" conflicts ${c} {
            depends_lib-append      port:${p}
            configure.args-append   --with-python=${prefix}/bin/python${v}
            patchfiles-append       patch-python-config.py.diff
        }
    }]
}

variant multiarch description {Support all target architectures} {
    configure.args-append    --enable-targets=all
}

if {${os.platform} eq "darwin" && ${os.major} >= 12} {
    notes "
You will need to make sure /System/Library/LaunchDaemons/com.apple.taskgated.plist\
has the '-p' option, e.g.
            <key>ProgramArguments</key>
            <array>
                    <string>/usr/libexec/taskgated</string>
                    <string>-sp</string>
            </array>

Due to kernel caching, you usually need to restart Mac OS X for this option to effect.
"
}


livecheck.type  regex
livecheck.url   http://ftp.gnu.org/gnu/gdb/
livecheck.regex gdb-(\\d+(?:\\.\\d+)+)\\.tar