xmake.lua 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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_versions("0.189", "39bd8f1a338e2b7cd4abc3ff11a0eddc6e690f69578a57478d8179b4148708c8")
  8. add_patches("0.183", path.join(os.scriptdir(), "patches", "0.183", "configure.patch"), "7a16719d9e3d8300b5322b791ba5dd02986f2663e419c6798077dd023ca6173a")
  9. add_patches("0.189", path.join(os.scriptdir(), "patches", "0.189", "configure.patch"), "b4016a97e6aaad92b15fad9a594961b1fc77a6d054ebadedef9bb3a55e99a8f8")
  10. add_configs("libelf", {description = "Enable libelf", default = true, type = "boolean"})
  11. add_configs("libdw", {description = "Enable libdw", default = true, type = "boolean"})
  12. add_configs("libasm", {description = "Enable libasm", default = false, type = "boolean"})
  13. add_deps("m4", "zstd", "zlib")
  14. if is_plat("android") then
  15. add_deps("libintl", "argp-standalone")
  16. end
  17. if is_plat("android") then
  18. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  19. end
  20. on_install("linux", "android", function (package)
  21. local configs = {"--disable-dependency-tracking",
  22. "--disable-silent-rules",
  23. "--program-prefix=elfutils-",
  24. "--disable-symbol-versioning",
  25. "--disable-debuginfod",
  26. "--disable-libdebuginfod"}
  27. local cflags = {}
  28. for _, makefile in ipairs(os.files(path.join("*/Makefile.in"))) do
  29. io.replace(makefile, "-Wtrampolines", "", {plain = true})
  30. io.replace(makefile, "-Wimplicit-fallthrough=5", "", {plain = true})
  31. io.replace(makefile, "-Werror", "", {plain = true})
  32. if package:has_tool("cc", "clang") then
  33. io.replace(makefile, "-Wno-packed-not-aligned", "", {plain = true})
  34. end
  35. end
  36. local subdirs = {}
  37. if package:config("libelf") then
  38. table.insert(subdirs, "libelf")
  39. end
  40. if package:config("libdw") then
  41. table.join2(subdirs, "libcpu", "backends", "libebl", "libdwelf", "libdwfl", "libdw")
  42. end
  43. if package:config("libasm") then
  44. table.insert(subdirs, "libasm")
  45. end
  46. io.replace("Makefile.in", [[SUBDIRS = config lib libelf libcpu backends libebl libdwelf libdwfl libdw \
  47. libasm debuginfod src po doc tests]], "SUBDIRS = lib " .. table.concat(subdirs, " "), {plain = true})
  48. if package:is_plat("android") then
  49. io.replace("libelf/Makefile.in", "-Wl,--whole-archive $(libelf_so_LIBS) -Wl,--no-whole-archive", "$(libelf_so_LIBS)", {plain = true})
  50. io.replace("libdw/Makefile.in", "-Wl,--whole-archive $(libdw_so_LIBS) -Wl,--no-whole-archive", "$(libdw_so_LIBS)", {plain = true})
  51. io.replace("libasm/Makefile.in", "-Wl,--whole-archive $(libasm_so_LIBS) -Wl,--no-whole-archive", "$(libasm_so_LIBS)", {plain = true})
  52. table.insert(cflags, "-Wno-error=conditional-type-mismatch")
  53. table.insert(cflags, "-Wno-error=unused-command-line-argument")
  54. table.insert(cflags, "-Wno-error=implicit-function-declaration")
  55. table.insert(cflags, "-Wno-error=int-conversion")
  56. table.insert(cflags, "-Wno-error=gnu-variable-sized-type-not-at-end")
  57. table.insert(cflags, '-Dprogram_invocation_short_name=\\\"test\\\"')
  58. table.insert(cflags, '-D_GNU_SOURCE=1')
  59. end
  60. local packagedeps = {"zlib"}
  61. if package:is_plat("android") then
  62. table.join2(packagedeps, "libintl", "argp-standalone")
  63. end
  64. import("package.tools.autoconf").install(package, configs, {cflags = cflags,
  65. packagedeps = packagedeps})
  66. if package:config("shared") then
  67. os.rm(path.join(package:installdir("lib"), "*.a"))
  68. else
  69. os.rm(path.join(package:installdir("lib"), "*.so"))
  70. os.tryrm(path.join(package:installdir("lib"), "*.so.*"))
  71. end
  72. os.trycp("libelf/elf.h", package:installdir("include"))
  73. end)
  74. on_test(function (package)
  75. assert(package:has_cfuncs("elf_begin", {includes = "gelf.h"}))
  76. end)