xmake.lua 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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("android") then
  29. add_syslinks("dl", "OpenSLES")
  30. elseif is_plat("macosx", "iphoneos") then
  31. add_frameworks("CoreAudio", "CoreFoundation", "AudioToolbox")
  32. end
  33. on_load(function (package)
  34. if not package:config("shared") then
  35. package:add("defines", "AL_LIBTYPE_STATIC")
  36. end
  37. end)
  38. on_install("windows", "linux", "mingw", "macosx", "android", "iphoneos", "cross", function (package)
  39. if is_plat("linux") and linuxos.name() == "fedora" then
  40. -- https://github.com/kcat/openal-soft/issues/864
  41. io.replace("CMakeLists.txt", "if(HAVE_GCC_PROTECTED_VISIBILITY)", "if(0)", {plain = true})
  42. end
  43. local configs = {"-DALSOFT_EXAMPLES=OFF", "-DALSOFT_UTILS=OFF"}
  44. if package:config("shared") then
  45. table.insert(configs, "-DBUILD_SHARED_LIBS=ON")
  46. table.insert(configs, "-DLIBTYPE=SHARED")
  47. else
  48. table.insert(configs, "-DBUILD_SHARED_LIBS=OFF")
  49. table.insert(configs, "-DLIBTYPE=STATIC")
  50. end
  51. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  52. import("package.tools.cmake").install(package, configs)
  53. end)
  54. on_test(function (package)
  55. assert(package:has_cfuncs("alGetProcAddress", {includes = "AL/al.h"}))
  56. end)