Commit | Line | Data |
adfe19db |
1 | ################################################################################ |
2 | # |
3 | # PPPort_xs.PL -- generate PPPort.xs |
4 | # |
5 | ################################################################################ |
6 | # |
7 | # $Revision: 7 $ |
8 | # $Author: mhx $ |
9 | # $Date: 2004/08/13 12:49:19 +0200 $ |
10 | # |
11 | ################################################################################ |
12 | # |
13 | # Version 3.x, Copyright (C) 2004, Marcus Holland-Moritz. |
14 | # Version 2.x, Copyright (C) 2001, Paul Marquess. |
15 | # Version 1.x, Copyright (C) 1999, Kenneth Albanowski. |
16 | # |
17 | # This program is free software; you can redistribute it and/or |
18 | # modify it under the same terms as Perl itself. |
19 | # |
20 | ################################################################################ |
21 | |
22 | use strict; |
23 | $^W = 1; |
24 | require "parts/ppptools.pl"; |
25 | |
26 | my %SECTION = ( |
27 | xshead => { code => '', header => "/* ---- from __FILE__ ---- */" }, |
28 | xsinit => { code => '', header => "/* ---- from __FILE__ ---- */" }, |
29 | xsmisc => { code => '', header => "/* ---- from __FILE__ ---- */" }, |
30 | xsboot => { code => '', header => "/* ---- from __FILE__ ---- */", indent => "\t" }, |
31 | xsubs => { code => '', header => "##".('-' x 70)."\n## XSUBs from __FILE__\n##".('-' x 70)."\n" }, |
32 | ); |
33 | |
34 | if (exists $ENV{PERL_NO_GET_CONTEXT} && $ENV{PERL_NO_GET_CONTEXT}) { |
35 | $SECTION{xshead}{code} .= <<END; |
36 | #define PERL_NO_GET_CONTEXT |
37 | END |
38 | } |
39 | |
40 | my $file; |
41 | my $sec; |
42 | |
43 | for $file (glob 'parts/inc/*') { |
44 | my $spec = parse_partspec($file); |
45 | |
46 | my $msg = 0; |
47 | for $sec (keys %SECTION) { |
48 | if (exists $spec->{$sec}) { |
49 | $msg++ or print "adding XS code from $file\n"; |
50 | if (exists $SECTION{$sec}{header}) { |
51 | my $header = $SECTION{$sec}{header}; |
52 | $header =~ s/__FILE__/$file/g; |
53 | $SECTION{$sec}{code} .= $header . "\n"; |
54 | } |
55 | $SECTION{$sec}{code} .= $spec->{$sec} . "\n"; |
56 | } |
57 | } |
58 | } |
59 | |
60 | my $data = do { local $/; <DATA> }; |
61 | |
62 | for $sec (keys %SECTION) { |
63 | my $code = $SECTION{$sec}{code}; |
64 | if (exists $SECTION{$sec}{indent}) { |
65 | $code =~ s/^/$SECTION{$sec}{indent}/gm; |
66 | } |
67 | $code =~ s/[\r\n]+$//; |
68 | $data =~ s/^__\U$sec\E__$/$code/m; |
69 | } |
70 | |
71 | open FH, ">PPPort.xs" or die "PPPort.xs: $!\n"; |
72 | print FH $data; |
73 | close FH; |
74 | |
75 | exit 0; |
76 | |
77 | __DATA__ |
78 | /******************************************************************************* |
79 | * |
80 | * !!!!! Do NOT edit this file directly! -- Edit PPPort_xs.PL instead. !!!!! |
81 | * |
82 | ******************************************************************************** |
83 | * |
84 | * Perl/Pollution/Portability |
85 | * |
86 | ******************************************************************************** |
87 | * |
88 | * $Revision: 7 $ |
89 | * $Author: mhx $ |
90 | * $Date: 2004/08/13 12:49:19 +0200 $ |
91 | * |
92 | ******************************************************************************** |
93 | * |
94 | * Version 3.x, Copyright (C) 2004, Marcus Holland-Moritz. |
95 | * Version 2.x, Copyright (C) 2001, Paul Marquess. |
96 | * Version 1.x, Copyright (C) 1999, Kenneth Albanowski. |
97 | * |
98 | * This program is free software; you can redistribute it and/or |
99 | * modify it under the same terms as Perl itself. |
100 | * |
101 | *******************************************************************************/ |
102 | |
103 | /* ========== BEGIN XSHEAD ================================================== */ |
104 | |
105 | __XSHEAD__ |
106 | |
107 | /* =========== END XSHEAD =================================================== */ |
108 | |
109 | #include "EXTERN.h" |
110 | #include "perl.h" |
111 | #include "XSUB.h" |
112 | |
113 | /* ========== BEGIN XSINIT ================================================== */ |
114 | |
115 | __XSINIT__ |
116 | |
117 | /* =========== END XSINIT =================================================== */ |
118 | |
119 | #include "ppport.h" |
120 | |
121 | /* ========== BEGIN XSMISC ================================================== */ |
122 | |
123 | __XSMISC__ |
124 | |
125 | /* =========== END XSMISC =================================================== */ |
126 | |
127 | MODULE = Devel::PPPort PACKAGE = Devel::PPPort |
128 | |
129 | BOOT: |
130 | __XSBOOT__ |
131 | |
132 | __XSUBS__ |