summaryrefslogtreecommitdiff
path: root/xmake/toolchains/gcc/xmake.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2020-05-20 00:36:09 +0800
committerruki <[email protected]>2020-05-19 21:36:54 +0800
commit1c7e32dea671abf42fc097db7141bd52a1fbfb19 (patch)
tree52f955cc55a9ef5dd173c7aa2a28ccff47f41ef2 /xmake/toolchains/gcc/xmake.lua
parent04493b00d03e87e3c2af7d9f58bb43edb77eb410 (diff)
improve linux platform
Diffstat (limited to 'xmake/toolchains/gcc/xmake.lua')
-rw-r--r--xmake/toolchains/gcc/xmake.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/xmake/toolchains/gcc/xmake.lua b/xmake/toolchains/gcc/xmake.lua
index 08bb2d062..ba1ef6989 100644
--- a/xmake/toolchains/gcc/xmake.lua
+++ b/xmake/toolchains/gcc/xmake.lua
@@ -37,3 +37,33 @@ toolchain("gcc")
on_check(function (toolchain)
return import("lib.detect.find_tool")("gcc")
end)
+
+ -- on load
+ on_load(function (toolchain)
+
+ -- get march
+ local march = is_arch("x86_64", "x64") and "-m64" or "-m32"
+
+ -- init flags for c/c++
+ toolchain:add("cxflags", march)
+ toolchain:add("ldflags", march)
+ toolchain:add("shflags", march)
+ if not is_plat("windows") and os.isdir("/usr") then
+ for _, includedir in ipairs({"/usr/local/include", "/usr/include"}) do
+ if os.isdir(includedir) then
+ toolchain:add("includedirs", includedir)
+ end
+ end
+ for _, linkdir in ipairs({"/usr/local/lib", "/usr/lib"}) do
+ if os.isdir(linkdir) then
+ toolchain:add("linkdirs", linkdir)
+ end
+ end
+ end
+
+ -- init flags for objc/c++ (with ldflags and shflags)
+ toolchain:add("mxflags", march)
+
+ -- init flags for asm
+ toolchain:add("asflags", march)
+ end)