head	1.2;
access;
symbols
	perseant-exfatfs-base-20250801:1.2
	perseant-exfatfs-base-20240630:1.2
	cjep_sun2x:1.2.0.24
	cjep_sun2x-base:1.2
	cjep_staticlib_x-base1:1.2
	cjep_staticlib_x:1.2.0.22
	cjep_staticlib_x-base:1.2
	phil-wifi-20200421:1.2
	phil-wifi-20200411:1.2
	phil-wifi-20200406:1.2
	pgoyette-compat-merge-20190127:1.2
	pgoyette-compat-20190127:1.2
	pgoyette-compat-20190118:1.2
	pgoyette-compat-1226:1.2
	pgoyette-compat-1126:1.2
	pgoyette-compat-1020:1.2
	pgoyette-compat-0930:1.2
	pgoyette-compat-0906:1.2
	pgoyette-compat-0728:1.2
	pgoyette-compat-0625:1.2
	pgoyette-compat-0521:1.2
	pgoyette-compat-0502:1.2
	pgoyette-compat-0422:1.2
	pgoyette-compat-0415:1.2
	pgoyette-compat-0407:1.2
	pgoyette-compat-0330:1.2
	pgoyette-compat-0322:1.2
	pgoyette-compat-0315:1.2
	pgoyette-compat:1.2.0.20
	pgoyette-compat-base:1.2
	perseant-stdc-iso10646:1.2.0.18
	perseant-stdc-iso10646-base:1.2
	prg-localcount2-base3:1.2
	prg-localcount2-base2:1.2
	prg-localcount2-base1:1.2
	prg-localcount2:1.2.0.16
	prg-localcount2-base:1.2
	pgoyette-localcount-20170426:1.2
	bouyer-socketcan-base1:1.2
	pgoyette-localcount-20170320:1.2
	bouyer-socketcan:1.2.0.14
	bouyer-socketcan-base:1.2
	pgoyette-localcount-20170107:1.2
	pgoyette-localcount-20161104:1.2
	localcount-20160914:1.2
	pgoyette-localcount-20160806:1.2
	pgoyette-localcount-20160726:1.2
	pgoyette-localcount:1.2.0.12
	pgoyette-localcount-base:1.2
	netbsd-5-2-3-RELEASE:1.1.1.3
	netbsd-5-1-5-RELEASE:1.1.1.3
	yamt-pagecache-base9:1.2
	yamt-pagecache-tag8:1.2
	tls-earlyentropy:1.2.0.8
	tls-earlyentropy-base:1.2
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.2
	riastradh-drm2-base3:1.2
	netbsd-5-2-2-RELEASE:1.1.1.3
	netbsd-5-1-4-RELEASE:1.1.1.3
	netbsd-5-2-1-RELEASE:1.1.1.3
	netbsd-5-1-3-RELEASE:1.1.1.3
	agc-symver:1.2.0.10
	agc-symver-base:1.2
	tls-maxphys-base:1.2
	yamt-pagecache-base8:1.2
	netbsd-5-2:1.1.1.3.0.38
	yamt-pagecache-base7:1.2
	netbsd-5-2-RELEASE:1.1.1.3
	matt-nb6-plus-base:1.1.1.3
	matt-nb6-plus:1.2.0.6
	matt-nb6-plus-nbase:1.1.1.3
	netbsd-5-2-RC1:1.1.1.3
	yamt-pagecache-base6:1.2
	yamt-pagecache-base5:1.2
	yamt-pagecache-base4:1.2
	netbsd-5-1-2-RELEASE:1.1.1.3
	netbsd-5-1-1-RELEASE:1.1.1.3
	yamt-pagecache-base3:1.2
	yamt-pagecache-base2:1.2
	yamt-pagecache:1.2.0.4
	yamt-pagecache-base:1.2
	bouyer-quota2-nbase:1.2
	bouyer-quota2:1.2.0.2
	bouyer-quota2-base:1.2
	matt-nb5-mips64-premerge-20101231:1.1.1.3
	matt-nb5-pq3:1.1.1.3.0.36
	matt-nb5-pq3-base:1.1.1.3
	netbsd-5-1:1.1.1.3.0.34
	netbsd-5-1-RELEASE:1.1.1.3
	netbsd-5-1-RC4:1.1.1.3
	matt-nb5-mips64-k15:1.1.1.3
	netbsd-5-1-RC3:1.1.1.3
	netbsd-5-1-RC2:1.1.1.3
	netbsd-5-1-RC1:1.1.1.3
	netbsd-5-0-2-RELEASE:1.1.1.3
	matt-nb5-mips64-premerge-20091211:1.1.1.3
	matt-nb5-mips64-u2-k2-k4-k7-k8-k9:1.1.1.3
	matt-nb4-mips64-k7-u2a-k9b:1.1.1.3
	matt-nb5-mips64-u1-k1-k5:1.1.1.3
	matt-nb5-mips64:1.1.1.3.0.32
	netbsd-5-0-1-RELEASE:1.1.1.3
	jym-xensuspend-nbase:1.1.1.3
	netbsd-5-0:1.1.1.3.0.30
	netbsd-5-0-RELEASE:1.1.1.3
	netbsd-5-0-RC4:1.1.1.3
	netbsd-5-0-RC3:1.1.1.3
	netbsd-5-0-RC2:1.1.1.3
	jym-xensuspend:1.1.1.3.0.28
	jym-xensuspend-base:1.1.1.3
	netbsd-5-0-RC1:1.1.1.3
	netbsd-5:1.1.1.3.0.26
	netbsd-5-base:1.1.1.3
	matt-mips64-base2:1.1.1.3
	matt-mips64:1.1.1.3.0.24
	mjf-devfs2:1.1.1.3.0.22
	mjf-devfs2-base:1.1.1.3
	netbsd-4-0-1-RELEASE:1.1.1.3
	wrstuden-revivesa-base-3:1.1.1.3
	wrstuden-revivesa-base-2:1.1.1.3
	wrstuden-fixsa-newbase:1.1.1.3
	wrstuden-revivesa-base-1:1.1.1.3
	yamt-pf42-base4:1.1.1.3
	yamt-pf42-base3:1.1.1.3
	hpcarm-cleanup-nbase:1.1.1.3
	yamt-pf42-baseX:1.1.1.3
	yamt-pf42-base2:1.1.1.3
	wrstuden-revivesa:1.1.1.3.0.20
	wrstuden-revivesa-base:1.1.1.3
	yamt-pf42:1.1.1.3.0.18
	yamt-pf42-base:1.1.1.3
	keiichi-mipv6:1.1.1.3.0.16
	keiichi-mipv6-base:1.1.1.3
	matt-armv6-nbase:1.1.1.3
	matt-armv6-prevmlocking:1.1.1.3
	wrstuden-fixsa-base-1:1.1.1.3
	netbsd-4-0:1.1.1.3.0.14
	netbsd-4-0-RELEASE:1.1.1.3
	cube-autoconf:1.1.1.3.0.12
	cube-autoconf-base:1.1.1.3
	netbsd-4-0-RC5:1.1.1.3
	netbsd-4-0-RC4:1.1.1.3
	netbsd-4-0-RC3:1.1.1.3
	netbsd-4-0-RC2:1.1.1.3
	netbsd-4-0-RC1:1.1.1.3
	matt-armv6:1.1.1.3.0.10
	matt-armv6-base:1.1.1.3
	matt-mips64-base:1.1.1.3
	hpcarm-cleanup:1.1.1.3.0.8
	hpcarm-cleanup-base:1.1.1.3
	netbsd-3-1-1-RELEASE:1.1.1.2
	netbsd-3-0-3-RELEASE:1.1.1.2
	wrstuden-fixsa:1.1.1.3.0.6
	wrstuden-fixsa-base:1.1.1.3
	abandoned-netbsd-4-base:1.1.1.3
	abandoned-netbsd-4:1.1.1.3.0.2
	netbsd-3-1:1.1.1.2.0.6
	netbsd-3-1-RELEASE:1.1.1.2
	netbsd-3-0-2-RELEASE:1.1.1.2
	netbsd-3-1-RC4:1.1.1.2
	netbsd-3-1-RC3:1.1.1.2
	netbsd-3-1-RC2:1.1.1.2
	netbsd-3-1-RC1:1.1.1.2
	netbsd-4:1.1.1.3.0.4
	netbsd-4-base:1.1.1.3
	netbsd-3-0-1-RELEASE:1.1.1.2
	binutils-2-16-1:1.1.1.3
	netbsd-3-0:1.1.1.2.0.4
	netbsd-3-0-RELEASE:1.1.1.2
	netbsd-3-0-RC6:1.1.1.2
	netbsd-3-0-RC5:1.1.1.2
	netbsd-3-0-RC4:1.1.1.2
	netbsd-3-0-RC3:1.1.1.2
	netbsd-3-0-RC2:1.1.1.2
	netbsd-3-0-RC1:1.1.1.2
	netbsd-2-0-3-RELEASE:1.1.1.1
	netbsd-2-1:1.1.1.1.0.6
	netbsd-2-1-RELEASE:1.1.1.1
	netbsd-2-1-RC6:1.1.1.1
	netbsd-2-1-RC5:1.1.1.1
	netbsd-2-1-RC4:1.1.1.1
	netbsd-2-1-RC3:1.1.1.1
	netbsd-2-1-RC2:1.1.1.1
	netbsd-2-1-RC1:1.1.1.1
	netbsd-2-0-2-RELEASE:1.1.1.1
	netbsd-3:1.1.1.2.0.2
	netbsd-3-base:1.1.1.2
	netbsd-2-0-1-RELEASE:1.1.1.1
	netbsd-2:1.1.1.1.0.4
	netbsd-2-base:1.1.1.1
	binutils-2-15-20041204:1.1.1.2
	netbsd-2-0-RELEASE:1.1.1.1
	netbsd-2-0-RC5:1.1.1.1
	netbsd-2-0-RC4:1.1.1.1
	netbsd-2-0-RC3:1.1.1.1
	netbsd-2-0-RC2:1.1.1.1
	netbsd-2-0-RC1:1.1.1.1
	netbsd-2-0:1.1.1.1.0.2
	netbsd-2-0-base:1.1.1.1
	binutils-2-14:1.1.1.1
	FSF:1.1.1;
