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.

231 lines
9.3KB

  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. # ---------------------------------------------------------------------------------------------------------------------
  16. # source setup code
  17. source setup/check_target.sh
  18. source setup/env.sh
  19. source setup/functions.sh
  20. source setup/versions.sh
  21. # ---------------------------------------------------------------------------------------------------------------------
  22. # wine bootstrap for python (needed for cross-compilation)
  23. if [ "${WIN32}" -eq 1 ] && [ -n "${EXE_WRAPPER}" ] && [ ! -d "${WINEPREFIX}" ]; then
  24. wineboot -u
  25. fi
  26. # ---------------------------------------------------------------------------------------------------------------------
  27. # custom function for python
  28. function build_conf_python() {
  29. local name="${1}"
  30. local version="${2}"
  31. local extraconfrules="${3}"
  32. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  33. if [ -n "${TOOLCHAIN_PREFIX}" ]; then
  34. extraconfrules+=" --host=${TOOLCHAIN_PREFIX} --build=$(gcc -dumpmachine)"
  35. fi
  36. _prebuild "${name}" "${pkgdir}"
  37. # remove flags not compatible with python
  38. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fvisibility=hidden//')"
  39. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-ffast-math//')"
  40. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  41. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fno-strict-aliasing -flto//')"
  42. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,-dead_strip,-dead_strip_dylibs,-x//')"
  43. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,-O1,--gc-sections,--no-undefined//')"
  44. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,--as-needed,--strip-all//')"
  45. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  46. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-fno-strict-aliasing -flto//')"
  47. # add host/native binaries to path
  48. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  49. export PATH="${PAWPAW_PREFIX}-host/bin:${PATH}"
  50. fi
  51. if [ "${WIN32}" -eq 1 ] && [ ! -f "${pkgdir}/.stamp_preconfigured" ]; then
  52. pushd "${pkgdir}"
  53. autoreconf -vfi
  54. touch .stamp_preconfigured
  55. popd
  56. fi
  57. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  58. pushd "${pkgdir}"
  59. ./configure ${extraconfrules}
  60. touch .stamp_configured
  61. popd
  62. fi
  63. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  64. pushd "${pkgdir}"
  65. # if [ "${WIN32}" -eq 1 ]; then
  66. # # inject exe-wrapper
  67. # if [ -n "${EXE_WRAPPER}" ]; then
  68. # sed -i -e "s|\t./Programs/_freeze_importlib|\t${EXE_WRAPPER} ./Programs/_freeze_importlib|" Makefile
  69. # fi
  70. # make regen-importlib
  71. # fi
  72. make ${MAKE_ARGS}
  73. touch .stamp_built
  74. popd
  75. fi
  76. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  77. pushd "${pkgdir}"
  78. make ${MAKE_ARGS} -j 1 install
  79. touch .stamp_installed
  80. popd
  81. fi
  82. _postbuild
  83. }
  84. # ---------------------------------------------------------------------------------------------------------------------
  85. # python
  86. # build for host first
  87. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  88. download host-Python "${PYTHON_VERSION}" "https://www.python.org/ftp/python/${PYTHON_VERSION}" "tgz" "" Python
  89. build_host_autoconf host-Python "${PYTHON_VERSION}" "--build=$(gcc -dumpmachine) --prefix=${PAWPAW_PREFIX}-host"
  90. # sed -i -e "s|${PAWPAW_PREFIX}-host|${PAWPAW_PREFIX}|" "${PAWPAW_PREFIX}-host/bin/python3.8-config"
  91. # # FIXME
  92. # mkdir -p "${PAWPAW_PREFIX}-host/lib/python3.8/config-3.8-x86_64-linux-gnu/Tools"
  93. # ln -sf "${PAWPAW_PREFIX}-host/bin" "${PAWPAW_PREFIX}-host/lib/python3.8/config-3.8-x86_64-linux-gnu/Tools/scripts"
  94. # # may be available in host, but not in build target
  95. # if [ "${WIN32}" -eq 1 ] && [ ! -e "${PAWPAW_PREFIX}-host/include/python3.8/pyconfig.h-e" ]; then
  96. # sed -i -e '/HAVE_CRYPT_H/d' "${PAWPAW_PREFIX}-host/include/python3.8/pyconfig.h"
  97. # sed -i -e '/HAVE_CRYPT_R/d' "${PAWPAW_PREFIX}-host/include/python3.8/pyconfig.h"
  98. # sed -i -e '/HAVE_SYS_SELECT_H/d' "${PAWPAW_PREFIX}-host/include/python3.8/pyconfig.h"
  99. # touch "${PAWPAW_PREFIX}-host/include/python3.8/pyconfig.h-e"
  100. # fi
  101. fi
  102. PYTHON_EXTRAFLAGS=""
  103. if [ "${MACOS}" -eq 1 ]; then
  104. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  105. PYTHON_EXTRAFLAGS+=" --enable-optimizations"
  106. PYTHON_EXTRAFLAGS+=" ac_cv_lib_intl_textdomain=no"
  107. PYTHON_EXTRAFLAGS+=" ac_cv_header_libintl_h=no"
  108. PYTHON_EXTRAFLAGS+=" ac_cv_func_setlocale=no"
  109. fi
  110. PYTHON_EXTRAFLAGS+=" ac_cv_func_futimens=no"
  111. PYTHON_EXTRAFLAGS+=" ac_cv_func_preadv=no"
  112. PYTHON_EXTRAFLAGS+=" ac_cv_func_pwritev=no"
  113. PYTHON_EXTRAFLAGS+=" ac_cv_func_sendfile=no"
  114. PYTHON_EXTRAFLAGS+=" ac_cv_func_utimensat=no"
  115. elif [ "${WIN32}" -eq 1 ]; then
  116. export EXTRA_CFLAGS=" -fwrapv -D_WIN32_WINNT=0x0601"
  117. export EXTRA_CXXFLAGS=" -fwrapv -D_WIN32_WINNT=0x0601"
  118. PYTHON_EXTRAFLAGS="--with-nt-threads"
  119. PYTHON_EXTRAFLAGS+=" --without-ensurepip"
  120. PYTHON_EXTRAFLAGS+=" --without-c-locale-coercion"
  121. # Workaround for conftest error on 64-bit builds
  122. PYTHON_EXTRAFLAGS+=" ac_cv_working_tzset=no"
  123. # Workaround for when dlfcn exists on Windows, which causes
  124. # some conftests to succeed when they shouldn't (we don't use dlfcn).
  125. PYTHON_EXTRAFLAGS+=" ac_cv_header_dlfcn_h=no"
  126. PYTHON_EXTRAFLAGS+=" ac_cv_lib_dl_dlopen=no"
  127. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_GLOBAL=no"
  128. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_LAZY=no"
  129. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_LOCAL=no"
  130. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_NOW=no"
  131. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_DEEPBIND=no"
  132. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_MEMBER=no"
  133. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_NODELETE=no"
  134. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_NOLOAD=no"
  135. fi
  136. download Python "${PYTHON_VERSION}" "https://www.python.org/ftp/python/${PYTHON_VERSION}" "tgz"
  137. if [ "${PYTHON_VERSION}" = "3.7.4" ]; then
  138. patch_file Python "${PYTHON_VERSION}" "Modules/Setup.dist" 's/#zlib zlibmodule.c/zlib zlibmodule.c/'
  139. fi
  140. build_conf_python Python "${PYTHON_VERSION}" "--prefix=${PAWPAW_PREFIX} --enable-shared ${PYTHON_EXTRAFLAGS}"
  141. # ---------------------------------------------------------------------------------------------------------------------
  142. # cython (optional)
  143. if [ -n "${CYTHON_VERSION}" ]; then
  144. download Cython "${CYTHON_VERSION}" "https://files.pythonhosted.org/packages/6c/9f/f501ba9d178aeb1f5bf7da1ad5619b207c90ac235d9859961c11829d0160"
  145. build_python Cython "${CYTHON_VERSION}"
  146. fi
  147. # ---------------------------------------------------------------------------------------------------------------------
  148. # setuptools_scm (optional)
  149. if [ -n "${SETUPTOOLS_SCM_VERSION}" ]; then
  150. download setuptools_scm "${SETUPTOOLS_SCM_VERSION}" "https://files.pythonhosted.org/packages/ed/b6/979bfa7b81878b2b4475dde092aac517e7f25dd33661796ec35664907b31"
  151. build_python setuptools_scm "${SETUPTOOLS_SCM_VERSION}"
  152. fi
  153. # ---------------------------------------------------------------------------------------------------------------------
  154. # toml (optional)
  155. if [ -n "${TOML_VERSION}" ]; then
  156. download toml "${TOML_VERSION}" "https://files.pythonhosted.org/packages/be/ba/1f744cdc819428fc6b5084ec34d9b30660f6f9daaf70eead706e3203ec3c"
  157. build_python toml "${TOML_VERSION}"
  158. fi
  159. # ---------------------------------------------------------------------------------------------------------------------
  160. # zipp (optional)
  161. if [ -n "${ZIPP_VERSION}" ]; then
  162. download zipp "${ZIPP_VERSION}" "https://files.pythonhosted.org/packages/ce/b0/757db659e8b91cb3ea47d90350d7735817fe1df36086afc77c1c4610d559"
  163. build_python zipp "${ZIPP_VERSION}"
  164. fi
  165. # ---------------------------------------------------------------------------------------------------------------------
  166. # importlib_metadata (optional)
  167. if [ -n "${IMPORTLIB_METADATA_VERSION}" ]; then
  168. download importlib_metadata "${IMPORTLIB_METADATA_VERSION}" "https://files.pythonhosted.org/packages/f8/41/8ffb059708359ea14a3ec74a99a2bf0cd44a0c983a0c480d9eb7a69438bb"
  169. build_python importlib_metadata "${IMPORTLIB_METADATA_VERSION}"
  170. fi
  171. # ---------------------------------------------------------------------------------------------------------------------
  172. # cxfreeze
  173. git_clone cx_Freeze "${CXFREEZE_VERSION}" "https://github.com/anthony-tuininga/cx_Freeze.git"
  174. build_python cx_Freeze "${CXFREEZE_VERSION}"
  175. if [ "${WIN32}" -eq 1 ] && [ "${CROSS_COMPILING}" -eq 1 ]; then
  176. PYTHONPATH="${PAWPAW_PREFIX}/lib/python3.8/site-packages"
  177. if [ ! -e "${PYTHONPATH}/cx_Freeze" ]; then
  178. ln -sv "${PYTHONPATH}"/cx_Freeze-*.egg/cx_Freeze "${PYTHONPATH}/cx_Freeze"
  179. fi
  180. if [ ! -e "${PYTHONPATH}/cx_Freeze/util.pyd" ]; then
  181. ln -sv "$(realpath "${PYTHONPATH}/cx_Freeze"/util.*)" "${PYTHONPATH}/cx_Freeze/util.pyd"
  182. fi
  183. unset PYTHONPATH
  184. fi
  185. # ---------------------------------------------------------------------------------------------------------------------