summaryrefslogtreecommitdiff
path: root/prj_install.pl
diff options
context:
space:
mode:
authorelliott_c <ocielliottc@users.noreply.github.com>2007-02-26 13:13:52 +0000
committerelliott_c <ocielliottc@users.noreply.github.com>2007-02-26 13:13:52 +0000
commit89cb635e4c34540708b8f1a5296a91d5cac10e10 (patch)
tree579208e17276caa645e572c9bc2ca72722900c1c /prj_install.pl
parent8b2c9b9821d493305b76e04c1bfd18fb5bcfc11f (diff)
downloadMPC-89cb635e4c34540708b8f1a5296a91d5cac10e10.tar.gz
ChangeLogTag: Mon Feb 26 13:09:44 UTC 2007 Chad Elliott <elliott_c@ociweb.com>
Diffstat (limited to 'prj_install.pl')
-rwxr-xr-xprj_install.pl33
1 files changed, 27 insertions, 6 deletions
diff --git a/prj_install.pl b/prj_install.pl
index c0dc0d61..1bd46153 100755
--- a/prj_install.pl
+++ b/prj_install.pl
@@ -13,6 +13,7 @@ eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}'
# ******************************************************************
use strict;
+use Cwd;
use FileHandle;
use File::Copy;
use File::Basename;
@@ -22,7 +23,7 @@ use File::Basename;
# ******************************************************************
my($insext) = 'ins';
-my($version) = '1.6';
+my($version) = '1.7';
my(%defaults) = ('header_files' => 1,
'idl_files' => 1,
'inline_files' => 1,
@@ -39,6 +40,9 @@ my(%base) = ();
my(%override) = ();
my($keepgoing) = 0;
+eval 'symlink("", "");';
+my($hasSymlink) = ($@ eq '');
+
# ******************************************************************
# Subroutine Section
# ******************************************************************
@@ -46,7 +50,10 @@ my($keepgoing) = 0;
sub copyFiles {
my($files) = shift;
my($insdir) = shift;
+ my($symlink) = shift;
my($verbose) = shift;
+ my($type) = ($symlink ? 'link' : 'copy');
+ my($cwd) = getcwd();
foreach my $file (@$files) {
my($dest) = $insdir . '/' .
@@ -63,10 +70,18 @@ sub copyFiles {
if (! -e $dest || (-M $file) < (-M $dest)) {
if ($verbose) {
- print "Copying to $dest\n";
+ print '', ($symlink ? 'Linking' : 'Copying'), " to $dest\n";
+ }
+ my($status) = undef;
+ if ($symlink) {
+ unlink($dest);
+ $status = symlink("$cwd/$file", $dest);
}
- if (!copy($file, $dest)) {
- print STDERR "ERROR: Unable to copy $file to $dest\n";
+ else {
+ $status = copy($file, $dest);
+ }
+ if (!$status) {
+ print STDERR "ERROR: Unable to $type $file to $dest\n";
if (!$keepgoing) {
return 0;
}
@@ -241,7 +256,8 @@ sub usageAndExit {
my($base) = basename($0);
my($spc) = ' ' x (length($base) + 8);
print STDERR "$base v$version\n",
- "Usage: $base [-a tag1[,tagN]] [-b tag=dir] [-o tag=dir]\n",
+ "Usage: $base [-a tag1[,tagN]] [-b tag=dir] ",
+ ($hasSymlink ? '[-l] ' : ''), "[-o tag=dir]\n",
$spc, "[-s tag1[,tagN]] [-v] [-k] [install directory]\n",
$spc, "[$insext files or directories]\n\n",
"Install files matching the tag specifications found ",
@@ -249,6 +265,7 @@ sub usageAndExit {
"-a Adds to the default set of tags that get copied.\n",
"-b Install tag into dir underneath the install directory.\n",
"-k Keep going if a file to be copied is missing.\n",
+ ($hasSymlink ? "-l Use symbolic links instead of copying.\n" : ''),
"-o Install tag into dir.\n",
"-s Sets the tags that get copied.\n",
"-v Enables verbose mode.\n",
@@ -271,6 +288,7 @@ sub usageAndExit {
my($verbose) = undef;
my($first) = 1;
my($insdir) = undef;
+my($symlink) = undef;
my(@insfiles) = ();
my(%tags) = %defaults;
@@ -305,6 +323,9 @@ for(my $i = 0; $i <= $#ARGV; ++$i) {
elsif ($arg eq '-k') {
$keepgoing = 1;
}
+ elsif ($arg eq '-l') {
+ $symlink = $hasSymlink;
+ }
elsif ($arg eq '-o') {
++$i;
if (defined $ARGV[$i]) {
@@ -365,7 +386,7 @@ elsif (!defined $insfiles[0]) {
my($status) = 1;
my(@files) = loadInsFiles(\@insfiles, \%tags, $verbose);
if (defined $files[0]) {
- $status = (copyFiles(\@files, $insdir, $verbose) ? 0 : 1);
+ $status = (copyFiles(\@files, $insdir, $symlink, $verbose) ? 0 : 1);
}
exit($status);