This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pod/perlipc.pod patch
[perl5.git] / embed.pl
CommitLineData
e50aee73
AD
1#!/usr/bin/perl
2
36477c24 3unlink "embed.h";
e50aee73
AD
4open(EM, ">embed.h") || die "Can't create embed.h: $!\n";
5
6print 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
PP
9 Any changes made here will be lost
10*/
e50aee73
AD
11
12/* (Doing namespace management portably in C is really gross.) */
13
820c3be9
PP
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 */
27END
28
29open(GL, "<global.sym") || die "Can't open global.sym: $!\n";
30
31while(<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
40close(GL) || warn "Can't close global.sym: $!\n";
41
42print EM <<'END';
43
44#endif /* EMBED */
45
46/* Put interpreter specific symbols into a struct? */
47
48#ifdef MULTIPLICITY
49
50END
51
760ac839
LW
52open(INT, "<interp.sym") || die "Can't open interp.sym: $!\n";
53while (<INT>) {
54 s/[ \t]*#.*//; # Delete comments.
55 next unless /\S/;
55497cff
PP
56 s/^\s*(\S+).*$/#define $1\t\t(curinterp->I$1)/;
57 s/(................\t)\t/$1/;
58 print EM $_;
760ac839
LW
59}
60close(INT) || warn "Can't close interp.sym: $!\n";
61
55497cff
PP
62print EM <<'END';
63
64#else /* not multiple, so translate interpreter symbols the other way... */
65
66END
760ac839 67
e50aee73
AD
68open(INT, "<interp.sym") || die "Can't open interp.sym: $!\n";
69while (<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}
76close(INT) || warn "Can't close interp.sym: $!\n";
77
56d28764
CS
78print EM <<'END';
79
80#ifdef EMBED
81
82END
e50aee73
AD
83
84open(INT, "<interp.sym") || die "Can't open interp.sym: $!\n";
85while (<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}
92close(INT) || warn "Can't close interp.sym: $!\n";
93
94print EM <<'END';
95
56d28764
CS
96#endif /* EMBED */
97
e50aee73
AD
98#endif /* MULTIPLICITY */
99END
100