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.

217 lines
7.4KB

  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. if [ -z "${PAWPAW_SKIP_QT}" ]; then
  17. ./bootstrap-python.sh "${target}"
  18. ./bootstrap-qt.sh "${target}"
  19. fi
  20. # ---------------------------------------------------------------------------------------------------------------------
  21. # source setup code
  22. source setup/check_target.sh
  23. source setup/env.sh
  24. source setup/functions.sh
  25. source setup/versions.sh
  26. # ---------------------------------------------------------------------------------------------------------------------
  27. # file/magic (posix only)
  28. if [ "${WASM}" -eq 0 ] && [ "${WIN32}" -eq 0 ]; then
  29. download file "${FILE_VERSION}" "${FILE_URL}"
  30. build_autoconf file "${FILE_VERSION}"
  31. fi
  32. # ---------------------------------------------------------------------------------------------------------------------
  33. # everything after this point requires Qt or PyQt
  34. if [ -n "${PAWPAW_SKIP_QT}" ]; then
  35. exit 0
  36. fi
  37. # ---------------------------------------------------------------------------------------------------------------------
  38. # custom function for sip and pyqt packages
  39. function build_pyqt() {
  40. local name="${1}"
  41. local version="${2}"
  42. local extraconfrules="${3}"
  43. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  44. local python="python$(echo ${PYTHON_VERSION} | cut -b 1,2,3)"
  45. _prebuild "${name}" "${pkgdir}"
  46. # remove flags not compatible with python
  47. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fvisibility=hidden//')"
  48. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-ffast-math//')"
  49. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  50. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fno-strict-aliasing -flto//')"
  51. export CXXFLAGS="$(echo ${CXXFLAGS} | sed -e 's/-fvisibility=hidden//')"
  52. export CXXFLAGS="$(echo ${CXXFLAGS} | sed -e 's/-fvisibility-inlines-hidden//')"
  53. export CXXFLAGS="$(echo ${CXXFLAGS} | sed -e 's/-ffast-math//')"
  54. export CXXFLAGS="$(echo ${CXXFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  55. export CXXFLAGS="$(echo ${CXXFLAGS} | sed -e 's/-fno-strict-aliasing -flto//')"
  56. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,-dead_strip,-dead_strip_dylibs,-x//')"
  57. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,-O1,--gc-sections,--no-undefined//')"
  58. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,--as-needed,--strip-all//')"
  59. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  60. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-fno-strict-aliasing -flto//')"
  61. # non-standard vars used by sip/pyqt
  62. export LFLAGS="${LDFLAGS}"
  63. export LINK="${CXX}"
  64. # add host/native binaries to path
  65. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  66. export PATH="${PAWPAW_PREFIX}-host/bin:${PATH}"
  67. fi
  68. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  69. pushd "${pkgdir}"
  70. # Place link to Qt DLLs for PyQt tests
  71. if [ "${WIN32}" -eq 1 ] && [ -d "pyuic" ] && [ ! -d "release" ]; then
  72. mkdir release
  73. ln -sf "${PAWPAW_PREFIX}/bin"/Qt* release/
  74. fi
  75. ${python} configure.py ${extraconfrules}
  76. if [ -f "QtCore/Makefile.Release" ]; then
  77. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  78. sed -i -e "s|${PAWPAW_PREFIX}-host|${PAWPAW_PREFIX}|" pylupdate5 pyrcc5 pyuic5
  79. fi
  80. if [ -n "${EXE_WRAPPER}" ]; then
  81. sed -i -e "s|exec /|exec ${EXE_WRAPPER} /|" pylupdate5 pyrcc5 pyuic5
  82. fi
  83. fi
  84. touch .stamp_configured
  85. popd
  86. fi
  87. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  88. pushd "${pkgdir}"
  89. # build sip as host tool first
  90. if [ "${CROSS_COMPILING}" -eq 1 ] && [ -d "sipgen" ] && [ ! -f "sipgen/sip" ]; then
  91. pushd "sipgen"
  92. PATH="${OLD_PATH}" make sip CC="gcc" CFLAGS= LINK="gcc" LFLAGS="-Wl,-s" ${MAKE_ARGS}
  93. popd
  94. fi
  95. # CC="${TARGET_CC}" CXX="${TARGET_CXX}" LFLAGS="${LDFLAGS}" LINK="${TARGET_CXX}" PREFIX="${PAWPAW_PREFIX}" PKG_CONFIG="${TARGET_PKG_CONFIG}"
  96. make ${MAKE_ARGS}
  97. touch .stamp_built
  98. popd
  99. fi
  100. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  101. pushd "${pkgdir}"
  102. # PREFIX="${PAWPAW_PREFIX}" PKG_CONFIG="${TARGET_PKG_CONFIG}"
  103. make ${MAKE_ARGS} -j 1 install
  104. touch .stamp_installed
  105. popd
  106. fi
  107. unset LFLAGS
  108. unset LINK
  109. }
  110. # ---------------------------------------------------------------------------------------------------------------------
  111. # sip
  112. if [ "${SIP_VERSION}" = "4.19.19" ]; then
  113. SIP_DOWNLOAD_URL="https://files.kde.org/krita/build/dependencies"
  114. SIP_EXTRAFLAGS="--sip-module PyQt5.sip"
  115. else
  116. SIP_DOWNLOAD_URL="http://sourceforge.net/projects/pyqt/files/sip/sip-${SIP_VERSION}"
  117. fi
  118. if [ "${WIN32}" -eq 1 ]; then
  119. SIP_EXTRAFLAGS+=" --platform win32-g++"
  120. SIP_EXTRAFLAGS+=" EXTENSION_PLUGIN=pyd"
  121. fi
  122. SIP_EXTRAFLAGS+=" --sysroot=${PAWPAW_PREFIX}"
  123. SIP_EXTRAFLAGS+=" INCDIR=${PAWPAW_PREFIX}/include/python3.8"
  124. SIP_EXTRAFLAGS+=" LIBDIR=${PAWPAW_PREFIX}/lib/python3.8/config-3.8"
  125. download sip "${SIP_VERSION}" "${SIP_DOWNLOAD_URL}"
  126. build_pyqt sip "${SIP_VERSION}" "${SIP_EXTRAFLAGS}"
  127. # ---------------------------------------------------------------------------------------------------------------------
  128. # pyqt5
  129. if [ "${PYQT5_VERSION}" = "5.13.1" ]; then
  130. PYQT5_DOWNLOAD_URL="https://files.kde.org/krita/build/dependencies"
  131. PYQT5_SUFFIX="_gpl"
  132. else
  133. PYQT5_DOWNLOAD_URL="http://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-${PYQT5_VERSION}"
  134. PYQT5_SUFFIX="_gpl"
  135. fi
  136. # qmake needs this
  137. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  138. export PKG_CONFIG_LIBDIR="${TARGET_PKG_CONFIG_PATH}"
  139. export PKG_CONFIG_SYSROOT_DIR="/"
  140. fi
  141. PYQT5_EXTRAFLAGS="--qmake ${PAWPAW_PREFIX}/bin/qmake --sip ${PAWPAW_PREFIX}/bin/sip --sysroot ${PAWPAW_PREFIX}"
  142. download PyQt5${PYQT5_SUFFIX} "${PYQT5_VERSION}" "${PYQT5_DOWNLOAD_URL}"
  143. build_pyqt PyQt5${PYQT5_SUFFIX} "${PYQT5_VERSION}" "${PYQT5_EXTRAFLAGS} --concatenate --confirm-license"
  144. # --verbose
  145. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  146. unset PKG_CONFIG_LIBDIR
  147. unset PKG_CONFIG_SYSROOT_DIR
  148. fi
  149. # ---------------------------------------------------------------------------------------------------------------------
  150. # pyliblo
  151. if [ "${WIN32}" -eq 1 ]; then
  152. export EXTRA_CFLAGS="$(${PAWPAW_PREFIX}/bin/pkg-config --cflags python3 liblo)"
  153. export EXTRA_LDFLAGS="-shared $(${PAWPAW_PREFIX}/bin/pkg-config --libs python3 liblo)"
  154. export LDSHARED="${TARGET_CXX}"
  155. fi
  156. download pyliblo "${PYLIBLO_VERSION}" "http://das.nasophon.de/download"
  157. build_python pyliblo "${PYLIBLO_VERSION}"
  158. if [ "${WIN32}" -eq 1 ]; then
  159. unset LDSHARED
  160. fi
  161. if [ "${WIN32}" -eq 1 ] && [ "${CROSS_COMPILING}" -eq 1 ]; then
  162. PYTHONPATH="${PAWPAW_PREFIX}/lib/python3.8/site-packages"
  163. if [ ! -e "${PYTHONPATH}/liblo.pyd" ]; then
  164. ln -sv "${PYTHONPATH}"/pyliblo-*.egg/*.so "${PYTHONPATH}/liblo.pyd"
  165. fi
  166. unset PYTHONPATH
  167. fi
  168. # ---------------------------------------------------------------------------------------------------------------------