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 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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.7}
  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. if [ -n "${PAWPAW_JACK2_NO_CUSTOM_PREFIX}" ]; then
  23. jack2_prefix="${PAWPAW_PREFIX}"
  24. else
  25. jack2_prefix="${PAWPAW_PREFIX}-jack2"
  26. if [ "${MACOS}" -eq 1 ]; then
  27. jack2_extra_prefix="/usr/local"
  28. fi
  29. fi
  30. # ---------------------------------------------------------------------------------------------------------------------
  31. # jack2
  32. jack2_args=""
  33. if [ -n "${jack2_extra_prefix}" ]; then
  34. jack2_args+=" --prefix=${jack2_extra_prefix}"
  35. jack2_args+=" --destdir="${jack2_prefix}""
  36. else
  37. jack2_args+=" --prefix=${jack2_prefix}"
  38. fi
  39. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  40. if [ "${LINUX}" -eq 1 ]; then
  41. jack2_args+=" --platform=linux"
  42. elif [ "${MACOS}" -eq 1 ]; then
  43. jack2_args+=" --platform=darwin"
  44. elif [ "${WIN32}" -eq 1 ]; then
  45. jack2_args+=" --platform=win32"
  46. fi
  47. fi
  48. if [ "${WIN32}" -eq 1 ]; then
  49. jack2_args+=" --static"
  50. fi
  51. if [ "${WIN64}" -eq 1 ]; then
  52. jack2_args="${jack2_args} --mixed"
  53. # win32 toolchain prefix
  54. TOOLCHAIN_PREFIX32=$(echo ${TOOLCHAIN_PREFIX} | sed 's/x86_64/i686/')
  55. # let jack2 find win32 binaries
  56. TARGET_PATH="${TARGET_PATH}:/usr/${TOOLCHAIN_PREFIX32}/bin"
  57. # setup linker for our custom folder
  58. export EXTRA_LDFLAGS="-L${PAWPAW_PREFIX}/lib32"
  59. fi
  60. if [ "${JACK2_VERSION}" = "git" ]; then
  61. if [ ! -d jack2 ]; then
  62. git clone --recursive "${jack2_repo}"
  63. fi
  64. if [ ! -e "${PAWPAW_BUILDDIR}/jack2-git" ]; then
  65. ln -sf "$(pwd)/jack2" "${PAWPAW_BUILDDIR}/jack2-git"
  66. fi
  67. rm -f "${PAWPAW_BUILDDIR}/jack2-git/.stamp_built"
  68. else
  69. download jack2 "${JACK2_VERSION}" "${jack2_repo}" "" "git"
  70. fi
  71. build_waf jack2 "${JACK2_VERSION}" "${jack2_args}"
  72. # remove useless dbus-specific file
  73. rm -f "${jack2_prefix}${jack2_extra_prefix}/bin/jack_control"
  74. # generate MSVC lib files
  75. if [ "${WIN64}" -eq 1 ]; then
  76. 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
  77. 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
  78. 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
  79. 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
  80. elif [ "${WIN32}" -eq 1 ]; then
  81. 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
  82. 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
  83. 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
  84. fi
  85. # copy jack pkg-config file to main system, so qjackctl can find it
  86. if [ ! -e "${PAWPAW_PREFIX}/lib/pkgconfig/jack.pc" ]; then
  87. cp -v "${jack2_prefix}${jack2_extra_prefix}/lib/pkgconfig/jack.pc" "${PAWPAW_PREFIX}/lib/pkgconfig/jack.pc"
  88. # patch pkg-config file for static win32 builds in regular prefix
  89. if [ "${WIN32}" -eq 1 ]; then
  90. if [ "${WIN64}" -eq 1 ]; then
  91. s="64"
  92. else
  93. s=""
  94. fi
  95. sed -i -e "s/lib -ljack${s}/lib -Wl,-Bdynamic -ljack${s} -Wl,-Bstatic/" "${PAWPAW_PREFIX}/lib/pkgconfig/jack.pc"
  96. fi
  97. fi
  98. # ---------------------------------------------------------------------------------------------------------------------
  99. # jack-router (download, win32 only)
  100. if [ "${WIN32}" -eq 1 ]; then
  101. download jack-router "${JACK_ROUTER_VERSION}" "https://github.com/jackaudio/jack-router.git" "" "git"
  102. fi
  103. # ---------------------------------------------------------------------------------------------------------------------
  104. # qjackctl (if qt is available)
  105. if [ -f "${PAWPAW_PREFIX}/bin/moc" ]; then
  106. # Join $2+ arguments into a string separated by $1
  107. function join() {
  108. local IFS=$1
  109. shift
  110. echo "$*"
  111. }
  112. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  113. # Use system's Qt tools for translations
  114. qjackctl_CMAKE_PREFIX_PATH="${PAWPAW_PREFIX}/lib/cmake;$(join ';' /usr/{lib/$(gcc -print-multiarch),lib*,share}/cmake)"
  115. echo "Using CMake prefix: ${qjackctl_CMAKE_PREFIX_PATH}"
  116. else
  117. qjackctl_CMAKE_PREFIX_PATH="${PAWPAW_PREFIX}/lib/cmake"
  118. fi
  119. QJACKCTL_EXTRAFLAGS="-DJack_ROOT=${jack2_prefix}${jack2_extra_prefix}"
  120. QJACKCTL_EXTRAFLAGS+=" -DCONFIG_ALSA_SEQ:BOOL=OFF"
  121. QJACKCTL_EXTRAFLAGS+=" -DCONFIG_DBUS:BOOL=OFF"
  122. QJACKCTL_EXTRAFLAGS+=" -DCMAKE_PREFIX_PATH=${qjackctl_CMAKE_PREFIX_PATH}"
  123. QJACKCTL_EXTRAFLAGS+=" -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
  124. download qjackctl "${QJACKCTL_VERSION}" https://download.sourceforge.net/qjackctl
  125. build_cmake qjackctl "${QJACKCTL_VERSION}" "${QJACKCTL_EXTRAFLAGS}"
  126. if [ "${WIN32}" -eq 1 ]; then
  127. copy_file qjackctl "${QJACKCTL_VERSION}" "build/src/qjackctl.exe" "${jack2_prefix}/bin/qjackctl.exe"
  128. fi
  129. fi
  130. # ---------------------------------------------------------------------------------------------------------------------