cc += -d --yacc ;
    case yacc  : yacc += -d ;
}
if $(debug) && $(yacc)
{
    yacc += -t -v ;
}
yacc += $(YACCFLAGS) ;

rule .yacc
{
    DEPENDS $(<) : $(>) ;
    LEAVES $(<) ;
    [YACC] $(<) : $(>) ;
}
if $(OS) = NT { actions [YACC] {
    "$(yacc)" "$(>)"
    if not errorlevel 1 (
        del /f "$(<[1])"
        rename y.tab$(<[1]:S) "$(<[1])"
        del /f $(<[2])
        rename y.tab$(<[2]:S) "$(<[2])"
    ) else set _error_ =
} }
if $(UNIX) = true { actions [YACC] {
    if ` "$(yacc)" "$(>)" ` ; then
        mv -f y.tab$(<[1]:S) "$(<[1])"
        mv -f y.tab$(<[2]:S) "$(<[2])"
    else
        exit 1
    fi
} }
if $(grammar) && ! $(yacc)
{
    EXIT Could not find the 'yacc' tool, and therefore can not build the
        grammar. ;
}
if $(grammar) && $(yacc)
{
    .yacc jamgram.c jamgram.h : jamgram.y ;
}

# How to build the compiled in jambase.
rule .mkjambase
{
    local exe = [ .exe mkjambase : mkjambase.c ] ;
    DEPENDS $(<) : $(exe) $(>) ;
    LEAVES $(<) ;
    mkjambase.exe on $(<) = $(exe:R=$(locate-target)) ;
    [MKJAMBASE] $(<) : $(>) ;
}
actions [MKJAMBASE] {
    $(--chmod+w)$(<)
    $(mkjambase.exe) "$(<)" "$(>)"
}
if $(debug)
{
    .mkjambase jambase.c : Jambase ;
}

# How to build Jam.
rule .jam
{
    $(>).exe = [ .exe $(>) : $(jam.source) ] ;
    DEPENDS all : $($(>).exe) ;

    # Make a copy under the old name.
    $(<).exe = $(<:S=$($(>).exe:S)) ;
    LOCATE on $($(<).exe) = $(locate-target) ;
    .copy $($(<).exe) : $($(>).exe) ;
    DEPENDS all : $($(<).exe) ;
}
.jam bjam : b2 ;


# Scan sources for header dependencies.
#
# In order to keep things simple, we made a slight compromise here - we only
# detect changes in headers included relative to the current folder as opposed
# to those included from somewhere on the include path.
rule .scan ( targets + )
{
    HDRRULE on $(targets) = .hdr.scan ;
    HDRSCAN on $(targets) = "^[ \t]*#[ \t]*include[ \t]*\"([^\"]*)\".*$" ;
}
rule .hdr.scan ( target : includes * : binding )
{
    local target-path = [ NORMALIZE_PATH $(binding:D) ] ;
    # Ext