This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Move finding perl versions from mktodo to devtools.pl
[perl5.git] / dist / 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#
b2049988 8# Version 3.x, Copyright (C) 2004-2013, Marcus Holland-Moritz.
adfe19db
MHM
9# Version 2.x, Copyright (C) 2001, Paul Marquess.
10# Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
11#
12# This program is free software; you can redistribute it and/or
13# modify it under the same terms as Perl itself.
14#
15################################################################################
16
17use strict;
49ef49fe
CBW
18use Getopt::Long;
19
3d7c117d 20require './parts/ppptools.pl';
55179e46 21require './parts/inc/inctools';
adfe19db 22
49ef49fe
CBW
23our %opt = (
24 mode => 'check',
25 install => '/tmp/perl/install/default',
26 blead => 'bleadperl',
27);
28
29GetOptions(\%opt, qw( install=s mode=s blead=s )) or die;
30
31my $write = $opt{mode} eq 'write';
adfe19db
MHM
32
33my %embed = map { ( $_->{name} => 1 ) }
679ad62d 34 parse_embed(qw(parts/embed.fnc parts/apidoc.fnc parts/ppport.fnc ));
adfe19db
MHM
35
36my @provided = grep { !exists $embed{$_} }
37 map { /^(\w+)/ ? $1 : () }
38 `$^X ppport.h --list-provided`;
39
adfe19db
MHM
40my @perls = sort { $b->{version} <=> $a->{version} }
41 map { { version => `$_ -e 'printf "%.6f", \$]'`, path => $_ } }
49ef49fe 42 ($opt{blead}, glob "$opt{install}/*/bin/perl5.*");
adfe19db
MHM
43
44for (1 .. $#perls) {
45 $perls[$_]{todo} = $perls[$_-1]{version};
46}
47
48shift @perls;
49
50my %v;
51
52for my $p (@perls) {
a745474a 53 print "checking perl $p->{version}...\n";
adfe19db
MHM
54 my $archlib = `$p->{path} -MConfig -l -e 'print \$Config{archlib}'`;
55 chomp $archlib;
56 local @ARGV = glob "$archlib/CORE/*.h";
57 my %sym;
58 while (<>) { $sym{$_}++ for /(\w+)/g; }
59 @provided = map { $sym{$_} or $v{$p->{todo}}{$_}++; $sym{$_} ? $_ : () } @provided;
60}
61
62my $out = 'parts/base';
a745474a 63my $todo = parse_todo($out);
adfe19db
MHM
64
65for my $v (keys %v) {
55179e46 66 my @new = sort dictionary_order grep { !exists $todo->{$_} } keys %{$v{$v}};
a745474a 67 @new or next;
adfe19db
MHM
68 my $file = $v;
69 $file =~ s/\.//g;
70 $file = "$out/$file";
71 -e $file or die "non-existent: $file\n";
a745474a 72 print "-- $file --\n";
49ef49fe 73 $write and (open F, ">>$file" or die "$file: $!\n");
a745474a
MHM
74 for (@new) {
75 print "adding $_\n";
49ef49fe 76 $write and printf F "%-30s # added by $0\n", $_;
a745474a 77 }
49ef49fe 78 $write and close F;
adfe19db 79}