locks; strict;
comment	@# @;


1.2
date	2009.11.07.18.01.11;	author skrll;	state dead;
branches
	1.2.6.1;
next	1.1;

1.1
date	2003.11.26.11.37.32;	author mrg;	state Exp;
branches
	1.1.1.1;
next	;

1.2.6.1
date	2009.11.07.18.01.11;	author matt;	state dead;
branches;
next	1.2.6.2;

1.2.6.2
date	2012.11.20.18.51.28;	author matt;	state Exp;
branches;
next	;

1.1.1.1
date	2003.11.26.11.37.32;	author mrg;	state Exp;
branches;
next	1.1.1.2;

1.1.1.2
date	2004.12.08.09.52.50;	author mrg;	state Exp;
branches;
next	1.1.1.3;

1.1.1.3
date	2006.02.02.21.13.11;	author skrll;	state Exp;
branches;
next	;


desc
@@


1.2
log
@Remove old binutils.
@
text
@#!/usr/bin/perl
# -*- perl -*-

#   Copyright (C) 2001
#   Free Software Foundation
#
# This file is part of the libiberty library.
# Libiberty is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# Libiberty is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with libiberty; see the file COPYING.LIB.  If not,
# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
# Originally written by DJ Delorie <dj@@redhat.com>


# This is a trivial script which checks the lists of C and O files in
# the Makefile for consistency.

