Commit | Line | Data |
---|---|---|
e50aee73 AD |
1 | #!/usr/bin/perl |
2 | ||
36477c24 | 3 | unlink "embed.h"; |
e50aee73 AD |
4 | open(EM, ">embed.h") || die "Can't create embed.h: $!\n"; |
5 | ||
6 | print EM <<'END'; | |
76b72cf1 | 7 | /* !!!!!!! DO NOT EDIT THIS FILE !!!!!!! |
6f84cdf9 | 8 | This file is built by embed.pl from global.sym and interp.sym. |
76b72cf1 | 9 | Any changes made here will be lost |
10 | */ | |
e50aee73 AD |
11 | |
12 | /* (Doing namespace management portably in C is really gross.) */ | |
13 | ||
820c3be9 | 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 | ||
e50aee73 AD |
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/; | |
760ac839 LW |
34 | s/^\s*(\S+).*$/#define $1\t\tPerl_$1/; |
35 | $global{$1} = 1; | |
e50aee73 AD |
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 | ||
760ac839 LW |
52 | open(INT, "<interp.sym") || die "Can't open interp.sym: $!\n"; |
53 | while (<INT>) { | |
54 | s/[ \t]*#.*//; # Delete comments. | |
55 | next unless /\S/; | |
55497cff | 56 | s/^\s*(\S+).*$/#define $1\t\t(curinterp->I$1)/; |
57 | s/(................\t)\t/$1/; | |
58 | print EM $_; | |
760ac839 LW |
59 | } |
60 | close(INT) || warn "Can't close interp.sym: $!\n"; | |
61 | ||
55497cff | 62 | print EM <<'END'; |
63 | ||
64 | #else /* not multiple, so translate interpreter symbols the other way... */ | |
65 | ||
66 | END | |
760ac839 | 67 | |
e50aee73 AD |
68 | open(INT, "<interp.sym") || die "Can't open interp.sym: $!\n"; |
69 | while (<INT>) { | |
70 | s/[ \t]*#.*//; # Delete comments. | |
71 | next unless /\S/; | |
55497cff | 72 | s/^\s*(\S+).*$/#define I$1\t\t$1/; |
e50aee73 AD |
73 | s/(................\t)\t/$1/; |
74 | print EM $_; | |
75 | } | |
76 | close(INT) || warn "Can't close interp.sym: $!\n"; | |
77 | ||
56d28764 CS |
78 | print EM <<'END'; |
79 | ||
80 | #ifdef EMBED | |
81 | ||
82 | END | |
e50aee73 AD |
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/; | |
55497cff | 88 | s/^\s*(\S+).*$/#define $1\t\tPerl_$1/; |
e50aee73 AD |
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 | ||
56d28764 CS |
96 | #endif /* EMBED */ |
97 | ||
e50aee73 AD |
98 | #endif /* MULTIPLICITY */ |
99 | END | |
100 |