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.

233 lines
8.1KB

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