38.6 Write Dependencies to STDOUT

The dependencies are converted into a format like:

libmyalps${LIBPOSTFIX}(myarith.${FILEEXTENSION}):\  
    libmyalps${LIBPOSTFIX}(myprtype.${FILEEXTENSION})

for lines that look like

myalps src/myalps/arith my  
myalps src/myalps/prtype my

in the corresponding file given as the first parameter (see page 502).

The generated files src/Makefile.dep and test/Makefile.dep are used for the generation of the .al as well as the .a libraries. The corresponding extensions will be set in src/Makefile.nw and test/Makefile.nw via the variables LIBPOSTFIX and FILEEXTENSION. They are set to

LIBPOSTFIX=.al  
FILEEXTENSION=ao

or

LIBPOSTFIX=.a  
FILEEXTENSION=o

in the corresponding Makefile before src/Makefile.dep and test/Makefile.dep become relevant.

If one wants to see the full set of dependencies, simply comment out the line

if ($DEP{$LIBfile}{$f} == 0) {next} #full or not full

530write dependencies in Makefile format to stdout 530  (507b)
sub printDependencies {
    my($file, $LIB)=@_;
    my($LIBfile)="$LIB $file";
    my($libal, $liba, $f, $fal, $fa);
    my(@dependencies);
    $file =~ s/.*\///;
    if ($file =~ /([^ ]+) (\w+)/) {$file="$2$1";}
    $target = "lib$LIB". ’${LIBPOSTFIX}’ . "($file." . ’${FILEEXTENSION})’;
    for $f (keys %{$DEP{$LIBfile}}) {
        if ($DEP{$LIBfile}{$f} == 0) {next} #full or not full
        $f =~ /([^ ]+) (.*)/;
        $L = $1;
        $f = $2;
        $f =~ s/.*\///;
        if ($f =~ /([^ ]+) (\w+)/) {$f="$2$1";}
        $dep = "lib$L" . ’${LIBPOSTFIX}’ . "($f." . ’${FILEEXTENSION})’;
        if ($target ne $dep) {push @dependencies, $dep;}
    }
    if (scalar(@dependencies) > 0) {
        print "$target:\\\n    ".join("\\\n    ",sort(@dependencies))."\n";
    }
}

Defines:
printDependencies, used in chunk 507a.

Uses DEP 504c, FILEEXTENSION 442, LIB 441b, and LIBPOSTFIX 442.