xmake.lua 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package("nettle")
  2. set_homepage("https://www.lysator.liu.se/~nisse/nettle/")
  3. set_description("Nettle is a cryptographic library that is designed to fit easily in more or less any context.")
  4. set_license("LGPL-3.0")
  5. add_urls("https://ftpmirror.gnu.org/gnu/nettle/nettle-$(version).tar.gz",
  6. "https://ftp.gnu.org/gnu/nettle/nettle-$(version).tar.gz")
  7. add_versions("3.6", "d24c0d0f2abffbc8f4f34dcf114b0f131ec3774895f3555922fe2f40f3d5e3f1")
  8. add_versions("3.9.1", "ccfeff981b0ca71bbd6fbcb054f407c60ffb644389a5be80d6716d5b550c6ce3")
  9. add_versions("3.10.1", "b0fcdd7fc0cdea6e80dcf1dd85ba794af0d5b4a57e26397eee3bc193272d9132")
  10. add_deps("m4")
  11. add_deps("gmp")
  12. if is_plat("linux") then
  13. add_extsources("apt::nettle-dev")
  14. end
  15. on_install("@!windows and !wasm", function (package)
  16. if package:is_plat("iphoneos") then
  17. io.replace("configure", "#define gid_t int", "")
  18. io.replace("configure", "#define uid_t int", "")
  19. end
  20. local configs = {"--disable-openssl", "--disable-documentation", "--enable-pic"}
  21. if package:config("shared") then
  22. table.insert(configs, "--enable-shared")
  23. table.insert(configs, "--disable-static")
  24. else
  25. table.insert(configs, "--disable-shared")
  26. table.insert(configs, "--enable-static")
  27. end
  28. import("package.tools.autoconf")
  29. local envs = autoconf.buildenvs(package, {packagedeps = {"gmp"}})
  30. autoconf.install(package, configs, {envs = envs})
  31. if os.isfile(package:installdir("lib64", "pkgconfig", "nettle.pc")) then
  32. package:add("linkdirs", "lib64")
  33. end
  34. end)
  35. on_test(function (package)
  36. assert(package:check_csnippets([[
  37. void sha1_test(void) {
  38. struct sha1_ctx ctx;
  39. sha1_init(&ctx);
  40. uint8_t const buffer[] = "test";
  41. sha1_update(&ctx, sizeof(buffer), buffer);
  42. uint8_t digest[SHA1_DIGEST_SIZE];
  43. sha1_digest(&ctx, SHA1_DIGEST_SIZE, digest);
  44. }
  45. ]], {includes = "nettle/sha1.h"}))
  46. assert(package:check_csnippets([[
  47. void rsa_test(void) {
  48. struct rsa_public_key pub;
  49. rsa_public_key_init(&pub);
  50. rsa_public_key_clear(&pub);
  51. }
  52. ]], {includes = "nettle/rsa.h"}))
  53. end)