diff -Nuar make-3.79.1.old/read.c make-3.79.1/read.c
--- make-3.79.1.old/read.c	Wed Jun 21 23:33:30 2000
+++ make-3.79.1/read.c	Tue Apr  9 15:45:08 2002
@@ -32,6 +32,21 @@
 #include "debug.h"
 
 
+/* Denx begins */
+extern char *denx_prefix;
+static void find_cross_dir(char *, char **);
+static void remove_relative_paths (char *);
+static int find_family_cpu(char **);
+
+#ifndef DIR_SEPARATOR
+#define DIR_SEPARATOR '/'
+#endif
+
+#ifndef PATH_SEPARATOR
+#define PATH_SEPARATOR ':'
+#endif
+/* Denx ends */
+
 #ifndef WINDOWS32
 #ifndef _AMIGA
 #ifndef VMS
@@ -689,6 +704,16 @@
 	     the default goal before those in the included makefile.  */
 	  record_waiting_files ();
 
+
+/* Denx begins */
+if (! denx_prefix) {
+  struct variable *v = lookup_variable ("CROSS_COMPILE", 13);
+  if (v && v->value) {
+    construct_include_path ((char **) 0);
+  }
+}
+ /* Denx ends */
+
 	  /* Read each included makefile.  */
 	  while (files != 0)
 	    {
@@ -2496,6 +2521,40 @@
   }
 #endif
 
+/* Denx begins */ 
+{
+  char *cross_dir;
+  char *cross_compile;
+  cross_compile=getenv("CROSS_COMPILE");
+
+  if (!cross_compile)
+  {
+    struct variable *v = lookup_variable ("CROSS_COMPILE", 13);
+    if (v && v->value) {
+        cross_compile=v->value;
+    }
+  }
+
+  if (cross_compile)
+  {
+    find_family_cpu (&cross_compile);
+    find_cross_dir ("make", &cross_dir);
+    denx_prefix=(char *)malloc(strlen(cross_dir)+1+strlen(cross_compile)+1);
+    sprintf(denx_prefix,"%s/%s",cross_dir,cross_compile);
+  }
+
+  if (denx_prefix && *denx_prefix)
+  {
+    for (i = 0; default_include_directories[i] != 0; ++i)
+    {
+      default_include_directories[i] = concat(denx_prefix,
+                                              default_include_directories[i],
+                                              "");
+    }
+  }
+}
+/* Denx ends */
+
   for (i = 0; default_include_directories[i] != 0; ++i)
     if (stat (default_include_directories[i], &stbuf) == 0
 	&& S_ISDIR (stbuf.st_mode))
@@ -2726,3 +2785,185 @@
 
   return new;
 }
