diff -Naur make-3.82//configure make-3.82.tpg//configure --- make-3.82//configure 2010-07-28 05:41:51.000000000 +0000 +++ make-3.82.tpg//configure 2010-08-01 12:54:55.000000000 +0000 @@ -9379,6 +9379,9 @@ DEFS=-DHAVE_CONFIG_H +# have lib64 dirs? +[[ -d /lib64 ]] && DEFS="$DEFS -DHAVE_LIB64DIRS" + ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue diff -Naur make-3.82//remake.c make-3.82.tpg//remake.c --- make-3.82//remake.c 2010-07-13 01:20:42.000000000 +0000 +++ make-3.82.tpg//remake.c 2010-08-01 13:08:30.000000000 +0000 @@ -39,6 +39,24 @@ #include <io.h> #endif +/* Define biarch platforms. */ +#if defined(__biarch__) +#define BIARCH_PLATFORM +#elif defined(__linux__) && \ + (defined(__x86_64__) || defined(__powerpc64__) || \ + defined(__s390x__) || defined(__sparc_v9__)) +#define BIARCH_PLATFORM +#endif + +/* Define IS_MODE_32_BIT if we are running under a 32-bit personality. */ +#ifdef BIARCH_PLATFORM +#if defined(__linux__) +#include <sys/syscall.h> +#include <sys/personality.h> +#define IS_MODE_32_BIT ((syscall(SYS_personality, 0xffffffff) & PER_MASK) == PER_LINUX32) +#endif +#endif + extern int try_implicit_rule (struct file *file, unsigned int depth); @@ -1506,11 +1524,30 @@ static const char * library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr) { - static char *dirs[] = + enum + { + MODE_32_BIT = 1, + MODE_64_BIT = 2, +#ifdef BIARCH_PLATFORM + MODE_NATIVE = MODE_64_BIT +#else + MODE_NATIVE = MODE_32_BIT +#endif + }; + struct dir + { + const char *name; + int mode; + }; + static const struct dir dirs[] = { #ifndef _AMIGA - "/lib", - "/usr/lib", +#if HAVE_LIB64DIRS + { "/lib64", MODE_64_BIT }, + { "/usr/lib64", MODE_64_BIT }, +#endif + { "/lib", MODE_32_BIT | MODE_NATIVE }, + { "/usr/lib", MODE_32_BIT | MODE_NATIVE }, #endif #if defined(WINDOWS32) && !defined(LIBDIR) /* @@ -1519,8 +1556,8 @@ */ #define LIBDIR "." #endif - LIBDIR, /* Defined by configuration. */ - 0 + { LIBDIR, MODE_NATIVE }, /* Defined by configuration. */ + { 0, 0 } }; const char *file = 0; @@ -1537,7 +1574,14 @@ unsigned int best_vpath, best_path; unsigned int std_dirs = 0; - char **dp; + const struct dir *dp; + + /* Check for running mode (personality). */ + int mode = MODE_NATIVE; +#ifdef BIARCH_PLATFORM + if (IS_MODE_32_BIT) + mode = MODE_32_BIT; +#endif libpatterns = xstrdup (variable_expand ("$(.LIBPATTERNS)")); @@ -1614,9 +1658,9 @@ if (!buflen) { - for (dp = dirs; *dp != 0; ++dp) + for (dp = dirs; dp->name != 0; ++dp) { - int l = strlen (*dp); + int l = strlen (dp->name); if (l > libdir_maxlen) libdir_maxlen = l; std_dirs++; @@ -1635,9 +1679,12 @@ was it will always be greater than the VPATH index. */ unsigned int vpath_index = ~((unsigned int)0) - std_dirs; - for (dp = dirs; *dp != 0; ++dp) + for (dp = dirs; dp->name != 0; ++dp) { - sprintf (buf, "%s/%s", *dp, libbuf); + /* skip dirs which don't fit in the running mode. */ + if ((dp->mode & mode) == 0) + continue; + sprintf (buf, "%s/%s", dp->name, libbuf); mtime = name_mtime (buf); if (mtime != NONEXISTENT_MTIME) {