%instance deftypesuffix(hh-src, '%.hh') ;
%instance deftypesuffix(cc-src, '%.cc') ;

ALLOCD = make.allocd;
NEXT = make.next;

%tool allochd (
    hhsrc:	%in [type = hh-src, persistent];
    hsrc:	%out [type = C-incl]	=> match($hhsrc);
    prog:	%in [type = command]	=> $ALLOCD;
)
{
    exec($prog, stdin => $hhsrc, stdout => $hsrc);
    echo({$hsrc ,'created'});
};


%tool alloccd (
    ccsrc:	%in [type = cc-src, persistent];
    csrc:	%out [type = C-src]	=> match($ccsrc);
    prog:	%in [type = command]	=> $ALLOCD;
)
{
    exec($prog, stdin => $ccsrc, stdout => $csrc);
    echo({$csrc ,'created'});
};


# Possibly there's only one type of { cc-src, hh-src } available,
# so introduce a new attribute.

%derive f[cc-or-hh-src] %when get($f, type) == cc-src
			%or   get($f, type) == hh-src;

%tool mknext (
    cchhsrc:	%in %list [cc-or-hh-src];
    next:	%out [type = C-src]	=> next.c;
    prog:	%in [type = command]	=> $NEXT;
)
{
    exec($prog, args => $cchhsrc, stdout => $next);
    echo({$next ,'created'});
};
