Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: compctl for Makefile targets?



Hank Hughes wrote:
> 	I noticed an example in with some documentation somewhere
> 	but it seemed incomplete so.... has anyone made a compctl
> 	for Makefile targets.

I've been using a perl script to do this.  It mostly does the
business.


compctl -s '$(targets)' -x 'n[1,=]' -f -c -- + make


#!/usr/local/bin/perl -- -*-perl-*-

if ($ARGV[0] =~ /^-f(.*)$/) {
    shift;
    $mfile = $1 || shift;
}
((-f "Makefile")  &&  ($mfile = 'Makefile'))
    || ((-f 'makefile') && ($mfile = 'makefile'));

(-f $mfile) || exit(1);

open(STDIN, $mfile) || exit(1);

while(<STDIN>) {
    if (/:/) {
	s/\#.*$//;		# remove quotes
	next unless /:/;
	$_ = $`;
	next if /^\s*\./;	# .SUFFIXES, .c.o, etc.
	next if /\$/;		# $(OBJS): etc.

	foreach $word (split) {
	    $word{$word} = 1;
	}
    }
}

$, = "\n";
print keys(%word);

__END__

-- 
Peter Stephenson <pws@xxxxxx>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77413
Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.



Messages sorted by: Reverse Date, Date, Thread, Author