This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Use $^O
[perl5.git] / embed.pl
CommitLineData
e50aee73
AD
1#!/usr/bin/perl
2
3open(EM, ">embed.h") || die "Can't create embed.h: $!\n";
4
5print EM <<'END';
6/* This file is derived from global.sym and interp.sym */
7
8/* (Doing namespace management portably in C is really gross.) */
9
820c3be9 10/* EMBED has no run-time penalty, but helps keep the Perl namespace
11 from colliding with that used by other libraries pulled in
12 by extensions or by embedding perl. Allow a cc -DNO_EMBED
13 override, however, to keep binary compatability with previous
14 versions of perl.
15*/
16#ifndef NO_EMBED
17# define EMBED 1
18#endif
19
e50aee73
AD
20#ifdef EMBED
21
22/* globals we need to hide from the world */
23END
24
25open(GL, "<global.sym") || die "Can't open global.sym: $!\n";
26
27while(<GL>) {
28 s/[ \t]*#.*//; # Delete comments.
29 next unless /\S/;
30 s/(.*)/#define $1\t\tPerl_$1/;
31 s/(................\t)\t/$1/;
32 print EM $_;
33}
34
35close(GL) || warn "Can't close global.sym: $!\n";
36
37print EM <<'END';
38
39#endif /* EMBED */
40
41/* Put interpreter specific symbols into a struct? */
42
43#ifdef MULTIPLICITY
44
45END
46
47open(INT, "<interp.sym") || die "Can't open interp.sym: $!\n";
48while (<INT>) {
49 s/[ \t]*#.*//; # Delete comments.
50 next unless /\S/;
51 s/(.*)/#define $1\t\t(curinterp->I$1)/;
52 s/(................\t)\t/$1/;
53 print EM $_;
54}
55close(INT) || warn "Can't close interp.sym: $!\n";
56
57print EM <<'END';
58
59#else /* not multiple, so translate interpreter symbols the other way... */
60
61END
62
63open(INT, "<interp.sym") || die "Can't open interp.sym: $!\n";
64while (<INT>) {
65 s/[ \t]*#.*//; # Delete comments.
66 next unless /\S/;
67 s/(.*)/#define I$1\t\t$1/;
68 s/(................\t)\t/$1/;
69 print EM $_;
70}
71close(INT) || warn "Can't close interp.sym: $!\n";
72
73print EM <<'END';
74
75#endif /* MULTIPLICITY */
76END
77