Plan 9 from Bell Labs’s /usr/web/sources/contrib/anothy/src/lib/djb-ape/weed.pl

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/usr/bin/perl

# Print all targets from Makefile that are not in TARGETS
# This is a trivial maintenance utility to help you keep TARGETS up to
# date.

open FILE,"TARGETS" || die "Could not open \"TARGETS\"\n";
while (<FILE>) {
  chomp; $da{$_}=1;
}
close FILE;

open FILE,"Makefile" || die "Could not open \"Makefile\"\n";
$skip=0;
while (<FILE>) {
  if (m/^([ a-zA-Z0-9\._-]*):/) {
    my @tmp=split(/\s/,$1);
    my @wanted=();
    foreach $i (@tmp) {
      if (exists $da{$i}) {
	push @wanted,$i;
#      } else {
#	print STDERR "ignoring $i\n";
      }
    }
    if ($#wanted==-1) {
      chomp;
#      print STDERR "skipping $_\n";
      $skip=1;
    } else {
      $skip=0;
      print join(' ',@wanted);
      s/^[^:]*:/:/;
      print;
    }
  } else {
    if (m/:/) {
      chomp;
      print STDERR "mismatch: %_\n";
    }
    print unless ($skip==1);
  }
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].