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.

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