浏览代码

OpenSSL: Add support for MinGW (#704)

* OpenSSL: Add support for MinGW

* Update xmake.lua

* Almost there

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

Co-authored-by: ruki <[email protected]>
Jérôme Leclercq 3 年之前
父节点
当前提交
51254c7a54
共有 1 个文件被更改,包括 40 次插入14 次删除
  1. 40 14
      packages/o/openssl/xmake.lua

+ 40 - 14
packages/o/openssl/xmake.lua

@@ -15,11 +15,12 @@ package("openssl")
 
 
     if is_plat("windows") then
     if is_plat("windows") then
         add_links("libssl", "libcrypto")
         add_links("libssl", "libcrypto")
-        add_syslinks("ws2_32", "user32", "crypt32", "advapi32")
     else
     else
         add_links("ssl", "crypto")
         add_links("ssl", "crypto")
     end
     end
-    if is_plat("linux", "cross") then
+    if is_plat("windows", "mingw") then
+        add_syslinks("ws2_32", "user32", "crypt32", "advapi32")
+    elseif is_plat("linux", "cross") then
         add_syslinks("dl")
         add_syslinks("dl")
     end
     end
 
 
@@ -39,23 +40,47 @@ package("openssl")
     end)
     end)
 
 
     on_install("windows", function (package)
     on_install("windows", function (package)
-        local args = {"Configure"}
-        table.insert(args, (package:is_arch("x86") and "VC-WIN32" or "VC-WIN64A"))
+        local configs = {"Configure"}
+        table.insert(configs, package:is_arch("x86") and "VC-WIN32" or "VC-WIN64A")
+        table.insert(configs, package:config("shared") and "shared" or "no-shared")
+        table.insert(configs, "--prefix=" .. package:installdir())
+        table.insert(configs, "--openssldir=" .. package:installdir())
+        os.vrunv("perl", configs)
+        import("package.tools.nmake").install(package)
+    end)
+
+    on_install("mingw", function (package)
+        local configs = {"Configure", "no-tests"}
+        table.insert(configs, package:is_arch("i386", "x86") and "mingw" or "mingw64")
+        table.insert(configs, package:config("shared") and "shared" or "no-shared")
+        local installdir = package:installdir()
+        -- Use MSYS2 paths instead of Windows paths
+        if is_subhost("msys") then
+            installdir = installdir:gsub("(%a):[/\\](.+)", "/%1/%2"):gsub("\\", "/")
+        end
+        table.insert(configs, "--prefix=" .. installdir)
+        table.insert(configs, "--openssldir=" .. installdir)
+        local buildenvs = import("package.tools.autoconf").buildenvs(package)
+        buildenvs.RC = package:build_getenv("mrc")
+        if is_subhost("msys") then
+            local rc = buildenvs.RC
+            if rc then
+                rc = rc:gsub("(%a):[/\\](.+)", "/%1/%2"):gsub("\\", "/")
+                buildenvs.RC = rc
+            end
+        end
+        -- fix 'cp: directory fuzz does not exist'
         if package:config("shared") then
         if package:config("shared") then
-            table.insert(args, "shared")
-        else
-            table.insert(args, "no-shared")
+            os.mkdir("fuzz")
         end
         end
-        table.insert(args, "--prefix=" .. package:installdir())
-        table.insert(args, "--openssldir=" .. package:installdir())
-        os.vrunv("perl", args)
-
-        import("package.tools.nmake").install(package)
+        os.vrunv("perl", configs, {envs = buildenvs})
+        import("package.tools.make").install(package)
     end)
     end)
 
 
     on_install("linux", "macosx", function (package)
     on_install("linux", "macosx", function (package)
         -- https://wiki.openssl.org/index.php/Compilation_and_Installation#PREFIX_and_OPENSSLDIR
         -- https://wiki.openssl.org/index.php/Compilation_and_Installation#PREFIX_and_OPENSSLDIR
-        os.vrun("./config %s --openssldir=\"%s\" --prefix=\"%s\"", package:debug() and "--debug" or "", package:installdir(), package:installdir())
+        os.vrun("./config %s --openssldir=\"%s\" --prefix=\"%s\"",
+            package:debug() and "--debug" or "", package:installdir(), package:installdir())
         import("package.tools.make").install(package)
         import("package.tools.make").install(package)
     end)
     end)
 
 
@@ -68,7 +93,8 @@ package("openssl")
                 target = "linux-armv4"
                 target = "linux-armv4"
             end
             end
         end
         end
-        local configs = {target, "-DOPENSSL_NO_HEARTBEATS", "no-shared", "no-threads", "--prefix=" .. package:installdir()}
+        local configs = {target, "-DOPENSSL_NO_HEARTBEATS", "no-shared", "no-threads",
+            "--prefix=" .. package:installdir()}
         local buildenvs = import("package.tools.autoconf").buildenvs(package)
         local buildenvs = import("package.tools.autoconf").buildenvs(package)
         os.vrunv("./Configure", configs, {envs = buildenvs})
         os.vrunv("./Configure", configs, {envs = buildenvs})
         local makeconfigs = {CFLAGS = buildenvs.CFLAGS, ASFLAGS = buildenvs.ASFLAGS}
         local makeconfigs = {CFLAGS = buildenvs.CFLAGS, ASFLAGS = buildenvs.ASFLAGS}