Index: branches/simtest_nebulous_branches/psconfig/pscheckperl
===================================================================
--- branches/simtest_nebulous_branches/psconfig/pscheckperl	(revision 25061)
+++ branches/simtest_nebulous_branches/psconfig/pscheckperl	(revision 27840)
@@ -9,15 +9,16 @@
 for (; @ARGV > 0; ) {
     if ($ARGV[0] eq "-version") {
-	$version = $ARGV[1];
+        $version = $ARGV[1];
         shift; shift; next;
     }
     if ($ARGV[0] eq "-build") {
-	$build = 1;
+        $build = 1;
         shift; next;
     }
     if ($ARGV[0] eq "-force") {
-	$force{$ARGV[1]} = 1;
-	shift; shift; next;
+        $force{$ARGV[1]} = 1;
+        shift; shift; next;
     }
+    if ($ARGV[0] eq "-path")  { &list_include_path (); }
     if ($ARGV[0] eq "-h")     { &usage (); }
     if ($ARGV[0] eq "help")   { &usage (); }
@@ -31,5 +32,5 @@
 if ( @ARGV > 1) { &usage(); }
 
-if ( @ARGV == 0) { 
+if ( @ARGV == 0) {
     @list = <$tagsets/*.perl>;
     $file = $list[-1];
@@ -52,4 +53,11 @@
 }
 
+# generate new psconfig.csh if needed
+if (! -e "psconfig.csh" || ! -e "psconfig.bash") {
+    $psconfdir = $ENV{'PSCONFDIR'};
+    if ($psconfdir eq "") { die "PSCONFDIR not found, run psbuild -bootstrap and follow instructions\n"; }
+    vsystem ("cat psconfig.csh.in | sed 's|\@PSCONFDIR@|$psconfdir|' > psconfig.csh");
+    vsystem ("cat psconfig.bash.in | sed 's|\@PSCONFDIR@|$psconfdir|' > psconfig.bash");
+}
 
 $prefix  = `csh -f psconfig.csh --prefix $version`; chomp $prefix;
@@ -77,22 +85,29 @@
     if ($line =~ m|^\s*\#|) { next; }
 
-    ($N, $module, $tarball, $modver, $prompts) = split (" ", $line);
+    $Nvalue = ($N, $module, $tarball, $modver, $buildopts, $prompts) = split (" ", $line);
+    if ($Nvalue < 6) {
+        print "Error in perl module config line $line\n";
+        exit 1;
+    }
+    # print "N: $N, module: $module, tarball: $tarball, modver: $modver, buildopts: $buildopts, prompts: $prompts\n";
 
-    if ($modver eq "") { $modver = 0; } 
+    # we require the number of fields to be fixed, so this test is now invalid:
+    # if ($modver eq "") { $modver = 0; }
+
     system ("pscheckmods $module $modver");
-    if (($? == 0) and not defined $force{$module} and not defined $force{'all'}) { 
-	# print "$module: found\n";
-	next; 
+    if (($? == 0) and not defined $force{$module} and not defined $force{'all'}) {
+        # print "$module: found\n";
+        next;
     }
 
     if (defined $force{$module}) {
-	print "$module: force\n";
+        print "$module: force\n";
     } else {
-	print "$module: missing\n";
+        print "$module: missing\n";
     }
-    unless ($build or defined $force{$module} or defined $force{'all'}) { 
-	$Nmissing ++;
-	push @missing, $module;
-	next; 
+    unless ($build or defined $force{$module} or defined $force{'all'}) {
+        $Nmissing ++;
+        push @missing, $module;
+        next;
     }
 
@@ -102,5 +117,5 @@
     print "extract $module from $tarball\n";
     vsystem ("tar xvzf $tarball");
-    
+
     ($tardir) = $tarball =~ m|(\S*).tar.gz|;
     print "tardir: $tardir\n";
@@ -108,18 +123,28 @@
     chdir $tardir;
 
-    # build the MakeMaker makefile, setting the output directories
-    if ($prompts) {
-	@answers = split (",", $prompts);
-	open (PIPE, "|perl Makefile.PL PREFIX=$prefix LIB=$perldir");
-	foreach $answer (@answers) {
-	    print PIPE "$answer\n";
-	}
-	close (PIPE);
+    # we use NONE as the empty word
+    if ($buildopts eq "NONE") { $buildopts = ""; }
+    if ($prompts eq "NONE") { $prompts = ""; }
+
+    if (-e "Build.PL" and $module ne "Params::Validate" and $module ne "DateTime::TimeZone") {
+        # vsystem("perl Build.PL --install_path lib=$perldir ");
+        vsystem("perl Build.PL --install_base $prefix $buildopts");
+        vsystem("Build");
+        vsystem("Build install");
     } else {
-	vsystem ("perl Makefile.PL PREFIX=$prefix LIB=$perldir");
+        # build the MakeMaker makefile, setting the output directories
+        if ($prompts) {
+            @answers = split (",", $prompts);
+            open (PIPE, "|perl Makefile.PL PREFIX=$prefix LIB=$perldir $buildopts");
+            foreach $answer (@answers) {
+                print PIPE "$answer\n";
+            }
+            close (PIPE);
+        } else {
+            vsystem ("perl Makefile.PL PREFIX=$prefix LIB=$perldir $buildopts");
+        }
+        vsystem ("make < /dev/null");
+        vsystem ("make install");
     }
-    
-    vsystem ("make < /dev/null");
-    vsystem ("make install");
 
     chdir $homedir;
@@ -127,11 +152,11 @@
 if (!$build) {
     if ($Nmissing > 0) {
-	print "The following $Nmissing perl modules are missing from your system\n";
-	foreach $name (@missing) {
-	    print "  $name\n";
-	}
-	print "you may install them in your local path by re-running pscheckperl with -build\n";
+        print "The following $Nmissing perl modules are missing from your system\n";
+        foreach $name (@missing) {
+            print "  $name\n";
+        }
+        print "you may install them in your local path by re-running pscheckperl with -build\n";
     } else {
-	print "no perl modules are missing from your system\n";
+        print "no perl modules are missing from your system\n";
     }
 }
@@ -139,5 +164,5 @@
 
 sub usage {
-    print STDERR "USAGE: pscheckperl [-version] [-build]\n";
+    print STDERR "USAGE: pscheckperl [-version] [-build] [-path]\n";
     exit 2;
 }
@@ -152,8 +177,15 @@
     @list = <$tagsets/*.perl>;
     foreach $line (@list) {
-	chomp $line;
-	($dist) = $line =~ m|$tagsets/(\S*).perl|;
-	print STDERR "$dist\n";
+        chomp $line;
+        ($dist) = $line =~ m|$tagsets/(\S*).perl|;
+        print STDERR "$dist\n";
     }
     exit 2;
 }
+
+sub list_include_path {
+    foreach $path (@INC) {
+        print STDERR "$path\n";
+    }
+    exit 2;
+}
