xmake.lua 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package("libelf")
  2. set_homepage("https://web.archive.org/web/20181111033959/www.mr511.de/software/english.html")
  3. set_description("ELF object file access library")
  4. set_urls("https://github.com/xmake-mirror/libelf/releases/download/$(version)/libelf-$(version).tar.gz",
  5. "https://github.com/xmake-mirror/libelf.git")
  6. add_versions("0.8.13", "591a9b4ec81c1f2042a97aa60564e0cb79d041c52faa7416acb38bc95bd2c76d")
  7. add_resources("0.8.13", "config", "https://dev.gentoo.org/~sam/distfiles/sys-devel/gnuconfig/gnuconfig-20240728.tar.xz", "6e3a7389d780cb0cf81bec0bba96ca278d5b76afd548352f70b4a444344430b7")
  8. add_includedirs("include", "include/libelf")
  9. if not is_subhost("windows") then
  10. add_deps("autotools")
  11. end
  12. on_install("cross", "linux", "android", function (package)
  13. local configs = {"--disable-dependency-tracking",
  14. "--disable-compat"}
  15. table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
  16. table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
  17. if package:debug() then
  18. table.insert(configs, "--enable-debug")
  19. end
  20. local cxflags = {}
  21. if package:is_plat("android") then
  22. io.replace("lib/private.h", "HAVE_MEMMOVE", "1")
  23. io.replace("lib/private.h", "HAVE_MEMCPY", "1")
  24. io.replace("lib/private.h", "STDC_HEADERS", "1")
  25. table.insert(cxflags, "-D__LIBELF64=1")
  26. table.insert(cxflags, "-D__libelf_u64_t=uint64_t")
  27. table.insert(cxflags, "-D__libelf_i64_t=int64_t")
  28. package:add("defines", "__LIBELF64=1")
  29. package:add("defines", "__libelf_u64_t=uint64_t")
  30. package:add("defines", "__libelf_i64_t=int64_t")
  31. end
  32. if not is_subhost("windows") then
  33. os.rm("configure")
  34. else
  35. io.replace("lib/Makefile.in", [[$(SHELL) $(top_srcdir)/mkinstalldirs $(instroot)$$dir;]], [["$(SHELL)" "$(top_srcdir)/mkinstalldirs" "$(instroot)$$dir";]], {plain = true})
  36. io.replace("po/Makefile.in", [[$(SHELL) $(top_srcdir)/mkinstalldirs $(instroot)$$dir;]], [["$(SHELL)" "$(top_srcdir)/mkinstalldirs" "$(instroot)$$dir";]], {plain = true})
  37. io.replace("configure", [[{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }]], [[ac_cv_prog_cc_works=yes]], {plain = true})
  38. io.replace("configure", [[libelf_cv_int64=no]], [[libelf_cv_int64='long']], {plain = true})
  39. io.replace("configure", [[libelf_cv_int32=no]], [[libelf_cv_int32='int']], {plain = true})
  40. io.replace("configure", [[libelf_cv_int16=no]], [[libelf_cv_int16='short']], {plain = true})
  41. end
  42. os.cp(path.join(package:resourcedir("config"), "config.guess"), "config.guess")
  43. os.cp(path.join(package:resourcedir("config"), "config.sub"), "config.sub")
  44. import("package.tools.autoconf").install(package, configs, {cxflags = cxflags})
  45. end)
  46. on_test(function (package)
  47. assert(package:has_cfuncs("gelf_getsym", {includes = "libelf/gelf.h"}))
  48. assert(package:has_cfuncs("elf_begin", {includes = "libelf/libelf.h"}))
  49. end)