Correctly handle SvOOK scalars. 5.12 and later don't use SvIVX().
[p5sagit/Devel-Size.git] / Makefile.PL
CommitLineData
d9b022a1 1#!/usr/bin/perl -w
9b8e6254 2use 5.008;
6cc998b7 3use ExtUtils::MakeMaker;
d9b022a1 4use strict;
6cc998b7 5
5f03b77e 6use Config;
7(unpack "B*", pack "N", $Config{ptrsize}) =~ /^0+1(0+)$/
390777e7 8 or die "Your pointer size of $Config{ptrsize} is very confusing";
5f03b77e 9my $ptr_bits = length $1;
10
d9b022a1 11my $svh = "$Config{archlibexp}/CORE/perl.h";
12my $vtable_file = 'vtables.inc';
13
14my %vtables;
15open FH, "<$svh"
16 or die "Can't open $svh ($!) - is your perl install missing its headers?";
17while (<FH>) {
18 next unless /^\s+(PL_vtbl_[a-z]+),\s*$/ or /^EXT MGVTBL (PL_vtbl_[a-z]+) =/;
19 ++$vtables{$1};
20}
21warn "Didn't find any vtable names in $svh" unless %vtables;
22close FH;
23
24
25my %special = (
26 PL_vtbl_collxfrm => 'USE_LOCALE_COLLATE',
27 PL_vtbl_mutex => 'USE_5005THREADS',
28);
29
30open FH, ">$vtable_file" or die "Can't open $vtable_file: $!";
31foreach (sort keys %vtables) {
ec404c23 32 print FH "#ifdef $special{$_}\n" if ($special{$_});
33 if ($Config{gccversion}) {
d9b022a1 34 print FH " &$_,\n";
ec404c23 35 } else {
36 print FH " check_new(st, &$_);\n";
d9b022a1 37 }
ec404c23 38 print FH "#endif\n" if ($special{$_});
d9b022a1 39}
40
41close FH or die "Error closing $vtable_file: $!";
42
1a36ac09 43WriteMakefile(
390777e7 44 NAME => 'Devel::Size',
45 VERSION_FROM => 'lib/Devel/Size.pm',
46 DEFINE => "-DALIGN_BITS=$ptr_bits",
33d464ba 47 (eval $ExtUtils::MakeMaker::VERSION >= 6.47 ? (MIN_PERL_VERSION => '5.008') : ()),
48 (eval $ExtUtils::MakeMaker::VERSION >= 6.31 ? (LICENSE => 'perl') : ()),
390777e7 49 realclean => {FILES=> $vtable_file},
6cc998b7 50);