+
+/* Find cross directory root */
+static void 
+find_cross_dir(char *progname, char **ptr)
+{
+  char *fullpath = xmalloc(MAXPATHLEN);
+  char *linkfile = xmalloc(MAXPATHLEN);
+  char *realpath = xmalloc(MAXPATHLEN);
+  struct stat file;
+  int ret = 0;
+  char *p;
+  int i;
+
+  *ptr = 0;
+
+  if (strchr (progname, '/'))
+  {
+    if (progname[0] == '/')
+    {
+      /* We have absolute path */
+      strcpy (fullpath, progname);
+    } else {
+      /* We have relative path, prepend $cwd */
+      getcwd (fullpath, MAXPATHLEN);
+      strcat (fullpath, "/");
+      strcat (fullpath, progname);
+    }
+  } else {
+    /* Search pathlist for matching progname  */
+    char *path;
+    char *beg, *end;
+
+    path = getenv("PATH");
+    beg = path;
+    while (1)
+    {
+      for (end = beg; *end && *end != PATH_SEPARATOR; end++) ;
+      strncpy (fullpath, beg, end - beg);
+      fullpath[end - beg] = '\0';
+      if (fullpath[end - beg - 1] == DIR_SEPARATOR)
+        fullpath[end - beg - 1] = '\0';
+      if (strcmp (fullpath, ".") == 0)
+        getcwd (fullpath, MAXPATHLEN);
+      strcat (fullpath, "/");
+      strcat (fullpath, progname);
+      if ((lstat (fullpath, &file) == 0) &&
+        (S_ISREG(file.st_mode) || S_ISLNK(file.st_mode))) break;
+      if (*end == '\0') {
+        free(realpath);
+        goto RET; /* Not found on path */
+      }
+      beg = end + 1;
+    }
+  }
+
+  /* Resolve all symbolic links in the full path */
+  while (fullpath[0])
+  {
+    char *t, *s, *q;
+    int len, off;
+
+    while ((ret = lstat (fullpath, &file)) == 0 && S_ISLNK(file.st_mode))
+    {
+      /* fullpath is a link */
+            linkfile[readlink (fullpath, linkfile, MAXPATHLEN)] = '\0';
+      if (linkfile[0] == DIR_SEPARATOR)
+      {
+        /* Link replaces path */
+        strcpy (fullpath, linkfile);
+      }
+      else
+      {
+        /* Link is relative to current directory */
+        q = strrchr (fullpath, DIR_SEPARATOR);
+        *(q + 1) = '\0';
+        strcat (fullpath, linkfile);
+      }
+      /* We might have added more relative paths -- remove them */
+      remove_relative_paths (fullpath);
+    }
+    if (ret)
+    {
+      free(realpath);
+      goto RET;
+    }
+    /* Strip off the last segment of the path */
+    if ((q = strrchr (fullpath, DIR_SEPARATOR)))
+      *q++ = '\0';
+    else
+      q = fullpath;
+
+    /* Shift realpath right to make room for new segment and slash */
+    off = strlen (q) + 1;
+    len = strlen (realpath);
+    for (i = len; i >= 0; i--)
+      realpath [off + i] = realpath [i];
+
+    /* Copy new segment to realpath */
+    s = q;
+    t = realpath + 1;
+    while (*s)
+      *t++ = *s++;
+
+    /* Stick in separator at beginning of segment. */
+    realpath[0] = DIR_SEPARATOR;
+  }
+
+  /* Split executable name from path */
+  p = strrchr (realpath, DIR_SEPARATOR);
+  *++p = '\0';
+
+  remove_relative_paths (realpath);
+
+  /* Exclude trailing segments to get to the cross root directory */
+  p = realpath;
+  for (i = 0; i< 3 ; i++) 
+  {
+    if (!(p = strrchr(realpath, '/'))) 
+    {
+      free(realpath);
+      goto RET;
+    }
+    *p = '\0';
+  }
+  *ptr = realpath;
+
+RET:
+  free (fullpath);
+  free (linkfile);
+}
+
+/* Remove relative paths -- .. and . */
+static void
+remove_relative_paths (char * path)
+{
+  char *p, *s;
+
+  p = path;
+  while ((p = strchr (p, DIR_SEPARATOR)))
+  {
+    p++;
+    if (*p == '.')
+    {
+      p++;
+      if (*p == DIR_SEPARATOR)
+      {
+        /*  Translate "/./" ==> "/"  */
+        strcpy (p-2, p);
+      }
+      else if (*p == '.' && *(p+1) == DIR_SEPARATOR)
+      {
+        /*  Translate "/<whatever>/../" ==> "/"  */
+        s = p + 1;
+        p -= 3;
+        while ( p > path && *p != DIR_SEPARATOR)
+          p--;
+        strcpy (p, s);
+      }
+    }
+  }
+}
+
+static int
+find_family_cpu(char **family_cpu)
+{
+  char *p;
+  int len;
+
+  p = getenv("CROSS_COMPILE");
+  if (p && *p)
+    {
+      p = basename(p);
+      len = strlen(p);
+      *family_cpu = (char *) xmalloc(len + 1);
+      strcpy(*family_cpu, p);
+      if ((*family_cpu)[len - 1] == '-')
+        (*family_cpu)[len - 1] = '\0';
+      return 1;
+    }
+  return 0;
+}
+
diff -Nuar make-3.79.1.old/remake.c make-3.79.1/remake.c
--- make-3.79.1.old/remake.c	Tue Jun 20 18:00:17 2000
+++ make-3.79.1/remake.c	Tue Apr  9 15:45:07 2002
@@ -40,6 +40,8 @@
 #include <io.h>
 #endif
 
+char *denx_prefix;
+
 extern int try_implicit_rule PARAMS ((struct file *file, unsigned int depth));
 
 
@@ -1348,6 +1350,8 @@
 	      int l = strlen (*dp);
 	      if (l > libdir_maxlen)
 		libdir_maxlen = l;
+		if (denx_prefix && *denx_prefix)
+			libdir_maxlen += strlen(denx_prefix);
 	    }
 	  buflen = strlen (libbuf);
 	  buf = xmalloc(libdir_maxlen + buflen + 2);
@@ -1360,7 +1364,10 @@
 
       for (dp = dirs; *dp != 0; ++dp)
 	{
-	  sprintf (buf, "%s/%s", *dp, libbuf);
+	  if (denx_prefix && *denx_prefix)
+	    sprintf (buf, "%s%s/%s", denx_prefix, *dp, libbuf);
+	  else
+	    sprintf (buf, "%s/%s", *dp, libbuf);
 	  mtime = name_mtime (buf);
 	  if (mtime != NONEXISTENT_MTIME)
 	    {
