This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[inseparable changes from patch from perl5.003_10 to perl5.003_11]
[perl5.git] / old_embed.pl
1 #!/usr/bin/perl
2 #
3 # FOR BACKWARDS COMPATIBILITY WITH OLD VERSIONS OF PERL
4 #
5 # This script uses an old method of creating "embed.h".  Use it
6 # if you need to maintain binary compatibility with older versions
7 # Perl with the EMBED feature enabled.
8 #
9
10 unlink "embed.h";
11 open(EM, ">embed.h") || die "Can't create embed.h: $!\n";
12
13 print EM <<'END';
14 /* !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!! 
15    This file is built by old_embed.pl from old_global.sym and interp.sym.
16    Any changes made here will be lost.
17    THIS FILE IS FOR BINARY COMPATIBILITY WITH OLD PERL VERSIONS.
18    Run "embed.pl" to get an up-to-date version.
19 */
20
21 /* (Doing namespace management portably in C is really gross.) */
22
23 /*  EMBED has no run-time penalty, but helps keep the Perl namespace
24     from colliding with that used by other libraries pulled in
25     by extensions or by embedding perl.  Allow a cc -DNO_EMBED
26     override, however, to keep binary compatability with previous
27     versions of perl.
28 */
29 #ifndef NO_EMBED
30 #  define EMBED 1 
31 #endif
32
33 #ifdef EMBED
34
35 /* globals we need to hide from the world */
36 END
37
38 open(GL, "<old_global.sym") || die "Can't open old_global.sym: $!\n";
39
40 while(<GL>) {
41         s/[ \t]*#.*//;          # Delete comments.
42         next unless /\S/;
43         s/^\s*(\S+).*$/#define $1\t\tPerl_$1/;
44         $global{$1} = 1; 
45         s/(................\t)\t/$1/;
46         print EM $_;
47 }
48
49 close(GL) || warn "Can't close old_global.sym: $!\n";
50
51 print EM <<'END';
52
53 #endif /* EMBED */
54
55 /* Put interpreter specific symbols into a struct? */
56
57 #ifdef MULTIPLICITY
58
59 /* Undefine symbols that were defined by EMBED. Somewhat ugly */
60
61 END
62
63
64 open(INT, "<interp.sym") || die "Can't open interp.sym: $!\n";
65 while (<INT>) {
66         s/[ \t]*#.*//;          # Delete comments.
67         next unless /\S/;
68         s/^\s*(\S*).*$/#undef $1/;
69         print EM $_ if (exists $global{$1});
70 }
71 close(INT) || warn "Can't close interp.sym: $!\n";
72
73 print EM "\n";
74
75 open(INT, "<interp.sym") || die "Can't open interp.sym: $!\n";
76 while (<INT>) {
77         s/[ \t]*#.*//;          # Delete comments.
78         next unless /\S/;
79         s/^\s*(\S+).*$/#define $1\t\t(curinterp->I$1)/;
80         s/(................\t)\t/$1/;
81         print EM $_;
82 }
83 close(INT) || warn "Can't close interp.sym: $!\n";
84
85 print EM <<'END';
86
87 #else   /* not multiple, so translate interpreter symbols the other way... */
88
89 END
90
91 open(INT, "<interp.sym") || die "Can't open interp.sym: $!\n";
92 while (<INT>) {
93         s/[ \t]*#.*//;          # Delete comments.
94         next unless /\S/;
95         s/^\s*(\S+).*$/#define I$1\t\t$1/;
96         s/(................\t)\t/$1/;
97         print EM $_;
98 }
99 close(INT) || warn "Can't close interp.sym: $!\n";
100
101 print EM <<'END';
102
103 #endif /* MULTIPLICITY */
104 END
105