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.

261 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+=" --platform=linux"
  130. elif [ "${MACOS}" -eq 1 ]; then
  131. jack2_args+=" --platform=darwin"
  132. elif [ "${WIN32}" -eq 1 ]; then
  133. jack2_args+=" --platform=win32"
  134. fi
  135. fi
  136. if [ "${MACOS}" -eq 1 ]; then
  137. jack2_extra_prefix="/usr/local"
  138. jack2_args+=" --prefix=${jack2_extra_prefix}"
  139. jack2_args+=" --destdir="${jack2_prefix}""
  140. fi
  141. if [ "${MACOS_OLD}" -eq 1 ]; then
  142. patch_file jack2 "git" "wscript" '/-std=gnu++11/d'
  143. patch_file jack2 "git" "wscript" '/-Wno-deprecated-register/d'
  144. fi
  145. if [ "${JACK2_VERSION}" = "git" ]; then
  146. if [ ! -d jack2 ]; then
  147. git clone --recursive "${jack2_repo}"
  148. fi
  149. if [ ! -e "${PAWPAW_BUILDDIR}/jack2-git" ]; then
  150. ln -sf "$(pwd)/jack2" "${PAWPAW_BUILDDIR}/jack2-git"
  151. fi
  152. rm -f "${PAWPAW_BUILDDIR}/jack2-git/.stamp_built"
  153. else
  154. download jack2 "${JACK2_VERSION}" "${jack2_repo}" "" "git"
  155. fi
  156. build_waf jack2 "${JACK2_VERSION}" "${jack2_args}"
  157. # remove useless dbus-specific file
  158. rm "${PAWPAW_PREFIX}/jack2${jack2_extra_prefix}/bin/jack_control"
  159. # copy jack pkg-config file to main system, so qjackctl can find it
  160. if [ ! -e "${PAWPAW_PREFIX}/lib/pkgconfig/jack.pc" ]; then
  161. cp -v "${PAWPAW_PREFIX}/jack2/${jack2_extra_prefix}lib/pkgconfig/jack.pc" "${PAWPAW_PREFIX}/lib/pkgconfig/jack.pc"
  162. # patch pkg-config file for static win32 builds in regular prefix
  163. if [ "${WIN32}" -eq 1 ]; then
  164. if [ "${WIN64}" -eq 1 ]; then
  165. s="64"
  166. else
  167. s=""
  168. fi
  169. # FIXME rule that works for server lib too, maybe ignoring suffix even
  170. sed -i -e "s/lib -ljack${s}/lib -Wl,-Bdynamic -ljack${s} -Wl,-Bstatic/" "${PAWPAW_PREFIX}/lib/pkgconfig/jack.pc"
  171. fi
  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. fi
  184. # ---------------------------------------------------------------------------------------------------------------------
  185. if [ -n "${PACKAGING_BUILD}" ]; then
  186. if [ "${MACOS}" -eq 1 ]; then
  187. for f in $(ls "${PAWPAW_PREFIX}/jack2${jack2_extra_prefix}/bin"/* \
  188. "${PAWPAW_PREFIX}/jack2${jack2_extra_prefix}/lib"/*.dylib \
  189. "${PAWPAW_PREFIX}/jack2${jack2_extra_prefix}/lib/jack"/*); do
  190. patch_osx_binary_libs "${f}"
  191. done
  192. ./jack2/macosx/generate-pkg.sh "${PAWPAW_PREFIX}/jack2${jack2_extra_prefix}/"
  193. qjackctl_app="${PAWPAW_PREFIX}/bin/qjackctl.app"
  194. qjackctl_dir="${qjackctl_app}/Contents/MacOS"
  195. patch_osx_qtapp qjackctl "${QJACKCTL_VERSION}" "${qjackctl_app}"
  196. patch_osx_binary_libs "${qjackctl_dir}/qjackctl"
  197. rm -rf jack2/macosx/qjackctl.app
  198. cp -rv "${PAWPAW_PREFIX}/bin/qjackctl.app" jack2/macosx/
  199. rm -f jack2-osx-1.9.14.tar.gz
  200. tar czf jack2-osx-1.9.14.tar.gz -C jack2/macosx jack2-osx-1.9.14.pkg qjackctl.app
  201. elif [ "${WIN32}" -eq 1 ]; then
  202. copy_file qjackctl "${QJACKCTL_VERSION}" "src/release/qjackctl.exe" "${PAWPAW_PREFIX}/jack2/bin/qjackctl.exe"
  203. fi
  204. fi
  205. # ---------------------------------------------------------------------------------------------------------------------