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.

360 lines
14KB

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