Index: trunk/psModules/src/config/pmConfig.c
===================================================================
--- trunk/psModules/src/config/pmConfig.c	(revision 7920)
+++ trunk/psModules/src/config/pmConfig.c	(revision 8064)
@@ -3,6 +3,6 @@
  *  @author PAP, IfA
  *
- *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-07-18 00:56:49 $
+ *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-08-02 05:03:50 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -638,64 +638,68 @@
     // We could use psMetadataCopy for this, but it's better to check that everything's of the correct type.
     // If it's not of the correct type, we can tell the user which file it's in, so they can find it easier.
-    psMetadataIterator *recipesIter = psMetadataIteratorAlloc(recipes, PS_LIST_HEAD, NULL); // Iterator
-    psMetadataItem *fileItem = NULL;    // MD item containing the filename, from recipe iteration
-    while ((fileItem = psMetadataGetAndIncrement(recipesIter))) {
-        if (fileItem->type != PS_DATA_STRING) {
-            psLogMsg(__func__, PS_LOG_WARN, "Recipe %s from %s is not of type STR --- ignored.\n",
-                     fileItem->name, sourceName);
-            continue;
-        }
-
-        // Check to see if it's currently defined
-        int check = psMetadataLookupS32(&mdok, config->recipesSource, fileItem->name);
-        if (mdok && check > sourceType) {
-            // It's already defined with a higher priority
-            continue;
-        }
-        psString comment = psStringCopy("Recipe added at ");
-        psStringAppend(&comment, "%s from %s", sourceName, fileItem->data.V);
-        psMetadataAddS32(config->recipesSource, PS_LIST_TAIL, fileItem->name,
-                         PS_META_REPLACE, comment, sourceType);
-        psFree(comment);
-
-        // Read the recipe
-        psMetadata *recipe = NULL;      // Recipe from file
-        if (readConfig(&recipe, fileItem->data.V, "recipe")) {
-            psMetadataAdd(config->recipes, PS_LIST_TAIL, fileItem->name,
-                          PS_DATA_METADATA | PS_META_REPLACE, fileItem->comment, recipe);
-        } else {
-            psError(PS_ERR_IO, false, "Failed to read recipe");
-
-            psFree(recipe);  // Drop reference
-            psFree(recipesIter);
-
-            return false;
-        }
-        psFree(recipe);                 // Drop reference
-    }
-    psFree(recipesIter);
-
+    {
+        psMetadataIterator *recipesIter = psMetadataIteratorAlloc(recipes, PS_LIST_HEAD, NULL); // Iterator
+        psMetadataItem *fileItem = NULL;    // MD item containing the filename, from recipe iteration
+        while ((fileItem = psMetadataGetAndIncrement(recipesIter)))
+        {
+            if (fileItem->type != PS_DATA_STRING) {
+                psLogMsg(__func__, PS_LOG_WARN, "Recipe %s from %s is not of type STR --- ignored.\n",
+                         fileItem->name, sourceName);
+                continue;
+            }
+
+            // Check to see if it's currently defined
+            int check = psMetadataLookupS32(&mdok, config->recipesSource, fileItem->name);
+            if (mdok && check > sourceType) {
+                // It's already defined with a higher priority
+                continue;
+            }
+            psString comment = psStringCopy("Recipe added at ");
+            psStringAppend(&comment, "%s from %s", sourceName, fileItem->data.V);
+            psMetadataAddS32(config->recipesSource, PS_LIST_TAIL, fileItem->name,
+                             PS_META_REPLACE, comment, sourceType);
+            psFree(comment);
+
+            // Read the recipe
+            psMetadata *recipe = NULL;      // Recipe from file
+            if (readConfig(&recipe, fileItem->data.V, "recipe")) {
+                psMetadataAdd(config->recipes, PS_LIST_TAIL, fileItem->name,
+                              PS_DATA_METADATA | PS_META_REPLACE, fileItem->comment, recipe);
+            } else {
+                psError(PS_ERR_IO, false, "Failed to read recipe");
+
+                psFree(recipe);  // Drop reference
+                psFree(recipesIter);
+
+                return false;
+            }
+            psFree(recipe);                 // Drop reference
+        }
+        psFree(recipesIter);
+    }
     config->recipesRead |= sourceType;
 
