From 3af0e63bcc7e04d36719c338f4cbbff4f256aa05 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 18 Sep 2012 20:32:38 -0300 Subject: Makes use of -rpath conditional on MacOSX version. Should fix #88, feedback welcome. --- src/luarocks/build/builtin.lua | 4 +++- src/luarocks/cfg.lua | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index fc4c2c04..485ff370 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua @@ -143,7 +143,9 @@ function run(rockspec) compile_library = function (library, objects, libraries, libdirs) local extras = { unpack(objects) } add_flags(extras, "-L%s", libdirs) - add_flags(extras, "-Wl,-rpath,%s:", libdirs) + if cfg.gcc_rpath then + add_flags(extras, "-Wl,-rpath,%s:", libdirs) + end add_flags(extras, "-l%s", libraries) if cfg.is_platform("cygwin") then add_flags(extras, "-l%s", {"lua"}) diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 263af063..e0b4060a 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -324,6 +324,7 @@ if detected.unix then defaults.platforms = { "unix" } defaults.variables.CC = "gcc" defaults.variables.LD = "gcc" + defaults.gcc_rpath = true defaults.variables.LIBFLAG = "-shared" defaults.external_deps_patterns = { bin = { "?" }, @@ -362,10 +363,17 @@ if detected.macosx then defaults.external_lib_extension = "dylib" defaults.arch = "macosx-"..proc defaults.platforms = {"unix", "bsd", "macosx"} - defaults.variables.CC = "export MACOSX_DEPLOYMENT_TARGET=10.3; gcc" - defaults.variables.LD = "export MACOSX_DEPLOYMENT_TARGET=10.3; gcc" defaults.variables.LIBFLAG = "-bundle -undefined dynamic_lookup -all_load" defaults.variables.STATFLAG = "-f '%A'" + local version = io.popen("sw_vers -productVersion"):read("*l") + version = tonumber(version and version:match("^[^.]+%.([^.]+)")) or 3 + if version >= 5 then + version = 5 + else + defaults.gcc_rpath = false + end + defaults.variables.CC = "export MACOSX_DEPLOYMENT_TARGET=10."..version.."; gcc" + defaults.variables.LD = "export MACOSX_DEPLOYMENT_TARGET=10."..version.."; gcc" end if detected.linux then -- cgit v1.2.3-55-g6feb