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.

340 lines
11KB

  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="${QT5_URL}/${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="/"
  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. popd
  81. fi
  82. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  83. pushd "${pkgdir}"
  84. make ${MAKE_ARGS}
  85. touch .stamp_built
  86. popd
  87. fi
  88. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  89. pushd "${pkgdir}"
  90. make ${MAKE_ARGS} -j 1 install
  91. if [ "${WIN32}" -eq 1 ]; then
  92. sed -i -e "s|d ||" ${PAWPAW_PREFIX}/lib/pkgconfig/Qt5*.pc
  93. fi
  94. touch .stamp_installed
  95. popd
  96. fi
  97. unset PKG_CONFIG
  98. unset PKG_CONFIG_LIBDIR
  99. unset PKG_CONFIG_PATH
  100. unset PKG_CONFIG_SYSROOT_DIR
  101. }
  102. # ---------------------------------------------------------------------------------------------------------------------
  103. # qt config
  104. # base
  105. qtbase_conf_args="-opensource -confirm-license"
  106. qtbase_conf_args+=" -c++std"
  107. if [ "${LINUX}" -eq 1 ] || [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  108. qtbase_conf_args+=" c++14"
  109. else
  110. qtbase_conf_args+=" c++11"
  111. fi
  112. # qtbase_conf_args+=" -optimized-qmake"
  113. qtbase_conf_args+=" -optimize-size"
  114. qtbase_conf_args+=" -release -strip"
  115. # qtbase_conf_args+=" -static"
  116. qtbase_conf_args+=" -shared"
  117. qtbase_conf_args+=" -silent"
  118. # qtbase_conf_args+=" -verbose"
  119. # build type
  120. qtbase_conf_args+=" -make libs"
  121. qtbase_conf_args+=" -make tools"
  122. qtbase_conf_args+=" -gui"
  123. qtbase_conf_args+=" -widgets"
  124. # paths
  125. qtbase_conf_args+=" -prefix ${PAWPAW_PREFIX}"
  126. qtbase_conf_args+=" -headerdir ${PAWPAW_PREFIX}/include/qt5"
  127. qtbase_conf_args+=" -libexecdir ${PAWPAW_PREFIX}/libexec"
  128. qtbase_conf_args+=" -plugindir ${PAWPAW_PREFIX}/lib/qt5/plugins"
  129. # enable optimizations (sse2 only)
  130. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  131. # TODO SSE2 and NEON
  132. qtbase_conf_args+=" -no-sse2"
  133. else
  134. qtbase_conf_args+=" -sse2"
  135. fi
  136. qtbase_conf_args+=" -no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2 -no-avx -no-avx2 -no-avx512"
  137. # enable some basic stuff
  138. qtbase_conf_args+=" -opengl desktop"
  139. qtbase_conf_args+=" -qt-doubleconversion"
  140. qtbase_conf_args+=" -qt-freetype"
  141. qtbase_conf_args+=" -qt-pcre"
  142. qtbase_conf_args+=" -qt-sqlite"
  143. # disable examples and tests
  144. qtbase_conf_args+=" -nomake examples"
  145. qtbase_conf_args+=" -nomake tests"
  146. qtbase_conf_args+=" -no-compile-examples"
  147. # disable a couple of things
  148. qtbase_conf_args+=" -no-cups"
  149. qtbase_conf_args+=" -no-dbus"
  150. qtbase_conf_args+=" -no-directfb"
  151. qtbase_conf_args+=" -no-eglfs"
  152. qtbase_conf_args+=" -no-evdev"
  153. qtbase_conf_args+=" -no-eventfd"
  154. qtbase_conf_args+=" -no-journald"
  155. qtbase_conf_args+=" -no-glib"
  156. qtbase_conf_args+=" -no-gtk"
  157. qtbase_conf_args+=" -no-icu"
  158. qtbase_conf_args+=" -no-libinput"
  159. qtbase_conf_args+=" -no-libproxy"
  160. qtbase_conf_args+=" -no-mtdev"
  161. qtbase_conf_args+=" -no-openssl"
  162. qtbase_conf_args+=" -no-pch"
  163. qtbase_conf_args+=" -no-sctp"
  164. qtbase_conf_args+=" -no-securetransport"
  165. qtbase_conf_args+=" -no-syslog"
  166. qtbase_conf_args+=" -no-tslib"
  167. if [ "${LINUX}" -eq 0 ]; then
  168. qtbase_conf_args+=" -no-fontconfig"
  169. qtbase_conf_args+=" -no-inotify"
  170. qtbase_conf_args+=" -no-linuxfb"
  171. fi
  172. if [ "${QT5_MVERSION}" = "5.9" ]; then
  173. qtbase_conf_args+=" -no-xinput2"
  174. qtbase_conf_args+=" -no-xkbcommon-evdev"
  175. qtbase_conf_args+=" -no-xkbcommon-x11"
  176. fi
  177. if [ "${QT5_MVERSION}" = "5.12" ]; then
  178. qtbase_conf_args+=" -qt-harfbuzz"
  179. else
  180. qtbase_conf_args+=" -no-harfbuzz"
  181. fi
  182. # supported image formats
  183. qtbase_conf_args+=" -qt-libjpeg"
  184. qtbase_conf_args+=" -qt-libpng"
  185. qtbase_conf_args+=" -no-gif"
  186. qtbase_conf_args+=" -no-ico"
  187. # use pkg-config
  188. qtbase_conf_args+=" -pkg-config"
  189. qtbase_conf_args+=" -force-pkg-config"
  190. # platform specific
  191. if [ -n "${TOOLCHAIN_PREFIX}" ]; then
  192. if [ "${LINUX}" -eq 1 ]; then
  193. if [ "${LINUX_TARGET}" = "linux-aarch64" ]; then
  194. qtbase_conf_args+=" -xplatform linux-aarch64-gnu-g++"
  195. elif [ "${LINUX_TARGET}" = "linux-armhf" ]; then
  196. qtbase_conf_args+=" -xplatform linux-arm-gnueabi-g++"
  197. elif [ "${LINUX_TARGET}" = "linux-i686" ]; then
  198. qtbase_conf_args+=" -xplatform linux-g++-32"
  199. elif [ "${LINUX_TARGET}" = "linux-riscv64" ]; then
  200. echo "error unsupported qt config"
  201. exit 3
  202. # qtbase_conf_args+=" -xplatform linux-g++"
  203. elif [ "${LINUX_TARGET}" = "linux-x86_64" ]; then
  204. qtbase_conf_args+=" -xplatform linux-g++-64"
  205. else
  206. qtbase_conf_args+=" -xplatform linux-g++"
  207. fi
  208. elif [ "${MACOS}" -eq 1 ]; then
  209. qtbase_conf_args+=" -xplatform macx-clang"
  210. elif [ "${WIN32}" -eq 1 ]; then
  211. qtbase_conf_args+=" -xplatform win32-g++"
  212. fi
  213. qtbase_conf_args+=" -device-option CROSS_COMPILE=${TOOLCHAIN_PREFIX_}"
  214. else
  215. if [ "${LINUX}" -eq 1 ]; then
  216. qtbase_conf_args+=" -platform linux-g++"
  217. elif [ "${MACOS}" -eq 1 ]; then
  218. qtbase_conf_args+=" -platform macx-clang"
  219. elif [ "${WIN32}" -eq 1 ]; then
  220. qtbase_conf_args+=" -platform win32-g++"
  221. fi
  222. fi
  223. # platform specific
  224. if [ "${LINUX}" -eq 1 ]; then
  225. qtbase_conf_args+=" -qpa xcb"
  226. qtbase_conf_args+=" -qt-xcb"
  227. #qtbase_conf_args+=" -xcb-xlib"
  228. #qtbase_conf_args+=" -xcb-xinput"
  229. elif [ "${MACOS}" -eq 1 ]; then
  230. qtbase_conf_args+=" -qpa cocoa"
  231. elif [ "${WIN32}" -eq 1 ]; then
  232. qtbase_conf_args+=" -qpa windows"
  233. fi
  234. # zlib
  235. if [ "${MACOS}" -eq 1 ]; then
  236. qtbase_conf_args+=" -system-zlib"
  237. else
  238. qtbase_conf_args+=" -qt-zlib"
  239. fi
  240. # ---------------------------------------------------------------------------------------------------------------------
  241. # qt build
  242. download_qt qtbase
  243. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  244. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/common/macx.conf" 's/QMAKE_APPLE_DEVICE_ARCHS = x86_64/QMAKE_APPLE_DEVICE_ARCHS = arm64 x86_64/'
  245. 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/'
  246. 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/'
  247. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/features/toolchain.prf" 's/-arch $$QMAKE_APPLE_DEVICE_ARCHS/-arch arm64/'
  248. elif [ "${MACOS}" -eq 1 ]; then
  249. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/macx-clang/qmake.conf" 's/10.10/10.8/'
  250. fi
  251. if [ "${WIN32}" -eq 1 ]; then
  252. if [ "${QT5_MVERSION}" = "5.12" ]; then
  253. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/common/g++-win32.conf" 's/= -shared/= -static -shared/'
  254. 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/'
  255. else
  256. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/win32-g++/qmake.conf" 's/= -shared/= -static -shared/'
  257. patch_file qtbase${qtsuffix} ${QT5_VERSION} "src/plugins/platforms/direct2d/direct2d.pro" 's/-lVersion/-lversion/'
  258. fi
  259. fi
  260. build_qt_conf qtbase "${qtbase_conf_args}"
  261. if [ "${MACOS}" -eq 1 ] && [ ! -e "${PAWPAW_PREFIX}/include/qt5/QtWidgets" ]; then
  262. ln -sfv ${PAWPAW_PREFIX}/lib/QtCore.framework/Headers ${PAWPAW_PREFIX}/include/qt5/QtCore
  263. ln -sfv ${PAWPAW_PREFIX}/lib/QtGui.framework/Headers ${PAWPAW_PREFIX}/include/qt5/QtGui
  264. ln -sfv ${PAWPAW_PREFIX}/lib/QtWidgets.framework/Headers ${PAWPAW_PREFIX}/include/qt5/QtWidgets
  265. fi
  266. # ---------------------------------------------------------------------------------------------------------------------
  267. # qtmacextras
  268. if [ "${MACOS}" -eq 1 ]; then
  269. download_qt qtmacextras
  270. build_qmake qtmacextras${qtsuffix} ${QT5_VERSION}
  271. fi
  272. # ---------------------------------------------------------------------------------------------------------------------
  273. # qtsvg
  274. download_qt qtsvg
  275. build_qmake qtsvg${qtsuffix} ${QT5_VERSION}
  276. # ---------------------------------------------------------------------------------------------------------------------
  277. # qttools (host only, thus not needed if cross-compiling)
  278. if [ "${CROSS_COMPILING}" -eq 0 ]; then
  279. if [ "${QT5_MVERSION}" = "5.12" ]; then
  280. QTTOOLS_EXTRAFLAGS=". -- -no-feature-qdoc"
  281. fi
  282. download_qt qttools
  283. build_qmake qttools${qtsuffix} ${QT5_VERSION} "${QTTOOLS_EXTRAFLAGS}"
  284. fi
  285. # ---------------------------------------------------------------------------------------------------------------------