-    // Having read that, we now need to check to see if any symbolic links need to be resolved
-    recipesIter = psMetadataIteratorAlloc(config->recipesSource, PS_LIST_HEAD, NULL);
-    psMetadataItem *sourceItem = NULL;  // Item containing source, from iteration
-    while ((sourceItem = psMetadataGetAndIncrement(recipesIter))) {
-        assert(sourceItem->type == PS_TYPE_S32); // It should be this type: we put it in ourselves
-        if (sourceItem->data.S32 == P_PM_RECIPE_SOURCE_SYMBOLIC) {
-            const char *linkName = sourceItem->comment; // The name of the link
-            psMetadata *linkSource = psMetadataLookupMD(&mdok, config->recipes, linkName); // The source
-            if (!mdok || !linkSource) {
-                psLogMsg(__func__, PS_LOG_WARN, "Unable to resolve symbolic link for recipe %s to %s "
-                         "--- ignored.\n", sourceItem->name, linkName);
-                continue;
-            }
-            psMetadataItem *target = psMetadataLookup(config->recipes, sourceItem->name); // The target item
-            assert(target);             // It had better be here: it's in the "sourcesRead" metadata
-            psFree(target->data.V); // Free old copy
-            target->data.V = psMetadataCopy(NULL, linkSource);
-        }
-    }
-    psFree(recipesIter);
+    {
+        // Having read that, we now need to check to see if any symbolic links need to be resolved
+        psMetadataIterator *recipesIter = psMetadataIteratorAlloc(config->recipesSource, PS_LIST_HEAD, NULL);
+        psMetadataItem *sourceItem = NULL;  // Item containing source, from iteration
+        while ((sourceItem = psMetadataGetAndIncrement(recipesIter))) {
+            assert(sourceItem->type == PS_TYPE_S32); // It should be this type: we put it in ourselves
+            if (sourceItem->data.S32 == P_PM_RECIPE_SOURCE_SYMBOLIC) {
+                const char *linkName = sourceItem->comment; // The name of the link
+                psMetadata *linkSource = psMetadataLookupMD(&mdok, config->recipes, linkName); // The source
+                if (!mdok || !linkSource) {
+                    // Can't yet resolve it
+                    continue;
+                }
+                psString comment = NULL;
+                psStringAppend(&comment, "Symbolic link from %s", linkName);
+                psMetadataAdd(config->recipes, PS_LIST_TAIL, sourceItem->name,
+                              PS_DATA_METADATA | PS_META_REPLACE, comment, linkSource);
+                psFree(comment);
+            }
+        }
+        psFree(recipesIter);
+    }
     return true;
 }
@@ -769,6 +773,6 @@
                                  recipeSource, P_PM_RECIPE_SOURCE_SYMBOLIC);
 
-            } else {
-                // Otherwise, treat the source as a filename
+            } else if (access(recipeSource, R_OK) == 0) {
+                // The source is a file
                 psMetadata *recipe = NULL;      // Recipe from file
                 if (readConfig(&recipe, recipeSource, "recipe")) {
@@ -782,4 +786,9 @@
                                      "Recipe added from command line", P_PM_RECIPE_SOURCE_CL);
                 }
+            } else {
+                // Assume it's a symbolic reference to something that's not yet read in
+                printf("==> %s points to %s\n", recipeName, recipeSource);
+                psMetadataAddS32(config->recipesSource, PS_LIST_TAIL, recipeName, PS_META_REPLACE,
+                                 recipeSource, P_PM_RECIPE_SOURCE_SYMBOLIC);
             }
             psFree(recipeName);
