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.

281 lines
9.1KB

  1. #!/bin/bash
  2. set -e
  3. cd $(dirname ${0})
  4. PAWPAW_ROOT="${PWD}"
  5. # ---------------------------------------------------------------------------------------------------------------------
  6. target="${1}"
  7. if [ -z "${target}" ]; then
  8. echo "usage: ${0} <target>"
  9. exit 1
  10. fi
  11. # ---------------------------------------------------------------------------------------------------------------------
  12. source setup/check_target.sh
  13. source setup/env.sh
  14. source setup/functions.sh
  15. source setup/versions.sh
  16. mkdir -p "${PAWPAW_BUILDDIR}"
  17. mkdir -p "${PAWPAW_DOWNLOADDIR}"
  18. mkdir -p "${PAWPAW_PREFIX}"
  19. mkdir -p "${PAWPAW_TMPDIR}"
  20. # ---------------------------------------------------------------------------------------------------------------------
  21. # let's use native glib for linux builds
  22. if [ "${LINUX}" -eq 1 ] && [ ! -e "${TARGET_PKG_CONFIG_PATH}/glib-2.0.pc" ]; then
  23. mkdir -p ${TARGET_PKG_CONFIG_PATH}
  24. ln -s $(pkg-config --variable=pcfiledir glib-2.0)/g{io,lib,module,object,thread}-2.0.pc ${TARGET_PKG_CONFIG_PATH}/
  25. ln -s $(pkg-config --variable=pcfiledir libpcre)/libpcre.pc ${TARGET_PKG_CONFIG_PATH}/
  26. fi
  27. # ---------------------------------------------------------------------------------------------------------------------
  28. # pkgconfig
  29. download pkg-config "${PKG_CONFIG_VERSION}" "https://pkg-config.freedesktop.org/releases"
  30. build_host_autoconf pkg-config "${PKG_CONFIG_VERSION}" "--enable-indirect-deps --with-internal-glib --with-pc-path=${TARGET_PKG_CONFIG_PATH}"
  31. # ---------------------------------------------------------------------------------------------------------------------
  32. qtsuffix="-opensource-src"
  33. # ---------------------------------------------------------------------------------------------------------------------
  34. function download_qt() {
  35. local name="${1}"
  36. local dlfile="${PAWPAW_DOWNLOADDIR}/${name}${qtsuffix}-${QT5_VERSION}.tar.xz"
  37. local dlfolder="${PAWPAW_BUILDDIR}/${name}${qtsuffix}-${QT5_VERSION}"
  38. if [ ! -f "${dlfile}" ]; then
  39. dlurl="https://download.qt.io/archive/qt/${QT5_MVERSION}/${QT5_VERSION}/submodules/${name}${qtsuffix}-${QT5_VERSION}.tar.xz"
  40. curl -L "${dlurl}" -o "${dlfile}"
  41. fi
  42. if [ ! -d "${dlfolder}" ]; then
  43. mkdir "${dlfolder}"
  44. tar -xf "${dlfile}" -C "${dlfolder}" --strip-components=1
  45. fi
  46. # if [ ! -d "${dlfolder}" ]; then
  47. # unzip "${dlfile}" -d "${PAWPAW_BUILDDIR}"
  48. # chmod +x "${dlfolder}/configure"
  49. # dos2unix "${dlfolder}/configure"
  50. # fi
  51. }
  52. # ---------------------------------------------------------------------------------------------------------------------
  53. function build_qt_conf() {
  54. local name="${1}"
  55. local extraconfrules="${2}"
  56. local pkgdir="${PAWPAW_BUILDDIR}/${name}${qtsuffix}-${QT5_VERSION}"
  57. unset AR
  58. unset CC
  59. unset CXX
  60. unset LD
  61. unset STRIP
  62. unset CFLAGS
  63. unset CPPFLAGS
  64. unset CXXFLAGS
  65. unset LDFLAGS
  66. export PKG_CONFIG="${TARGET_PKG_CONFIG}"
  67. export PKG_CONFIG_LIBDIR="${TARGET_PKG_CONFIG_PATH}"
  68. export PKG_CONFIG_PATH="${TARGET_PKG_CONFIG_PATH}"
  69. export PKG_CONFIG_SYSROOT_DIR="${TARGET_PKG_CONFIG_PATH}"
  70. if [ -d "${PAWPAW_ROOT}/patches/${name}" ]; then
  71. for p in $(ls "${PAWPAW_ROOT}/patches/${name}/" | grep "\.patch" | sort); do
  72. if [ ! -f "${pkgdir}/.stamp_applied_${p}" ]; then
  73. patch -p1 -d "${pkgdir}" -i "${PAWPAW_ROOT}/patches/${name}/${p}"
  74. touch "${pkgdir}/.stamp_applied_${p}"
  75. fi
  76. done
  77. fi
  78. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  79. pushd "${pkgdir}"
  80. ./configure ${extraconfrules}
  81. touch .stamp_configured
  82. popd
  83. fi
  84. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  85. pushd "${pkgdir}"
  86. # NOTE: Qt win32 builds are very verbose, too many warnings, which makes CI build fail
  87. if [ "${WIN32}" -eq 1 ] && [ -n "${TRAVIS_BUILD_DIR}" ]; then
  88. make ${MAKE_ARGS} 2>/dev/null
  89. else
  90. make ${MAKE_ARGS}
  91. fi
  92. touch .stamp_built
  93. popd
  94. fi
  95. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  96. pushd "${pkgdir}"
  97. make ${MAKE_ARGS} -j 1 install
  98. touch .stamp_installed
  99. popd
  100. fi
  101. unset PKG_CONFIG
  102. unset PKG_CONFIG_LIBDIR
  103. unset PKG_CONFIG_PATH
  104. unset PKG_CONFIG_SYSROOT_DIR
  105. }
  106. # ---------------------------------------------------------------------------------------------------------------------
  107. # base
  108. qtbase_conf_args="-opensource -confirm-license"
  109. qtbase_conf_args+=" -c++std c++11"
  110. # qtbase_conf_args+=" -optimized-qmake"
  111. qtbase_conf_args+=" -optimize-size"
  112. qtbase_conf_args+=" -release -strip"
  113. # qtbase_conf_args+=" -static"
  114. qtbase_conf_args+=" -shared"
  115. qtbase_conf_args+=" -silent"
  116. # qtbase_conf_args+=" -verbose"
  117. # build type
  118. qtbase_conf_args+=" -make libs"
  119. qtbase_conf_args+=" -make tools"
  120. qtbase_conf_args+=" -gui"
  121. qtbase_conf_args+=" -widgets"
  122. # paths
  123. qtbase_conf_args+=" -prefix ${PAWPAW_PREFIX}"
  124. qtbase_conf_args+=" -headerdir ${PAWPAW_PREFIX}/include/qt5"
  125. qtbase_conf_args+=" -libexecdir ${PAWPAW_PREFIX}/libexec"
  126. qtbase_conf_args+=" -plugindir ${PAWPAW_PREFIX}/lib/qt5/plugins"
  127. # enable optimizations (sse2 only)
  128. qtbase_conf_args+=" -sse2"
  129. qtbase_conf_args+=" -no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2 -no-avx -no-avx2 -no-avx512"
  130. # enable some basic stuff
  131. qtbase_conf_args+=" -opengl desktop"
  132. qtbase_conf_args+=" -qt-doubleconversion"
  133. qtbase_conf_args+=" -qt-pcre"
  134. qtbase_conf_args+=" -qt-sqlite"
  135. # disable examples and tests
  136. qtbase_conf_args+=" -nomake examples"
  137. qtbase_conf_args+=" -nomake tests"
  138. qtbase_conf_args+=" -no-compile-examples"
  139. # disable a couple of things
  140. qtbase_conf_args+=" -no-cups"
  141. qtbase_conf_args+=" -no-dbus"
  142. qtbase_conf_args+=" -no-directfb"
  143. qtbase_conf_args+=" -no-eglfs"
  144. qtbase_conf_args+=" -no-evdev"
  145. qtbase_conf_args+=" -no-eventfd"
  146. qtbase_conf_args+=" -no-journald"
  147. qtbase_conf_args+=" -no-glib"
  148. qtbase_conf_args+=" -no-gtk"
  149. qtbase_conf_args+=" -no-icu"
  150. qtbase_conf_args+=" -no-inotify"
  151. qtbase_conf_args+=" -no-libinput"
  152. qtbase_conf_args+=" -no-libproxy"
  153. qtbase_conf_args+=" -no-mtdev"
  154. qtbase_conf_args+=" -no-openssl"
  155. qtbase_conf_args+=" -no-pch"
  156. qtbase_conf_args+=" -no-sctp"
  157. qtbase_conf_args+=" -no-securetransport"
  158. qtbase_conf_args+=" -no-syslog"
  159. qtbase_conf_args+=" -no-tslib"
  160. qtbase_conf_args+=" -no-xinput2"
  161. qtbase_conf_args+=" -no-xkbcommon-evdev"
  162. qtbase_conf_args+=" -no-xkbcommon-x11"
  163. # font stuff
  164. qtbase_conf_args+=" -qt-freetype"
  165. qtbase_conf_args+=" -no-fontconfig"
  166. qtbase_conf_args+=" -no-harfbuzz"
  167. # supported image formats
  168. qtbase_conf_args+=" -qt-libjpeg"
  169. qtbase_conf_args+=" -qt-libpng"
  170. qtbase_conf_args+=" -no-gif"
  171. qtbase_conf_args+=" -no-ico"
  172. # use pkg-config
  173. qtbase_conf_args+=" -pkg-config"
  174. qtbase_conf_args+=" -force-pkg-config"
  175. # platform specific
  176. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  177. if [ "${LINUX}" -eq 1 ]; then
  178. qtbase_conf_args+=" -xplatform linux-g++"
  179. elif [ "${MACOS}" -eq 1 ]; then
  180. qtbase_conf_args+=" -xplatform macx-clang"
  181. elif [ "${WIN32}" -eq 1 ]; then
  182. qtbase_conf_args+=" -xplatform win32-g++"
  183. fi
  184. qtbase_conf_args+=" -device-option CROSS_COMPILE=${TOOLCHAIN_PREFIX_}"
  185. else
  186. if [ "${LINUX}" -eq 1 ]; then
  187. qtbase_conf_args+=" -platform linux-g++"
  188. elif [ "${MACOS}" -eq 1 ]; then
  189. qtbase_conf_args+=" -platform macx-clang"
  190. elif [ "${WIN32}" -eq 1 ]; then
  191. qtbase_conf_args+=" -platform win32-g++"
  192. fi
  193. fi
  194. # platform specific
  195. if [ "${LINUX}" -eq 1 ]; then
  196. qtbase_conf_args+=" -qpa xcb"
  197. qtbase_conf_args+=" -qt-xcb"
  198. qtbase_conf_args+=" -xcb-xlib"
  199. elif [ "${MACOS}" -eq 1 ]; then
  200. qtbase_conf_args+=" -qpa cocoa"
  201. elif [ "${WIN32}" -eq 1 ]; then
  202. qtbase_conf_args+=" -qpa windows"
  203. fi
  204. # zlib
  205. if [ "${MACOS}" -eq 1 ]; then
  206. qtbase_conf_args+=" -system-zlib"
  207. else
  208. qtbase_conf_args+=" -qt-zlib"
  209. fi
  210. download_qt qtbase
  211. # patch_file qtbase${qtsuffix} ${QT5_VERSION} "configure" 's/ --sdk $sdk / /'
  212. # patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/features/mac/sdk.prf" 's/ --sdk $$sdk / /'
  213. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/macx-clang/qmake.conf" 's/10.10/10.8/'
  214. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/win32-g++/qmake.conf" 's/= -shared/= -static -shared/'
  215. patch_file qtbase${qtsuffix} ${QT5_VERSION} "src/plugins/platforms/direct2d/direct2d.pro" 's/-lVersion/-lversion/'
  216. build_qt_conf qtbase "${qtbase_conf_args}"
  217. if [ "${MACOS}" -eq 1 ] && [ ! -e "ln -s ${PAWPAW_PREFIX}/include/qt5/QtCore" ]; then
  218. ln -sfv ${PAWPAW_PREFIX}/lib/QtCore.framework/Headers ${PAWPAW_PREFIX}/include/qt5/QtCore
  219. ln -sfv ${PAWPAW_PREFIX}/lib/QtGui.framework/Headers ${PAWPAW_PREFIX}/include/qt5/QtGui
  220. ln -sfv ${PAWPAW_PREFIX}/lib/QtWidgets.framework/Headers ${PAWPAW_PREFIX}/include/qt5/QtWidgets
  221. fi
  222. # ---------------------------------------------------------------------------------------------------------------------
  223. download_qt qtsvg
  224. build_qmake qtsvg${qtsuffix} ${QT5_VERSION}
  225. # ---------------------------------------------------------------------------------------------------------------------
  226. if [ "${CROSS_COMPILING}" -eq 0 ]; then
  227. download_qt qttools
  228. build_qmake qttools${qtsuffix} ${QT5_VERSION}
  229. fi
  230. # ---------------------------------------------------------------------------------------------------------------------