diff --git a/Makefile b/Makefile
index 8883503f..e56b457e 100644
--- a/Makefile
+++ b/Makefile
@@ -25,11 +25,12 @@ ABIVER= 5.1
# the paths in src/luaconf.h, too. Note: PREFIX must be an absolute path!
#
export PREFIX= /usr/local
+export MULTILIB= lib
##############################################################################
DPREFIX= $(DESTDIR)$(PREFIX)
INSTALL_BIN= $(DPREFIX)/bin
-INSTALL_LIB= $(DPREFIX)/lib
+INSTALL_LIB= $(DPREFIX)/$(MULTILIB)
INSTALL_SHARE= $(DPREFIX)/share
INSTALL_INC= $(DPREFIX)/include/luajit-$(MAJVER).$(MINVER)
@@ -73,7 +74,8 @@ INSTALL_X= install -m 0755
INSTALL_F= install -m 0644
UNINSTALL= $(RM)
LDCONFIG= ldconfig -n
-SED_PC= sed -e "s|^prefix=.*|prefix=$(PREFIX)|"
+SED_PC= sed -e "s|^prefix=.*|prefix=$(PREFIX)|" \
+ -e "s|^multilib=.*|multilib=$(MULTILIB)|"
FILE_T= luajit
FILE_A= libluajit.a
diff --git a/doc/install.html b/doc/install.html
index faf19c43..b7bf75ce 100644
--- a/doc/install.html
+++ b/doc/install.html
@@ -565,9 +565,11 @@ for a regular distribution build:
- PREFIX overrides the installation path and should usually
be set to /usr. Setting this also changes the module paths and
-the -rpath of the shared library.
+the paths needed to locate the shared library.
- DESTDIR is an absolute path which allows you to install
to a shadow tree instead of the root tree of the build system.
+- MULTILIB sets the architecture-specific library path component
+for multilib systems. The default is lib.
- Have a look at the top-level Makefile and src/Makefile
for additional variables to tweak. The following variables may be
overridden, but it's not recommended, except for special needs
diff --git a/etc/luajit.pc b/etc/luajit.pc
index 5a982a62..48233965 100644
--- a/etc/luajit.pc
+++ b/etc/luajit.pc
@@ -6,13 +6,14 @@ version=${majver}.${minver}.${relver}
abiver=5.1
prefix=/usr/local
+multilib=lib
exec_prefix=${prefix}
-libdir=${exec_prefix}/lib
+libdir=${exec_prefix}/${multilib}
libname=luajit-${abiver}
includedir=${prefix}/include/luajit-${majver}.${minver}
INSTALL_LMOD=${prefix}/share/lua/${abiver}
-INSTALL_CMOD=${prefix}/lib/lua/${abiver}
+INSTALL_CMOD=${prefix}/${multilib}/lua/${abiver}
Name: LuaJIT
Description: Just-in-time compiler for Lua
diff --git a/src/Makefile b/src/Makefile
index 999e2808..04699343 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -188,9 +188,10 @@ TARGET_LD= $(CROSS)$(CC)
TARGET_AR= $(CROSS)ar rcus
TARGET_STRIP= $(CROSS)strip
+TARGET_LIBPATH= $(or $(PREFIX),/usr/local)/$(or $(MULTILIB),lib)
TARGET_SONAME= libluajit-$(ABIVER).so.$(MAJVER)
TARGET_DYLIBNAME= libluajit-$(ABIVER).$(MAJVER).dylib
-TARGET_DYLIBPATH= $(or $(PREFIX),/usr/local)/lib/$(TARGET_DYLIBNAME)
+TARGET_DYLIBPATH= $(TARGET_LIBPATH)/$(TARGET_DYLIBNAME)
TARGET_DLLNAME= lua$(NODOTABIVER).dll
TARGET_XSHLDFLAGS= -shared -fPIC -Wl,-soname,$(TARGET_SONAME)
TARGET_DYNXLDOPTS=
@@ -249,12 +250,18 @@ TARGET_ARCH+= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET_LJARCH))
ifneq (,$(PREFIX))
ifneq (/usr/local,$(PREFIX))
- TARGET_XCFLAGS+= -DLUA_XROOT=\"$(PREFIX)/\"
+ TARGET_XCFLAGS+= -DLUA_ROOT=\"$(PREFIX)\"
ifneq (/usr,$(PREFIX))
- TARGET_DYNXLDOPTS= -Wl,-rpath,$(PREFIX)/lib
+ TARGET_DYNXLDOPTS= -Wl,-rpath,$(TARGET_LIBPATH)
endif
endif
endif
+ifneq (,$(MULTILIB))
+ TARGET_XCFLAGS+= -DLUA_MULTILIB=\"$(MULTILIB)\"
+endif
+ifneq (,$(LMULTILIB))
+ TARGET_XCFLAGS+= -DLUA_LMULTILIB=\"$(LMULTILIB)\"
+endif
##############################################################################
# System detection.
diff --git a/src/luaconf.h b/src/luaconf.h
index d55caab1..224bfada 100644
--- a/src/luaconf.h
+++ b/src/luaconf.h
@@ -23,26 +23,40 @@
".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
#else
/*
-** Note to distribution maintainers: do NOT patch the following line!
+** Note to distribution maintainers: do NOT patch the following lines!
** Please read ../doc/install.html#distro and pass PREFIX=/usr instead.
*/
-#define LUA_ROOT "/usr/local/"
-#define LUA_LDIR LUA_ROOT "share/lua/5.1/"
-#define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
-#ifdef LUA_XROOT
-#define LUA_JDIR LUA_XROOT "share/luajit-2.0.2/"
-#define LUA_XPATH \
- ";" LUA_XROOT "share/lua/5.1/?.lua;" LUA_XROOT "share/lua/5.1/?/init.lua"
-#define LUA_XCPATH LUA_XROOT "lib/lua/5.1/?.so;"
-#else
-#define LUA_JDIR LUA_ROOT "share/luajit-2.0.2/"
-#define LUA_XPATH
-#define LUA_XCPATH
+#ifndef LUA_MULTILIB
+#define LUA_MULTILIB "lib"
#endif
-#define LUA_PATH_DEFAULT \
- "./?.lua;" LUA_JDIR"?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua" LUA_XPATH
-#define LUA_CPATH_DEFAULT \
- "./?.so;" LUA_CDIR"?.so;" LUA_XCPATH LUA_CDIR"loadall.so"
+#ifndef LUA_LMULTILIB
+#define LUA_LMULTILIB "lib"
+#endif
+#define LUA_LROOT "/usr/local"
+#define LUA_LUADIR "/lua/5.1/"
+#define LUA_LJDIR "/luajit-2.0.2/"
+
+#ifdef LUA_ROOT
+#define LUA_JROOT LUA_ROOT
+#define LUA_RLDIR LUA_ROOT "/share" LUA_LUADIR
+#define LUA_RCDIR LUA_ROOT "/" LUA_MULTILIB LUA_LUADIR
+#define LUA_RLPATH ";" LUA_RLDIR "?.lua;" LUA_RLDIR "?/init.lua"
+#define LUA_RCPATH ";" LUA_RCDIR "?.so"
+#else
+#define LUA_JROOT LUA_LROOT
+#define LUA_RLPATH
+#define LUA_RCPATH
+#endif
+
+#define LUA_JPATH ";" LUA_JROOT "/share" LUA_LJDIR "?.lua"
+#define LUA_LLDIR LUA_LROOT "/share" LUA_LUADIR
+#define LUA_LCDIR LUA_LROOT "/" LUA_LMULTILIB LUA_LUADIR
+#define LUA_LLPATH ";" LUA_LLDIR "?.lua;" LUA_LLDIR "?/init.lua"
+#define LUA_LCPATH1 ";" LUA_LCDIR "?.so"
+#define LUA_LCPATH2 ";" LUA_LCDIR "loadall.so"
+
+#define LUA_PATH_DEFAULT "./?.lua" LUA_JPATH LUA_LLPATH LUA_RLPATH
+#define LUA_CPATH_DEFAULT "./?.so" LUA_LCPATH1 LUA_RCPATH LUA_LCPATH2
#endif
/* Environment variable names for path overrides and initialization code. */