readme.test 2.53 KB
Newer Older
1
2
#! /usr/bin/perl -w
# -*- cperl -*-
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#
# Copyright (C) 2010 Laboratoire de Recherche et Dveloppement de
# l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
#
# Spot is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Spot 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 General Public
# License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Spot; see the file COPYING.  If not, write to the Free
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#
# Check that all the directories documented in README exist, and that
# all directories listed in configure.ac are documented.
#
27
# Also has an option --list to print directories which are
28
# documented.
29
30
31
32
33
34

use strict;
use warnings;

local $\ = "\n";
my $top_srcdir = $ENV{top_srcdir} || "../../";
35
my $top_srcdir_len = length($top_srcdir) + 1;
36
37
38
39
40
41
42
43
my $list_mode = ($#ARGV != -1 && $ARGV[0] eq "--list");

unless (-f "$top_srcdir/README")
{
  print STDERR "$top_srcdir/README not found";
  exit 2;
}

44
45
open(FD, "$top_srcdir/README")
  or die "$!: cannot open $top_srcdir/README";
46
47
48
my @directory = ();
my $exit_status = 0;

49
50
my %documenteddirs;

51
52
while (<FD>)
{
53
54
  # Skip non-distributed directories.
  next if /Not distributed/i;
55
56
57
58
59
60
61
62
63
64
65
66
67
  # We consider Third party software?
  # last if (/^Third party software$/);
  next unless (m{^(\s*)(\S+/)\s+});
  my $level = length($1) / 3;
  my $name = $2;

  $directory[$level] = $name;
  $#directory = $level;
  my $filename = join "", @directory;

  # Use globbing on the filename.
  for my $directory (glob("$top_srcdir/$filename"))
  {
68
69
    my $striped = substr($directory, $top_srcdir_len);
    $documenteddirs{$striped} = 1;
70
71
    if ($list_mode)
    {
72
      print "$striped";
73
74
75
76
77
    }
    else
    {
      unless (-d $directory || -f $directory)
      {
78
        print STDERR "$directory mentioned in README does not exist.";
79
80
81
82
83
84
85
86
        $exit_status = 1;
      }
    }
  }
}

close(FD);

87
88
89
90
91
92
93
94
95
96
97
98
99
open(FD, "$top_srcdir/configure.ac")
  or die "$!: cannot open $top_srcdir/configure.ac";
while (<FD>)
{
  next unless m{\s*(\S+/)Makefile};
  unless (exists $documenteddirs{$1})
  {
    print STDERR "$1 directory undocumented in README.";
    $exit_status = 1;
  }
}
close(FD);

100
exit $exit_status;