#! /usr/bin/perl -w

use strict;

my $dirs = `ls -d */usr/share/doc/RFC`;

for my $dir (split /\s+/, $dirs) {
	print "$dir ...\n";
	mkdir "$dir/links";
	my $files = `ls $dir/*/rfc[0-9]* $dir/*/*/rfc[0-9]* 2>/dev/null`;
	for my $file (split /\s+/, $files) {
		$file =~ s[^.*/RFC/][../];
		my $file2 = $file;
		$file2 =~ s[^.*/][];
		symlink $file, "$dir/links/$file2" or die "$file: $!";
	}
}

