@@ -40,14 +40,17 @@ self = stdenv.mkDerivation rec {
4040 "PLAT=macosx"
4141 ] else [
4242 "PLAT=linux"
43− ])
43+ ]) ++ (if stdenv.buildPlatform != stdenv.hostPlatform then [
44+ "CC=${stdenv.hostPlatform.config}-gcc"
45+ "RANLIB=${stdenv.hostPlatform.config}-ranlib"
46+ ] else [])
4447 ;
4548
4649 configurePhase = ''
4750 runHook preConfigure
4851
4952 makeFlagsArray+=(CFLAGS="-DLUA_USE_LINUX -O2 -fPIC${if compat then " -DLUA_COMPAT_ALL" else ""}" )
50− makeFlagsArray+=(${stdenv.lib.optionalString stdenv.isDarwin "CC=\"$CC\""})
53+ makeFlagsArray+=(${stdenv.lib.optionalString stdenv.isDarwin "CC=\"$CC\""}${stdenv.lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) " 'AR=${stdenv.hostPlatform.config}-ar rcu'"})
5154
5255 installFlagsArray=( TO_BIN="lua luac" INSTALL_DATA='cp -d' \
5356 TO_LIB="${if stdenv.isDarwin then "liblua.${version}.dylib" else "liblua.a liblua.so liblua.so.${luaversion} liblua.so.${version}"}" )