summaryrefslogtreecommitdiff
path: root/old_embed.pl
blob: 9453febf6ae46323a686e9ac21269b877cbe203c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/perl
#
# FOR BACKWARDS COMPATIBILITY WITH OLD VERSIONS OF PERL
#
# This script uses an old method of creating "embed.h".  Use it
# if you need to maintain binary compatibility with older versions
# Perl with the EMBED feature enabled.
#

unlink "embed.h";
open(EM, ">embed.h") || die "Can't create embed.h: $!\n";

print EM <<'END';
/* !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!! 
   This file is built by old_embed.pl from old_global.sym and interp.sym.
   Any changes made here will be lost.
   THIS FILE IS FOR BINARY COMPATIBILITY WITH OLD PERL VERSIONS.
   Run "embed.pl" to get an up-to-date version.
*/

/* (Doing namespace management portably in C is really gross.) */

/*  EMBED has no run-time penalty, but helps keep the Perl namespace
    from colliding with that used by other libraries pulled in
    by extensions or by embedding perl.  Allow a cc -DNO_EMBED
    override, however, to keep binary compatability with previous
    versions of perl.
*/
#ifndef NO_EMBED
#  define EMBED 1 
#endif

#ifdef EMBED

/* globals we need to hide from the world */
END

open(GL, "<old_global.sym") || die "Can't open old_global.sym: $!\n";

while(<GL>) {
	s/[ \t]*#.*//;		# Delete comments.
	next unless /\S/;
	s/^\s*(\S+).*$/#define $1\t\tPerl_$1/;
	$global{$1} = 1; 
	s/(................\t)\t/$1/;
	print EM $_;
}

close(GL) || warn "Can't close old_global.sym: $!\n";

print EM <<'END';

#endif /* EMBED */

/* Put interpreter specific symbols into a struct? */

#ifdef MULTIPLICITY

/* Undefine symbols that were defined by EMBED. Somewhat ugly */

END


open(INT, "<interp.sym") || die "Can't open interp.sym: $!\n";
while (<INT>) {
	s/[ \t]*#.*//;		# Delete comments.
	next unless /\S/;
	s/^\s*(\S*).*$/#undef $1/;
	print EM $_ if (exists $global{$1});
}
close(INT) || warn "Can't close interp.sym: $!\n";

print EM "\n";

open(INT, "<interp.sym") || die "Can't open interp.sym: $!\n";
while (<INT>) {
	s/[ \t]*#.*//;		# Delete comments.
	next unless /\S/;
	s/^\s*(\S+).*$/#define $1\t\t(curinterp->I$1)/;
	s/(................\t)\t/$1/;
	print EM $_;
}
close(INT) || warn "Can't close interp.sym: $!\n";

print EM <<'END';

#else	/* not multiple, so translate interpreter symbols the other way... */

END

open(INT, "<interp.sym") || die "Can't open interp.sym: $!\n";
while (<INT>) {
	s/[ \t]*#.*//;		# Delete comments.
	next unless /\S/;
	s/^\s*(\S+).*$/#define I$1\t\t$1/;
	s/(................\t)\t/$1/;
	print EM $_;
}
close(INT) || warn "Can't close interp.sym: $!\n";

print EM <<'END';

#endif /* MULTIPLICITY */
END