cvsuser 04/10/03 21:18:52
Modified: tools/dev install_files.pl
Log:
Make this have some hope of working portably.
Revision Changes Path
1.5 +24 -9 parrot/tools/dev/install_files.pl
Index: install_files.pl
===================================================================
RCS file: /cvs/public/parrot/tools/dev/install_files.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -r1.4 -r1.5
--- install_files.pl 29 Sep 2004 06:24:50 -0000 1.4
+++ install_files.pl 4 Oct 2004 04:18:52 -0000 1.5
@@ -1,7 +1,7 @@
#! perl -w
################################################################################
# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-# $Id: install_files.pl,v 1.4 2004/09/29 06:24:50 sfink Exp $
+# $Id: install_files.pl,v 1.5 2004/10/04 04:18:52 sfink Exp $
################################################################################
=head1 TITLE
@@ -111,8 +111,12 @@
################################################################################
use File::Basename qw(dirname);
+use File::Copy;
+use File::Spec;
use strict;
+# When run from the makefile, which is probably the only time this
+# script will ever be used, all of these defaults will get overridden.
my %options = ( buildprefix => '',
prefix => '/usr',
exec_prefix => '/usr',
@@ -148,26 +152,37 @@
$meta{$_} = 1 for (keys %meta); # Laziness
if ($meta{lib}) {
- $dest = "$options{libdir}/$dest";
+ $dest = File::Spec->catdir($options{libdir}, $dest);
} elsif ($meta{bin}) {
- $dest = "$options{bindir}/$dest";
+ $dest = File::Spec->catdir($options{bindir}, $dest);
} elsif ($meta{include}) {
- $dest = "$options{includedir}/$dest";
+ $dest = File::Spec->catdir($options{includedir}, $dest);
} else {
- $dest = "$options{prefix}/$dest";
+ $dest = File::Spec->catdir($options{prefix}, $dest);
}
- $dest = "$options{buildprefix}/$dest" if $options{buildprefix};
+ $dest = File::Spec->catdir($options{buildprefix}, $dest)
+ if $options{buildprefix};
$directories{dirname($dest)} = 1;
push(@files, [ $src => $dest ]);
}
-foreach (sort keys %directories) {
- print "install -d $_\n";
+for my $dir (keys %directories) {
+ unless (-d $dir) {
+ # Make full path to the directory $dir
+ my @dirs;
+ while (! -d $dir) { # Scan up to nearest existing ancestor
+ unshift @dirs, $dir;
+ $dir = dirname($dir);
+ }
+ foreach (@dirs) {
+ mkdir($_, 0777) or die "mkdir $_: $!";
+ }
+ }
}
foreach (@files) {
my ($src, $dest) = @$_;
- print "install -c $src $dest\n";
+ copy($src, $dest) or die "copy $src to $dest: $!";
}