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.

344 lines
13KB

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