$mode = shift;
$srcdir = ".";

if ($mode eq "-s") {
    $srcdir = shift;
    $mode = shift;
}

&missing() if $mode eq "missing";
&undoc() if $mode eq "undoc";
&deps() if $mode eq "deps";

exit 0;

format STDOUT =
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~
$out
        ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
$out
.

######################################################################

sub missing {

    opendir(S, $srcdir);
    while ($f = readdir S) {
	$have{$f} = 1;
    }
    closedir(S);
    opendir(S, ".");
    while ($f = readdir S) {
	$have{$f} = 1;
    }
    closedir(S);

    for $a (@@ARGV) {
	$listed{$a} = 1;
	$have{$a} = 0;
    }

    for $f (sort keys %have) {
	next unless $have{$f};
	if ($f =~ /\.c$/) {
	    print "S $f\n";
	}
    }
    for $f (sort keys %listed) {
	if ($f =~ /(.*)\.c$/) {
	    $base = $1;
	    if (! $listed{"$base.o"}) {
		print "O $f\n";
	    }
	}
    }
}

######################################################################

sub undoc {

    opendir(S, $srcdir);
    while ($file = readdir S) {
	if ($file =~ /\.texi$/) {
	    open(T, "$srcdir/$file");
	    while (<T>) {
		if (/^\@@deftype[^\(]* ([^\s\(]+) *\(/) {
		    $documented{$1} = 1;
		}
	    }
	    close(T);
	}
	if ($file =~ /\.c$/) {
	    open(C, "$srcdir/$file");
	    while (<C>) {
		if (/\@@undocumented (\S+)/) {
		    $documented{$1} = 1;
		}
		if (/^static /) {
		    if (! /[\(;]/) {
			s/[\r\n]+$/ /;
			$_ .= <C>;
		    }
		    while ($_ =~ /\([^\)]*$/) {
			s/[\r\n]+$/ /;
			$_ .= <C>;
		    }
		}
		s/ VPARAMS([ \(])/$1/;
		s/PREFIX\(([^\)]*)\)/byte_$1/;
		if (/^static [^\(]* ([^\s\(]+) *\(.*\)$/) {
		    $documented{$1} = 1;
		}
	    }
	}
    }
    closedir(D);

    # $out = join(' ', sort keys %documented);
    # write;
    # print "\n";

    system "etags $srcdir/*.c $srcdir/../include/*.h";
    open(TAGS, "TAGS");
    while (<TAGS>) {
	s/[\r\n]+$//;
	if (/^\014$/) {
	    $filename = <TAGS>;
	    $filename =~ s/[\r\n]+$//;
	    $filename =~ s/,\d+$//;
	    $filename =~ s@@.*[/\\]@@@@;
	    next;
	}
	if ($filename =~ /\.c$/ ) {
	    next unless /^[_a-zA-Z]/;
	} else {
	    next unless /^\# *define/;
	    s/\# *define *//;
	}
	next if $filename =~ /mpw\.c/;

	s/ VPARAMS//;
	s/ *\177.*//;
	s/,$//;
	s/DEFUN\(//;
	s/\(//;

	next if /^static /;
	next if /\s/;
	next if /^_/;
	next if $documented{$_};
	next if /_H_?$/;

	if ($seen_in{$_} ne $filename) {
	    $saw{$_} ++;
	}
	$seen_in{$_} = $filename;
    }

    for $k (keys %saw) {
	delete $saw{$k} if $saw{$k} > 1;
    }

    for $k (sort keys %saw) {
	$fromfile{$seen_in{$k}} .= " " if $fromfile{$seen_in{$k}};
	$fromfile{$seen_in{$k}} .= $k;
    }

    for $f (sort keys %fromfile) {
	$out = "$f: $fromfile{$f}";
	write;
    }
}

######################################################################

sub deps_for {
    my($f) = @@_;
    my(%d);
    open(F, $f);
    %d = ();
    while (<F>) {
	if (/^#\s*include\s+["<](.*)[">]/) {
	    $d{$1} = 1;
	}
    }
    close(F);
    return keys %d;
}

sub canonicalize {
    my ($p) = @@_;
    0 while $p =~ s@@/\./@@/@@g;
    0 while $p =~ s@@^\./@@@@g;
    0 while $p =~ s@@/[^/]+/\.\./@@/@@g;
    return $p;
}

sub locals_first {
    my ($a,$b) = @@_;
    return -1 if $a eq "config.h";
    return  1 if $b eq "config.h";
    return $a cmp $b;
}

sub deps {

    $incdir = shift @@ARGV;

    opendir(INC, $incdir);
    while ($f = readdir INC) {
	next unless $f =~ /\.h$/;
	$mine{$f} = "\$(INCDIR)/$f";
	$deps{$f} = join(' ', &deps_for("$incdir/$f"));
    }
    $mine{'config.h'} = "config.h";

    opendir(INC, $srcdir);
    while ($f = readdir INC) {
	next unless $f =~ /\.h$/;
	$mine{$f} = "\$(srcdir)/$f";
	$deps{$f} = join(' ', &deps_for("$srcdir/$f"));
    }
    $mine{'config.h'} = "config.h";

    open(IN, "$srcdir/Makefile.in");
    open(OUT, ">$srcdir/Makefile.tmp");
    while (<IN>) {
	last if /remainder of this file/;
	print OUT;
    }
    print OUT "# The dependencies in the remainder of this file are automatically\n";
    print OUT "# generated by \"make maint-deps\".  Manual edits will be lost.\n\n";

    opendir(S, $srcdir);
    for $f (sort readdir S) {
	if ($f =~ /\.c$/) {

	    %scanned = ();
	    @@pending = &deps_for("$srcdir/$f");
	    while (@@pending) {
		@@tmp = @@pending;
		@@pending = ();
		for $p (@@tmp) {
		    next unless $mine{$p};
		    if (!$scanned{$p}) {
			push(@@pending, split(' ', $deps{$p}));
			$scanned{$p} = 1;
		    }
		}
	    }
	    @@deps = sort { &locals_first($a,$b) } keys %scanned;
	    $obj = $f;
	    $obj =~ s/\.c$/.o/;
	    $obj = "$obj:";
	    if ($#deps >= 0) {
		print OUT $obj;
		$len = length($obj);
		for $dt (@@deps) {
		    $d = $mine{$dt};
		    if ($len + length($d) > 70) {
			printf OUT " \\\n\t$d";
			$len = 8 + length($d);
		    } else {
			print OUT " $d";
			$len += length($d) + 1;
		    }
		}
		print OUT "\n";
	    }
	}
    }
    closedir(S);
    close(IN);
    close(OUT);

    rename("$srcdir/Makefile.tmp", "$srcdir/Makefile.in");
}
@


1.2.6.1
log
@file maint-tool was added on branch matt-nb6-plus on 2012-11-20 18:51:28 +0000
@
text
@d1 286
@


1.2.6.2
log
@Bring back GPL2 version of binutils.
@
text
@a0 296
#!/usr/bin/perl
# -*- perl -*-

#   Copyright (C) 2001
#   Free Software Foundation
#
# This file is part of the libiberty library.
# Libiberty is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# Libiberty is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with libiberty; see the file COPYING.LIB.  If not,
# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
# Originally written by DJ Delorie <dj@@redhat.com>


# This is a trivial script which checks the lists of C and O files in
# the Makefile for consistency.

$mode = shift;
$srcdir = ".";

if ($mode eq "-s") {
    $srcdir = shift;
    $mode = shift;
}

&missing() if $mode eq "missing";
&undoc() if $mode eq "undoc";
&deps() if $mode eq "deps";

exit 0;

format STDOUT =
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~
$out
        ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
$out
.

######################################################################

sub missing {

    opendir(S, $srcdir);
    while ($f = readdir S) {
	$have{$f} = 1;
    }
    closedir(S);
    opendir(S, ".");
    while ($f = readdir S) {
	$have{$f} = 1;
    }
    closedir(S);

    for $a (@@ARGV) {
	$listed{$a} = 1;
	$have{$a} = 0;
    }

    for $f (sort keys %have) {
	next unless $have{$f};
	if ($f =~ /\.c$/) {
	    print "S $f\n";
	}
    }
    for $f (sort keys %listed) {
	if ($f =~ /(.*)\.c$/) {
	    $base = $1;
	    if (! $listed{"$base.o"}) {
		print "O $f\n";
	    }
	}
    }
}

######################################################################

sub undoc {

    opendir(S, $srcdir);
    while ($file = readdir S) {
	if ($file =~ /\.texi$/) {
	    open(T, "$srcdir/$file");
	    while (<T>) {
		if (/^\@@deftype[^\(]* ([^\s\(]+) *\(/) {
		    $documented{$1} = 1;
		}
	    }
	    close(T);
	}
	if ($file =~ /\.c$/) {
	    open(C, "$srcdir/$file");
	    while (<C>) {
		if (/\@@undocumented (\S+)/) {
		    $documented{$1} = 1;
		}
		if (/^static /) {
		    if (! /[\(;]/) {
			s/[\r\n]+$/ /;
			$_ .= <C>;
		    }
		    while ($_ =~ /\([^\)]*$/) {
			s/[\r\n]+$/ /;
			$_ .= <C>;
		    }
		}
		s/ VPARAMS([ \(])/$1/;
		s/PREFIX\(([^\)]*)\)/byte_$1/;
		if (/^static [^\(]* ([^\s\(]+) *\(.*\)$/) {
		    $documented{$1} = 1;
		}
	    }
	}
    }
    closedir(D);

    # $out = join(' ', sort keys %documented);
    # write;
    # print "\n";

    system "etags $srcdir/*.c $srcdir/../include/*.h";
    open(TAGS, "TAGS");
    while (<TAGS>) {
	s/[\r\n]+$//;
	if (/^\014$/) {
	    $filename = <TAGS>;
	    $filename =~ s/[\r\n]+$//;
	    $filename =~ s/,\d+$//;
	    $filename =~ s@@.*[/\\]@@@@;
	    next;
	}
	if ($filename =~ /\.c$/ ) {
	    next unless /^[_a-zA-Z]/;
	} else {
	    next unless /^\# *define/;
	    s/\# *define *//;
	}

	s/ VPARAMS//;
	s/ *\177.*//;
	s/,$//;
	s/DEFUN\(//;
	s/\(//;

	next if /^static /;
	next if /\s/;
	next if /^_/;
	next if $documented{$_};
	next if /_H_?$/;

	if ($seen_in{$_} ne $filename) {
	    $saw{$_} ++;
	}
	$seen_in{$_} = $filename;
    }

    for $k (keys %saw) {
	delete $saw{$k} if $saw{$k} > 1;
    }

    for $k (sort keys %saw) {
	$fromfile{$seen_in{$k}} .= " " if $fromfile{$seen_in{$k}};
	$fromfile{$seen_in{$k}} .= $k;
    }

    for $f (sort keys %fromfile) {
	$out = "$f: $fromfile{$f}";
	write;
    }
}

######################################################################

sub deps_for {
    my($f) = @@_;
    my(%d);
    open(F, $f);
    %d = ();
    while (<F>) {
	if (/^#\s*include\s+["<](.*)[">]/) {
	    $d{$1} = 1;
	}
    }
    close(F);
    return keys %d;
}

sub canonicalize {
    my ($p) = @@_;
    0 while $p =~ s@@/\./@@/@@g;
    0 while $p =~ s@@^\./@@@@g;
    0 while $p =~ s@@/[^/]+/\.\./@@/@@g;
    return $p;
}

sub locals_first {
    my ($a,$b) = @@_;
    return -1 if $a eq "config.h";
    return  1 if $b eq "config.h";
    return $a cmp $b;
}

sub deps {

    $crule  = "\tif [ x\"\$(PICFLAG)\" != x ]; then \\\n";
    $crule .= "\t  \$(COMPILE.c) \$(PICFLAG) \$< -o pic/\$@@; \\\n";
    $crule .= "\telse true; fi\n";
    $crule .= "\t\$(COMPILE.c) \$< \$(OUTPUT_OPTION)\n";
    $crule .= "\n";

    $incdir = shift @@ARGV;

    opendir(INC, $incdir);
    while ($f = readdir INC) {
	next unless $f =~ /\.h$/;
	$mine{$f} = "\$(INCDIR)/$f";
	$deps{$f} = join(' ', &deps_for("$incdir/$f"));
    }
    $mine{'config.h'} = "config.h";

    opendir(INC, $srcdir);
    while ($f = readdir INC) {
	next unless $f =~ /\.h$/;
	$mine{$f} = "\$(srcdir)/$f";
	$deps{$f} = join(' ', &deps_for("$srcdir/$f"));
    }
    $mine{'config.h'} = "config.h";

    open(IN, "$srcdir/Makefile.in");
    open(OUT, ">$srcdir/Makefile.tmp");
    while (<IN>) {
	last if /remainder of this file/;
	print OUT;
    }
    print OUT "# The dependencies in the remainder of this file are automatically\n";
    print OUT "# generated by \"make maint-deps\".  Manual edits will be lost.\n\n";

    opendir(S, $srcdir);
    for $f (sort readdir S) {
	if ($f =~ /\.c$/) {

	    %scanned = ();
	    @@pending = &deps_for("$srcdir/$f");
	    while (@@pending) {
		@@tmp = @@pending;
		@@pending = ();
		for $p (@@tmp) {
		    next unless $mine{$p};
		    if (!$scanned{$p}) {
			push(@@pending, split(' ', $deps{$p}));
			$scanned{$p} = 1;
		    }
		}
	    }
	    @@deps = sort { &locals_first($a,$b) } keys %scanned;
	    $obj = $f;
	    $obj =~ s/\.c$/.o/;
	    $obj = "./$obj:";
	    if ($#deps >= 0) {
		print OUT "$obj \$(srcdir)/$f";
		$len = length("$obj $f");
		for $dt (@@deps) {
		    $d = $mine{$dt};
		    if ($len + length($d) > 70) {
			printf OUT " \\\n\t$d";
			$len = 8 + length($d);
		    } else {
			print OUT " $d";
			$len += length($d) + 1;
		    }
		}
		print OUT "\n";
	    } else {
		print OUT "$obj \$(srcdir)/$f\n";
	    }
	    $c = $crule;
	    $c =~ s@@\$\<@@\$\(srcdir\)\/$f@@g;
	    print OUT $c;
	}
    }
    closedir(S);
    close(IN);
    close(OUT);

    rename("$srcdir/Makefile.tmp", "$srcdir/Makefile.in");
}
@


1.1
log
@Initial revision
@
text
@@


1.1.1.1
log
@initial import of binutils 2.14 into gnu/dist/binutils.
@
text
@@


1.1.1.2
log
@initial import of binutils 2.15 branch (20041204)
@
text
@a215 6
    $crule  = "\tif [ x\"\$(PICFLAG)\" != x ]; then \\\n";
    $crule .= "\t  \$(COMPILE.c) \$(PICFLAG) \$< -o pic/\$@@; \\\n";
    $crule .= "\telse true; fi\n";
    $crule .= "\t\$(COMPILE.c) \$< \$(OUTPUT_OPTION)\n";
    $crule .= "\n";

d263 1
a263 1
	    $obj = "./$obj:";
d265 2
a266 2
		print OUT "$obj \$(srcdir)/$f";
		$len = length("$obj $f");
a277 2
	    } else {
		print OUT "$obj \$(srcdir)/$f\n";
a278 3
	    $c = $crule;
	    $c =~ s@@\$\<@@\$\(srcdir\)\/$f@@g;
	    print OUT $c;
@


1.1.1.3
log
@Import binutils 2.16.1.
@
text
@d148 1
@


