summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRedbeanw44602 <[email protected]>2025-10-23 17:44:04 +0800
committerRedbeanw44602 <[email protected]>2025-10-23 17:44:04 +0800
commit64d61226cb275c214aa7160f1a1947e722be0ec0 (patch)
tree0a01b603f851568f220ea374709568c12c36777b
parent6796d33e9a788313207199ecc441c7e47b579168 (diff)
add libtool patch for cross compile.
-rw-r--r--xmake/modules/package/tools/autoconf.lua29
1 files changed, 29 insertions, 0 deletions
diff --git a/xmake/modules/package/tools/autoconf.lua b/xmake/modules/package/tools/autoconf.lua
index 56168fd6b..04f66cea4 100644
--- a/xmake/modules/package/tools/autoconf.lua
+++ b/xmake/modules/package/tools/autoconf.lua
@@ -276,6 +276,33 @@ function _get_ldflags_from_packagedeps(package, opt)
return result
end
+-- @see https://github.com/xmake-io/xmake-repo/pull/8165#issuecomment-3354492014
+function _apply_libtool_patch_for_cross(package, opt)
+ if package:is_cross() and os.isfile("libtool") then
+ io.replace("libtool", "--sysroot=*|", "--sysroot=*|--target=*|", {plain = true})
+ io.replace("libtool", "-Z*)", [[
+ -target)
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ func_append compiler_flags " $arg"
+ prev=target
+ continue
+ ;;
+ -Z*)
+ ]], {plain = true})
+ io.replace("libtool", "xcclinker)", [[
+ target)
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ func_append compiler_flags " $arg"
+ prev=
+ continue
+ ;;
+ xcclinker)
+ ]], {plain = true})
+ end
+end
+
-- get the build environments
function buildenvs(package, opt)
opt = opt or {}
@@ -584,6 +611,8 @@ function configure(package, configs, opt)
-- do configure
os.vrunv("./configure", argv, {shell = true, envs = envs})
+
+ _apply_libtool_patch_for_cross(package, opt)
end
-- do make