This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add links to Windows documentation of shell and CRT quote parsing rules
[perl5.git] / cpan / Devel-PPPort / devel / scanprov
CommitLineData
adfe19db
MHM
1#!/usr/bin/perl -w
2################################################################################
3#
4# scanprov -- scan Perl headers for provided macros
5#
6################################################################################
7#
3f0c6e0c 8# $Revision: 9 $
adfe19db 9# $Author: mhx $
3f0c6e0c 10# $Date: 2009/01/18 14:10:50 +0100 $
adfe19db
MHM
11#
12################################################################################
13#
3f0c6e0c 14# Version 3.x, Copyright (C) 2004-2009, Marcus Holland-Moritz.
adfe19db
MHM
15# Version 2.x, Copyright (C) 2001, Paul Marquess.
16# Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
17#
18# This program is free software; you can redistribute it and/or
19# modify it under the same terms as Perl itself.
20#
21################################################################################
22
23use strict;
24require 'parts/ppptools.pl';
25
3f0c6e0c
JV
26die "Usage: $0 [check|write]\n" unless @ARGV && $ARGV[0] =~ /^(check|write)$/;
27my $mode = $1;
adfe19db
MHM
28
29my %embed = map { ( $_->{name} => 1 ) }
679ad62d 30 parse_embed(qw(parts/embed.fnc parts/apidoc.fnc parts/ppport.fnc ));
adfe19db
MHM
31
32my @provided = grep { !exists $embed{$_} }
33 map { /^(\w+)/ ? $1 : () }
34 `$^X ppport.h --list-provided`;
35
3f0c6e0c
JV
36my $install = '/tmp/perl/install/default';
37
adfe19db
MHM
38my @perls = sort { $b->{version} <=> $a->{version} }
39 map { { version => `$_ -e 'printf "%.6f", \$]'`, path => $_ } }
3f0c6e0c 40 ('bleadperl', glob "$install/*/bin/perl5.*");
adfe19db
MHM
41
42for (1 .. $#perls) {
43 $perls[$_]{todo} = $perls[$_-1]{version};
44}
45
46shift @perls;
47
48my %v;
49
50for my $p (@perls) {
a745474a 51 print "checking perl $p->{version}...\n";
adfe19db
MHM
52 my $archlib = `$p->{path} -MConfig -l -e 'print \$Config{archlib}'`;
53 chomp $archlib;
54 local @ARGV = glob "$archlib/CORE/*.h";
55 my %sym;
56 while (<>) { $sym{$_}++ for /(\w+)/g; }
57 @provided = map { $sym{$_} or $v{$p->{todo}}{$_}++; $sym{$_} ? $_ : () } @provided;
58}
59
60my $out = 'parts/base';
a745474a 61my $todo = parse_todo($out);
adfe19db
MHM
62
63for my $v (keys %v) {
a745474a
MHM
64 my @new = sort grep { !exists $todo->{$_} } keys %{$v{$v}};
65 @new or next;
adfe19db
MHM
66 my $file = $v;
67 $file =~ s/\.//g;
68 $file = "$out/$file";
69 -e $file or die "non-existent: $file\n";
a745474a 70 print "-- $file --\n";
3f0c6e0c 71 $mode eq 'write' and (open F, ">>$file" or die "$file: $!\n");
a745474a
MHM
72 for (@new) {
73 print "adding $_\n";
3f0c6e0c 74 $mode eq 'write' and printf F "%-30s # added by $0\n", $_;
a745474a 75 }
3f0c6e0c 76 $mode eq 'write' and close F;
adfe19db 77}