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.

313 lines
12KB

  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. # check for depedencies
  23. if [ "${LINUX}" -eq 1 ] && ! command -v patchelf >/dev/null; then
  24. echo "missing 'patchelf' program, cannot continue!"
  25. exit 2
  26. fi
  27. # ---------------------------------------------------------------------------------------------------------------------
  28. # wine bootstrap for python (needed for cross-compilation)
  29. if [ "${WIN32}" -eq 1 ] && [ -n "${EXE_WRAPPER}" ] && [ ! -d "${WINEPREFIX}" ]; then
  30. wineboot -u
  31. fi
  32. # ---------------------------------------------------------------------------------------------------------------------
  33. # custom function for openssl
  34. function build_conf_openssl() {
  35. local name="${1}"
  36. local version="${2}"
  37. local extraconfrules="${3}"
  38. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  39. local extraflags=""
  40. if [ -n "${TOOLCHAIN_PREFIX}" ]; then
  41. if [ "${WIN64}" -eq 1 ]; then
  42. export MACHINE="x86_64"
  43. export SYSTEM="mingw64"
  44. extraflags="-Wa,-mbig-obj"
  45. elif [ "${WIN32}" -eq 1 ]; then
  46. export MACHINE="i686"
  47. export SYSTEM="mingw"
  48. else
  49. export MACHINE="$(uname -m)"
  50. export SYSTEM="linux2"
  51. fi
  52. export RELEASE="whatever"
  53. export BUILD="unknown"
  54. fi
  55. _prebuild "${name}" "${pkgdir}"
  56. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  57. pushd "${pkgdir}"
  58. ./config --prefix="${PAWPAW_PREFIX}" ${extraconfrules} CFLAGS="${TARGET_CFLAGS} ${extraflags}"
  59. touch .stamp_configured
  60. popd
  61. fi
  62. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  63. pushd "${pkgdir}"
  64. make ${MAKE_ARGS} ${EXTRA_MAKE_ARGS}
  65. touch .stamp_built
  66. popd
  67. fi
  68. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  69. pushd "${pkgdir}"
  70. make ${MAKE_ARGS} install_sw -j 1
  71. touch .stamp_installed
  72. popd
  73. fi
  74. if [ -n "${TOOLCHAIN_PREFIX}" ]; then
  75. unset MACHINE
  76. unset SYSTEM
  77. unset RELEASE
  78. unset BUILD
  79. fi
  80. _postbuild
  81. }
  82. # ---------------------------------------------------------------------------------------------------------------------
  83. # openssl
  84. OPENSSL_URL="https://www.openssl.org/source"
  85. OPENSSL_VERSION="1.1.1w"
  86. OPENSSL_EXTRAFLAGS="no-shared no-hw threads no-zlib no-capieng no-pinshared"
  87. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  88. OPENSSL_EXTRAFLAGS+=" no-asm"
  89. fi
  90. download openssl "${OPENSSL_VERSION}" "${OPENSSL_URL}"
  91. build_conf_openssl openssl "${OPENSSL_VERSION}" "${OPENSSL_EXTRAFLAGS}"
  92. # ---------------------------------------------------------------------------------------------------------------------
  93. # custom function for python
  94. function build_conf_python() {
  95. local name="${1}"
  96. local version="${2}"
  97. local extraconfrules="${3}"
  98. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  99. if [ -n "${TOOLCHAIN_PREFIX}" ]; then
  100. extraconfrules+=" --host=${TOOLCHAIN_PREFIX} --build=$(gcc -dumpmachine)"
  101. fi
  102. _prebuild "${name}" "${pkgdir}"
  103. # remove flags not compatible with python
  104. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fvisibility=hidden//')"
  105. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-ffast-math//')"
  106. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  107. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fno-strict-aliasing -flto//')"
  108. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,-dead_strip,-dead_strip_dylibs,-x//')"
  109. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,-O1,--gc-sections,--no-undefined//')"
  110. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,--as-needed,--strip-all//')"
  111. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  112. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-fno-strict-aliasing -flto//')"
  113. # add host/native binaries to path
  114. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  115. export PATH="${PAWPAW_PREFIX}-host/bin:${PATH}"
  116. fi
  117. if [ "${WIN32}" -eq 1 ] && [ ! -f "${pkgdir}/.stamp_preconfigured" ]; then
  118. pushd "${pkgdir}"
  119. autoreconf -vfi
  120. touch .stamp_preconfigured
  121. popd
  122. fi
  123. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  124. pushd "${pkgdir}"
  125. ./configure ${extraconfrules}
  126. touch .stamp_configured
  127. popd
  128. fi
  129. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  130. pushd "${pkgdir}"
  131. # if [ "${WIN32}" -eq 1 ]; then
  132. # # inject exe-wrapper
  133. # if [ -n "${EXE_WRAPPER}" ]; then
  134. # sed -i -e "s|\t./Programs/_freeze_importlib|\t${EXE_WRAPPER} ./Programs/_freeze_importlib|" Makefile
  135. # fi
  136. # make regen-importlib
  137. # fi
  138. make ${MAKE_ARGS}
  139. touch .stamp_built
  140. popd
  141. fi
  142. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  143. pushd "${pkgdir}"
  144. make ${MAKE_ARGS} -j 1 install
  145. touch .stamp_installed
  146. popd
  147. fi
  148. _postbuild
  149. }
  150. # ---------------------------------------------------------------------------------------------------------------------
  151. # python
  152. # build for host first
  153. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  154. download host-Python "${PYTHON_VERSION}" "https://www.python.org/ftp/python/${PYTHON_VERSION}" "tgz" "" Python
  155. build_host_autoconf host-Python "${PYTHON_VERSION}" "--build=$(gcc -dumpmachine) --prefix=${PAWPAW_PREFIX}-host"
  156. # sed -i -e "s|${PAWPAW_PREFIX}-host|${PAWPAW_PREFIX}|" "${PAWPAW_PREFIX}-host/bin/python3.8-config"
  157. # # FIXME
  158. # mkdir -p "${PAWPAW_PREFIX}-host/lib/python3.8/config-3.8-x86_64-linux-gnu/Tools"
  159. # ln -sf "${PAWPAW_PREFIX}-host/bin" "${PAWPAW_PREFIX}-host/lib/python3.8/config-3.8-x86_64-linux-gnu/Tools/scripts"
  160. # # may be available in host, but not in build target
  161. # if [ "${WIN32}" -eq 1 ] && [ ! -e "${PAWPAW_PREFIX}-host/include/python3.8/pyconfig.h-e" ]; then
  162. # sed -i -e '/HAVE_CRYPT_H/d' "${PAWPAW_PREFIX}-host/include/python3.8/pyconfig.h"
  163. # sed -i -e '/HAVE_CRYPT_R/d' "${PAWPAW_PREFIX}-host/include/python3.8/pyconfig.h"
  164. # sed -i -e '/HAVE_SYS_SELECT_H/d' "${PAWPAW_PREFIX}-host/include/python3.8/pyconfig.h"
  165. # touch "${PAWPAW_PREFIX}-host/include/python3.8/pyconfig.h-e"
  166. # fi
  167. fi
  168. PYTHON_EXTRAFLAGS=""
  169. if [ "${MACOS}" -eq 1 ]; then
  170. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  171. PYTHON_EXTRAFLAGS+=" --enable-optimizations"
  172. PYTHON_EXTRAFLAGS+=" ac_cv_lib_intl_textdomain=no"
  173. PYTHON_EXTRAFLAGS+=" ac_cv_header_libintl_h=no"
  174. PYTHON_EXTRAFLAGS+=" ac_cv_func_setlocale=no"
  175. fi
  176. PYTHON_EXTRAFLAGS+=" ac_cv_func_futimens=no"
  177. PYTHON_EXTRAFLAGS+=" ac_cv_func_preadv=no"
  178. PYTHON_EXTRAFLAGS+=" ac_cv_func_pwritev=no"
  179. PYTHON_EXTRAFLAGS+=" ac_cv_func_sendfile=no"
  180. PYTHON_EXTRAFLAGS+=" ac_cv_func_utimensat=no"
  181. elif [ "${WIN32}" -eq 1 ]; then
  182. export EXTRA_CFLAGS=" -fwrapv -D_WIN32_WINNT=0x0601"
  183. export EXTRA_CXXFLAGS=" -fwrapv -D_WIN32_WINNT=0x0601"
  184. PYTHON_EXTRAFLAGS="--with-nt-threads"
  185. PYTHON_EXTRAFLAGS+=" --without-ensurepip"
  186. PYTHON_EXTRAFLAGS+=" --without-c-locale-coercion"
  187. # Workaround for conftest error on 64-bit builds
  188. PYTHON_EXTRAFLAGS+=" ac_cv_working_tzset=no"
  189. # Workaround for when dlfcn exists on Windows, which causes
  190. # some conftests to succeed when they shouldn't (we don't use dlfcn).
  191. PYTHON_EXTRAFLAGS+=" ac_cv_header_dlfcn_h=no"
  192. PYTHON_EXTRAFLAGS+=" ac_cv_lib_dl_dlopen=no"
  193. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_GLOBAL=no"
  194. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_LAZY=no"
  195. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_LOCAL=no"
  196. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_NOW=no"
  197. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_DEEPBIND=no"
  198. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_MEMBER=no"
  199. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_NODELETE=no"
  200. PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_NOLOAD=no"
  201. fi
  202. download Python "${PYTHON_VERSION}" "https://www.python.org/ftp/python/${PYTHON_VERSION}" "tgz"
  203. if [ "${PYTHON_VERSION}" = "3.7.4" ]; then
  204. patch_file Python "${PYTHON_VERSION}" "Modules/Setup.dist" 's/#zlib zlibmodule.c/zlib zlibmodule.c/'
  205. fi
  206. build_conf_python Python "${PYTHON_VERSION}" "--prefix=${PAWPAW_PREFIX} --enable-shared ${PYTHON_EXTRAFLAGS}"
  207. # ---------------------------------------------------------------------------------------------------------------------
  208. # cython (optional)
  209. if [ -n "${CYTHON_VERSION}" ]; then
  210. download Cython "${CYTHON_VERSION}" "https://files.pythonhosted.org/packages/6c/9f/f501ba9d178aeb1f5bf7da1ad5619b207c90ac235d9859961c11829d0160"
  211. build_python Cython "${CYTHON_VERSION}"
  212. fi
  213. # ---------------------------------------------------------------------------------------------------------------------
  214. # setuptools_scm (optional)
  215. if [ -n "${SETUPTOOLS_SCM_VERSION}" ]; then
  216. download setuptools_scm "${SETUPTOOLS_SCM_VERSION}" "https://files.pythonhosted.org/packages/ed/b6/979bfa7b81878b2b4475dde092aac517e7f25dd33661796ec35664907b31"
  217. build_python setuptools_scm "${SETUPTOOLS_SCM_VERSION}"
  218. fi
  219. # ---------------------------------------------------------------------------------------------------------------------
  220. # toml (optional)
  221. if [ -n "${TOML_VERSION}" ]; then
  222. download toml "${TOML_VERSION}" "https://files.pythonhosted.org/packages/be/ba/1f744cdc819428fc6b5084ec34d9b30660f6f9daaf70eead706e3203ec3c"
  223. build_python toml "${TOML_VERSION}"
  224. fi
  225. # ---------------------------------------------------------------------------------------------------------------------
  226. # zipp (optional)
  227. if [ -n "${ZIPP_VERSION}" ]; then
  228. download zipp "${ZIPP_VERSION}" "https://files.pythonhosted.org/packages/ce/b0/757db659e8b91cb3ea47d90350d7735817fe1df36086afc77c1c4610d559"
  229. build_python zipp "${ZIPP_VERSION}"
  230. fi
  231. # ---------------------------------------------------------------------------------------------------------------------
  232. # importlib_metadata (optional)
  233. if [ -n "${IMPORTLIB_METADATA_VERSION}" ]; then
  234. download importlib_metadata "${IMPORTLIB_METADATA_VERSION}" "https://files.pythonhosted.org/packages/f8/41/8ffb059708359ea14a3ec74a99a2bf0cd44a0c983a0c480d9eb7a69438bb"
  235. build_python importlib_metadata "${IMPORTLIB_METADATA_VERSION}"
  236. fi
  237. # ---------------------------------------------------------------------------------------------------------------------
  238. # cxfreeze
  239. git_clone cx_Freeze "${CXFREEZE_VERSION}" "https://github.com/anthony-tuininga/cx_Freeze.git"
  240. build_python cx_Freeze "${CXFREEZE_VERSION}"
  241. if [ "${WIN32}" -eq 1 ] && [ "${CROSS_COMPILING}" -eq 1 ]; then
  242. PYTHONPATH="${PAWPAW_PREFIX}/lib/python3.8/site-packages"
  243. if [ ! -e "${PYTHONPATH}/cx_Freeze" ]; then
  244. ln -sv "${PYTHONPATH}"/cx_Freeze-*.egg/cx_Freeze "${PYTHONPATH}/cx_Freeze"
  245. fi
  246. if [ ! -e "${PYTHONPATH}/cx_Freeze/util.pyd" ]; then
  247. ln -sv "$(realpath "${PYTHONPATH}/cx_Freeze"/util.*)" "${PYTHONPATH}/cx_Freeze/util.pyd"
  248. fi
  249. unset PYTHONPATH
  250. fi
  251. # ---------------------------------------------------------------------------------------------------------------------