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