/
Makefile.PL
184 lines (159 loc) · 4.92 KB
/
Makefile.PL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
###############################################################################
#
# $Id: Makefile.PL,v 1.32 2003/02/18 10:34:57 rjray Exp $
#
# This is the MakeMaker skeleton for the RPC-XML extension. Besides the usual
# tricks, this has to add rules to make the *.xpl files from *.code in the
# methods/ subdir, as well as get them into a place where they get installed
# correctly.
#
###############################################################################
use ExtUtils::MakeMaker;
use File::Spec;
use File::Find;
use Cwd 'cwd';
$cwd = cwd;
$CLEAN = 'pod2html-* *.html *.spec *.rpm rpmrc rpmmacro *.log t/*.log ';
@scripts = (File::Spec->catfile(qw(etc make_method)));
$CLEAN .= File::Spec->catfile(qw(methods *.xpl));
@PM_FILES = ();
find(sub { push(@PM_FILES, $File::Find::name) if (-f $_ and /\.pm$/) }, 'lib');
# Exclude Apache2 stuff until it's ready for deployment
@PM_FILES = grep(! /Apache2/, @PM_FILES);
%PM_FILES = map { ($temp = $_) =~ s|^lib|\$\(INST_LIB\)|; $_ => $temp }
@PM_FILES;
# Handle the method code in "methods" specially:
find(sub {
if (-f $_ and /\.base$/)
{
s/\.base$//;
$PM_FILES{File::Spec->catfile('methods', "$_.xpl")} =
File::Spec->catfile('$(INST_LIB)', 'RPC', 'XML', "$_.xpl");
}
}, 'methods');
# Anything stuck under "lib" is more generic
find(sub {
if (-f $_ and /\.base$/)
{
$File::Find::name =~ s/base$/xpl/;
($tmp = $File::Find::name) =~ s|^lib|\$(INST_LIB)|;
$PM_FILES{$File::Find::name} = $tmp;
$CLEAN .= " $File::Find::name";
}
}, 'lib');
WriteMakefile(
NAME => 'RPC::XML',
VERSION => '0.53',
AUTHOR => 'Randy J. Ray',
ABSTRACT => 'Data, client and server classes for XML-RPC',
EXE_FILES => \@scripts,
PM => \%PM_FILES,
PREREQ_PM => { XML::Parser => 2.25,
File::Spec => 0.8,
LWP => 0 },
dist => { COMPRESS => 'gzip -9f' },
clean => { FILES => $CLEAN },
);
sub MY::post_initialize
{
my $self = shift;
my @text;
my $makemeth = File::Spec->catfile(qw(etc make_method));
push(@text,
'.SUFFIXES: .xpl .base',
'',
'.base.xpl:',
"\t\$(PERL) $makemeth --base=\$*",
'');
join("\n", @text);
}
sub MY::tools_other
{
package MY;
my $text = shift->SUPER::tools_other(@_);
"$text\nECHO=\@echo\nRPM=rpmbuild\n";
}
sub MY::post_constants
{
my $self = shift;
"SPECFILE=perl-$self->{DISTNAME}.spec";
}
sub MY::postamble
{
my $self = shift;
my @text;
my $makemeth = File::Spec->catfile(qw(etc make_method));
if (-e 'spec.in' and -f _)
{
#
# Generate the spec file from spec.in with substitutions
#
print "Generating perl-$self->{DISTNAME}.spec...\n";
$self->{RELEASE} = 1 unless $self->{RELEASE};
$self->{INSTALLDIR} = $Config{installsitelib}
unless $self->{INSTALLDIR};
open(SPECI, "< spec.in");
if ($?)
{
die "Error opening template spec file: $!, stopped";
}
open(SPECO, "> perl-$self->{DISTNAME}.spec");
if ($?)
{
die "Error creating output spec file: $!, stopped";
}
for (<SPECI>)
{
s/(\$\{(\w+)\})/$self->{$2}/eg;
print SPECO $_;
}
close(SPECO); close(SPECI);
print "Generating rpmrc...\n";
open(RPMRC, "> rpmrc");
if ($?)
{
die "Error creating rpmrc file: $!, stopped";
}
else
{
print RPMRC <<END_rpmrc;
include: /usr/lib/rpm/rpmrc
macrofiles: /usr/lib/rpm/macros:rpmmacro
END_rpmrc
close(RPMRC);
}
print "Generating rpmmacros...\n";
open(MACRO, "> rpmmacro");
if ($?)
{
die "Error creating macro file: $!, stopped";
}
else
{
print MACRO <<END_macro;
%_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm
%_builddir %{_topdir}
%_sourcedir %{_topdir}
%_specdir %{_topdir}
%_srcrpmdir %{_topdir}
%_rpmdir %{_topdir}
%_topdir $cwd
END_macro
close(MACRO);
}
# Create the rules that create RPM and SRPM files
push(@text, qq{
rpm: \$(SPECFILE) \$(DISTVNAME).tar\$(SUFFIX)
\t\$(RPM) -bb --clean --rcfile rpmrc \$(SPECFILE)
srpm: \$(SPECFILE) \$(DISTVNAME).tar\$(SUFFIX)
\t\$(RPM) -bs --clean --rcfile rpmrc \$(SPECFILE)
});
}
# Create the dependancy rules for the methods/XPL files
for (sort grep(/\.xpl$/, keys %::PM_FILES))
{
s/\.xpl$//;
push(@text, "$_.xpl: $_.base $_.help $_.code $makemeth");
}
join("\n", @text);
}