xmake.lua 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package("elfutils")
  2. set_homepage("https://fedorahosted.org/elfutils/")
  3. set_description("Libraries and utilities for handling ELF objects")
  4. set_license("GPL-2.0")
  5. set_urls("https://sourceware.org/elfutils/ftp/$(version)/elfutils-$(version).tar.bz2")
  6. add_versions("0.183", "c3637c208d309d58714a51e61e63f1958808fead882e9b607506a29e5474f2c5")
  7. add_patches("0.183", path.join(os.scriptdir(), "patches", "0.183", "configure.patch"), "7a16719d9e3d8300b5322b791ba5dd02986f2663e419c6798077dd023ca6173a")
  8. add_configs("libelf", {description = "Enable libelf", default = true, type = "boolean"})
  9. add_configs("libcpu", {description = "Enable libcpu", default = false, type = "boolean"})
  10. add_configs("libebl", {description = "Enable libebl", default = false, type = "boolean"})
  11. add_configs("libdw", {description = "Enable libdw", default = false, type = "boolean"})
  12. add_configs("libdwelf", {description = "Enable libdwelf", default = false, type = "boolean"})
  13. add_configs("libdwfl", {description = "Enable libdwfl", default = false, type = "boolean"})
  14. add_configs("libasm", {description = "Enable libasm", default = false, type = "boolean"})
  15. add_deps("m4", "zlib")
  16. if is_plat("android") then
  17. add_deps("libintl", "argp-standalone")
  18. end
  19. if is_plat("android") then
  20. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  21. end
  22. on_install("linux", "android", function (package)
  23. local configs = {"--disable-dependency-tracking",
  24. "--disable-silent-rules",
  25. "--program-prefix=elfutils-",
  26. "--disable-symbol-versioning",
  27. "--disable-debuginfod",
  28. "--disable-libdebuginfod"}
  29. local cflags = {}
  30. if package:config("pic") ~= false then
  31. table.insert(cflags, "-fPIC")
  32. end
  33. for _, makefile in ipairs(os.files(path.join("*/Makefile.in"))) do
  34. io.replace(makefile, "-Wtrampolines", "", {plain = true})
  35. io.replace(makefile, "-Wimplicit-fallthrough=5", "", {plain = true})
  36. if package:has_tool("cc", "clang") then
  37. io.replace(makefile, "-Wno-packed-not-aligned", "", {plain = true})
  38. end
  39. end
  40. local subdirs = {}
  41. for name, enabled in pairs(package:configs()) do
  42. if not package:extraconf("configs", name, "builtin") then
  43. if enabled then
  44. table.insert(subdirs, name)
  45. end
  46. end
  47. end
  48. io.replace("Makefile.in", [[SUBDIRS = config lib libelf libcpu backends libebl libdwelf libdwfl libdw \
  49. libasm debuginfod src po doc tests]], "SUBDIRS = lib " .. table.concat(subdirs, " "), {plain = true})
  50. if package:is_plat("android") then
  51. io.replace("libelf/Makefile.in", "-Wl,--whole-archive $(libelf_so_LIBS) -Wl,--no-whole-archive", "$(libelf_so_LIBS)", {plain = true})
  52. io.replace("libdw/Makefile.in", "-Wl,--whole-archive $(libdw_so_LIBS) -Wl,--no-whole-archive", "$(libdw_so_LIBS)", {plain = true})
  53. io.replace("libasm/Makefile.in", "-Wl,--whole-archive $(libasm_so_LIBS) -Wl,--no-whole-archive", "$(libasm_so_LIBS)", {plain = true})
  54. table.insert(cflags, "-Wno-error=conditional-type-mismatch")
  55. table.insert(cflags, "-Wno-error=unused-command-line-argument")
  56. table.insert(cflags, "-Wno-error=implicit-function-declaration")
  57. table.insert(cflags, "-Wno-error=int-conversion")
  58. table.insert(cflags, "-Wno-error=gnu-variable-sized-type-not-at-end")
  59. table.insert(cflags, '-Dprogram_invocation_short_name=\\\"test\\\"')
  60. table.insert(cflags, '-D_GNU_SOURCE=1')
  61. end
  62. import("package.tools.autoconf").install(package, configs, {cflags = cflags,
  63. packagedeps = {"zlib", "libintl", "argp-standalone"}})
  64. if package:config("shared") then
  65. os.rm(path.join(package:installdir("lib"), "*.a"))
  66. else
  67. os.rm(path.join(package:installdir("lib"), "*.so"))
  68. end
  69. end)
  70. on_test(function (package)
  71. assert(package:has_cfuncs("elf_begin", {includes = "gelf.h"}))
  72. end)