* included in the distribution.
*
* $RCSfile: connect.h,v $
- * $Revision: 1.17 $
- * $Date: 1999/11/23 15:12:10 $
+ * $Revision: 1.18 $
+ * $Date: 1999/11/25 10:19:15 $
* ------------------------------------------------------------------------*/
/* --------------------------------------------------------------------------
Bool writeRegInt Args((String var, Int val));
#endif
+#define N_INSTALLDIR 200
+extern char installDir[N_INSTALLDIR];
+
/*---------------------------------------------------------------------------
* File operations:
*-------------------------------------------------------------------------*/
* included in the distribution.
*
* $RCSfile: dynamic.c,v $
- * $Revision: 1.12 $
- * $Date: 1999/10/29 13:41:23 $
+ * $Revision: 1.13 $
+ * $Date: 1999/11/25 10:19:15 $
* ------------------------------------------------------------------------*/
#include "prelude.h"
#include "storage.h"
#include "errors.h"
#include "dynamic.h"
+#include "connect.h"
#if HAVE_WINDOWS_H && !defined(__MSDOS__)
char symbol[100];
ObjectFile instance;
- if (strlen(dll0) > 996) {
+ if (strlen(dll0) > 996-strlen(installDir)) {
ERRMSG(line) "Excessively long library name:\n%s\n",dll0
EEND;
}
- strcpy(dll,dll0);
+ dll[0] = 0;
+ if (strcmp("nHandle",dll0)==0) strcat(dll,installDir);
+ strcat(dll,dll0);
strcat(dll, ".dll");
if (strlen(symbol0) > 96) {
void* sym;
char dll[1000];
ObjectFile instance;
- if (strlen(dll0) > 996) {
+ if (strlen(dll0) > 996-strlen(installDir)) {
ERRMSG(line) "Excessively long library name:\n%s\n",dll0
EEND;
}
- strcpy(dll,dll0);
+ dll[0] = 0;
+ if (strcmp("nHandle",dll0)==0) strcat(dll,installDir);
+ strcat(dll,dll0);
strcat(dll, ".so");
#ifdef RTLD_NOW
instance = dlopen(dll,RTLD_NOW);
* included in the distribution.
*
* $RCSfile: hugs.c,v $
- * $Revision: 1.23 $
- * $Date: 1999/11/23 15:12:09 $
+ * $Revision: 1.24 $
+ * $Date: 1999/11/25 10:19:16 $
* ------------------------------------------------------------------------*/
#include <setjmp.h>
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)) {
Printf("|| || Report bugs to: hugs-bugs@haskell.org\n");
Printf("|| || Version: %s _________________________________________\n\n",HUGS_VERSION);
+ /* Get the absolute path to the directory containing the hugs
+ executable, so that we know where the Prelude and nHandle.so/.dll are.
+ We do this by reading env var STGHUGSDIR. This needs to succeed, so
+ setInstallDir won't return unless it succeeds.
+ */
+ setInstallDir ( argv[0] );
+
#if SYMANTEC_C
Printf(" Ported to Macintosh by Hans Aberg, compiled " __DATE__ ".\n\n");
#endif
}
#if DEBUG
- DEBUG_LoadSymbols(argv_0_orig);
+ {
+ char exe_name[N_INSTALLDIR + 6];
+ strcpy(exe_name, installDir);
+ strcat(exe_name, "hugs");
+ DEBUG_LoadSymbols(exe_name);
+ }
#endif
* included in the distribution.
*
* $RCSfile: machdep.c,v $
- * $Revision: 1.13 $
- * $Date: 1999/11/24 17:32:41 $
+ * $Revision: 1.14 $
+ * $Date: 1999/11/25 10:19:16 $
* ------------------------------------------------------------------------*/
#ifdef HAVE_SIGNAL_H
* New path handling stuff for the Combined System (tm)
* ------------------------------------------------------------------------*/
-#define N_DEFAULT_LIBDIR 1000
-char defaultLibDir[N_DEFAULT_LIBDIR];
+char installDir[N_INSTALLDIR];
-/* Assumes that getcwd()++argv[0] is the absolute path to the
- executable. Basically wrong.
+/* Sets installDir to $STGHUGSDIR, and ensures there is a trailing
+ slash at the end.
*/
-void setDefaultLibDir ( String argv_0 )
+void setInstallDir ( 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);
- if (defaultLibDir[i-1] != SLASH) defaultLibDir[i++] = SLASH;
- } else {
- i = 0;
+ int i;
+ char* r = getenv("STGHUGSDIR");
+ if (!r) {
+ fprintf(stderr,
+ "%s: installation error: environment variable STGHUGSDIR is not set.\n",
+ argv_0 );
+ fprintf(stderr,
+ "%s: pls set it to be the directory where STGHugs98 is installed.\n\n",
+ argv_0 );
+ exit(2);
+
}
- 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 ); */
+
+ if (strlen(r) > N_INSTALLDIR-30 ) {
+ fprintf(stderr,
+ "%s: environment variable STGHUGSDIR is suspiciously long; pls remedy\n\n",
+ argv_0 );
+ exit(2);
+ }
+
+ strcpy ( installDir, r );
+ i = strlen(installDir);
+ if (installDir[i-1] != SLASH) installDir[i++] = SLASH;
+ installDir[i] = 0;
}
+
Bool findFilesForModule (
String modName,
String* path,
Int nPath;
Bool literate;
String peStart, peEnd;
- String augdPath; /* .:hugsPath:defaultLibDir */
+ String augdPath; /* .:hugsPath:installDir/lib */
*path = *sExt = NULL;
*sAvail = *iAvail = *oAvail = FALSE;
*sSize = *iSize = *oSize = 0;
- augdPath = malloc(4+strlen(defaultLibDir)+strlen(hugsPath));
+ augdPath = malloc(4+3+strlen(installDir)+strlen(hugsPath));
if (!augdPath)
internal("moduleNameToFileNames: malloc failed(2)");
augdPath[0] = '.';
strcat ( augdPath, hugsPath );
augdPath[2+strlen(hugsPath)] = PATHSEP;
augdPath[3+strlen(hugsPath)] = 0;
- strcat(augdPath,defaultLibDir);
+ strcat(augdPath,installDir);
+ strcat(augdPath,"lib");
peEnd = augdPath-1;
while (1) {
if [ -f $NROOT/$1/$2/$2.stdin ]
then
-echo "$HUGZ/hugs +Q -P$NROOT/$1/$2 Main -- $3 $4 $5 $6 $7 $8 $9"
+echo "$HUGZ/hugs -Q -P$NROOT/$1/$2 Main -- $3 $4 $5 $6 $7 $8 $9"
echo " < $NROOT/$1/$2/$2.stdin 2> /dev/null"
echo " > $TMPFILE"
else
-echo "$HUGZ/hugs +Q -P$NROOT/$1/$2 Main -- $3 $4 $5 $6 $7 $8 $9"
+echo "$HUGZ/hugs -Q -P$NROOT/$1/$2 Main -- $3 $4 $5 $6 $7 $8 $9"
echo " < /dev/null 2> /dev/null"
echo " > $TMPFILE"
fi
if [ -f $NROOT/$1/$2/$2.stdin ]
then
-$HUGZ/hugs +Q -P$NROOT/$1/$2 Main -- $3 $4 $5 $6 $7 $8 $9 < $NROOT/$1/$2/$2.stdin 2> /dev/null > $TMPFILE
+$HUGZ/hugs -Q -P$NROOT/$1/$2 Main -- $3 $4 $5 $6 $7 $8 $9 < $NROOT/$1/$2/$2.stdin 2> /dev/null > $TMPFILE
else
-$HUGZ/hugs +Q -P$NROOT/$1/$2 Main -- $3 $4 $5 $6 $7 $8 $9 < /dev/null 2> /dev/null > $TMPFILE
+$HUGZ/hugs -Q -P$NROOT/$1/$2 Main -- $3 $4 $5 $6 $7 $8 $9 < /dev/null 2> /dev/null > $TMPFILE
fi
if [ $? -ne 0 ]; then
#if MAJOR_RELEASE
#define HUGS_VERSION "November 1999 "
#else
-#define HUGS_VERSION "STGHugs-991123"
+#define HUGS_VERSION "STGHugs-991124"
#endif