This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to Devel::PPPort 3.00.
[perl5.git] / ext / 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#
8# $Revision: 3 $
9# $Author: mhx $
10# $Date: 2004/08/13 12:50:11 +0200 $
11#
12################################################################################
13#
14# Version 3.x, Copyright (C) 2004, Marcus Holland-Moritz.
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
26my $file = 'provided.c';
27
28my %embed = map { ( $_->{name} => 1 ) }
29 parse_embed(qw(parts/embed.fnc parts/apidoc.fnc));
30
31my @provided = grep { !exists $embed{$_} }
32 map { /^(\w+)/ ? $1 : () }
33 `$^X ppport.h --list-provided`;
34
35my $install = '/tmp/perl/install/default';
36
37my @perls = sort { $b->{version} <=> $a->{version} }
38 map { { version => `$_ -e 'printf "%.6f", \$]'`, path => $_ } }
39 ('bleadperl', glob "$install/*/bin/perl5.*");
40
41for (1 .. $#perls) {
42 $perls[$_]{todo} = $perls[$_-1]{version};
43}
44
45shift @perls;
46
47my %v;
48
49for my $p (@perls) {
50 my $archlib = `$p->{path} -MConfig -l -e 'print \$Config{archlib}'`;
51 chomp $archlib;
52 local @ARGV = glob "$archlib/CORE/*.h";
53 my %sym;
54 while (<>) { $sym{$_}++ for /(\w+)/g; }
55 @provided = map { $sym{$_} or $v{$p->{todo}}{$_}++; $sym{$_} ? $_ : () } @provided;
56}
57
58my $out = 'parts/base';
59
60for my $v (keys %v) {
61 my $file = $v;
62 $file =~ s/\.//g;
63 $file = "$out/$file";
64 -e $file or die "non-existent: $file\n";
65 open F, ">>$file" or die "$file: $!\n";
66 printf F "%-30s # added by $0\n", $_ for sort keys %{$v{$v}};
67 close F;
68}