Index: branches/simtest_nebulous_branches/psconfig/pschecklibs
===================================================================
--- branches/simtest_nebulous_branches/psconfig/pschecklibs	(revision 25061)
+++ branches/simtest_nebulous_branches/psconfig/pschecklibs	(revision 27840)
@@ -11,4 +11,6 @@
 $version = "";
 $build = 0;
+$list_modules = 0;
+my $only = "";
 my %force;
 my %done;                       # Tarballs that have been processed
@@ -35,4 +37,9 @@
         shift; shift; next;
     }
+    if ($ARGV[0] eq "-only") {
+        if (@ARGV < 2) { die "-only must be coupled to a library name\n"; }
+	$only = lc($ARGV[1]);
+        shift; shift; next;
+    }
     if ($ARGV[0] eq "-h")     { &usage (); }
     if ($ARGV[0] eq "help")   { &usage (); }
@@ -40,4 +47,5 @@
     if ($ARGV[0] eq "--help") { &usage (); }
     if ($ARGV[0] eq "-list")  { &list_distributions(); }
+    if ($ARGV[0] eq "-modules") { $list_modules = 1; shift; next; }
     @tARGV = (@tARGV, $ARGV[0]);
     shift;
@@ -59,4 +67,6 @@
 close (FILE);
 
+if ($list_modules) { &list_modules(); }
+
 # set the psconfig version:
 if ("$version" eq "") {
@@ -65,4 +75,12 @@
 if ("$version" eq "") {
     $version = "default";
+}
+
+# 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");
 }
 
@@ -146,4 +164,5 @@
     if (($auto_force ne "Y") && ($auto_force ne "N")) { die "invalid value for auto_force field\n"; }
 
+    if ($only && ($only ne lc($name))) { next; }
 
     if ((defined $force{lc($name)} or defined $force{'all'}) and
@@ -501,5 +520,8 @@
 
 sub usage {
-    print STDERR "USAGE: pschecklibs [-version] [-build]\n";
+    print STDERR "USAGE: pschecklibs [-version] [-build] [-only module] [-force module] [-force all]\n";
+    print STDERR "  multiple [-force (module)] options may be specified\n";
+    print STDERR "USAGE: pschecklibs [-list] : show C libraries file\n";
+    print STDERR "USAGE: pschecklibs [-modules] : list available C modules\n";
     exit 2;
 }
@@ -521,4 +543,22 @@
 }
 
+sub list_modules {
+
+    foreach $line (@list) {
+	chop $line;
+	if ($line =~ m|^\s*$|) { next; }
+	if ($line =~ m|^\s*\#|) { next; }
+
+	($type, $name, $altnames, $altpaths, $tarball, $tardir, $auto_force, $configure_opts, $make_opts, $install_opts) = split (" ", $line);
+	if ($type eq "bin") {
+	    print STDERR "bin: $name\n";
+	}
+	if ($type eq "lib") {
+	    print STDERR "lib: $name\n";
+	}
+    }
+    exit 0;
+}
+
 sub failure {
     system ("ls");
