xmake.lua 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package("c-ares")
  2. set_homepage("https://c-ares.haxx.se/")
  3. set_description("A C library for asynchronous DNS requests")
  4. add_urls("https://c-ares.haxx.se/download/c-ares-$(version).tar.gz")
  5. add_versions("1.16.1", "d08312d0ecc3bd48eee0a4cc0d2137c9f194e0a28de2028928c0f6cae85f86ce")
  6. add_versions("1.17.1", "d73dd0f6de824afd407ce10750ea081af47eba52b8a6cb307d220131ad93fc40")
  7. if is_plat("macosx") then
  8. add_syslinks("resolv")
  9. end
  10. on_install("windows", function (package)
  11. local configs = {"-f", "Makefile.msvc"}
  12. local cfg = (package:config("shared") and "dll" or "lib") .. "-" .. (package:config("debug") and "debug" or "release")
  13. table.insert(configs, "CFG=" .. cfg)
  14. if package:config("vs_runtime"):startswith("MT") then
  15. table.insert(configs, "RTLIBCFG=static")
  16. end
  17. import("package.tools.nmake").build(package, configs)
  18. os.cp(path.join("include", "*.h"), package:installdir("include"))
  19. os.cp(path.join("msvc", "cares", cfg, "*.lib"), package:installdir("lib"))
  20. os.trycp(path.join("msvc", "cares", cfg, "*.dll"), package:installdir("bin"))
  21. if not package:config("shared") then
  22. package:add("defines", "CARES_STATICLIB")
  23. end
  24. end)
  25. on_install("macosx", "linux", function (package)
  26. local configs = {}
  27. if package:config("shared") then
  28. table.insert(configs, "--enable-shared=yes")
  29. table.insert(configs, "--enable-static=no")
  30. else
  31. table.insert(configs, "--enable-shared=no")
  32. table.insert(configs, "--enable-static=yes")
  33. end
  34. if package:config("debug") then
  35. table.insert(configs, "--enable-debug")
  36. else
  37. table.insert(configs, "--disable-debug")
  38. end
  39. import("package.tools.autoconf").install(package, configs)
  40. end)
  41. on_test(function (package)
  42. assert(package:has_cfuncs("ares_library_init", {includes = "ares.h"}))
  43. end)