2
0

xmake.lua 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package("libsdl_mixer")
  2. set_homepage("https://www.libsdl.org/projects/SDL_mixer/")
  3. set_description("Simple DirectMedia Layer mixer audio library")
  4. if is_plat("windows", "mingw") then
  5. set_urls("https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-devel-$(version)-VC.zip")
  6. add_versions("2.0.4", "258788438b7e0c8abb386de01d1d77efe79287d9967ec92fbb3f89175120f0b0")
  7. else
  8. set_urls("https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-$(version).zip")
  9. add_versions("2.0.4", "9affb8c7bf6fbffda0f6906bfb99c0ea50dca9b188ba9e15be90042dc03c5ded")
  10. end
  11. if is_plat("mingw") and is_subhost("msys") then
  12. add_extsources("pacman::SDL2_mixer")
  13. elseif is_plat("linux") then
  14. add_extsources("pacman::sdl2_mixer", "apt::libsdl2-mixer-dev")
  15. elseif is_plat("macosx") then
  16. add_extsources("brew::sdl2_mixer")
  17. end
  18. add_deps("libsdl")
  19. add_links("SDL2_mixer")
  20. add_includedirs("include", "include/SDL2")
  21. on_install("windows", "mingw", function (package)
  22. local arch = package:arch()
  23. if package:is_plat("mingw") then
  24. arch = (arch == "x86_64") and "x64" or "x86"
  25. end
  26. os.cp("include/*", package:installdir("include/SDL2"))
  27. os.cp(path.join("lib", arch, "*.lib"), package:installdir("lib"))
  28. os.cp(path.join("lib", arch, "*.dll"), package:installdir("bin"))
  29. end)
  30. on_install("macosx", "linux", function (package)
  31. local configs = {}
  32. if package:config("shared") then
  33. table.insert(configs, "--enable-shared=yes")
  34. else
  35. table.insert(configs, "--enable-shared=no")
  36. end
  37. if package:is_plat("linux") and package:config("pic") ~= false then
  38. table.insert(configs, "--with-pic")
  39. end
  40. local libsdl = package:dep("libsdl")
  41. if libsdl and not libsdl:is_system() then
  42. table.insert(configs, "--with-sdl-prefix=" .. libsdl:installdir())
  43. end
  44. import("package.tools.autoconf").install(package, configs)
  45. end)
  46. on_test(function (package)
  47. assert(package:has_cfuncs("Mix_Init", {includes = "SDL2/SDL_mixer.h", configs = {defines = "SDL_MAIN_HANDLED"}}))
  48. end)