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.

bootstrap-carla.sh 14KB

8 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. #!/bin/bash
  2. set -e
  3. cd $(dirname ${0})
  4. PAWPAW_ROOT="${PWD}"
  5. # ---------------------------------------------------------------------------------------------------------------------
  6. # check target
  7. target="${1}"
  8. if [ -z "${target}" ]; then
  9. echo "usage: ${0} <target>"
  10. exit 1
  11. fi
  12. # ---------------------------------------------------------------------------------------------------------------------
  13. # run bootstrap dependencies
  14. ./bootstrap-common.sh "${target}"
  15. ./bootstrap-plugins.sh "${target}"
  16. ./bootstrap-qt.sh "${target}"
  17. # ---------------------------------------------------------------------------------------------------------------------
  18. # source setup code
  19. source setup/check_target.sh
  20. source setup/env.sh
  21. source setup/functions.sh
  22. source setup/versions.sh
  23. # ---------------------------------------------------------------------------------------------------------------------
  24. # custom function as needed for pyqt packages
  25. function build_conf_python() {
  26. local name="${1}"
  27. local version="${2}"
  28. local extraconfrules="${3}"
  29. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  30. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  31. extraconfrules+=" --host=${TOOLCHAIN_PREFIX} --build=$(gcc -dumpmachine)"
  32. fi
  33. _prebuild "${name}" "${pkgdir}"
  34. # remove flags not compatible with python
  35. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fvisibility=hidden//')"
  36. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-ffast-math//')"
  37. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  38. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fno-strict-aliasing -flto//')"
  39. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,-dead_strip -Wl,-dead_strip_dylibs//')"
  40. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,--strip-all//')"
  41. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  42. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-fno-strict-aliasing -flto//')"
  43. if [ ! -f "${pkgdir}/.stamp_preconfigured" ] && [ "${WIN32}" -eq 1 ]; then
  44. pushd "${pkgdir}"
  45. autoreconf -vfi
  46. touch .stamp_preconfigured
  47. popd
  48. fi
  49. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  50. pushd "${pkgdir}"
  51. ./configure ${extraconfrules}
  52. touch .stamp_configured
  53. popd
  54. fi
  55. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  56. pushd "${pkgdir}"
  57. if [ "${WIN32}" -eq 1 ]; then
  58. # inject exe-wrapper
  59. if [ -n "${EXE_WRAPPER}" ]; then
  60. sed -i -e "s|\t./Programs/_freeze_importlib|\t${EXE_WRAPPER} ./Programs/_freeze_importlib|" Makefile
  61. fi
  62. make regen-importlib
  63. fi
  64. make ${MAKE_ARGS}
  65. touch .stamp_built
  66. popd
  67. fi
  68. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  69. pushd "${pkgdir}"
  70. make ${MAKE_ARGS} -j 1 install
  71. touch .stamp_installed
  72. popd
  73. fi
  74. _postbuild
  75. }
  76. function build_pyqt() {
  77. local name="${1}"
  78. local version="${2}"
  79. local extraconfrules="${3}"
  80. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  81. _prebuild "${name}" "${pkgdir}"
  82. # remove flags not compatible with python
  83. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fvisibility=hidden//')"
  84. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-ffast-math//')"
  85. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  86. export CXXFLAGS="$(echo ${CXXFLAGS} | sed -e 's/-fvisibility=hidden//')"
  87. export CXXFLAGS="$(echo ${CXXFLAGS} | sed -e 's/-ffast-math//')"
  88. export CXXFLAGS="$(echo ${CXXFLAGS} | sed -e 's/-fvisibility-inlines-hidden//')"
  89. export CXXFLAGS="$(echo ${CXXFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  90. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,-dead_strip -Wl,-dead_strip_dylibs//')"
  91. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,--strip-all//')"
  92. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,--gc-sections//')"
  93. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  94. if [ "${WIN32}" -eq 1 ]; then
  95. export CXXFLAGS+=" -Wno-deprecated-copy"
  96. fi
  97. # non-standard vars used by sip/pyqt
  98. export LFLAGS="${LDFLAGS}"
  99. export LINK="${CXX}"
  100. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  101. pushd "${pkgdir}"
  102. local python="python$(echo ${PYTHON_VERSION} | cut -b 1,2,3)"
  103. # Place link to Qt DLLs for PyQt tests
  104. if [ "${WIN32}" -eq 1 ] && [ -d "pyuic" ] && [ ! -d "release" ]; then
  105. mkdir release
  106. ln -sf "${PAWPAW_PREFIX}/bin"/Qt* release/
  107. fi
  108. ${python} configure.py ${extraconfrules}
  109. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  110. # use abstract python3 path
  111. sed -i -e 's|/usr/bin/python3|python3|g' Makefile
  112. # use PREFIX var
  113. sed -i -e "s|/usr|${PAWPAW_PREFIX}|g" installed.txt Makefile */Makefile
  114. if [ -f "QtCore/Makefile.Release" ]; then
  115. sed -i -e "s|/usr/include|${PAWPAW_PREFIX}/include|g" */Makefile.Release
  116. sed -i -e "s|/usr/lib|${PAWPAW_PREFIX}/lib|g" */Makefile.Release
  117. fi
  118. fi
  119. touch .stamp_configured
  120. popd
  121. fi
  122. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  123. pushd "${pkgdir}"
  124. # build sip as host tool first
  125. if [ "${CROSS_COMPILING}" -eq 1 ] && [ -d "sipgen" ] && [ ! -f "sipgen/sip" ]; then
  126. pushd "sipgen"
  127. PATH="${OLD_PATH}" make sip CC="gcc" LINK="gcc" LFLAGS="-Wl,-s" ${MAKE_ARGS}
  128. popd
  129. fi
  130. make PREFIX="${PAWPAW_PREFIX}" PKG_CONFIG="${TARGET_PKG_CONFIG}" ${MAKE_ARGS}
  131. touch .stamp_built
  132. popd
  133. fi
  134. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  135. pushd "${pkgdir}"
  136. make PREFIX="${PAWPAW_PREFIX}" PKG_CONFIG="${TARGET_PKG_CONFIG}" ${MAKE_ARGS} -j 1 install
  137. if [ -f "QtCore/Makefile.Release" ]; then
  138. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  139. sed -i -e "s|/usr|${PAWPAW_PREFIX}|g" "${PAWPAW_PREFIX}/bin"/py*5
  140. fi
  141. if [ -n "${EXE_WRAPPER}" ]; then
  142. sed -i -e "s|exec /|exec ${EXE_WRAPPER} /|" "${PAWPAW_PREFIX}/bin"/py*5
  143. fi
  144. else
  145. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  146. sed -i -e "s|/usr|${PAWPAW_PREFIX}|g" "${PAWPAW_PREFIX}/lib/python3/dist-packages/sipconfig.py"
  147. fi
  148. fi
  149. touch .stamp_installed
  150. popd
  151. fi
  152. unset LFLAGS
  153. unset LINK
  154. }
  155. # ---------------------------------------------------------------------------------------------------------------------
  156. # file/magic (posix only)
  157. if [ "${WIN32}" -eq 0 ]; then
  158. download file "${FILE_VERSION}" "${FILE_URL}"
  159. build_autoconf file "${FILE_VERSION}"
  160. fi
  161. # ---------------------------------------------------------------------------------------------------------------------
  162. # wine bootstrap for python (needed for cross-compilation)
  163. if [ "${WIN32}" -eq 1 ] && [ -n "${EXE_WRAPPER}" ] && [ ! -d "${WINEPREFIX}" ]; then
  164. wineboot -u
  165. fi
  166. # ---------------------------------------------------------------------------------------------------------------------
  167. # python
  168. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  169. PYTHON_EXTRAFLAGS="--enable-optimizations"
  170. PYTHON_EXTRAFLAGS+=" ac_cv_lib_intl_textdomain=no"
  171. PYTHON_EXTRAFLAGS+=" ac_cv_header_libintl_h=no"
  172. PYTHON_EXTRAFLAGS+=" ac_cv_func_setlocale=no"
  173. elif [ "${WIN32}" -eq 1 ]; then
  174. export EXTRA_CFLAGS=" -fwrapv -D__USE_MINGW_ANSI_STDIO=1 -D_WIN32_WINNT=0x0601"
  175. export EXTRA_CXXFLAGS=" -fwrapv -D__USE_MINGW_ANSI_STDIO=1 -D_WIN32_WINNT=0x0601"
  176. PYTHON_EXTRAFLAGS="--with-nt-threads"
  177. PYTHON_EXTRAFLAGS+=" --without-ensurepip"
  178. PYTHON_EXTRAFLAGS+=" --without-c-locale-coercion"
  179. # Workaround for conftest error on 64-bit builds
  180. PYTHON_EXTRAFLAGS+=" ac_cv_working_tzset=no"
  181. # Workaround for when dlfcn exists on Windows, which causes
  182. # some conftests to succeed when they shouldn't (we don't use dlfcn).
  183. PYTHON_EXTRAFLAGS+=" ac_cv_header_dlfcn_h=no"
  184. PYTHON_EXTRAFLAGS+=" ac_cv_lib_dl_dlopen=no"
  185. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_GLOBAL=no"
  186. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_LAZY=no"
  187. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_LOCAL=no"
  188. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_NOW=no"
  189. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_DEEPBIND=no"
  190. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_MEMBER=no"
  191. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_NODELETE=no"
  192. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_NOLOAD=no"
  193. fi
  194. download Python "${PYTHON_VERSION}" "https://www.python.org/ftp/python/${PYTHON_VERSION}" "tgz"
  195. if [ "${PYTHON_VERSION}" = "3.7.4" ]; then
  196. patch_file Python "${PYTHON_VERSION}" "Modules/Setup.dist" 's/#zlib zlibmodule.c/zlib zlibmodule.c/'
  197. fi
  198. build_conf_python Python "${PYTHON_VERSION}" "--prefix=${PAWPAW_PREFIX} --enable-shared ${PYTHON_EXTRAFLAGS}"
  199. # ---------------------------------------------------------------------------------------------------------------------
  200. # sip
  201. if [ "${SIP_VERSION}" = "4.19.19" ]; then
  202. SIP_DOWNLOAD_URL="https://files.kde.org/krita/build/dependencies"
  203. SIP_EXTRAFLAGS="--sip-module PyQt5.sip"
  204. else
  205. SIP_DOWNLOAD_URL="http://sourceforge.net/projects/pyqt/files/sip/sip-${SIP_VERSION}"
  206. fi
  207. if [ "${WIN32}" -eq 1 ]; then
  208. SIP_EXTRAFLAGS+=" --platform win32-g++"
  209. SIP_EXTRAFLAGS+=" EXTENSION_PLUGIN=pyd"
  210. SIP_EXTRAFLAGS+=" INCDIR=${PAWPAW_PREFIX}/include/python3.8"
  211. SIP_EXTRAFLAGS+=" LIBDIR=${PAWPAW_PREFIX}/lib/python3.8/config-3.8"
  212. fi
  213. download sip "${SIP_VERSION}" "${SIP_DOWNLOAD_URL}"
  214. build_pyqt sip "${SIP_VERSION}" "${SIP_EXTRAFLAGS}"
  215. # ---------------------------------------------------------------------------------------------------------------------
  216. # pyqt5
  217. if [ "${PYQT5_VERSION}" = "5.13.1" ]; then
  218. PYQT5_DOWNLOAD_URL="https://files.kde.org/krita/build/dependencies"
  219. PYQT5_SUFFIX="_gpl"
  220. else
  221. PYQT5_DOWNLOAD_URL="http://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-${PYQT5_VERSION}"
  222. PYQT5_SUFFIX="_gpl"
  223. fi
  224. # qmake needs this
  225. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  226. export PKG_CONFIG_LIBDIR="${TARGET_PKG_CONFIG_PATH}"
  227. export PKG_CONFIG_SYSROOT_DIR="/"
  228. fi
  229. PYQT5_EXTRAFLAGS="--qmake ${PAWPAW_PREFIX}/bin/qmake --sip ${PAWPAW_PREFIX}/bin/sip"
  230. download PyQt5${PYQT5_SUFFIX} "${PYQT5_VERSION}" "${PYQT5_DOWNLOAD_URL}"
  231. build_pyqt PyQt5${PYQT5_SUFFIX} "${PYQT5_VERSION}" "${PYQT5_EXTRAFLAGS} --concatenate --confirm-license"
  232. # --verbose
  233. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  234. unset PKG_CONFIG_LIBDIR
  235. unset PKG_CONFIG_SYSROOT_DIR
  236. fi
  237. # ---------------------------------------------------------------------------------------------------------------------
  238. # cython (optional)
  239. if [ -n "${CYTHON_VERSION}" ]; then
  240. download Cython "${CYTHON_VERSION}" "https://files.pythonhosted.org/packages/6c/9f/f501ba9d178aeb1f5bf7da1ad5619b207c90ac235d9859961c11829d0160"
  241. build_python Cython "${CYTHON_VERSION}"
  242. fi
  243. # ---------------------------------------------------------------------------------------------------------------------
  244. # pyliblo
  245. if [ "${WIN32}" -eq 1 ]; then
  246. export EXTRA_CFLAGS="$(${PAWPAW_PREFIX}/bin/pkg-config --cflags python3 liblo)"
  247. export EXTRA_LDFLAGS="-shared $(${PAWPAW_PREFIX}/bin/pkg-config --libs python3 liblo)"
  248. export LDSHARED="${TARGET_CXX}"
  249. export PYTHONPATH="${PAWPAW_PREFIX}/lib/python3.8/site-packages"
  250. fi
  251. download pyliblo "${PYLIBLO_VERSION}" "http://das.nasophon.de/download"
  252. build_python pyliblo "${PYLIBLO_VERSION}"
  253. if [ "${WIN32}" -eq 1 ]; then
  254. if [ "${CROSS_COMPILING}" -eq 1 ] && [ ! -e "${PYTHONPATH}/liblo.pyd" ]; then
  255. ln -sv "${PYTHONPATH}"/pyliblo-*.egg/*.so "${PYTHONPATH}/liblo.pyd"
  256. fi
  257. unset LDSHARED
  258. unset PYTHONPATH
  259. fi
  260. # ---------------------------------------------------------------------------------------------------------------------
  261. # setuptools_scm (optional)
  262. if [ -n "${SETUPTOOLS_SCM_VERSION}" ]; then
  263. download setuptools_scm "${SETUPTOOLS_SCM_VERSION}" "https://files.pythonhosted.org/packages/ed/b6/979bfa7b81878b2b4475dde092aac517e7f25dd33661796ec35664907b31"
  264. build_python setuptools_scm "${SETUPTOOLS_SCM_VERSION}"
  265. fi
  266. # ---------------------------------------------------------------------------------------------------------------------
  267. # toml (optional)
  268. if [ -n "${TOML_VERSION}" ]; then
  269. download toml "${TOML_VERSION}" "https://files.pythonhosted.org/packages/be/ba/1f744cdc819428fc6b5084ec34d9b30660f6f9daaf70eead706e3203ec3c"
  270. build_python toml "${TOML_VERSION}"
  271. fi
  272. # ---------------------------------------------------------------------------------------------------------------------
  273. # zipp (optional)
  274. if [ -n "${ZIPP_VERSION}" ]; then
  275. download zipp "${ZIPP_VERSION}" "https://files.pythonhosted.org/packages/ce/b0/757db659e8b91cb3ea47d90350d7735817fe1df36086afc77c1c4610d559"
  276. build_python zipp "${ZIPP_VERSION}"
  277. fi
  278. # ---------------------------------------------------------------------------------------------------------------------
  279. # importlib_metadata (optional)
  280. if [ -n "${IMPORTLIB_METADATA_VERSION}" ]; then
  281. download importlib_metadata "${IMPORTLIB_METADATA_VERSION}" "https://files.pythonhosted.org/packages/f8/41/8ffb059708359ea14a3ec74a99a2bf0cd44a0c983a0c480d9eb7a69438bb"
  282. build_python importlib_metadata "${IMPORTLIB_METADATA_VERSION}"
  283. fi
  284. # ---------------------------------------------------------------------------------------------------------------------
  285. # cxfreeze
  286. git_clone cx_Freeze "${CXFREEZE_VERSION}" "https://github.com/anthony-tuininga/cx_Freeze.git"
  287. if [ "${WIN32}" -eq 1 ]; then
  288. export PYTHONPATH="${PAWPAW_PREFIX}/lib/python3.8/site-packages"
  289. fi
  290. build_python cx_Freeze "${CXFREEZE_VERSION}"
  291. if [ "${WIN32}" -eq 1 ]; then
  292. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  293. if [ ! -e "${PYTHONPATH}/cx_Freeze" ]; then
  294. ln -sv "${PYTHONPATH}"/cx_Freeze-*.egg/cx_Freeze "${PYTHONPATH}/cx_Freeze"
  295. fi
  296. if [ ! -e "${PYTHONPATH}/cx_Freeze/util.pyd" ]; then
  297. ln -sv "$(realpath "${PYTHONPATH}/cx_Freeze"/util.*)" "${PYTHONPATH}/cx_Freeze/util.pyd"
  298. fi
  299. fi
  300. unset PYTHONPATH
  301. fi
  302. # ---------------------------------------------------------------------------------------------------------------------