Audio plugin host https://kx.studio/carla
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.

250 lines
6.3KB

  1. #!/bin/bash
  2. # ---------------------------------------------------------------------------------------------------------------------
  3. # stop on error
  4. set -e
  5. # ---------------------------------------------------------------------------------------------------------------------
  6. # cd to correct path
  7. cd $(dirname $0)
  8. # ---------------------------------------------------------------------------------------------------------------------
  9. # set variables
  10. source common.env
  11. # ---------------------------------------------------------------------------------------------------------------------
  12. # function to remove old stuff
  13. cleanup_prefix()
  14. {
  15. rm -rf ${TARGETDIR}/msys2-i686 ${TARGETDIR}/msys2-x86_64
  16. rm -rf python-pkgs-*
  17. }
  18. cleanup_pkgs()
  19. {
  20. rm -rf Carla
  21. rm -rf Carla.exe
  22. rm -rf Carla.lv2
  23. rm -rf Carla.vst
  24. rm -rf Carla_*
  25. rm -rf pyliblo-*
  26. }
  27. cleanup()
  28. {
  29. cleanup_prefix
  30. cleanup_pkgs
  31. exit 0
  32. }
  33. # ---------------------------------------------------------------------------------------------------------------------
  34. # function to download python stuff from msys2
  35. download_python()
  36. {
  37. # ---------------------------------------------------------------------------------------------------------------------
  38. # setup
  39. if [ x"${ARCH}" != x"32" ]; then
  40. CPUARCH="x86_64"
  41. else
  42. CPUARCH="i686"
  43. fi
  44. # ---------------------------------------------------------------------------------------------------------------------
  45. # list packages
  46. PACKAGES=(
  47. "binutils-2.32-3"
  48. "bzip2-1.0.8-1"
  49. "crt-git-7.0.0.5524.2346384e-1"
  50. "dbus-1.12.8-1"
  51. "double-conversion-3.1.5-1"
  52. "expat-2.2.8-1"
  53. "freetype-2.10.1-1"
  54. "gcc-9.2.0-2"
  55. "gcc-libs-9.2.0-2"
  56. "gettext-0.19.8.1-8"
  57. "glib2-2.62.1-1"
  58. "gmp-6.1.2-1"
  59. "graphite2-1.3.13-1"
  60. "harfbuzz-2.6.2-1"
  61. "icu-64.2-1"
  62. "jasper-2.0.16-1"
  63. "libffi-3.2.1-4"
  64. "libiconv-1.16-1"
  65. "libjpeg-turbo-2.0.3-1"
  66. "libpng-1.6.37-3"
  67. "libtiff-4.0.9-2"
  68. "libwebp-1.0.3-1"
  69. "libxml2-2.9.9-2"
  70. "libxslt-1.1.33-1"
  71. "libwinpthread-git-7.0.0.5522.977a9720-1"
  72. "headers-git-7.0.0.5524.2346384e-1"
  73. "openssl-1.1.1.d-1"
  74. "pcre-8.43-1"
  75. "pcre2-10.33-1"
  76. "pyqt5-common-5.13.1-1"
  77. "python3-3.7.4-7"
  78. "python3-cx_Freeze-5.1.1-3"
  79. "python3-nuitka-0.6.4-1"
  80. "python3-sip-4.19.19-1"
  81. "python3-pyqt5-5.13.1-1"
  82. "qt5-5.13.1-1"
  83. "qtwebkit-5.212.0alpha2-6"
  84. "sqlite3-3.30.0-1"
  85. "windows-default-manifest-6.4-3"
  86. "winpthreads-git-7.0.0.5522.977a9720-1"
  87. "xz-5.2.4-1"
  88. "zlib-1.2.11-7"
  89. "zstd-1.4.3-1"
  90. )
  91. # qt5-static-5.12.4-1
  92. PKG_DIR="$(pwd)/python-pkgs-${CPUARCH}"
  93. PKG_PREFIX="mingw-w64-${CPUARCH}-"
  94. PKG_SUFFIX="-any.pkg.tar.xz"
  95. REPO_URL="http://repo.msys2.org/mingw/${CPUARCH}"
  96. # ---------------------------------------------------------------------------------------------------------------------
  97. # download stuff
  98. mkdir -p "${PKG_DIR}"
  99. pushd "${PKG_DIR}"
  100. for PKG in ${PACKAGES[@]}; do
  101. wget -c "${REPO_URL}/${PKG_PREFIX}${PKG}${PKG_SUFFIX}"
  102. done
  103. popd
  104. # ---------------------------------------------------------------------------------------------------------------------
  105. # extract into target dir
  106. rm -rf "${TARGETDIR}/msys2-${CPUARCH}"
  107. mkdir "${TARGETDIR}/msys2-${CPUARCH}"
  108. pushd "${TARGETDIR}/msys2-${CPUARCH}"
  109. for PKG in ${PACKAGES[@]}; do
  110. tar xf "${PKG_DIR}/${PKG_PREFIX}${PKG}${PKG_SUFFIX}"
  111. done
  112. sed -i "s|E:/mingwbuild/mingw-w64-qt5/pkg/mingw-w64-${CPUARCH}-qt5|${TARGETDIR}/msys2-${CPUARCH}|" ./mingw${ARCH}/lib/pkgconfig/Qt5*.pc
  113. popd
  114. }
  115. # ---------------------------------------------------------------------------------------------------------------------
  116. # function to build python modules
  117. build_python()
  118. {
  119. # ---------------------------------------------------------------------------------------------------------------------
  120. # setup
  121. if [ x"${ARCH}" != x"32" ]; then
  122. CPUARCH="x86_64"
  123. else
  124. CPUARCH="i686"
  125. fi
  126. # ---------------------------------------------------------------------------------------------------------------------
  127. # clean env
  128. unset AR
  129. unset CC
  130. unset CXX
  131. unset STRIP
  132. unset WINDRES
  133. unset CFLAGS
  134. unset CPPFLAGS
  135. unset CXXFLAGS
  136. unset LDFLAGS
  137. export DEPS_PREFIX=${TARGETDIR}/carla-w${ARCH_PREFIX}
  138. export MSYS2_PREFIX=${TARGETDIR}/msys2-${CPUARCH}/mingw${ARCH}
  139. export PATH=${DEPS_PREFIX}/bin:${MSYS2_PREFIX}/bin:/usr/sbin:/usr/bin:/sbin:/bin
  140. export PKG_CONFIG_PATH=${DEPS_PREFIX}/lib/pkgconfig:${MSYS2_PREFIX}/lib/pkgconfig
  141. HOST_ARCH=$(dpkg-architecture -qDEB_BUILD_GNU_TYPE)
  142. MINGW_PREFIX="${CPUARCH}-w64-mingw32"
  143. export AR=${MINGW_PREFIX}-ar
  144. export CC=${MINGW_PREFIX}-gcc
  145. export CXX=${MINGW_PREFIX}-g++
  146. export STRIP=${MINGW_PREFIX}-strip
  147. export WINDRES=${MINGW_PREFIX}-windres
  148. export CFLAGS="-O2 -DNDEBUG -mstackrealign -fvisibility=hidden -fdata-sections -ffunction-sections"
  149. export CFLAGS="${CFLAGS} -I${DEPS_PREFIX}/include -I${MSYS2_PREFIX}/include"
  150. export CXXFLAGS="${CFLAGS} -fvisibility-inlines-hidden"
  151. export LDFLAGS="-Wl,--gc-sections -Wl,-O1 -Wl,--as-needed -Wl,--strip-all"
  152. export LDFLAGS="${LDFLAGS} -L${DEPS_PREFIX}/lib -L${MSYS2_PREFIX}/lib"
  153. # ---------------------------------------------------------------------------------------------------------------------
  154. # pyliblo
  155. if [ ! -d pyliblo-${PYLIBLO_VERSION} ]; then
  156. wget -c http://das.nasophon.de/download/pyliblo-${PYLIBLO_VERSION}.tar.gz
  157. tar -xf pyliblo-${PYLIBLO_VERSION}.tar.gz
  158. fi
  159. if [ ! -f pyliblo-${PYLIBLO_VERSION}/build-done ]; then
  160. cd pyliblo-${PYLIBLO_VERSION}
  161. if [ ! -f patched ]; then
  162. patch -p1 -i ../patches/pyliblo-python3.7.patch
  163. touch patched
  164. fi
  165. mkdir -p build
  166. # build
  167. ${CC} -pthread -Wall ${CFLAGS} \
  168. src/liblo.c -c -o build/liblo.o \
  169. $(python3-config --cflags | awk 'sub("-ne ","")') \
  170. -D_FORTIFY_SOURCE=2 -fPIC -fno-strict-aliasing \
  171. -Wdate-time -Werror-implicit-function-declaration -Wfatal-errors
  172. # link
  173. ${CC} -pthread -shared ${LDFLAGS} \
  174. build/liblo.o -o build/liblo-cpython-37m.dll \
  175. -llo $(python3-config --ldflags | awk 'sub("-ne ","")') -lws2_32 -liphlpapi
  176. # install
  177. install -m 644 build/liblo-cpython-37m.dll ${MSYS2_PREFIX}/lib/python3.7/site-packages/
  178. touch build-done
  179. cd ..
  180. fi
  181. }
  182. # ---------------------------------------------------------------------------------------------------------------------
  183. # build base libs
  184. export ARCH=32
  185. export ARCH_PREFIX=32nosse
  186. download_python
  187. build_python
  188. cleanup_pkgs
  189. export ARCH=64
  190. export ARCH_PREFIX=64
  191. download_python
  192. build_python
  193. cleanup_pkgs
  194. # ---------------------------------------------------------------------------------------------------------------------