فهرست منبع

Improve elfutils (#1262)

* improve libintl dep

* add argp-standalone to elfutils

* improve elfutils

* improve deps

* add libintl to elfutils

* fix some errors for android

* improve elfutils

* improve elfutils

* fix errors

* improve elfutils

* improve elfutils

* disable so for android

* fix errors
ruki 3 سال پیش
والد
کامیت
eb8cce95ad
1فایلهای تغییر یافته به همراه49 افزوده شده و 17 حذف شده
  1. 49 17
      packages/e/elfutils/xmake.lua

+ 49 - 17
packages/e/elfutils/xmake.lua

@@ -9,9 +9,24 @@ package("elfutils")
 
     add_patches("0.183", path.join(os.scriptdir(), "patches", "0.183", "configure.patch"), "7a16719d9e3d8300b5322b791ba5dd02986f2663e419c6798077dd023ca6173a")
 
+    add_configs("libelf",   {description = "Enable libelf", default = true, type = "boolean"})
+    add_configs("libcpu",   {description = "Enable libcpu", default = false, type = "boolean"})
+    add_configs("libebl",   {description = "Enable libebl", default = false, type = "boolean"})
+    add_configs("libdw",    {description = "Enable libdw", default = false, type = "boolean"})
+    add_configs("libdwelf", {description = "Enable libdwelf", default = false, type = "boolean"})
+    add_configs("libdwfl",  {description = "Enable libdwfl", default = false, type = "boolean"})
+    add_configs("libasm",   {description = "Enable libasm", default = false, type = "boolean"})
+
     add_deps("m4", "zlib")
+    if is_plat("android") then
+        add_deps("libintl", "argp-standalone")
+    end
+
+    if is_plat("android") then
+        add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
+    end
 
-    on_install("linux", function (package)
+    on_install("linux", "android", function (package)
         local configs = {"--disable-dependency-tracking",
                          "--disable-silent-rules",
                          "--program-prefix=elfutils-",
@@ -19,29 +34,46 @@ package("elfutils")
                          "--disable-debuginfod",
                          "--disable-libdebuginfod"}
         local cflags = {}
-        local ldflags = {}
-        for _, dep in ipairs(package:orderdeps()) do
-            local fetchinfo = dep:fetch()
-            if fetchinfo then
-                for _, includedir in ipairs(fetchinfo.includedirs or fetchinfo.sysincludedirs) do
-                    table.insert(cflags, "-I" .. includedir)
-                end
-                for _, linkdir in ipairs(fetchinfo.linkdirs) do
-                    table.insert(ldflags, "-L" .. linkdir)
-                end
-                for _, link in ipairs(fetchinfo.links) do
-                    table.insert(ldflags, "-l" .. link)
-                end
-            end
-        end
         if package:config("pic") ~= false then
             table.insert(cflags, "-fPIC")
         end
         for _, makefile in ipairs(os.files(path.join("*/Makefile.in"))) do
             io.replace(makefile, "-Wtrampolines", "", {plain = true})
             io.replace(makefile, "-Wimplicit-fallthrough=5", "", {plain = true})
+            if package:has_tool("cc", "clang") then
+                io.replace(makefile, "-Wno-packed-not-aligned", "", {plain = true})
+            end
+        end
+        local subdirs = {}
+        for name, enabled in pairs(package:configs()) do
+            if not package:extraconf("configs", name, "builtin") then
+                if enabled then
+                    table.insert(subdirs, name)
+                end
+            end
+        end
+        io.replace("Makefile.in", [[SUBDIRS = config lib libelf libcpu backends libebl libdwelf libdwfl libdw \
+	  libasm debuginfod src po doc tests]], "SUBDIRS = lib " .. table.concat(subdirs, " "), {plain = true})
+
+        if package:is_plat("android") then
+            io.replace("libelf/Makefile.in", "-Wl,--whole-archive $(libelf_so_LIBS) -Wl,--no-whole-archive", "$(libelf_so_LIBS)", {plain = true})
+            io.replace("libdw/Makefile.in", "-Wl,--whole-archive $(libdw_so_LIBS) -Wl,--no-whole-archive", "$(libdw_so_LIBS)", {plain = true})
+            io.replace("libasm/Makefile.in", "-Wl,--whole-archive $(libasm_so_LIBS) -Wl,--no-whole-archive", "$(libasm_so_LIBS)", {plain = true})
+            table.insert(cflags, "-Wno-error=conditional-type-mismatch")
+            table.insert(cflags, "-Wno-error=unused-command-line-argument")
+            table.insert(cflags, "-Wno-error=implicit-function-declaration")
+            table.insert(cflags, "-Wno-error=int-conversion")
+            table.insert(cflags, "-Wno-error=gnu-variable-sized-type-not-at-end")
+            table.insert(cflags, '-Dprogram_invocation_short_name=\\\"test\\\"')
+            table.insert(cflags, '-D_GNU_SOURCE=1')
+        end
+        import("package.tools.autoconf").install(package, configs, {cflags = cflags,
+            packagedeps = {"zlib", "libintl", "argp-standalone"}})
+        if package:config("shared") then
+            os.rm(path.join(package:installdir("lib"), "*.a"))
+        else
+            os.rm(path.join(package:installdir("lib"), "*.so"))
         end
-        import("package.tools.autoconf").install(package, configs, {cflags = cflags, ldflags = ldflags})
     end)
 
     on_test(function (package)