forked from GMOD/GBrowse
/
Makefile.PL
426 lines (366 loc) · 13.1 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
#!/usr/bin/perl
use lib './install_util';
use ExtUtils::MakeMaker;
use GuessDirectories;
use FindBin '$Bin';
use Cwd;
require 5.005003;
my $VERSION = '1.64';
my $working_dir = cwd;
my @OPTIONS = qw(APACHE CONF HTDOCS CGIBIN
LIB BIN
DO_XS NONROOT SELINUX);
my $OPTIONS = join ('|',@OPTIONS);
my %OPTIONS;
my @argv = @ARGV;
@ARGV = ();
foreach (@argv) {
if (/^--?h/i) {
die <<END;
To customize install locations, provide one or more of the options
APACHE, CONF, HTDOCS, or CGIBIN, as in CONF=/usr/local/apache/conf.
For RedHat Linux, you will want to use:
perl Makefile.PL CONF=/etc/httpd/conf \\
HTDOCS=/var/www/html \\
CGIBIN=/var/www/cgi-bin \\
DO_XS=1
For Macintosh OS X, you will want to use:
perl Makefile.PL CONF=/etc/httpd \\
HTDOCS=/Library/WebServer/Documents \\
CGIBIN=/Library/WebServer/CGI-Executables \\
DO_XS=1
For Slackware systems, you will want to use:
perl Makefile.PL CONF=/etc/apache \\
HTDOCS=/var/www/htdocs \\
CGIBIN=/var/www/cgi-bin \\
DO_XS=1
For most versions of Apache built from source code, use:
perl Makefile.PL APACHE=/usr/local/apache DO_XS=1
To install as a user without root privileges, in addition to
the arguments above, provide the arguments NONROOT=1,
LIB=/path/to/perl/libs and BIN=/path/to/scripts
For example:
perl Makefile.PL APACHE=~/gbrowse/www \\
LIB=~/gbrowse/lib \\
BIN=~/gbrowse/bin \\
NONROOT=1
will perform a non-privileged installation that places all gbrowse
components (including perl libraries) in the path ~/gbrowse.
To make the CGI scipts aware of the custom library location, you can
either ask someone with root privileges to edit the apache
configuration file or define the environmental variable $PERL5LIB for
the owner of the httpd processes serving gbrowse. Failing that, you
will want to add the line
use lib "$ENV{HOME}/gbrowse/lib";
to each of the CGI scripts.
If you have a C compiler and wish to compile the XS extensions, set
DO_XS=1. Currently all this does is to speed up the multiple
alignment plugin.
END
;
}
elsif (/($OPTIONS)=(.+)/og) {
$OPTIONS{$1} = interpolate($2);
}
else {
push @ARGV,$_;
}
}
if (-e 'GGB.def' && !%OPTIONS) {
print STDERR "\nShould I use your previous settings to set the file paths and options (y/n) [y]? ";
chomp (my $line = <>);
if (!$line || $line =~ /^[yY]/) {
print STDERR "Using previous settings for file paths and options.\n";
open F,'GGB.def' or die "GGB.def: $!";
while (<F>) {
chomp;
next if /^\#/;
next unless /^($OPTIONS)=(.+)/o;
$OPTIONS{$1} = interpolate($2);
}
close F;
}
}
if(-e '/proc/filesystems'
&& `grep selinux /proc/filesystems`
&& !$OPTIONS{SELINUX} ) {
die <<"END"
------------------------------------------------------------------
WARNING:
You appear to have SELinux installed on this computer.
GBrowse can have problems working on SELinux systems.
Before you complete this installation please read 'README.fedora'
Then you can avoid this message by adding the flag --SELINUX=1 when
you execute perl Makefile.PL.
------------------------------------------------------------------
perl Makefile.PL aborted.
END
;
}
$OPTIONS{APACHE} ||= $OPTIONS{PREFIX} if exists $OPTIONS{PREFIX};
$OPTIONS{BIN} ||= $OPTIONS{INSTALLSCRIPT} if exists $OPTIONS{INSTALLSCRIPT};
if ($OPTIONS{APACHE} && !(defined $OPTIONS{CONF})) {
$OPTIONS{CONF} = "$OPTIONS{APACHE}/conf";
}
if ($OPTIONS{APACHE} && !(defined $OPTIONS{HTDOCS})) {
$OPTIONS{HTDOCS} = "$OPTIONS{APACHE}/htdocs";
}
if ($OPTIONS{APACHE} && !(defined $OPTIONS{CGIBIN})) {
$OPTIONS{CGIBIN} = "$OPTIONS{APACHE}/cgi-bin";
}
# set hard-coded values
$OPTIONS{APACHE} ||= '/usr/local/apache';
unless ($OPTIONS{CONF}) {
$OPTIONS{CONF} = GuessDirectories->conf || "$OPTIONS{APACHE}/conf";
}
unless ($OPTIONS{HTDOCS}) {
$OPTIONS{HTDOCS} = GuessDirectories->htdocs || "$OPTIONS{APACHE}/htdocs";
}
unless ($OPTIONS{CGIBIN}) {
$OPTIONS{CGIBIN} = GuessDirectories->cgibin || "$OPTIONS{APACHE}/cgi-bin";
}
unless (defined $OPTIONS{DO_XS}) {
$OPTIONS{DO_XS} = $^O =~ /^(MSWin|dos)/i ? '' : 1;
}
# look for non-root installation
if (defined $OPTIONS{NONROOT}) {
$OPTIONS{INSTALLSITEMAN3DIR} = 'none';
$OPTIONS{INSTALLSITEMAN1DIR} = 'none';
}
# workaround for known bug in FindBin library
$Bin = "." if -f './Makefile.PL' && -T './Makefile.PL';
my $biographics_version = biographics_version();
my $patch_version = biographics_patch_version();
my $bioperl_needs_patching = $biographics_version < $patch_version;
open F,">$Bin/GGB.def" or die "Can't open $Bin/GGB.def for writing: $!";
print F "# This hints file contains configuration information used by the generic browser\n\n";
print F "# To reconfigure, run perl Makefile.PL `cat GGB.def`\n\n";
foreach (keys %OPTIONS) {
print F "$_=$OPTIONS{$_}\n";
}
print F "VERSION=$VERSION\n";
print F "BIOGRAPHICS_VERSION=$biographics_version\n";
close F;
print STDERR <<END;
----------------------------------------------
File Paths
END
;
foreach (@OPTIONS) {
printf STDERR "%7s %s\n",$_,$OPTIONS{$_};
}
print STDERR <<END;
(Run perl Makefile.PL -h for help on changing)
----------------------------------------------
END
;
if ($bioperl_needs_patching) {
print STDERR "\nInstalled Bio::Graphics version $biographics_version is less than desired version $patch_version. I will update to latest versions of the BioGraphics and GFF libraries.\n";
}
my @dir = ();
push @dir,'libalign' if $OPTIONS{DO_XS};
push @dir,'extras/BioPerl' if $bioperl_needs_patching;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
'NAME' => 'Generic-Genome-Browser',
'VERSION' => $VERSION,
'PREREQ_PM' => {
Bio::Perl => 1.5,
#Bio::Root::Version => 1.5,
GD => 2.07,
IO::String => 0,
Text::Shellwords => 1.08,
CGI::Session => 4.03,
}, # e.g., Module::Name => 1.1
PL_FILES => {
'install_util/htdocs_install.PLS' => 'install_util/htdocs_install.pl',
'install_util/cgi_install.PLS' => 'install_util/cgi_install.pl',
'install_util/conf_install.PLS' => 'install_util/conf_install.pl',
'bin/bp_load_gff.PLS' => 'bin/bp_load_gff.pl',
'bin/make_das_conf.PLS' => 'bin/make_das_conf.pl',
'bin/process_sgd.PLS' => 'bin/process_sgd.pl',
'bin/process_gadfly.PLS' => 'bin/process_gadfly.pl',
'bin/process_wormbase.PLS' => 'bin/process_wormbase.pl',
'bin/ucsc_genes2gff.PLS' => 'bin/ucsc_genes2gff.pl',
'bin/load_genbank.PLS' => 'bin/load_genbank.pl',
'bin/register_moby_services.PLS' => 'bin/register_moby_services.pl',
'install_util/gbrowse_ppm_install.PLS' => 'install_util/gbrowse_ppm_install.pl',
'cgi-bin/gbrowse.PLS' => 'cgi-bin/gbrowse',
'cgi-bin/gbrowse_img.PLS' => 'cgi-bin/gbrowse_img',
'cgi-bin/gbrowse_details.PLS' => 'cgi-bin/gbrowse_details',
'cgi-bin/gbrowse_est.PLS' => 'cgi-bin/gbrowse_est',
'cgi-bin/gbrowse_moby.PLS' => 'cgi-bin/gbrowse_moby',
'cgi-bin/moby_server.PLS' => 'cgi-bin/moby_server',
'cgi-bin/das.PLS' => 'cgi-bin/das',
'conf/MobyServices/GbrowseServices.PMS' => 'conf/MobyServices/GbrowseServices.pm',
},
EXE_FILES => [
'bin/register_moby_services.pl',
'bin/make_das_conf.pl',
'bin/process_wormbase.pl',
'bin/process_sgd.pl',
'bin/process_gadfly.pl',
'bin/load_genbank.pl',
],
'LIBS' => [''], # e.g., '-lm'
'LIB' => $OPTIONS{LIB}, # custom location for perl modules
'DIR' => \@dir,
'DEFINE' => '',
'INC' => '', # e.g., '-I/usr/include/other'
($] ge '5.005') ? (
'AUTHOR' => 'Lincoln Stein (lstein@cshl.org)',
'ABSTRACT' => 'A CGI-driven browser for genomic annotations.',
) : (),
'INSTALLSITEMAN1DIR' => $OPTIONS{INSTALLSITEMAN1DIR}, # don't install man pages for
'INSTALLSITEMAN3DIR' => $OPTIONS{INSTALLSITEMAN3DIR}, # non-root user
'INSTALLSCRIPT' => $OPTIONS{BIN} || $OPTIONS{INSTALLSCRIPT}
);
sub biographics_version {
delete $INC{'Bio/Graphics/Panel.pm'};
eval <<'END' || 0;
require Bio::Graphics::Panel;
Bio::Graphics::Panel->api_version;
END
}
sub biographics_patch_version {
delete $INC{'Bio/Graphics/Panel.pm'};
my @inc = @INC;
local @INC = @inc;
unshift @INC,'./extras/BioPerl';
require Bio::Graphics::Panel;
Bio::Graphics::Panel->api_version;
}
sub interpolate {
my $path = shift;
my ($to_expand,$homedir);
return $path unless $path =~ m!^~([^/]*)!;
eval {
if ($to_expand = $1) {
$homedir = (getpwnam($to_expand))[7];
} else {
$homedir = (getpwuid($<))[7];
}
return $path unless $homedir;
$path =~ s!^~[^/]*!$homedir!;
};
return $path;
}
sub MY::clean {
package MY;
my $inherited = shift->SUPER::clean(@_);
$inherited .= "\t-\$(PERL) install_util/make_clean_add.pl\n";
$inherited;
}
sub MY::dist_dir {
package MY;
my $inherited = shift->SUPER::dist_dir(@_);
$inherited =~ s!^(\s+.+)!\tpod2text docs/pod/INSTALL.pod > INSTALL\n$1!m;
$inherited;
}
sub MY::processPL {
package MY;
my $inherited = shift->SUPER::processPL(@_);
$inherited =~ s/(cgi-bin\/gbrowse\w*)\s\:\:.+/$1 : FORCE/g;
$inherited;
}
sub MY::install {
package MY;
my $inherited = shift->SUPER::install(@_);
$inherited =~ s/doc_install/doc_install conf_install cgi_install htdocs_install/;
$inherited;
}
sub MY::postamble {
my $paths;
for my $key (keys %OPTIONS) {
$paths .= qq('$key=$OPTIONS{$key}' ) if defined $OPTIONS{$key};
}
qq{
conf_install ::
\$(PERL) \"$working_dir/install_util/conf_install.pl\" $paths
htdocs_install ::
\$(PERL) \"$working_dir/install_util/htdocs_install.pl\" $paths
cgi_install ::
\$(PERL) \"$working_dir/install_util/cgi_install.pl\" $paths
};
}
sub MY::libscan {
package MY;
my $self = shift;
my $from = shift;
my $to = $self->SUPER::libscan($from);
return undef if $to=~/README/;
return $to;
}
sub MY::ppd {
package MY;
my $repository = 'http://www.gmod.org/ggb/ppm';
my $arch = 'MSWin32-x86-multi-thread';
my $inherited = shift->SUPER::ppd(@_);
my $implementation;
my $newimp;
my $oldMM =0;
#VERY irritating--different versions of ExtUtils::MakeMaker has
#different ways of generating the ppd file.
if ($inherited =~ /qq\{(<S.*R>\\n)\}.*qq\{(\\t<I.*\/>\\n)\}.*qq\{(\\t\\t<O.*G>\\n)\}/sg){
$oldMM=1;
my $xml = $1.$2.$3;
#warn "$xml\n";
$inherited =~ s/qq\{.*>>/qq{$xml}" >/s;
} elsif ($inherited =~ /NOECHO/) {
my @la = split /\n/, $inherited;
my $grab = 0;
for (@la) {
$grab++ if (m!<IMPLEMENTATION>!);
if ($grab and $_ =~ /\'(.*)\'/) {
$implementation .= "$1\n";
}
$grab = 0 if (m!</IMPLEMENTATION>!);
}
}
if ($oldMM and $inherited =~ /(\s*\<IMPLEMENTATION\>.*\<\/IMPLEMENTATION\>)/m) {
$implementation = $newimp = $1;
$newimp =~ s/ARCHITECTURE NAME=\\"\S+\\"/ARCHITECTURE NAME=\\"$arch\\"/;
$newimp =~ s/\$\(OSNAME\)/MSWin32/;
my $impl58 = $newimp;
$impl58 =~ s/\Q$arch\E/$arch\-5\.8/;
$newimp .= "\\n\\t\\t$impl58";
$inherited =~ s/\Q$implementation\E/$newimp/;
} elsif (!$oldMM and $implementation) {
$newimp = $implementation;
$newimp =~ s/ARCHITECTURE NAME="\S+"/ARCHITECTURE NAME="$arch"/;
$newimp =~ s/\$\(OSNAME\)/MSWin32/;
my $impl58 = $newimp;
$impl58 =~ s/\Q$arch\E/$arch\-5\.8/;
$newimp .= $impl58;
my @la = split /\n/, $newimp;
for my $line (@la) {
$line = qq{\t\$(NOECHO) \$(ECHO) '$line' >> \$(DISTNAME).ppd};
}
my @inherit_array = split /\n/, $inherited;
my @newinherit;
$inherited = '';
for (@inherit_array) {
if (/<IMPLEMENTATION>/) {
push @newinherit, @la;
last;
} else {
push @newinherit, $_;
}
}
push @newinherit, qq{\t\$(NOECHO) \$(ECHO) '</SOFTPKG>' >> \$(DISTNAME).ppd\n};
$inherited = join "\n", @newinherit;
}
$inherited .= <<END;
\@echo "creating Generic-Genome-Browser.ppd"
\@echo "creating gbrowse_ppm_support_files-$VERSION.tar.gz"
\@\$(TAR) zcf gbrowse_ppm_support_files-$VERSION.tar.gz --exclude CVS --exclude '*~' --exclude '*.PLS' --exclude '.*' --exclude README --exclude '#*' DISCLAIMER INSTALL docs htdocs conf cgi-bin install_util sample_data contrib
\@echo "creating gbrowse_ppm-$VERSION.tar.gz"
\@\$(TAR) zcf gbrowse_ppm-$VERSION.tar.gz --exclude man1 --exclude man3 blib
\@perl -pi -e 's!HREF=""!HREF="$repository/gbrowse_ppm-$VERSION.tar.gz"!' Generic-Genome-Browser.ppd
\@perl -pi -e 's!(\\s*</IMPLEMENTATION>)!\\t\\t<INSTALL HREF="$repository/install_util/gbrowse_ppm_install.pl" EXEC="PPM_PERL" />\\n\\1!' Generic-Genome-Browser.ppd
\@perl -pi -e 's!Bio-Perl!bioperl!' Generic-Genome-Browser.ppd
\@cp install_util/gbrowse_ppm_install.pl .
END
;
}