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.

263 lines
10KB

  1. #!/bin/bash
  2. set -e
  3. cd $(dirname ${0})
  4. PAWPAW_ROOT="${PWD}"
  5. JACK2_VERSION=git
  6. QJACKCTL_VERSION=0.6.2
  7. # ---------------------------------------------------------------------------------------------------------------------
  8. target="${1}"
  9. if [ -z "${target}" ]; then
  10. echo "usage: ${0} <target> [package-build?]"
  11. exit 1
  12. fi
  13. if [ -n "${2}" ]; then
  14. PACKAGING_BUILD="y"
  15. fi
  16. # ---------------------------------------------------------------------------------------------------------------------
  17. # TODO check that bootstrap.sh has been run
  18. source setup/check_target.sh
  19. source setup/env.sh
  20. source setup/functions.sh
  21. source setup/versions.sh
  22. # ---------------------------------------------------------------------------------------------------------------------
  23. # aften (macos only)
  24. if [ "${MACOS}" -eq 1 ]; then
  25. download aften "${AFTEN_VERSION}" "http://downloads.sourceforge.net/aften" "tar.bz2"
  26. build_cmake aften "${AFTEN_VERSION}"
  27. if [ ! -f "${PAWPAW_BUILDDIR}/aften-${AFTEN_VERSION}/.stamp_installed_libs" ]; then
  28. cp -v "${PAWPAW_BUILDDIR}/aften-${AFTEN_VERSION}/build/libaften_pcm.a" "${PAWPAW_PREFIX}/lib/libaften_pcm.a"
  29. cp -v "${PAWPAW_BUILDDIR}/aften-${AFTEN_VERSION}/build/libaften_static.a" "${PAWPAW_PREFIX}/lib/libaften.a"
  30. touch "${PAWPAW_BUILDDIR}/aften-${AFTEN_VERSION}/.stamp_installed_libs"
  31. fi
  32. fi
  33. # ---------------------------------------------------------------------------------------------------------------------
  34. # db
  35. download db "${DB_VERSION}" "https://download.oracle.com/berkeley-db"
  36. # based on build_autoconf
  37. function build_custom_db() {
  38. local name="${1}"
  39. local version="${2}"
  40. local extraconfrules="${3}"
  41. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  42. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  43. extraconfrules="--host=${TOOLCHAIN_PREFIX} ${extraconfrules}"
  44. fi
  45. if [ "${WIN32}" -eq 1 ]; then
  46. extraconfrules="--enable-mingw ${extraconfrules}"
  47. fi
  48. _prebuild "${name}" "${pkgdir}"
  49. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  50. pushd "${pkgdir}/build_unix"
  51. ../dist/configure --enable-static --disable-shared --disable-debug --disable-doc --disable-maintainer-mode --prefix="${PAWPAW_PREFIX}" ${extraconfrules}
  52. touch ../.stamp_configured
  53. popd
  54. fi
  55. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  56. pushd "${pkgdir}/build_unix"
  57. make ${MAKE_ARGS}
  58. touch ../.stamp_built
  59. popd
  60. fi
  61. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  62. pushd "${pkgdir}/build_unix"
  63. make ${MAKE_ARGS} install
  64. touch ../.stamp_installed
  65. popd
  66. fi
  67. _postbuild
  68. }
  69. patch_file db "${DB_VERSION}" "src/dbinc/atomic.h" 's/__atomic_compare_exchange/__db_atomic_compare_exchange/'
  70. build_custom_db db "${DB_VERSION}" "--disable-java --disable-replication --disable-sql --disable-tcl"
  71. # --enable-posixmutexes --enable-compat185 --enable-cxx --enable-dbm --enable-stl
  72. # ---------------------------------------------------------------------------------------------------------------------
  73. # opus
  74. download opus "${OPUS_VERSION}" "https://archive.mozilla.org/pub/opus"
  75. build_autoconf opus "${OPUS_VERSION}" "--disable-extra-programs --enable-custom-modes --enable-float-approx"
  76. # ---------------------------------------------------------------------------------------------------------------------
  77. # rtaudio (download, win32 only)
  78. if [ "${WIN32}" -eq 1 ]; then
  79. download rtaudio "${RTAUDIO_VERSION}" "https://github.com/falkTX/rtaudio.git" "" "git"
  80. # fixes for portaudio
  81. link_file rtaudio "${RTAUDIO_VERSION}" "." "include/common"
  82. link_file rtaudio "${RTAUDIO_VERSION}" "." "include/host"
  83. link_file rtaudio "${RTAUDIO_VERSION}" "." "include/pc"
  84. fi
  85. # ---------------------------------------------------------------------------------------------------------------------
  86. # portaudio (win32 only)
  87. if [ "${WIN32}" -eq 1 ]; then
  88. ASIO_DIR="${PAWPAW_BUILDDIR}/rtaudio-${RTAUDIO_VERSION}/include"
  89. export EXTRA_CFLAGS="-I${ASIO_DIR}"
  90. export EXTRA_CXXFLAGS="-I${ASIO_DIR}"
  91. export EXTRA_MAKE_ARGS="-j 1"
  92. download portaudio19 "${PORTAUDIO_VERSION}" "http://deb.debian.org/debian/pool/main/p/portaudio19" "orig.tar.gz"
  93. remove_file portaudio19 "${PORTAUDIO_VERSION}" "src/hostapi/wasapi/mingw-include/audioclient.h"
  94. remove_file portaudio19 "${PORTAUDIO_VERSION}" "src/hostapi/wasapi/mingw-include/devicetopology.h"
  95. remove_file portaudio19 "${PORTAUDIO_VERSION}" "src/hostapi/wasapi/mingw-include/endpointvolume.h"
  96. remove_file portaudio19 "${PORTAUDIO_VERSION}" "src/hostapi/wasapi/mingw-include/functiondiscoverykeys.h"
  97. remove_file portaudio19 "${PORTAUDIO_VERSION}" "src/hostapi/wasapi/mingw-include/ksguid.h"
  98. remove_file portaudio19 "${PORTAUDIO_VERSION}" "src/hostapi/wasapi/mingw-include/ksproxy.h"
  99. remove_file portaudio19 "${PORTAUDIO_VERSION}" "src/hostapi/wasapi/mingw-include/ksuuids.h"
  100. remove_file portaudio19 "${PORTAUDIO_VERSION}" "src/hostapi/wasapi/mingw-include/mmdeviceapi.h"
  101. remove_file portaudio19 "${PORTAUDIO_VERSION}" "src/hostapi/wasapi/mingw-include/propkeydef.h"
  102. remove_file portaudio19 "${PORTAUDIO_VERSION}" "src/hostapi/wasapi/mingw-include/propsys.h"
  103. remove_file portaudio19 "${PORTAUDIO_VERSION}" "src/hostapi/wasapi/mingw-include/rpcsal.h"
  104. remove_file portaudio19 "${PORTAUDIO_VERSION}" "src/hostapi/wasapi/mingw-include/sal.h"
  105. remove_file portaudio19 "${PORTAUDIO_VERSION}" "src/hostapi/wasapi/mingw-include/structuredquery.h"
  106. build_autoconf portaudio19 "${PORTAUDIO_VERSION}" "--enable-cxx --with-asiodir="${ASIO_DIR}" --with-winapi=asio,directx,wasapi,wdmks,wmme"
  107. fi
  108. # ---------------------------------------------------------------------------------------------------------------------
  109. # tre (win32 only)
  110. if [ "${WIN32}" -eq 1 ]; then
  111. download tre "${TRE_VERSION}" "https://laurikari.net/tre"
  112. build_autoconf tre "${TRE_VERSION}" "--disable-nls"
  113. fi
  114. # ---------------------------------------------------------------------------------------------------------------------
  115. # stop here if CI test build
  116. if [ -n "${TRAVIS_BUILD_DIR}" ]; then
  117. exit 0
  118. fi
  119. # ---------------------------------------------------------------------------------------------------------------------
  120. # and finally jack2
  121. jack2_repo="git@github.com:jackaudio/jack2.git"
  122. jack2_prefix="${PAWPAW_PREFIX}/jack2"
  123. jack2_args="--prefix=${jack2_prefix}"
  124. # if [ "${MACOS_OLD}" -eq 1 ] || [ "${WIN64}" -eq 1 ]; then
  125. # jack2_args="${jack2_args} --mixed"
  126. # fi
  127. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  128. if [ "${LINUX}" -eq 1 ]; then
  129. jack2_args="${jack2_args} --platform=linux"
  130. elif [ "${MACOS}" -eq 1 ]; then
  131. jack2_args="${jack2_args} --platform=darwin"
  132. elif [ "${WIN32}" -eq 1 ]; then
  133. jack2_args="${jack2_args} --platform=win32"
  134. fi
  135. fi
  136. if [ "${MACOS_OLD}" -eq 1 ]; then
  137. patch_file jack2 "git" "wscript" '/-std=gnu++11/d'
  138. patch_file jack2 "git" "wscript" '/-Wno-deprecated-register/d'
  139. fi
  140. if [ "${JACK2_VERSION}" = "git" ]; then
  141. if [ ! -d jack2 ]; then
  142. git clone --recursive "${jack2_repo}"
  143. fi
  144. if [ ! -e "${PAWPAW_BUILDDIR}/jack2-git" ]; then
  145. ln -sf "$(pwd)/jack2" "${PAWPAW_BUILDDIR}/jack2-git"
  146. fi
  147. rm -f "${PAWPAW_BUILDDIR}/jack2-git/.stamp_built"
  148. else
  149. download jack2 "${JACK2_VERSION}" "${jack2_repo}" "" "git"
  150. fi
  151. build_waf jack2 "${JACK2_VERSION}" "${jack2_args}"
  152. # remove useless dbus-specific file
  153. rm "${PAWPAW_PREFIX}/jack2/bin/jack_control"
  154. # copy jack pkg-config file to main system, so qjackctl can find it
  155. if [ ! -e "${PAWPAW_PREFIX}/lib/pkgconfig/jack.pc" ]; then
  156. cp -v "${PAWPAW_PREFIX}/jack2/lib/pkgconfig/jack.pc" "${PAWPAW_PREFIX}/lib/pkgconfig/jack.pc"
  157. # patch pkg-config file for static win32 builds in regular prefix
  158. if [ "${WIN32}" -eq 1 ]; then
  159. if [ "${WIN64}" -eq 1 ]; then
  160. s="64"
  161. else
  162. s=""
  163. fi
  164. # FIXME rule that works for server lib too, maybe ignoring suffix even
  165. sed -i -e "s/lib -ljack${s}/lib -Wl,-Bdynamic -ljack${s} -Wl,-Bstatic/" "${PAWPAW_PREFIX}/lib/pkgconfig/jack.pc"
  166. fi
  167. fi
  168. if [ "${MACOS}" -eq 1 ]; then
  169. for f in $(ls "${PAWPAW_PREFIX}/jack2/bin/"); do
  170. patch_osx_binary_libs "${PAWPAW_PREFIX}/jack2/bin/${f}"
  171. done
  172. fi
  173. # ---------------------------------------------------------------------------------------------------------------------
  174. # if qt is available, build qjackctl
  175. if [ -f "${PAWPAW_PREFIX}/bin/moc" ]; then
  176. download qjackctl "${QJACKCTL_VERSION}" https://download.sourceforge.net/qjackctl
  177. if [ "${WIN64}" -eq 1 ]; then
  178. patch_file qjackctl "${QJACKCTL_VERSION}" "configure" 's/-ljack /-Wl,-Bdynamic -ljack64 -Wl,-Bstatic /'
  179. elif [ "${WIN32}" -eq 1 ]; then
  180. patch_file qjackctl "${QJACKCTL_VERSION}" "configure" 's/-ljack /-Wl,-Bdynamic -ljack -Wl,-Bstatic /'
  181. fi
  182. build_autoconf qjackctl "${QJACKCTL_VERSION}" "--enable-jack-version"
  183. if [ "${MACOS}" -eq 1 ]; then
  184. qjackctl_dir="${PAWPAW_PREFIX}/bin/qjackctl.app/Contents/MacOS"
  185. patch_osx_binary_libs "${qjackctl_dir}/qjackctl"
  186. if [ ! -e "${qjackctl_dir}/QtXml" ]; then
  187. cp -v "${PAWPAW_PREFIX}/lib/QtCore.framework/Versions/5/QtCore" "${qjackctl_dir}/"
  188. patch_osx_binary_libs "${qjackctl_dir}/QtCore"
  189. cp -v "${PAWPAW_PREFIX}/lib/QtGui.framework/Versions/5/QtGui" "${qjackctl_dir}/"
  190. patch_osx_binary_libs "${qjackctl_dir}/QtGui"
  191. cp -v "${PAWPAW_PREFIX}/lib/QtWidgets.framework/Versions/5/QtWidgets" "${qjackctl_dir}/"
  192. patch_osx_binary_libs "${qjackctl_dir}/QtWidgets"
  193. cp -v "${PAWPAW_PREFIX}/lib/QtXml.framework/Versions/5/QtXml" "${qjackctl_dir}/"
  194. patch_osx_binary_libs "${qjackctl_dir}/QtXml"
  195. fi
  196. elif [ "${WIN32}" -eq 1 ]; then
  197. copy_file qjackctl "${QJACKCTL_VERSION}" "src/release/qjackctl.exe" "${PAWPAW_PREFIX}/jack2/bin/qjackctl.exe"
  198. fi
  199. fi
  200. # ---------------------------------------------------------------------------------------------------------------------
  201. if [ -n "${PACKAGING_BUILD}" ]; then
  202. if [ "${MACOS}" -eq 1 ]; then
  203. ./jack2/macosx/generate-pkg.sh "${PAWPAW_PREFIX}/jack2/"
  204. rm -rf jack2/macosx/qjackctl.app
  205. cp -rv "${PAWPAW_PREFIX}/bin/qjackctl.app" "jack2/macosx/"
  206. tar czf jack2-osx-1.9.14.tar.gz -C jack2/macosx jack2-osx-1.9.14.pkg qjackctl.app
  207. fi
  208. fi
  209. # ---------------------------------------------------------------------------------------------------------------------