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.

272 lines
10KB

  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=x86_64-linux-gnu"
  32. export PYTHON_FOR_BUILD=python3
  33. fi
  34. _prebuild "${name}" "${pkgdir}"
  35. # remove flags not compatible with python
  36. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fvisibility=hidden//')"
  37. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-ffast-math//')"
  38. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  39. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,-dead_strip -Wl,-dead_strip_dylibs//')"
  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. sed -i -e 's|./Programs/_freeze_importlib zipimport|./Programs/_freeze_importlib$(EXE) zipimport|' Makefile
  57. sed -i -e 's|\twindres|\tx86_64-w64-mingw32-windres|' Makefile
  58. make regen-importlib
  59. fi
  60. make ${MAKE_ARGS} ${EXTRA_MAKE_ARGS}
  61. touch .stamp_built
  62. popd
  63. fi
  64. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  65. pushd "${pkgdir}"
  66. make ${MAKE_ARGS} -j 1 install
  67. touch .stamp_installed
  68. popd
  69. fi
  70. _postbuild
  71. }
  72. function build_pyqt() {
  73. local name="${1}"
  74. local version="${2}"
  75. local extraconfrules="${3}"
  76. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  77. _prebuild "${name}" "${pkgdir}"
  78. # remove flags not compatible with python
  79. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fvisibility=hidden//')"
  80. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-ffast-math//')"
  81. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  82. export CXXFLAGS="$(echo ${CXXFLAGS} | sed -e 's/-fvisibility=hidden//')"
  83. export CXXFLAGS="$(echo ${CXXFLAGS} | sed -e 's/-ffast-math//')"
  84. export CXXFLAGS="$(echo ${CXXFLAGS} | sed -e 's/-fvisibility-inlines-hidden//')"
  85. export CXXFLAGS="$(echo ${CXXFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  86. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,-dead_strip -Wl,-dead_strip_dylibs//')"
  87. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  88. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  89. pushd "${pkgdir}"
  90. python3 configure.py ${extraconfrules}
  91. # used in sip
  92. sed -i -e 's/CFLAGS *=/CFLAGS +=/' */Makefile
  93. sed -i -e 's/CXXFLAGS *=/CXXFLAGS +=/' */Makefile
  94. sed -i -e 's/LIBS *=/LIBS += $(LDFLAGS)/' */Makefile
  95. sed -i -e 's|$(DESTDIR)/usr|$(DESTDIR)$(PREFIX)|g' */Makefile
  96. touch .stamp_configured
  97. popd
  98. fi
  99. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  100. pushd "${pkgdir}"
  101. make PREFIX="${PAWPAW_PREFIX}" PKG_CONFIG="${TARGET_PKG_CONFIG}" ${MAKE_ARGS}
  102. touch .stamp_built
  103. popd
  104. fi
  105. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  106. pushd "${pkgdir}"
  107. make PREFIX="${PAWPAW_PREFIX}" PKG_CONFIG="${TARGET_PKG_CONFIG}" ${MAKE_ARGS} -j 1 install
  108. touch .stamp_installed
  109. popd
  110. fi
  111. }
  112. # ---------------------------------------------------------------------------------------------------------------------
  113. # file/magic (posix only)
  114. if [ "${WIN32}" -eq 0 ]; then
  115. download file "${FILE_VERSION}" "ftp://ftp.astron.com/pub/file"
  116. build_autoconf file "${FILE_VERSION}"
  117. fi
  118. # ---------------------------------------------------------------------------------------------------------------------
  119. # python
  120. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  121. PYTHON_EXTRAFLAGS="--enable-optimizations"
  122. elif [ "${WIN32}" -eq 1 ]; then
  123. export EXTRA_CFLAGS=" -fwrapv -D__USE_MINGW_ANSI_STDIO=1 -D_WIN32_WINNT=0x0601"
  124. export EXTRA_CXXFLAGS=" -fwrapv -D__USE_MINGW_ANSI_STDIO=1 -D_WIN32_WINNT=0x0601"
  125. PYTHON_EXTRAFLAGS="--with-nt-threads"
  126. PYTHON_EXTRAFLAGS+=" --without-ensurepip"
  127. PYTHON_EXTRAFLAGS+=" --without-c-locale-coercion"
  128. # PYTHON_EXTRAFLAGS+=" --enable-optimizations"
  129. # Workaround for conftest error on 64-bit builds
  130. PYTHON_EXTRAFLAGS+=" ac_cv_working_tzset=no"
  131. # Workaround for when dlfcn exists on Windows, which causes
  132. # some conftests to succeed when they shouldn't (we don't use dlfcn).
  133. PYTHON_EXTRAFLAGS+=" ac_cv_header_dlfcn_h=no"
  134. PYTHON_EXTRAFLAGS+=" ac_cv_lib_dl_dlopen=no"
  135. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_GLOBAL=no"
  136. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_LAZY=no"
  137. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_LOCAL=no"
  138. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_NOW=no"
  139. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_DEEPBIND=no"
  140. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_MEMBER=no"
  141. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_NODELETE=no"
  142. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_NOLOAD=no"
  143. PYTHON_EXTRAFLAGS+=" OPT="
  144. export MSYSTEM=MINGW
  145. fi
  146. download Python "${PYTHON_VERSION}" "https://www.python.org/ftp/python/${PYTHON_VERSION}" "tgz"
  147. if [ "${PYTHON_VERSION}" = "3.7.4" ]; then
  148. patch_file Python "${PYTHON_VERSION}" "Modules/Setup.dist" 's/#zlib zlibmodule.c/zlib zlibmodule.c/'
  149. fi
  150. build_conf_python Python "${PYTHON_VERSION}" "--prefix=${PAWPAW_PREFIX} --enable-shared ${PYTHON_EXTRAFLAGS}"
  151. if [ "${WIN32}" -eq 1 ]; then
  152. unset MSYSTEM
  153. endif
  154. # ---------------------------------------------------------------------------------------------------------------------
  155. # sip
  156. if [ "${SIP_VERSION}" = "4.19.19" ]; then
  157. SIP_DOWNLOAD_URL="https://files.kde.org/krita/build/dependencies"
  158. SIP_EXTRAFLAGS="--sip-module PyQt5.sip"
  159. else
  160. SIP_DOWNLOAD_URL="http://sourceforge.net/projects/pyqt/files/sip/sip-${SIP_VERSION}"
  161. fi
  162. download sip "${SIP_VERSION}" "${SIP_DOWNLOAD_URL}"
  163. build_pyqt sip "${SIP_VERSION}" "${SIP_EXTRAFLAGS}"
  164. # ---------------------------------------------------------------------------------------------------------------------
  165. # pyqt5
  166. if [ "${PYQT5_VERSION}" = "5.13.1" ]; then
  167. PYQT5_DOWNLOAD_URL="https://files.kde.org/krita/build/dependencies"
  168. PYQT5_SUFFIX="_gpl"
  169. else
  170. PYQT5_DOWNLOAD_URL="http://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-${PYQT5_VERSION}"
  171. PYQT5_SUFFIX="_gpl"
  172. fi
  173. download PyQt5${PYQT5_SUFFIX} "${PYQT5_VERSION}" "${PYQT5_DOWNLOAD_URL}"
  174. build_pyqt PyQt5${PYQT5_SUFFIX} "${PYQT5_VERSION}" "--concatenate --confirm-license -c"
  175. # ---------------------------------------------------------------------------------------------------------------------
  176. # cython (optional)
  177. if [ -n "${CYTHON_VERSION}" ]; then
  178. download Cython "${CYTHON_VERSION}" "https://files.pythonhosted.org/packages/6c/9f/f501ba9d178aeb1f5bf7da1ad5619b207c90ac235d9859961c11829d0160"
  179. build_python Cython "${CYTHON_VERSION}"
  180. fi
  181. # ---------------------------------------------------------------------------------------------------------------------
  182. # pyliblo
  183. download pyliblo "${PYLIBLO_VERSION}" "http://das.nasophon.de/download"
  184. build_python pyliblo "${PYLIBLO_VERSION}"
  185. # ---------------------------------------------------------------------------------------------------------------------
  186. # setuptools_scm (optional)
  187. if [ -n "${SETUPTOOLS_SCM_VERSION}" ]; then
  188. download setuptools_scm "${SETUPTOOLS_SCM_VERSION}" "https://files.pythonhosted.org/packages/ed/b6/979bfa7b81878b2b4475dde092aac517e7f25dd33661796ec35664907b31"
  189. build_python setuptools_scm "${SETUPTOOLS_SCM_VERSION}"
  190. fi
  191. # ---------------------------------------------------------------------------------------------------------------------
  192. # toml (optional)
  193. if [ -n "${TOML_VERSION}" ]; then
  194. download toml "${TOML_VERSION}" "https://files.pythonhosted.org/packages/be/ba/1f744cdc819428fc6b5084ec34d9b30660f6f9daaf70eead706e3203ec3c"
  195. build_python toml "${TOML_VERSION}"
  196. fi
  197. # ---------------------------------------------------------------------------------------------------------------------
  198. # zipp (optional)
  199. if [ -n "${ZIPP_VERSION}" ]; then
  200. download zipp "${ZIPP_VERSION}" "https://files.pythonhosted.org/packages/ce/b0/757db659e8b91cb3ea47d90350d7735817fe1df36086afc77c1c4610d559"
  201. build_python zipp "${ZIPP_VERSION}"
  202. fi
  203. # ---------------------------------------------------------------------------------------------------------------------
  204. # importlib_metadata (optional)
  205. if [ -n "${IMPORTLIB_METADATA_VERSION}" ]; then
  206. download importlib_metadata "${IMPORTLIB_METADATA_VERSION}" "https://files.pythonhosted.org/packages/3f/a8/16dc098b0addd1c20719c18a86e985be851b3ec1e103e703297169bb22cc"
  207. build_python importlib_metadata "${IMPORTLIB_METADATA_VERSION}"
  208. fi
  209. # ---------------------------------------------------------------------------------------------------------------------
  210. # cxfreeze
  211. download cx_Freeze "${CXFREEZE_VERSION}" "https://github.com/anthony-tuininga/cx_Freeze/archive" "" "nv"
  212. if [ "${CXFREEZE_VERSION}" = "6.4.2" ]; then
  213. patch_file cx_Freeze "${CXFREEZE_VERSION}" "setup.py" 's/extra_postargs=extraArgs,/extra_postargs=extraArgs+os.getenv("LDFLAGS").split(),/'
  214. patch_file cx_Freeze "${CXFREEZE_VERSION}" "cx_Freeze/macdist.py" 's/, use_builtin_types=False//'
  215. fi
  216. build_python cx_Freeze "${CXFREEZE_VERSION}"
  217. # ---------------------------------------------------------------------------------------------------------------------