xmake.lua 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package("openal-soft")
  2. set_homepage("https://openal-soft.org")
  3. set_description("OpenAL Soft is a software implementation of the OpenAL 3D audio API.")
  4. set_license("LGPL-2.0")
  5. add_urls("https://github.com/kcat/openal-soft/archive/refs/tags/$(version).tar.gz", {version = function (version)
  6. return version:ge("1.21.0") and version or "openal-soft-" .. version
  7. end})
  8. add_urls("https://github.com/kcat/openal-soft.git")
  9. add_versions("1.23.1", "dfddf3a1f61059853c625b7bb03de8433b455f2f79f89548cbcbd5edca3d4a4a")
  10. add_versions("1.22.2", "3e58f3d4458f5ee850039b1a6b4dac2343b3a5985a6a2e7ae2d143369c5b8135")
  11. add_versions("1.22.0", "814831a8013d7365dfd1917b27f1fb6e723f3be3fe1c6a7ff4516425d8392f68")
  12. add_versions("1.21.1", "8ac17e4e3b32c1af3d5508acfffb838640669b4274606b7892aa796ca9d7467f")
  13. if is_plat("mingw") and is_subhost("msys") then
  14. add_extsources("pacman::openal")
  15. elseif is_plat("linux") then
  16. add_extsources("pacman::openal", "apt::libopenal-dev")
  17. elseif is_plat("macosx") then
  18. add_extsources("brew::openal-soft")
  19. end
  20. add_deps("cmake")
  21. if is_plat("linux") then
  22. add_deps("libsndio")
  23. end
  24. if is_plat("windows", "mingw") then
  25. add_syslinks("ole32", "shell32", "user32", "winmm", "kernel32")
  26. elseif is_plat("linux", "cross") then
  27. add_syslinks("dl", "pthread")
  28. elseif is_plat("bsd", "cross") then
  29. add_syslinks("pthread")
  30. elseif is_plat("android") then
  31. add_syslinks("dl", "OpenSLES")
  32. elseif is_plat("macosx", "iphoneos") then
  33. add_frameworks("CoreAudio", "CoreFoundation", "AudioToolbox")
  34. end
  35. on_load(function (package)
  36. if not package:config("shared") then
  37. package:add("defines", "AL_LIBTYPE_STATIC")
  38. end
  39. end)
  40. on_install("windows", "linux", "mingw", "macosx", "android", "iphoneos", "cross", "bsd" , function (package)
  41. if (package:is_plat("linux") and linuxos.name() == "fedora") or package:is_plat("bsd") then
  42. -- https://github.com/kcat/openal-soft/issues/864
  43. io.replace("CMakeLists.txt", "if(HAVE_GCC_PROTECTED_VISIBILITY)", "if(0)", {plain = true})
  44. end
  45. local configs = {"-DALSOFT_EXAMPLES=OFF", "-DALSOFT_UTILS=OFF"}
  46. if package:config("shared") then
  47. table.insert(configs, "-DBUILD_SHARED_LIBS=ON")
  48. table.insert(configs, "-DLIBTYPE=SHARED")
  49. else
  50. table.insert(configs, "-DBUILD_SHARED_LIBS=OFF")
  51. table.insert(configs, "-DLIBTYPE=STATIC")
  52. end
  53. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  54. import("package.tools.cmake").install(package, configs)
  55. end)
  56. on_test(function (package)
  57. assert(package:has_cfuncs("alGetProcAddress", {includes = "AL/al.h"}))
  58. end)