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.

313 lines
9.9KB

  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. # qt package suffix changes depending on the version
  23. if [ "${QT5_MVERSION}" = "5.12" ]; then
  24. qtsuffix="-everywhere-src"
  25. else
  26. qtsuffix="-opensource-src"
  27. fi
  28. # ---------------------------------------------------------------------------------------------------------------------
  29. # custom functions for qt handling
  30. function download_qt() {
  31. local name="${1}"
  32. local dlfile="${PAWPAW_DOWNLOADDIR}/${name}${qtsuffix}-${QT5_VERSION}.tar.xz"
  33. local dlfolder="${PAWPAW_BUILDDIR}/${name}${qtsuffix}-${QT5_VERSION}"
  34. if [ ! -f "${dlfile}" ]; then
  35. dlurl="https://download.qt.io/archive/qt/${QT5_MVERSION}/${QT5_VERSION}/submodules/${name}${qtsuffix}-${QT5_VERSION}.tar.xz"
  36. curl -L "${dlurl}" -o "${dlfile}"
  37. fi
  38. if [ ! -d "${dlfolder}" ]; then
  39. mkdir "${dlfolder}"
  40. tar -xf "${dlfile}" -C "${dlfolder}" --strip-components=1
  41. fi
  42. }
  43. function build_qt_conf() {
  44. local name="${1}"
  45. local extraconfrules="${2}"
  46. local pkgdir="${PAWPAW_BUILDDIR}/${name}${qtsuffix}-${QT5_VERSION}"
  47. unset AR
  48. unset CC
  49. unset CXX
  50. unset LD
  51. unset STRIP
  52. unset CFLAGS
  53. unset CPPFLAGS
  54. unset CXXFLAGS
  55. unset LDFLAGS
  56. export PKG_CONFIG="${TARGET_PKG_CONFIG}"
  57. export PKG_CONFIG_LIBDIR="${TARGET_PKG_CONFIG_PATH}"
  58. export PKG_CONFIG_PATH="${TARGET_PKG_CONFIG_PATH}"
  59. export PKG_CONFIG_SYSROOT_DIR="${TARGET_PKG_CONFIG_PATH}"
  60. if [ -d "${PAWPAW_ROOT}/patches/${name}" ]; then
  61. for p in $(ls "${PAWPAW_ROOT}/patches/${name}/" | grep "\.patch" | sort); do
  62. if [ ! -f "${pkgdir}/.stamp_applied_${p}" ]; then
  63. patch -p1 -d "${pkgdir}" -i "${PAWPAW_ROOT}/patches/${name}/${p}"
  64. touch "${pkgdir}/.stamp_applied_${p}"
  65. fi
  66. done
  67. fi
  68. if [ -d "${PAWPAW_ROOT}/patches/${name}/${PAWPAW_TARGET}" ]; then
  69. for p in $(ls "${PAWPAW_ROOT}/patches/${name}/${PAWPAW_TARGET}/" | grep "\.patch" | sort); do
  70. if [ ! -f "${pkgdir}/.stamp_applied_${p}" ]; then
  71. patch -p1 -d "${pkgdir}" -i "${PAWPAW_ROOT}/patches/${name}/${PAWPAW_TARGET}/${p}"
  72. touch "${pkgdir}/.stamp_applied_${p}"
  73. fi
  74. done
  75. fi
  76. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  77. pushd "${pkgdir}"
  78. ./configure ${extraconfrules}
  79. touch .stamp_configured
  80. #sed -i -e 's/sub-tests //' Makefile
  81. #sed -i -e 's/sub-tests-all //' Makefile
  82. #sed -i -e 's/sub-tests-qmake_all //' Makefile
  83. popd
  84. fi
  85. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  86. pushd "${pkgdir}"
  87. # NOTE: Qt win32 builds are very verbose, too many warnings, which makes CI build fail
  88. if [ "${WIN32}" -eq 1 ] && [ -n "${TRAVIS_BUILD_DIR}" ]; then
  89. make ${MAKE_ARGS} 2>/dev/null
  90. else
  91. make ${MAKE_ARGS}
  92. fi
  93. touch .stamp_built
  94. popd
  95. fi
  96. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  97. pushd "${pkgdir}"
  98. make ${MAKE_ARGS} -j 1 install
  99. touch .stamp_installed
  100. popd
  101. fi
  102. unset PKG_CONFIG
  103. unset PKG_CONFIG_LIBDIR
  104. unset PKG_CONFIG_PATH
  105. unset PKG_CONFIG_SYSROOT_DIR
  106. }
  107. # ---------------------------------------------------------------------------------------------------------------------
  108. # qt config
  109. # base
  110. qtbase_conf_args="-opensource -confirm-license"
  111. qtbase_conf_args+=" -c++std"
  112. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  113. qtbase_conf_args+=" c++14"
  114. else
  115. qtbase_conf_args+=" c++11"
  116. fi
  117. # qtbase_conf_args+=" -optimized-qmake"
  118. qtbase_conf_args+=" -optimize-size"
  119. qtbase_conf_args+=" -release -strip"
  120. # qtbase_conf_args+=" -static"
  121. qtbase_conf_args+=" -shared"
  122. qtbase_conf_args+=" -silent"
  123. # qtbase_conf_args+=" -verbose"
  124. # build type
  125. qtbase_conf_args+=" -make libs"
  126. qtbase_conf_args+=" -make tools"
  127. qtbase_conf_args+=" -gui"
  128. qtbase_conf_args+=" -widgets"
  129. # paths
  130. qtbase_conf_args+=" -prefix ${PAWPAW_PREFIX}"
  131. qtbase_conf_args+=" -headerdir ${PAWPAW_PREFIX}/include/qt5"
  132. qtbase_conf_args+=" -libexecdir ${PAWPAW_PREFIX}/libexec"
  133. qtbase_conf_args+=" -plugindir ${PAWPAW_PREFIX}/lib/qt5/plugins"
  134. # enable optimizations (sse2 only)
  135. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  136. # TODO SSE2 and NEON
  137. qtbase_conf_args+=" -no-sse2"
  138. else
  139. qtbase_conf_args+=" -sse2"
  140. fi
  141. qtbase_conf_args+=" -no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2 -no-avx -no-avx2 -no-avx512"
  142. # enable some basic stuff
  143. qtbase_conf_args+=" -opengl desktop"
  144. qtbase_conf_args+=" -qt-doubleconversion"
  145. qtbase_conf_args+=" -qt-pcre"
  146. qtbase_conf_args+=" -qt-sqlite"
  147. # disable examples and tests
  148. qtbase_conf_args+=" -nomake examples"
  149. qtbase_conf_args+=" -nomake tests"
  150. qtbase_conf_args+=" -no-compile-examples"
  151. # disable a couple of things
  152. qtbase_conf_args+=" -no-cups"
  153. qtbase_conf_args+=" -no-dbus"
  154. qtbase_conf_args+=" -no-directfb"
  155. qtbase_conf_args+=" -no-eglfs"
  156. qtbase_conf_args+=" -no-evdev"
  157. qtbase_conf_args+=" -no-eventfd"
  158. qtbase_conf_args+=" -no-journald"
  159. qtbase_conf_args+=" -no-glib"
  160. qtbase_conf_args+=" -no-gtk"
  161. qtbase_conf_args+=" -no-icu"
  162. qtbase_conf_args+=" -no-inotify"
  163. qtbase_conf_args+=" -no-libinput"
  164. qtbase_conf_args+=" -no-libproxy"
  165. qtbase_conf_args+=" -no-mtdev"
  166. qtbase_conf_args+=" -no-openssl"
  167. qtbase_conf_args+=" -no-pch"
  168. qtbase_conf_args+=" -no-sctp"
  169. qtbase_conf_args+=" -no-securetransport"
  170. qtbase_conf_args+=" -no-syslog"
  171. qtbase_conf_args+=" -no-tslib"
  172. if [ "${MACOS_UNIVERSAL}" -eq 0 ]; then
  173. qtbase_conf_args+=" -no-xinput2"
  174. qtbase_conf_args+=" -no-xkbcommon-evdev"
  175. qtbase_conf_args+=" -no-xkbcommon-x11"
  176. fi
  177. # font stuff
  178. qtbase_conf_args+=" -qt-freetype"
  179. qtbase_conf_args+=" -no-fontconfig"
  180. qtbase_conf_args+=" -no-harfbuzz"
  181. # supported image formats
  182. qtbase_conf_args+=" -qt-libjpeg"
  183. qtbase_conf_args+=" -qt-libpng"
  184. qtbase_conf_args+=" -no-gif"
  185. qtbase_conf_args+=" -no-ico"
  186. # use pkg-config
  187. qtbase_conf_args+=" -pkg-config"
  188. qtbase_conf_args+=" -force-pkg-config"
  189. # platform specific
  190. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  191. if [ "${LINUX}" -eq 1 ]; then
  192. qtbase_conf_args+=" -xplatform linux-g++"
  193. elif [ "${MACOS}" -eq 1 ]; then
  194. qtbase_conf_args+=" -xplatform macx-clang"
  195. elif [ "${WIN32}" -eq 1 ]; then
  196. qtbase_conf_args+=" -xplatform win32-g++"
  197. fi
  198. qtbase_conf_args+=" -device-option CROSS_COMPILE=${TOOLCHAIN_PREFIX_}"
  199. else
  200. if [ "${LINUX}" -eq 1 ]; then
  201. qtbase_conf_args+=" -platform linux-g++"
  202. elif [ "${MACOS}" -eq 1 ]; then
  203. qtbase_conf_args+=" -platform macx-clang"
  204. elif [ "${WIN32}" -eq 1 ]; then
  205. qtbase_conf_args+=" -platform win32-g++"
  206. fi
  207. fi
  208. # platform specific
  209. if [ "${LINUX}" -eq 1 ]; then
  210. qtbase_conf_args+=" -qpa xcb"
  211. qtbase_conf_args+=" -qt-xcb"
  212. qtbase_conf_args+=" -xcb-xlib"
  213. elif [ "${MACOS}" -eq 1 ]; then
  214. qtbase_conf_args+=" -qpa cocoa"
  215. elif [ "${WIN32}" -eq 1 ]; then
  216. qtbase_conf_args+=" -qpa windows"
  217. fi
  218. # zlib
  219. if [ "${MACOS}" -eq 1 ]; then
  220. qtbase_conf_args+=" -system-zlib"
  221. else
  222. qtbase_conf_args+=" -qt-zlib"
  223. fi
  224. # ---------------------------------------------------------------------------------------------------------------------
  225. # qt build
  226. download_qt qtbase
  227. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  228. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/common/macx.conf" 's/QMAKE_APPLE_DEVICE_ARCHS = x86_64/QMAKE_APPLE_DEVICE_ARCHS = arm64 x86_64/'
  229. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/common/macx.conf" 's/QT_MAC_SDK_VERSION_MIN = 10.13/QT_MAC_SDK_VERSION_MIN = 10.12/'
  230. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/common/macx.conf" 's/QT_MAC_SDK_VERSION_MAX = 10.15/QT_MAC_SDK_VERSION_MAX = 10.12/'
  231. elif [ "${MACOS}" -eq 1 ]; then
  232. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/macx-clang/qmake.conf" 's/10.10/10.8/'
  233. fi
  234. if [ "${WIN32}" -eq 1 ]; then
  235. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/win32-g++/qmake.conf" 's/= -shared/= -static -shared/'
  236. patch_file qtbase${qtsuffix} ${QT5_VERSION} "src/plugins/platforms/direct2d/direct2d.pro" 's/-lVersion/-lversion/'
  237. fi
  238. build_qt_conf qtbase "${qtbase_conf_args}"
  239. if [ "${MACOS}" -eq 1 ] && [ ! -e "${PAWPAW_PREFIX}/include/qt5/QtCore" ]; then
  240. ln -sfv ${PAWPAW_PREFIX}/lib/QtCore.framework/Headers ${PAWPAW_PREFIX}/include/qt5/QtCore
  241. ln -sfv ${PAWPAW_PREFIX}/lib/QtGui.framework/Headers ${PAWPAW_PREFIX}/include/qt5/QtGui
  242. ln -sfv ${PAWPAW_PREFIX}/lib/QtWidgets.framework/Headers ${PAWPAW_PREFIX}/include/qt5/QtWidgets
  243. fi
  244. # ---------------------------------------------------------------------------------------------------------------------
  245. # qtmacextras
  246. if [ "${MACOS}" -eq 1 ]; then
  247. download_qt qtmacextras
  248. build_qmake qtmacextras${qtsuffix} ${QT5_VERSION}
  249. fi
  250. # ---------------------------------------------------------------------------------------------------------------------
  251. # qtsvg
  252. download_qt qtsvg
  253. build_qmake qtsvg${qtsuffix} ${QT5_VERSION}
  254. # ---------------------------------------------------------------------------------------------------------------------
  255. # qttools (host only, thus not needed if cross-compiling)
  256. if [ "${CROSS_COMPILING}" -eq 0 ]; then
  257. download_qt qttools
  258. build_qmake qttools${qtsuffix} ${QT5_VERSION}
  259. fi
  260. # ---------------------------------------------------------------------------------------------------------------------