# -*- 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: Portfile 91326 2012-03-29 23:13:00Z jeremyhu@macports.org $

PortSystem      1.0
PortGroup       muniversal 1.0

name            gdb
version         7.3
revision        1
categories      devel
maintainers     dweber 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

master_sites    gnu

use_bzip2       yes

checksums       sha1    fefd90275d6decdca00c5c29c533e2ef3d439664 \
                rmd160  3df9a15e2d276f4f7f30e5d2a7d86a8c63f30a34

depends_build   port:gettext

if {${configure.build_arch} == "ppc" || ${configure.build_arch} == "ppc64"} {
    notes "${name} does not support building on ${configure.build_arch}."
    pre-fetch {
        ui_error "${name} does not support building on ${configure.build_arch}."
        return -code error "Unsupported architecture."
    }
}

patch.pre_args -p1
patchfiles buggy-memset.patch

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

configure.cflags-append     -I${prefix}/include
configure.cxxflags-append   -I${prefix}/include

if {${configure.compiler} == "clang"} {
    configure.cflags-append -Wno-unused-value
}

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}
    }
    move ${destroot}${prefix}/share/info/standards.info ${destroot}${prefix}/share/info/ggdb-standards.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]
    }
}

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