xmake.lua 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package("libxslt")
  2. set_homepage("http://xmlsoft.org/XSLT/")
  3. set_description("Libxslt is the XSLT C library developed for the GNOME project.")
  4. set_license("MIT")
  5. add_urls("http://xmlsoft.org/sources/libxslt-$(version).tar.gz")
  6. add_versions("1.1.34", "98b1bd46d6792925ad2dfe9a87452ea2adebf69dcb9919ffd55bf926a7f93f7f")
  7. add_configs("iconv", {description = "Enable libiconv support.", default = false, type = "boolean"})
  8. on_load("windows", "macosx", "linux", function (package)
  9. if package:is_plat("windows") and not package:config("shared") then
  10. package:add("defines", "LIBXSLT_STATIC")
  11. end
  12. package:add("deps", "libxml2", {configs = {iconv = package:config("iconv")}})
  13. end)
  14. on_install("windows", function (package)
  15. io.replace("libxslt/xsltconfig.h.in", "@WITH_PROFILER@", "0", {plain = true})
  16. os.cd("win32")
  17. local args = {"configure.js", "compiler=msvc", "iconv=no"}
  18. table.insert(args, "cruntime=/" .. package:config("vs_runtime"))
  19. table.insert(args, "debug=" .. (package:debug() and "yes" or "no"))
  20. local cflags = "/DLIBXML_STATIC \"/I$(INCPREFIX)\" \"/I" .. package:dep("libxml2"):installdir("include", "libxml2") .. "\""
  21. local ldflags = "ws2_32.lib \"/LIBPATH:$(LIBPREFIX)\" \"/LIBPATH:" .. package:dep("libxml2"):installdir("lib") .. "\""
  22. io.replace("Makefile.msvc", "libxml2.lib", "libxml2_a.lib", {plain = true})
  23. io.replace("Makefile.msvc", "/I$(INCPREFIX)", cflags, {plain = true})
  24. io.replace("Makefile.msvc", "/LIBPATH:$(LIBPREFIX)", ldflags, {plain = true})
  25. table.insert(args, "prefix=" .. package:installdir())
  26. os.vrunv("cscript", args)
  27. import("package.tools.nmake").install(package, {"/f", "Makefile.msvc"})
  28. if package:config("shared") then
  29. os.tryrm(path.join(package:installdir("lib"), "libxslt_a.lib"))
  30. os.tryrm(path.join(package:installdir("lib"), "libexslt_a.lib"))
  31. else
  32. os.tryrm(path.join(package:installdir("lib"), "libxslt.lib"))
  33. os.tryrm(path.join(package:installdir("lib"), "libexslt.lib"))
  34. os.tryrm(path.join(package:installdir("bin"), "libxslt.dll"))
  35. os.tryrm(path.join(package:installdir("bin"), "libexslt.dll"))
  36. end
  37. package:addenv("PATH", "bin")
  38. end)
  39. on_install("macosx", "linux", function (package)
  40. local configs = {}
  41. if package:config("shared") then
  42. table.insert(configs, "--enable-shared=yes")
  43. table.insert(configs, "--enable-static=no")
  44. else
  45. table.insert(configs, "--enable-shared=no")
  46. table.insert(configs, "--enable-static=yes")
  47. end
  48. if package:config("pic") ~= false then
  49. table.insert(configs, "--with-pic")
  50. end
  51. import("package.tools.autoconf").install(package, configs)
  52. package:addenv("PATH", "bin")
  53. end)
  54. on_test(function (package)
  55. assert(package:has_cfuncs("xsltInit", {includes = {"libxslt/xslt.h"}}))
  56. end)