pod/perlipc.pod patch
[p5sagit/p5-mst-13.2.git] / embed.pl
1 #!/usr/bin/perl
2
3 unlink "embed.h";
4 open(EM, ">embed.h") || die "Can't create embed.h: $!\n";
5
6 print EM <<'END';
7 /* !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!! 
8    This file is built by embed.pl from global.sym and interp.sym.
9    Any changes made here will be lost 
10 */
11
12 /* (Doing namespace management portably in C is really gross.) */
13
14 /*  EMBED has no run-time penalty, but helps keep the Perl namespace
15     from colliding with that used by other libraries pulled in
16     by extensions or by embedding perl.  Allow a cc -DNO_EMBED
17     override, however, to keep binary compatability with previous
18     versions of perl.
19 */
20 #ifndef NO_EMBED
21 #  define EMBED 1 
22 #endif
23
24 #ifdef EMBED
25
26 /* globals we need to hide from the world */
27 END
28
29 open(GL, "<global.sym") || die "Can't open global.sym: $!\n";
30
31 while(<GL>) {
32         s/[ \t]*#.*//;          # Delete comments.
33         next unless /\S/;
34         s/^\s*(\S+).*$/#define $1\t\tPerl_$1/;
35         $global{$1} = 1; 
36         s/(................\t)\t/$1/;
37         print EM $_;
38 }
39
40 close(GL) || warn "Can't close global.sym: $!\n";
41
42 print EM <<'END';
43
44 #endif /* EMBED */
45
46 /* Put interpreter specific symbols into a struct? */
47
48 #ifdef MULTIPLICITY
49
50 END
51
52 open(INT, "<interp.sym") || die "Can't open interp.sym: $!\n";
53 while (<INT>) {
54         s/[ \t]*#.*//;          # Delete comments.
55         next unless /\S/;
56         s/^\s*(\S+).*$/#define $1\t\t(curinterp->I$1)/;
57         s/(................\t)\t/$1/;
58         print EM $_;
59 }
60 close(INT) || warn "Can't close interp.sym: $!\n";
61
62 print EM <<'END';
63
64 #else   /* not multiple, so translate interpreter symbols the other way... */
65
66 END
67
68 open(INT, "<interp.sym") || die "Can't open interp.sym: $!\n";
69 while (<INT>) {
70         s/[ \t]*#.*//;          # Delete comments.
71         next unless /\S/;
72         s/^\s*(\S+).*$/#define I$1\t\t$1/;
73         s/(................\t)\t/$1/;
74         print EM $_;
75 }
76 close(INT) || warn "Can't close interp.sym: $!\n";
77
78 print EM <<'END';
79
80 #ifdef EMBED
81
82 END
83
84 open(INT, "<interp.sym") || die "Can't open interp.sym: $!\n";
85 while (<INT>) {
86         s/[ \t]*#.*//;          # Delete comments.
87         next unless /\S/;
88         s/^\s*(\S+).*$/#define $1\t\tPerl_$1/;
89         s/(................\t)\t/$1/;
90         print EM $_;
91 }
92 close(INT) || warn "Can't close interp.sym: $!\n";
93
94 print EM <<'END';
95
96 #endif /* EMBED */
97
98 #endif /* MULTIPLICITY */
99 END
100