--- 1.1	1996/02/25 18:23:37
+++ driver.c	1996/02/25 18:40:11
@@ -13,6 +13,8 @@
 #include <string.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <sys/stat.h>
+#include <unistd.h>
 
 #include "proto.h"
 
@@ -20,8 +22,6 @@
 extern int   setenv ARGS((char*, char*, int));
 extern int   system ARGS((char*));
 
-extern int unlink ARGS((char*));
-
 /*
  * Collect up various compile time options.
  */
@@ -103,6 +103,8 @@
     bool	verbose;	/* Be verbose about invoked programs? */
     bool	leave;		/* Leave intermediate files behind */
 
+    bool        linuxaout;      /* Do we need to explicitly specify a.out? */
+
     char*	program;	/* Program to link together */
     char*	library;	/* Library to create */
 
@@ -249,6 +251,7 @@
      Options* options;
 {
     int i;
+    struct stat statbuf;	/* For linux aout check */
 
     /*
      * Clear out options.
@@ -263,6 +266,8 @@
     options->verbose	  = FALSE;
     options->leave	  = FALSE;
 
+    options->linuxaout	  = FALSE;
+
     options->program	  = NULL;
     options->library	  = NULL;
 
@@ -467,11 +472,23 @@
 	options->spec = TRUE;
     }
 
+    /* Checks to see if this is a Linux ELF system and
+     * we need to force linux-aout */
+    if (0 == stat("/usr/lib/gcc-lib/i486-linuxaout", &statbuf)) {
+      options->linuxaout = TRUE;
+    }
+	
+
     /* Set-up CLU home */
     options->cluhome = getenv("CLUHOME");
     if (options->cluhome == NULL) {
-	/* Use compiled in value */
-	options->cluhome = CLUHOME;
+
+        /* Use compiled in value */
+        if (options->linuxaout)
+  	  options->cluhome 
+	    = "/afs/sipb.mit.edu/project/linux/lockers/PCLU/lib-aout";
+        else
+	  options->cluhome = CLUHOME;
 
 	/* Set-up environment */
 	if (setenv("CLUHOME", options->cluhome, TRUE) < 0) {
@@ -719,6 +736,9 @@
 	Buffer_append(buffer, "/");
 	Buffer_append(buffer, CLU_INCLUDE);
     }
+    if (options->linuxaout) {
+        Buffer_append(buffer, " -b i486-linuxaout ");
+    }
 
     return buffer;
 }
@@ -760,6 +780,11 @@
 	Buffer_append(buffer, CLU_DEBUG_SUPPORT);
     }
 */
+
+    /* For linux a.out support */
+    if (options->linuxaout) {
+        Buffer_append(buffer, " -b i486-linuxaout ");
+    }
 
     /* Add library */
     Buffer_append(buffer, " -L");
