xmake.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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.24.3", "7e1fecdeb45e7f78722b776c5cf30bd33934b961d7fd2a11e0494e064cc631ce")
  10. add_versions("1.23.1", "dfddf3a1f61059853c625b7bb03de8433b455f2f79f89548cbcbd5edca3d4a4a")
  11. add_versions("1.22.2", "3e58f3d4458f5ee850039b1a6b4dac2343b3a5985a6a2e7ae2d143369c5b8135")
  12. add_versions("1.22.0", "814831a8013d7365dfd1917b27f1fb6e723f3be3fe1c6a7ff4516425d8392f68")
  13. add_versions("1.21.1", "8ac17e4e3b32c1af3d5508acfffb838640669b4274606b7892aa796ca9d7467f")
  14. if is_plat("mingw") and is_subhost("msys") then
  15. add_extsources("pacman::openal")
  16. elseif is_plat("linux") then
  17. add_extsources("pacman::openal", "apt::libopenal-dev")
  18. elseif is_plat("macosx") then
  19. add_extsources("brew::openal-soft")
  20. end
  21. add_deps("cmake")
  22. if is_plat("linux") then
  23. add_deps("libsndio")
  24. end
  25. if is_plat("windows", "mingw") then
  26. add_syslinks("ole32", "shell32", "user32", "winmm", "kernel32", "Avrt")
  27. if is_plat("mingw") then
  28. add_syslinks("uuid")
  29. end
  30. elseif is_plat("linux", "cross") then
  31. add_syslinks("dl", "pthread")
  32. elseif is_plat("bsd") then
  33. add_syslinks("stdthreads", "pthread")
  34. elseif is_plat("android") then
  35. add_syslinks("dl", "OpenSLES")
  36. elseif is_plat("macosx", "iphoneos") then
  37. add_frameworks("CoreAudio", "CoreFoundation", "AudioToolbox")
  38. end
  39. on_load(function (package)
  40. if not package:config("shared") then
  41. package:add("defines", "AL_LIBTYPE_STATIC")
  42. end
  43. end)
  44. on_install("windows", "linux", "mingw", "macosx", "android", "iphoneos", "cross", "bsd" , function (package)
  45. -- https://github.com/kcat/openal-soft/issues/864
  46. io.replace("CMakeLists.txt", "if(HAVE_GCC_PROTECTED_VISIBILITY)", "if(0)", { plain = true })
  47. local configs = {"-DALSOFT_EXAMPLES=OFF", "-DALSOFT_UTILS=OFF"}
  48. if package:config("shared") then
  49. table.insert(configs, "-DBUILD_SHARED_LIBS=ON")
  50. table.insert(configs, "-DLIBTYPE=SHARED")
  51. else
  52. table.insert(configs, "-DBUILD_SHARED_LIBS=OFF")
  53. table.insert(configs, "-DLIBTYPE=STATIC")
  54. end
  55. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  56. import("package.tools.cmake").install(package, configs)
  57. end)
  58. on_test(function (package)
  59. assert(package:has_cfuncs("alGetProcAddress", {includes = "AL/al.h"}))
  60. end)