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.

317 lines
10KB

  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 [ "${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-pcre"
  141. qtbase_conf_args+=" -qt-sqlite"
  142. # disable examples and tests
  143. qtbase_conf_args+=" -nomake examples"
  144. qtbase_conf_args+=" -nomake tests"
  145. qtbase_conf_args+=" -no-compile-examples"
  146. # disable a couple of things
  147. qtbase_conf_args+=" -no-cups"
  148. qtbase_conf_args+=" -no-dbus"
  149. qtbase_conf_args+=" -no-directfb"
  150. qtbase_conf_args+=" -no-eglfs"
  151. qtbase_conf_args+=" -no-evdev"
  152. qtbase_conf_args+=" -no-eventfd"
  153. qtbase_conf_args+=" -no-journald"
  154. qtbase_conf_args+=" -no-glib"
  155. qtbase_conf_args+=" -no-gtk"
  156. qtbase_conf_args+=" -no-icu"
  157. qtbase_conf_args+=" -no-inotify"
  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 [ "${QT5_MVERSION}" = "5.9" ]; then
  168. qtbase_conf_args+=" -no-xinput2"
  169. qtbase_conf_args+=" -no-xkbcommon-evdev"
  170. qtbase_conf_args+=" -no-xkbcommon-x11"
  171. fi
  172. # font stuff
  173. qtbase_conf_args+=" -qt-freetype"
  174. qtbase_conf_args+=" -no-fontconfig"
  175. qtbase_conf_args+=" -no-harfbuzz"
  176. # supported image formats
  177. qtbase_conf_args+=" -qt-libjpeg"
  178. qtbase_conf_args+=" -qt-libpng"
  179. qtbase_conf_args+=" -no-gif"
  180. qtbase_conf_args+=" -no-ico"
  181. # use pkg-config
  182. qtbase_conf_args+=" -pkg-config"
  183. qtbase_conf_args+=" -force-pkg-config"
  184. # platform specific
  185. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  186. if [ "${LINUX}" -eq 1 ]; then
  187. qtbase_conf_args+=" -xplatform linux-g++"
  188. elif [ "${MACOS}" -eq 1 ]; then
  189. qtbase_conf_args+=" -xplatform macx-clang"
  190. elif [ "${WIN32}" -eq 1 ]; then
  191. qtbase_conf_args+=" -xplatform win32-g++"
  192. fi
  193. qtbase_conf_args+=" -device-option CROSS_COMPILE=${TOOLCHAIN_PREFIX_}"
  194. else
  195. if [ "${LINUX}" -eq 1 ]; then
  196. qtbase_conf_args+=" -platform linux-g++"
  197. elif [ "${MACOS}" -eq 1 ]; then
  198. qtbase_conf_args+=" -platform macx-clang"
  199. elif [ "${WIN32}" -eq 1 ]; then
  200. qtbase_conf_args+=" -platform win32-g++"
  201. fi
  202. fi
  203. # platform specific
  204. if [ "${LINUX}" -eq 1 ]; then
  205. qtbase_conf_args+=" -qpa xcb"
  206. qtbase_conf_args+=" -qt-xcb"
  207. qtbase_conf_args+=" -xcb-xlib"
  208. elif [ "${MACOS}" -eq 1 ]; then
  209. qtbase_conf_args+=" -qpa cocoa"
  210. elif [ "${WIN32}" -eq 1 ]; then
  211. qtbase_conf_args+=" -qpa windows"
  212. fi
  213. # zlib
  214. if [ "${MACOS}" -eq 1 ]; then
  215. qtbase_conf_args+=" -system-zlib"
  216. else
  217. qtbase_conf_args+=" -qt-zlib"
  218. fi
  219. # ---------------------------------------------------------------------------------------------------------------------
  220. # qt build
  221. download_qt qtbase
  222. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  223. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/common/macx.conf" 's/QMAKE_APPLE_DEVICE_ARCHS = x86_64/QMAKE_APPLE_DEVICE_ARCHS = arm64 x86_64/'
  224. 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/'
  225. 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/'
  226. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/features/toolchain.prf" 's/-arch $$QMAKE_APPLE_DEVICE_ARCHS/-arch arm64/'
  227. elif [ "${MACOS}" -eq 1 ]; then
  228. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/macx-clang/qmake.conf" 's/10.10/10.8/'
  229. fi
  230. if [ "${WIN32}" -eq 1 ]; then
  231. if [ "${QT5_MVERSION}" = "5.12" ]; then
  232. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/common/g++-win32.conf" 's/= -shared/= -static -shared/'
  233. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/win32-g++/qmake.conf" 's/= -fno-keep-inline-dllexport/= -Wno-deprecated-declarations -fno-keep-inline-dllexport/'
  234. else
  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. fi
  239. build_qt_conf qtbase "${qtbase_conf_args}"
  240. if [ "${MACOS}" -eq 1 ] && [ ! -e "${PAWPAW_PREFIX}/include/qt5/QtWidgets" ]; then
  241. ln -sfv ${PAWPAW_PREFIX}/lib/QtCore.framework/Headers ${PAWPAW_PREFIX}/include/qt5/QtCore
  242. ln -sfv ${PAWPAW_PREFIX}/lib/QtGui.framework/Headers ${PAWPAW_PREFIX}/include/qt5/QtGui
  243. ln -sfv ${PAWPAW_PREFIX}/lib/QtWidgets.framework/Headers ${PAWPAW_PREFIX}/include/qt5/QtWidgets
  244. fi
  245. # ---------------------------------------------------------------------------------------------------------------------
  246. # qtmacextras
  247. if [ "${MACOS}" -eq 1 ]; then
  248. download_qt qtmacextras
  249. build_qmake qtmacextras${qtsuffix} ${QT5_VERSION}
  250. fi
  251. # ---------------------------------------------------------------------------------------------------------------------
  252. # qtsvg
  253. download_qt qtsvg
  254. build_qmake qtsvg${qtsuffix} ${QT5_VERSION}
  255. # ---------------------------------------------------------------------------------------------------------------------
  256. # qttools (host only, thus not needed if cross-compiling)
  257. if [ "${CROSS_COMPILING}" -eq 0 ]; then
  258. if [ "${QT5_MVERSION}" = "5.12" ]; then
  259. QTTOOLS_EXTRAFLAGS=". -- -no-feature-qdoc"
  260. fi
  261. download_qt qttools
  262. build_qmake qttools${qtsuffix} ${QT5_VERSION} "${QTTOOLS_EXTRAFLAGS}"
  263. fi
  264. # ---------------------------------------------------------------------------------------------------------------------