[project @ 1999-10-11 12:15:12 by sewardj]
authorsewardj <unknown>
Mon, 11 Oct 1999 12:15:13 +0000 (12:15 +0000)
committersewardj <unknown>
Mon, 11 Oct 1999 12:15:13 +0000 (12:15 +0000)
Try and make finding of Prelude libraries for hugs a bit saner.
Guess (badly) the absolute pathname to the hugs executable, and
use that to derive the location of the default library.

ghc/interpreter/hugs.c
ghc/interpreter/machdep.c

index 0c1c925..d076064 100644 (file)
@@ -8,8 +8,8 @@
  * in the distribution for details.
  *
  * $RCSfile: hugs.c,v $
- * $Revision: 1.8 $
- * $Date: 1999/07/06 15:24:37 $
+ * $Revision: 1.9 $
+ * $Date: 1999/10/11 12:15:13 $
  * ------------------------------------------------------------------------*/
 
 #include <setjmp.h>
@@ -217,6 +217,12 @@ char *argv[]; {
 
     CStackBase = &argc;                 /* Save stack base for use in gc   */
 
+    /* Try and figure out an absolute path to the executable, so
+       we can make a reasonable guess about where the default
+       libraries (Prelude etc) are.
+    */
+    setDefaultLibDir ( argv[0] );
+
     /* If first arg is +Q or -Q, be entirely silent, and automatically run
        main after loading scripts.  Useful for running the nofib suite.    */
     if (argc > 1 && (strcmp(argv[1],"+Q") == 0 || strcmp(argv[1],"-Q")==0)) {
@@ -813,9 +819,15 @@ static Void local makeStackEntry ( ScriptInfo* ent, String iname )
    if (!(sAvail || (oAvail && iAvail))) 
       internal("chase");
    /* Load objects in preference to sources if both are available */
+   /* 11 Oct 99: disable object loading in the interim.
+      Will probably only reinstate when HEP becomes available.
    fromObj = sAvail
                 ? (oAvail && iAvail && timeEarlier(sTime,oTime))
                 : TRUE;
+   */
+
+   fromObj = FALSE;
+
    /* ToDo: namesUpto overflow */
    ent->modName     = strCopy(iname);
    ent->details     = TRUE;
@@ -1162,7 +1174,7 @@ static Void local whatScripts() {       /* list scripts in current session */
     if (projectLoaded)
         Printf(" (project: %s)",currProject);
     for (i=0; i<numScripts; ++i)
-        Printf("\n%s",scriptInfo[i].modName);
+      Printf("\n%s%s",scriptInfo[i].path, scriptInfo[i].modName);
     Putchar('\n');
 }
 
index 2847b41..7bfa0d5 100644 (file)
@@ -12,8 +12,8 @@
  * in the distribution for details.
  *
  * $RCSfile: machdep.c,v $
- * $Revision: 1.6 $
- * $Date: 1999/06/07 17:22:37 $
+ * $Revision: 1.7 $
+ * $Date: 1999/10/11 12:15:12 $
  * ------------------------------------------------------------------------*/
 
 #ifdef HAVE_SIGNAL_H
@@ -599,6 +599,33 @@ String path; {
  * New path handling stuff for the Combined System (tm)
  * ------------------------------------------------------------------------*/
 
+#define N_DEFAULT_LIBDIR 1000
+char defaultLibDir[N_DEFAULT_LIBDIR];
+
+/* Assumes that getcwd()++argv[0] is the absolute path to the
+   executable.  Basically wrong.
+*/
+void setDefaultLibDir ( String argv_0 )
+{
+   int i;
+   if (argv_0[0] != SLASH) {
+      if (!getcwd(defaultLibDir,N_DEFAULT_LIBDIR-strlen(argv_0)-10)) {
+         ERRMSG(0) "Can't get current working directory"
+         EEND;
+      }
+      i = strlen(defaultLibDir);
+      defaultLibDir[i++] = SLASH;
+   } else {
+      i = 0;
+   }
+   strcpy(&defaultLibDir[i],argv_0);
+   i += strlen(argv_0);
+   while (defaultLibDir[i] != SLASH) i--;
+   i++;
+   strcpy(&defaultLibDir[i], "lib");
+   /* fprintf ( stderr, "default lib dir = %s\n", defaultLibDir ); */
+}
+
 Bool findFilesForModule ( 
         String  modName,
         String* path,
@@ -621,18 +648,21 @@ Bool findFilesForModule (
    Int    nPath;
    Bool   literate;
    String peStart, peEnd;
-   String augdPath;       /* . and then hugsPath */
+   String augdPath;       /* .:defaultLibDir:hugsPath */
 
    *path = *sExt = NULL;
    *sAvail = *iAvail = *oAvail = FALSE;
    *sSize  = *iSize  = *oSize  = 0;
 
-   augdPath = malloc(3+strlen(hugsPath));
+   augdPath = malloc(4+strlen(defaultLibDir)+strlen(hugsPath));
    if (!augdPath)
       internal("moduleNameToFileNames: malloc failed(2)");
    augdPath[0] = '.';
    augdPath[1] = PATHSEP;
    augdPath[2] = 0;
+   strcat ( augdPath, defaultLibDir );
+   augdPath[2+strlen(defaultLibDir)] = PATHSEP;
+   augdPath[3+strlen(defaultLibDir)] = 0;
    strcat(augdPath,hugsPath);
 
    peEnd = augdPath-1;