summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2022-02-16 18:08:18 -0300
committerHisham Muhammad <hisham@gobolinux.org>2022-02-17 12:47:41 -0300
commit7e8058bc399ede42b8eb57d62694015b4c0401e0 (patch)
tree49e64ac5cb10e932ea579a96ed7d771348038b81 /src
parent9e22f32dd442d7c95766aca54ceea9833efa4f9d (diff)
downloadluarocks-7e8058bc399ede42b8eb57d62694015b4c0401e0.tar.gz
luarocks-7e8058bc399ede42b8eb57d62694015b4c0401e0.tar.bz2
luarocks-7e8058bc399ede42b8eb57d62694015b4c0401e0.zip
builtin: always respect CC, CFLAGS, LDFLAGS
There were already workarounds in place for some platforms. This should make the behavior consistent. Fixes #429.
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/build/builtin.lua8
-rw-r--r--src/luarocks/core/cfg.lua10
2 files changed, 10 insertions, 8 deletions
diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua
index 98db29da..d8826851 100644
--- a/src/luarocks/build/builtin.lua
+++ b/src/luarocks/build/builtin.lua
@@ -157,6 +157,10 @@ function builtin.run(rockspec, no_install)
157 local variables = rockspec.variables 157 local variables = rockspec.variables
158 local checked_lua_h = false 158 local checked_lua_h = false
159 159
160 for _, var in ipairs{ "CC", "CFLAGS", "LDFLAGS" } do
161 variables[var] = os.getenv(var) or variables[var] or ""
162 end
163
160 local function add_flags(extras, flag, flags) 164 local function add_flags(extras, flag, flags)
161 if flags then 165 if flags then
162 if type(flags) ~= "table" then 166 if type(flags) ~= "table" then
@@ -182,7 +186,7 @@ function builtin.run(rockspec, no_install)
182 add_flags(extras, "-l%s", libraries) 186 add_flags(extras, "-l%s", libraries)
183 extras[#extras+1] = dir.path(variables.LUA_LIBDIR, variables.LUALIB) 187 extras[#extras+1] = dir.path(variables.LUA_LIBDIR, variables.LUALIB)
184 extras[#extras+1] = "-l" .. (variables.MSVCRT or "m") 188 extras[#extras+1] = "-l" .. (variables.MSVCRT or "m")
185 local ok = execute(variables.LD.." "..variables.LIBFLAG, "-o", library, unpack(extras)) 189 local ok = execute(variables.LD.." "..variables.LDFLAGS, variables.LIBFLAG, "-o", library, unpack(extras))
186 return ok 190 return ok
187 end 191 end
188 --[[ TODO disable static libs until we fix the conflict in the manifest, which will take extending the manifest format. 192 --[[ TODO disable static libs until we fix the conflict in the manifest, which will take extending the manifest format.
@@ -250,7 +254,7 @@ function builtin.run(rockspec, no_install)
250 extras[#extras+1] = "-L"..variables.LUA_LIBDIR 254 extras[#extras+1] = "-L"..variables.LUA_LIBDIR
251 extras[#extras+1] = "-llua" 255 extras[#extras+1] = "-llua"
252 end 256 end
253 return execute(variables.LD.." "..variables.LIBFLAG, "-o", library, unpack(extras)) 257 return execute(variables.LD.." "..variables.LDFLAGS, variables.LIBFLAG, "-o", library, unpack(extras))
254 end 258 end
255 compile_static_library = function(library, objects, libraries, libdirs, name) -- luacheck: ignore 211 259 compile_static_library = function(library, objects, libraries, libdirs, name) -- luacheck: ignore 211
256 local ok = execute(variables.AR, "rc", library, unpack(objects)) 260 local ok = execute(variables.AR, "rc", library, unpack(objects))
diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua
index fca315e0..c88d3892 100644
--- a/src/luarocks/core/cfg.lua
+++ b/src/luarocks/core/cfg.lua
@@ -477,19 +477,17 @@ local function make_defaults(lua_version, target_cpu, platforms, home)
477 if platforms.freebsd then 477 if platforms.freebsd then
478 defaults.arch = "freebsd-"..target_cpu 478 defaults.arch = "freebsd-"..target_cpu
479 defaults.gcc_rpath = false 479 defaults.gcc_rpath = false
480 defaults.variables.CC = os.getenv("CC") or "cc" 480 defaults.variables.CC = "cc"
481 defaults.variables.CFLAGS = os.getenv("CFLAGS") or defaults.variables.CFLAGS
482 defaults.variables.LD = defaults.variables.CC 481 defaults.variables.LD = defaults.variables.CC
483 defaults.variables.LIBFLAG = (os.getenv("LDFLAGS") or "").." -shared" 482 defaults.variables.LIBFLAG = "-shared"
484 end 483 end
485 484
486 if platforms.openbsd then 485 if platforms.openbsd then
487 defaults.arch = "openbsd-"..target_cpu 486 defaults.arch = "openbsd-"..target_cpu
488 defaults.gcc_rpath = false 487 defaults.gcc_rpath = false
489 defaults.variables.CC = os.getenv("CC") or "cc" 488 defaults.variables.CC = "cc"
490 defaults.variables.CFLAGS = os.getenv("CFLAGS") or defaults.variables.CFLAGS
491 defaults.variables.LD = defaults.variables.CC 489 defaults.variables.LD = defaults.variables.CC
492 defaults.variables.LIBFLAG = (os.getenv("LDFLAGS") or "").." -shared" 490 defaults.variables.LIBFLAG = "-shared"
493 end 491 end
494 492
495 if platforms.netbsd then 493 if platforms.netbsd then