Cross-Platform build scripts for audio plugins
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build-jack2.sh 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #!/bin/bash
  2. set -e
  3. cd $(dirname ${0})
  4. PAWPAW_ROOT="${PWD}"
  5. JACK2_VERSION=${JACK2_VERSION:=git}
  6. JACK_ROUTER_VERSION=${JACK_ROUTER_VERSION:=6c2e532bb05d2ba59ef210bef2fe270d588c2fdf}
  7. QJACKCTL_VERSION=${QJACKCTL_VERSION:=0.9.4}
  8. # ---------------------------------------------------------------------------------------------------------------------
  9. target="${1}"
  10. if [ -z "${target}" ]; then
  11. echo "usage: ${0} <target>"
  12. exit 1
  13. fi
  14. # TODO check that bootstrap-jack.sh has been run
  15. # ---------------------------------------------------------------------------------------------------------------------
  16. source setup/check_target.sh
  17. source setup/env.sh
  18. source setup/functions.sh
  19. source setup/versions.sh
  20. # ---------------------------------------------------------------------------------------------------------------------
  21. jack2_repo="https://github.com/jackaudio/jack2.git"
  22. jack2_prefix="${PAWPAW_PREFIX}-jack2"
  23. if [ "${MACOS}" -eq 1 ]; then
  24. jack2_extra_prefix="/usr/local"
  25. fi
  26. # ---------------------------------------------------------------------------------------------------------------------
  27. # jack2
  28. jack2_args="--prefix=${jack2_prefix}"
  29. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  30. if [ "${LINUX}" -eq 1 ]; then
  31. jack2_args+=" --platform=linux"
  32. elif [ "${MACOS}" -eq 1 ]; then
  33. jack2_args+=" --platform=darwin"
  34. elif [ "${WIN32}" -eq 1 ]; then
  35. jack2_args+=" --platform=win32"
  36. fi
  37. fi
  38. if [ "${MACOS}" -eq 1 ]; then
  39. jack2_args+=" --prefix=${jack2_extra_prefix}"
  40. jack2_args+=" --destdir="${jack2_prefix}""
  41. elif [ "${WIN32}" -eq 1 ]; then
  42. jack2_args+=" --static"
  43. fi
  44. if [ "${WIN64}" -eq 1 ]; then
  45. jack2_args="${jack2_args} --mixed"
  46. # win32 toolchain prefix
  47. TOOLCHAIN_PREFIX32=$(echo ${TOOLCHAIN_PREFIX} | sed 's/x86_64/i686/')
  48. # let jack2 find win32 binaries
  49. TARGET_PATH="${TARGET_PATH}:/usr/${TOOLCHAIN_PREFIX32}/bin"
  50. # setup linker for our custom folder
  51. export EXTRA_LDFLAGS="-L${PAWPAW_PREFIX}/lib32"
  52. fi
  53. if [ "${JACK2_VERSION}" = "git" ]; then
  54. if [ ! -d jack2 ]; then
  55. git clone --recursive "${jack2_repo}"
  56. fi
  57. if [ ! -e "${PAWPAW_BUILDDIR}/jack2-git" ]; then
  58. ln -sf "$(pwd)/jack2" "${PAWPAW_BUILDDIR}/jack2-git"
  59. fi
  60. rm -f "${PAWPAW_BUILDDIR}/jack2-git/.stamp_built"
  61. else
  62. download jack2 "${JACK2_VERSION}" "${jack2_repo}" "" "git"
  63. fi
  64. build_waf jack2 "${JACK2_VERSION}" "${jack2_args}"
  65. # remove useless dbus-specific file
  66. rm -f "${jack2_prefix}${jack2_extra_prefix}/bin/jack_control"
  67. # generate MSVC lib files
  68. if [ "${WIN64}" -eq 1 ]; then
  69. llvm-dlltool -m i386 -D libjack.dll -d ${jack2_prefix}${jack2_extra_prefix}/lib32/libjack.def -l ${jack2_prefix}${jack2_extra_prefix}/lib32/libjack.lib
  70. llvm-dlltool -m i386:x86-64 -D libjack64.dll -d ${jack2_prefix}${jack2_extra_prefix}/lib/libjack64.def -l ${jack2_prefix}${jack2_extra_prefix}/lib/libjack64.lib
  71. llvm-dlltool -m i386:x86-64 -D libjacknet64.dll -d ${jack2_prefix}${jack2_extra_prefix}/lib/libjacknet64.def -l ${jack2_prefix}${jack2_extra_prefix}/lib/libjacknet64.lib
  72. llvm-dlltool -m i386:x86-64 -D libjackserver64.dll -d ${jack2_prefix}${jack2_extra_prefix}/lib/libjackserver64.def -l ${jack2_prefix}${jack2_extra_prefix}/lib/libjackserver64.lib
  73. elif [ "${WIN32}" -eq 1 ]; then
  74. llvm-dlltool -m i386 -D libjack.dll -d ${jack2_prefix}${jack2_extra_prefix}/lib/libjack.def -l ${jack2_prefix}${jack2_extra_prefix}/lib/libjack.lib
  75. llvm-dlltool -m i386 -D libjacknet.dll -d ${jack2_prefix}${jack2_extra_prefix}/lib/libjacknet.def -l ${jack2_prefix}${jack2_extra_prefix}/lib/libjacknet.lib
  76. llvm-dlltool -m i386 -D libjackserver.dll -d ${jack2_prefix}${jack2_extra_prefix}/lib/libjackserver.def -l ${jack2_prefix}${jack2_extra_prefix}/lib/libjackserver.lib
  77. fi
  78. # copy jack pkg-config file to main system, so qjackctl can find it
  79. if [ ! -e "${PAWPAW_PREFIX}/lib/pkgconfig/jack.pc" ]; then
  80. cp -v "${jack2_prefix}${jack2_extra_prefix}/lib/pkgconfig/jack.pc" "${PAWPAW_PREFIX}/lib/pkgconfig/jack.pc"
  81. # patch pkg-config file for static win32 builds in regular prefix
  82. if [ "${WIN32}" -eq 1 ]; then
  83. if [ "${WIN64}" -eq 1 ]; then
  84. s="64"
  85. else
  86. s=""
  87. fi
  88. # FIXME rule that works for server lib too, maybe ignoring suffix even
  89. sed -i -e "s/lib -ljack${s}/lib -Wl,-Bdynamic -ljack${s} -Wl,-Bstatic/" "${PAWPAW_PREFIX}/lib/pkgconfig/jack.pc"
  90. fi
  91. fi
  92. # ---------------------------------------------------------------------------------------------------------------------
  93. # jack-router (download, win32 only)
  94. if [ "${WIN32}" -eq 1 ]; then
  95. download jack-router "${JACK_ROUTER_VERSION}" "https://github.com/jackaudio/jack-router.git" "" "git"
  96. fi
  97. # ---------------------------------------------------------------------------------------------------------------------
  98. # qjackctl (if qt is available)
  99. if [ -f "${PAWPAW_PREFIX}/bin/moc" ]; then
  100. download qjackctl "${QJACKCTL_VERSION}" https://download.sourceforge.net/qjackctl
  101. if [ "${WIN64}" -eq 1 ]; then
  102. patch_file qjackctl "${QJACKCTL_VERSION}" "configure" 's/-ljack /-Wl,-Bdynamic -ljack64 -Wl,-Bstatic /'
  103. elif [ "${WIN32}" -eq 1 ]; then
  104. patch_file qjackctl "${QJACKCTL_VERSION}" "configure" 's/-ljack /-Wl,-Bdynamic -ljack -Wl,-Bstatic /'
  105. fi
  106. if [ "${MACOS}" -eq 1 ]; then
  107. qjackctl_extra_args="--with-jack="${jack2_prefix}${jack2_extra_prefix}""
  108. elif [ "${WIN32}" -eq 1 ]; then
  109. qjackctl_extra_args="--enable-portaudio"
  110. fi
  111. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  112. export EXTRA_CXXFLAGS="-std=gnu++11"
  113. fi
  114. build_autoconf qjackctl "${QJACKCTL_VERSION}" "--enable-jack-version ${qjackctl_extra_args}"
  115. if [ "${WIN32}" -eq 1 ]; then
  116. copy_file qjackctl "${QJACKCTL_VERSION}" "src/release/qjackctl.exe" "${jack2_prefix}/bin/qjackctl.exe"
  117. fi
  118. fi
  119. # ---------------------------------------------------------------------------------------------------------------------