Move Locale::Maketext::Simple from ext/ to dist/
[perl.git] / h2pl / mksizes
1 #!/usr/local/bin/perl
2
3 ($iam = $0) =~ s%.*/%%;
4 $tmp = "$iam.$$";
5 open (CODE,">$tmp.c") || die "$iam: cannot create $tmp.c: $!\n";
6
7 $mask = q/printf ("$sizeof{'%s'} = %d;\n"/; 
8
9 # write C program
10 select(CODE);
11
12 print <<EO_C_PROGRAM;
13 #include <sys/param.h>
14 #include <sys/types.h>
15 #include <sys/socket.h>
16 #include <net/if_arp.h>
17 #include <net/if.h>
18 #include <net/route.h>
19 #include <sys/ioctl.h>
20
21 main() {
22 EO_C_PROGRAM
23
24 while ( <> ) {
25     chop;
26     printf "\t%s, \n\t\t\"%s\", sizeof(%s));\n", $mask, $_,$_;
27 }
28
29 print "\n}\n";
30
31 close CODE;
32
33 # compile C program
34
35 select(STDOUT);
36
37 system "cc $tmp.c -o $tmp";
38 die "couldn't compile $tmp.c" if $?;
39 system "./$tmp";           
40 die "couldn't run $tmp" if $?;
41
42 unlink "$tmp.c", $tmp;