diff -Nurp make-4.0/configure make-4.0-lib64/configure --- make-4.0/configure 2013-10-09 09:11:51.000000000 +0300 +++ make-4.0-lib64/configure 2013-10-12 20:58:34.059216232 +0300 @@ -10296,6 +10296,9 @@ test "x$exec_prefix" = xNONE && exec_pre DEFS=-DHAVE_CONFIG_H +# have lib64 dirs? +[[ -d /lib64 ]] && DEFS="$DEFS -DHAVE_LIB64DIRS" + ac_libobjs= ac_ltlibobjs= U= diff -Nurp make-4.0/remake.c make-4.0-lib64/remake.c --- make-4.0/remake.c 2013-10-06 02:12:18.000000000 +0300 +++ make-4.0-lib64/remake.c 2013-10-12 21:06:42.860064470 +0300 @@ -37,6 +37,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 + /* The test for circular dependencies is based on the 'updating' bit in 'struct file'. However, double colon targets have separate 'struct @@ -1520,11 +1538,30 @@ name_mtime (const char *name) static const char * library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr) { - static const 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) /* @@ -1533,8 +1570,8 @@ library_search (const char *lib, FILE_TI */ #define LIBDIR "." #endif - LIBDIR, /* Defined by configuration. */ - 0 + { LIBDIR, MODE_NATIVE }, /* Defined by configuration. */ + { 0, 0 } }; const char *file = 0; @@ -1550,7 +1587,14 @@ library_search (const char *lib, FILE_TI /* Information about the earliest (in the vpath sequence) match. */ unsigned int best_vpath = 0, best_path = 0; - const 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)")); @@ -1628,9 +1672,9 @@ library_search (const char *lib, FILE_TI 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++; @@ -1649,9 +1693,12 @@ library_search (const char *lib, FILE_TI 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) {