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.

315 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. if [ -z "${PAWPAW_SKIP_OPENSSL}" ]; then
  85. OPENSSL_URL="https://www.openssl.org/source"
  86. OPENSSL_VERSION="1.1.1w"
  87. OPENSSL_EXTRAFLAGS="no-shared no-hw threads no-zlib no-capieng no-pinshared"
  88. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  89. OPENSSL_EXTRAFLAGS+=" no-asm"
  90. fi
  91. download openssl "${OPENSSL_VERSION}" "${OPENSSL_URL}"
  92. build_conf_openssl openssl "${OPENSSL_VERSION}" "${OPENSSL_EXTRAFLAGS}"
  93. fi # PAWPAW_SKIP_OPENSSL
  94. # ---------------------------------------------------------------------------------------------------------------------
  95. # custom function for python
  96. function build_conf_python() {
  97. local name="${1}"
  98. local version="${2}"
  99. local extraconfrules="${3}"
  100. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  101. if [ -n "${TOOLCHAIN_PREFIX}" ]; then
  102. extraconfrules+=" --host=${TOOLCHAIN_PREFIX} --build=$(gcc -dumpmachine)"
  103. fi
  104. _prebuild "${name}" "${pkgdir}"
  105. # remove flags not compatible with python
  106. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fvisibility=hidden//')"
  107. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-ffast-math//')"
  108. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  109. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fno-strict-aliasing -flto//')"
  110. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,-dead_strip,-dead_strip_dylibs,-x//')"
  111. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,-O1,--gc-sections,--no-undefined//')"
  112. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,--as-needed,--strip-all//')"
  113. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  114. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-fno-strict-aliasing -flto//')"
  115. # add host/native binaries to path
  116. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  117. export PATH="${PAWPAW_PREFIX}-host/bin:${PATH}"
  118. fi
  119. if [ "${WIN32}" -eq 1 ] && [ ! -f "${pkgdir}/.stamp_preconfigured" ]; then
  120. pushd "${pkgdir}"
  121. autoreconf -vfi
  122. touch .stamp_preconfigured
  123. popd
  124. fi
  125. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  126. pushd "${pkgdir}"
  127. ./configure ${extraconfrules}
  128. touch .stamp_configured
  129. popd
  130. fi
  131. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  132. pushd "${pkgdir}"
  133. # if [ "${WIN32}" -eq 1 ]; then
  134. # # inject exe-wrapper
  135. # if [ -n "${EXE_WRAPPER}" ]; then
  136. # sed -i -e "s|\t./Programs/_freeze_importlib|\t${EXE_WRAPPER} ./Programs/_freeze_importlib|" Makefile
  137. # fi
  138. # make regen-importlib
  139. # fi
  140. make ${MAKE_ARGS}
  141. touch .stamp_built
  142. popd
  143. fi
  144. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  145. pushd "${pkgdir}"
  146. make ${MAKE_ARGS} -j 1 install
  147. touch .stamp_installed
  148. popd
  149. fi
  150. _postbuild
  151. }
  152. # ---------------------------------------------------------------------------------------------------------------------
  153. # python
  154. # build for host first
  155. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  156. download host-Python "${PYTHON_VERSION}" "https://www.python.org/ftp/python/${PYTHON_VERSION}" "tgz" "" Python
  157. build_host_autoconf host-Python "${PYTHON_VERSION}" "--build=$(gcc -dumpmachine) --prefix=${PAWPAW_PREFIX}-host"
  158. # sed -i -e "s|${PAWPAW_PREFIX}-host|${PAWPAW_PREFIX}|" "${PAWPAW_PREFIX}-host/bin/python3.8-config"
  159. # # FIXME
  160. # mkdir -p "${PAWPAW_PREFIX}-host/lib/python3.8/config-3.8-x86_64-linux-gnu/Tools"
  161. # ln -sf "${PAWPAW_PREFIX}-host/bin" "${PAWPAW_PREFIX}-host/lib/python3.8/config-3.8-x86_64-linux-gnu/Tools/scripts"
  162. # # may be available in host, but not in build target
  163. # if [ "${WIN32}" -eq 1 ] && [ ! -e "${PAWPAW_PREFIX}-host/include/python3.8/pyconfig.h-e" ]; then
  164. # sed -i -e '/HAVE_CRYPT_H/d' "${PAWPAW_PREFIX}-host/include/python3.8/pyconfig.h"
  165. # sed -i -e '/HAVE_CRYPT_R/d' "${PAWPAW_PREFIX}-host/include/python3.8/pyconfig.h"
  166. # sed -i -e '/HAVE_SYS_SELECT_H/d' "${PAWPAW_PREFIX}-host/include/python3.8/pyconfig.h"
  167. # touch "${PAWPAW_PREFIX}-host/include/python3.8/pyconfig.h-e"
  168. # fi
  169. fi
  170. PYTHON_EXTRAFLAGS=""
  171. if [ "${MACOS}" -eq 1 ]; then
  172. PYTHON_EXTRAFLAGS+=" --enable-optimizations"
  173. PYTHON_EXTRAFLAGS+=" ac_cv_lib_intl_textdomain=no"
  174. PYTHON_EXTRAFLAGS+=" ac_cv_header_libintl_h=no"
  175. PYTHON_EXTRAFLAGS+=" ac_cv_func_setlocale=no"
  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. # ---------------------------------------------------------------------------------------------------------------------