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.

401 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. # ---------------------------------------------------------------------------------------------------------------------
  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. # Use local Qt on Linux builds
  23. if [ "${LINUX}" -eq 1 ]; then
  24. if [ "${LINUX_TARGET}" = "linux-aarch64" ]; then
  25. export PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig
  26. elif [ "${LINUX_TARGET}" = "linux-armhf" ]; then
  27. export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig
  28. elif [ "${LINUX_TARGET}" = "linux-i686" ]; then
  29. export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig
  30. elif [ "${LINUX_TARGET}" = "linux-riscv64" ]; then
  31. export PKG_CONFIG_PATH=/usr/lib/riscv64-linux-gnu/pkgconfig
  32. elif [ "${LINUX_TARGET}" = "linux-x86_64" ]; then
  33. export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig
  34. fi
  35. if ! pkg-config --print-errors --exists Qt5Core Qt5Gui Qt5Svg Qt5Widgets; then
  36. echo "Qt system libs are not available, cannot continue"
  37. exit 2
  38. fi
  39. if [ ! -e "${TARGET_PKG_CONFIG_PATH}/Qt5Core.pc" ]; then
  40. cp $(pkg-config --variable=pcfiledir Qt5Core)/Qt5Core.pc ${TARGET_PKG_CONFIG_PATH}/
  41. sed -i '/Libs.private/d' ${TARGET_PKG_CONFIG_PATH}/Qt5Core.pc
  42. fi
  43. if [ ! -e "${TARGET_PKG_CONFIG_PATH}/Qt5Gui.pc" ]; then
  44. cp $(pkg-config --variable=pcfiledir Qt5Gui)/Qt5Gui.pc ${TARGET_PKG_CONFIG_PATH}/
  45. sed -i '/Libs.private/d' ${TARGET_PKG_CONFIG_PATH}/Qt5Gui.pc
  46. fi
  47. if [ ! -e "${TARGET_PKG_CONFIG_PATH}/Qt5Svg.pc" ]; then
  48. cp $(pkg-config --variable=pcfiledir Qt5Svg)/Qt5Svg.pc ${TARGET_PKG_CONFIG_PATH}/
  49. sed -i '/Libs.private/d' ${TARGET_PKG_CONFIG_PATH}/Qt5Svg.pc
  50. fi
  51. if [ ! -e "${TARGET_PKG_CONFIG_PATH}/Qt5Widgets.pc" ]; then
  52. cp $(pkg-config --variable=pcfiledir Qt5Widgets)/Qt5Widgets.pc ${TARGET_PKG_CONFIG_PATH}/
  53. sed -i '/Libs.private/d' ${TARGET_PKG_CONFIG_PATH}/Qt5Widgets.pc
  54. fi
  55. exit 0
  56. fi
  57. # ---------------------------------------------------------------------------------------------------------------------
  58. # qt package suffix changes depending on the version
  59. if [ "${QT5_MVERSION}" = "5.12" ]; then
  60. qtsuffix="-everywhere-src"
  61. else
  62. qtsuffix="-opensource-src"
  63. fi
  64. # ---------------------------------------------------------------------------------------------------------------------
  65. # custom functions for qt handling
  66. function download_qt() {
  67. local name="${1}"
  68. local dlfile="${PAWPAW_DOWNLOADDIR}/${name}${qtsuffix}-${QT5_VERSION}.tar.xz"
  69. local dlfolder="${PAWPAW_BUILDDIR}/${name}${qtsuffix}-${QT5_VERSION}"
  70. if [ ! -f "${dlfile}" ]; then
  71. dlurl="${QT5_URL}/${name}${qtsuffix}-${QT5_VERSION}.tar.xz"
  72. curl -L "${dlurl}" -o "${dlfile}"
  73. fi
  74. if [ ! -d "${dlfolder}" ]; then
  75. mkdir "${dlfolder}"
  76. tar -xf "${dlfile}" -C "${dlfolder}" --strip-components=1
  77. fi
  78. }
  79. function build_qt_conf() {
  80. local pkgname="${1}"
  81. local extraconfrules="${2}"
  82. local pkgdir="${PAWPAW_BUILDDIR}/${pkgname}${qtsuffix}-${QT5_VERSION}"
  83. unset AR
  84. unset CC
  85. unset CXX
  86. unset LD
  87. unset STRIP
  88. unset CFLAGS
  89. unset CPPFLAGS
  90. unset CXXFLAGS
  91. unset LDFLAGS
  92. export PKG_CONFIG="${TARGET_PKG_CONFIG}"
  93. export PKG_CONFIG_LIBDIR="${TARGET_PKG_CONFIG_PATH}"
  94. export PKG_CONFIG_PATH="${TARGET_PKG_CONFIG_PATH}"
  95. export PKG_CONFIG_SYSROOT_DIR="/"
  96. if [ -e "${PAWPAW_ROOT}/patches/${pkgname}" ] && [ ! -f "${pkgdir}/.stamp_cleanup" ] && [ ! -f "${pkgdir}/.stamp_configured" ]; then
  97. local patchtargets="${PAWPAW_TARGET}"
  98. if [[ "${PAWPAW_TARGET}" = "linux-"* ]]; then
  99. patchtargets+=" linux"
  100. elif [ "${PAWPAW_TARGET}" = "macos-universal-10.15" ]; then
  101. patchtargets+=" macos-10.15 macos-universal"
  102. elif [ "${PAWPAW_TARGET}" = "win64" ]; then
  103. patchtargets+=" win32"
  104. fi
  105. for target in ${patchtargets[@]}; do
  106. if [ -e "${PAWPAW_ROOT}/patches/${pkgname}/${target}" ]; then
  107. for p in $(ls "${PAWPAW_ROOT}/patches/${pkgname}/${target}/" | grep "\.patch$" | sort); do
  108. if [ ! -f "${pkgdir}/.stamp_applied_${p}" ]; then
  109. patch -p1 -d "${pkgdir}" -i "${PAWPAW_ROOT}/patches/${pkgname}/${target}/${p}"
  110. touch "${pkgdir}/.stamp_applied_${p}"
  111. fi
  112. done
  113. fi
  114. done
  115. for p in $(ls "${PAWPAW_ROOT}/patches/${pkgname}/" | grep "\.patch$" | sort); do
  116. if [ ! -f "${pkgdir}/.stamp_applied_${p}" ]; then
  117. patch -p1 -d "${pkgdir}" -i "${PAWPAW_ROOT}/patches/${pkgname}/${p}"
  118. touch "${pkgdir}/.stamp_applied_${p}"
  119. fi
  120. done
  121. fi
  122. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  123. pushd "${pkgdir}"
  124. ./configure ${extraconfrules}
  125. touch .stamp_configured
  126. popd
  127. fi
  128. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  129. pushd "${pkgdir}"
  130. make ${MAKE_ARGS}
  131. touch .stamp_built
  132. popd
  133. fi
  134. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  135. pushd "${pkgdir}"
  136. make ${MAKE_ARGS} -j 1 install
  137. if [ "${WIN32}" -eq 1 ]; then
  138. sed -i -e "s|d ||" ${PAWPAW_PREFIX}/lib/pkgconfig/Qt5*.pc
  139. fi
  140. touch .stamp_installed
  141. popd
  142. fi
  143. unset PKG_CONFIG
  144. unset PKG_CONFIG_LIBDIR
  145. unset PKG_CONFIG_PATH
  146. unset PKG_CONFIG_SYSROOT_DIR
  147. }
  148. # ---------------------------------------------------------------------------------------------------------------------
  149. # qt config
  150. # base
  151. qtbase_conf_args="-opensource -confirm-license"
  152. qtbase_conf_args+=" -c++std"
  153. if [ "${QT5_MVERSION}" = "5.12" ]; then
  154. qtbase_conf_args+=" c++14"
  155. else
  156. qtbase_conf_args+=" c++11"
  157. fi
  158. # qtbase_conf_args+=" -optimized-qmake"
  159. qtbase_conf_args+=" -optimize-size"
  160. qtbase_conf_args+=" -release -strip"
  161. # qtbase_conf_args+=" -static"
  162. qtbase_conf_args+=" -shared"
  163. qtbase_conf_args+=" -silent"
  164. # qtbase_conf_args+=" -verbose"
  165. # build type
  166. qtbase_conf_args+=" -make libs"
  167. qtbase_conf_args+=" -make tools"
  168. qtbase_conf_args+=" -gui"
  169. qtbase_conf_args+=" -widgets"
  170. # paths
  171. qtbase_conf_args+=" -prefix ${PAWPAW_PREFIX}"
  172. qtbase_conf_args+=" -headerdir ${PAWPAW_PREFIX}/include/qt5"
  173. qtbase_conf_args+=" -libexecdir ${PAWPAW_PREFIX}/libexec"
  174. qtbase_conf_args+=" -plugindir ${PAWPAW_PREFIX}/lib/qt5/plugins"
  175. # enable optimizations (sse2 only)
  176. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  177. # TODO SSE2 and NEON
  178. qtbase_conf_args+=" -no-sse2"
  179. else
  180. qtbase_conf_args+=" -sse2"
  181. fi
  182. qtbase_conf_args+=" -no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2 -no-avx -no-avx2 -no-avx512"
  183. # enable some basic stuff
  184. qtbase_conf_args+=" -opengl desktop"
  185. qtbase_conf_args+=" -qt-doubleconversion"
  186. qtbase_conf_args+=" -qt-freetype"
  187. qtbase_conf_args+=" -qt-pcre"
  188. qtbase_conf_args+=" -qt-sqlite"
  189. # disable examples and tests
  190. qtbase_conf_args+=" -nomake examples"
  191. qtbase_conf_args+=" -nomake tests"
  192. qtbase_conf_args+=" -no-compile-examples"
  193. # disable a couple of things
  194. qtbase_conf_args+=" -no-cups"
  195. qtbase_conf_args+=" -no-dbus"
  196. qtbase_conf_args+=" -no-directfb"
  197. qtbase_conf_args+=" -no-eglfs"
  198. qtbase_conf_args+=" -no-evdev"
  199. qtbase_conf_args+=" -no-eventfd"
  200. qtbase_conf_args+=" -no-journald"
  201. qtbase_conf_args+=" -no-glib"
  202. qtbase_conf_args+=" -no-gtk"
  203. qtbase_conf_args+=" -no-icu"
  204. qtbase_conf_args+=" -no-libinput"
  205. qtbase_conf_args+=" -no-libproxy"
  206. qtbase_conf_args+=" -no-mtdev"
  207. qtbase_conf_args+=" -no-openssl"
  208. qtbase_conf_args+=" -no-pch"
  209. qtbase_conf_args+=" -no-sctp"
  210. qtbase_conf_args+=" -no-securetransport"
  211. qtbase_conf_args+=" -no-syslog"
  212. qtbase_conf_args+=" -no-tslib"
  213. if [ "${LINUX}" -eq 0 ]; then
  214. qtbase_conf_args+=" -no-fontconfig"
  215. qtbase_conf_args+=" -no-inotify"
  216. qtbase_conf_args+=" -no-linuxfb"
  217. fi
  218. if [ "${QT5_MVERSION}" = "5.9" ]; then
  219. qtbase_conf_args+=" -no-xinput2"
  220. qtbase_conf_args+=" -no-xkbcommon-evdev"
  221. qtbase_conf_args+=" -no-xkbcommon-x11"
  222. fi
  223. if [ "${QT5_MVERSION}" = "5.12" ]; then
  224. qtbase_conf_args+=" -qt-harfbuzz"
  225. else
  226. qtbase_conf_args+=" -no-harfbuzz"
  227. fi
  228. # supported image formats
  229. qtbase_conf_args+=" -qt-libjpeg"
  230. qtbase_conf_args+=" -qt-libpng"
  231. qtbase_conf_args+=" -no-gif"
  232. qtbase_conf_args+=" -no-ico"
  233. # use pkg-config
  234. qtbase_conf_args+=" -pkg-config"
  235. qtbase_conf_args+=" -force-pkg-config"
  236. # platform specific
  237. if [ -n "${TOOLCHAIN_PREFIX}" ]; then
  238. if [ "${LINUX}" -eq 1 ]; then
  239. if [ "${LINUX_TARGET}" = "linux-aarch64" ]; then
  240. qtbase_conf_args+=" -xplatform linux-aarch64-gnu-g++"
  241. elif [ "${LINUX_TARGET}" = "linux-armhf" ]; then
  242. qtbase_conf_args+=" -xplatform linux-arm-gnueabi-g++"
  243. elif [ "${LINUX_TARGET}" = "linux-i686" ]; then
  244. qtbase_conf_args+=" -xplatform linux-g++-32"
  245. elif [ "${LINUX_TARGET}" = "linux-riscv64" ]; then
  246. echo "error unsupported qt config"
  247. exit 3
  248. # qtbase_conf_args+=" -xplatform linux-g++"
  249. elif [ "${LINUX_TARGET}" = "linux-x86_64" ]; then
  250. qtbase_conf_args+=" -xplatform linux-g++-64"
  251. else
  252. qtbase_conf_args+=" -xplatform linux-g++"
  253. fi
  254. elif [ "${MACOS}" -eq 1 ]; then
  255. qtbase_conf_args+=" -xplatform macx-clang"
  256. elif [ "${WIN32}" -eq 1 ]; then
  257. qtbase_conf_args+=" -xplatform win32-g++"
  258. fi
  259. qtbase_conf_args+=" -device-option CROSS_COMPILE=${TOOLCHAIN_PREFIX_}"
  260. else
  261. if [ "${LINUX}" -eq 1 ]; then
  262. qtbase_conf_args+=" -platform linux-g++"
  263. elif [ "${MACOS}" -eq 1 ]; then
  264. qtbase_conf_args+=" -platform macx-clang"
  265. elif [ "${WIN32}" -eq 1 ]; then
  266. qtbase_conf_args+=" -platform win32-g++"
  267. fi
  268. fi
  269. # platform specific
  270. if [ "${LINUX}" -eq 1 ]; then
  271. qtbase_conf_args+=" -qpa xcb"
  272. qtbase_conf_args+=" -qt-xcb"
  273. #qtbase_conf_args+=" -xcb-xlib"
  274. #qtbase_conf_args+=" -xcb-xinput"
  275. elif [ "${MACOS}" -eq 1 ]; then
  276. qtbase_conf_args+=" -qpa cocoa"
  277. elif [ "${WIN32}" -eq 1 ]; then
  278. qtbase_conf_args+=" -qpa windows"
  279. fi
  280. # zlib
  281. if [ "${MACOS}" -eq 0 ] || ld -v 2>&1 | grep -q ld-classic; then
  282. qtbase_conf_args+=" -qt-zlib"
  283. else
  284. qtbase_conf_args+=" -system-zlib"
  285. fi
  286. # ---------------------------------------------------------------------------------------------------------------------
  287. # qt build
  288. download_qt qtbase
  289. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  290. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/common/macx.conf" 's/QMAKE_APPLE_DEVICE_ARCHS = x86_64/QMAKE_APPLE_DEVICE_ARCHS = arm64 x86_64/'
  291. 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/'
  292. 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/'
  293. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/features/toolchain.prf" 's/-arch $$QMAKE_APPLE_DEVICE_ARCHS/-arch arm64/'
  294. elif [ "${MACOS_10_15}" -eq 1 ]; then
  295. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/common/macx.conf" 's/QT_MAC_SDK_VERSION_MIN = 10.13/QT_MAC_SDK_VERSION_MIN = 10.15/'
  296. elif [ "${MACOS}" -eq 1 ]; then
  297. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/macx-clang/qmake.conf" 's/10.10/10.8/'
  298. elif [ "${WIN32}" -eq 1 ]; then
  299. if [ "${QT5_MVERSION}" = "5.12" ]; then
  300. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/common/g++-win32.conf" 's/= -shared/= -static -shared/'
  301. else
  302. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/win32-g++/qmake.conf" 's/= -shared/= -static -shared/'
  303. patch_file qtbase${qtsuffix} ${QT5_VERSION} "src/plugins/platforms/direct2d/direct2d.pro" 's/-lVersion/-lversion/'
  304. fi
  305. fi
  306. if [ "${MACOS}" -eq 1 ] && ld -v 2>&1 | grep -q ld-classic; then
  307. if [ "${QT5_MVERSION}" = "5.12" ]; then
  308. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/common/clang-mac.conf" 's/QMAKE_LFLAGS += -stdlib=libc++/QMAKE_LFLAGS += -Wl,-ld_classic -stdlib=libc++/'
  309. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/features/toolchain.prf" 's/isEmpty(QMAKE_DEFAULT_LIBDIRS)|isEmpty(QMAKE_DEFAULT_INCDIRS):/isEmpty(QMAKE_DEFAULT_INCDIRS):/'
  310. fi
  311. fi
  312. if [ "${QT5_MVERSION}" = "5.12" ]; then
  313. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/common/clang-mac.conf" 's/QMAKE_CXXFLAGS += -stdlib=libc++/QMAKE_CXXFLAGS += -Wno-deprecated-copy -Wno-deprecated-copy-with-user-provided-copy -stdlib=libc++/'
  314. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/win32-g++/qmake.conf" 's/= -fno-keep-inline-dllexport/= -Wno-deprecated-copy -Wno-deprecated-declarations -fno-keep-inline-dllexport/'
  315. fi
  316. build_qt_conf qtbase "${qtbase_conf_args}"
  317. if [ "${MACOS}" -eq 1 ] && [ ! -e "${PAWPAW_PREFIX}/include/qt5/QtWidgets" ]; then
  318. ln -sfv ${PAWPAW_PREFIX}/lib/QtCore.framework/Headers ${PAWPAW_PREFIX}/include/qt5/QtCore
  319. ln -sfv ${PAWPAW_PREFIX}/lib/QtGui.framework/Headers ${PAWPAW_PREFIX}/include/qt5/QtGui
  320. ln -sfv ${PAWPAW_PREFIX}/lib/QtWidgets.framework/Headers ${PAWPAW_PREFIX}/include/qt5/QtWidgets
  321. fi
  322. # ---------------------------------------------------------------------------------------------------------------------
  323. # qtmacextras
  324. if [ "${MACOS}" -eq 1 ]; then
  325. download_qt qtmacextras
  326. build_qmake qtmacextras${qtsuffix} ${QT5_VERSION}
  327. fi
  328. # ---------------------------------------------------------------------------------------------------------------------
  329. # qtsvg
  330. download_qt qtsvg
  331. build_qmake qtsvg${qtsuffix} ${QT5_VERSION}
  332. # ---------------------------------------------------------------------------------------------------------------------
  333. # qttools (host only, thus not needed if cross-compiling)
  334. if [ "${CROSS_COMPILING}" -eq 0 ]; then
  335. if [ "${QT5_MVERSION}" = "5.12" ]; then
  336. QTTOOLS_EXTRAFLAGS=". -- -no-feature-qdoc"
  337. fi
  338. download_qt qttools
  339. build_qmake qttools${qtsuffix} ${QT5_VERSION} "${QTTOOLS_EXTRAFLAGS}"
  340. fi
  341. # ---------------------------------------------------------------------------------------------------------------------