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.

372 lines
9.1KB

  1. #!/bin/bash
  2. # ---------------------------------------------------------------------------------------------------------------------
  3. function download() {
  4. local name="${1}"
  5. local version="${2}"
  6. local dlbaseurl="${3}"
  7. local dlext="${4}"
  8. local dlmethod="${5}"
  9. if [ -z "${dlext}" ]; then
  10. dlext="tar.gz"
  11. fi
  12. local dlfile="${PAWPAW_DOWNLOADDIR}/${name}-${version}.${dlext}"
  13. local dlfolder="${PAWPAW_BUILDDIR}/${name}-${version}"
  14. if [ ! -f "${dlfile}" ]; then
  15. if [ -n "${dlmethod}" ] && [ "${dlmethod}" = "git" ]; then
  16. local tmprepodir="${PAWPAW_TMPDIR}/${name}-${version}"
  17. rm -rf "${tmprepodir}"
  18. git clone --recursive "${dlbaseurl}" "${tmprepodir}"
  19. git -C "${tmprepodir}" checkout "${version}"
  20. git -C "${tmprepodir}" submodule update
  21. tar --exclude=".git" -czf "${dlfile}" -C "${PAWPAW_TMPDIR}" "${name}-${version}"
  22. rm -rf "${tmprepodir}"
  23. else
  24. local dlurl
  25. if echo ${dlbaseurl} | grep -q github.com; then
  26. dlurl="${dlbaseurl}/v${version}.${dlext}"
  27. else
  28. dlurl="${dlbaseurl}/${name}-${version}.${dlext}"
  29. fi
  30. curl -L "${dlurl}" -o "${dlfile}"
  31. fi
  32. fi
  33. if [ ! -d "${dlfolder}" ]; then
  34. mkdir "${dlfolder}"
  35. tar -xf "${dlfile}" -C "${dlfolder}" --strip-components=1
  36. fi
  37. }
  38. function copy_download() {
  39. local name1="${1}"
  40. local name2="${2}"
  41. local version="${3}"
  42. local dlext="${4}"
  43. if [ -z "${dlext}" ]; then
  44. dlext="tar.gz"
  45. fi
  46. local dlfile1="${PAWPAW_DOWNLOADDIR}/${name1}-${version}.${dlext}"
  47. local dlfolder2="${PAWPAW_BUILDDIR}/${name2}-${version}"
  48. if [ ! -d "${dlfolder2}" ]; then
  49. mkdir "${dlfolder2}"
  50. tar -xf "${dlfile1}" -C "${dlfolder2}" --strip-components=1
  51. fi
  52. }
  53. # ---------------------------------------------------------------------------------------------------------------------
  54. function _prebuild() {
  55. local pkgdir="${1}"
  56. export AR="${TARGET_AR}"
  57. export CC="${TARGET_CC}"
  58. export CXX="${TARGET_CXX}"
  59. export LD="${TARGET_LD}"
  60. export STRIP="${TARGET_STRIP}"
  61. export CFLAGS="${TARGET_CFLAGS}"
  62. export CXXFLAGS="${TARGET_CXXFLAGS}"
  63. export LDFLAGS="${TARGET_LDFLAGS}"
  64. export PKG_CONFIG_PATH="${TARGET_PKG_CONFIG_PATH}"
  65. unset CPPFLAGS
  66. export OLD_PATH="${PATH}"
  67. export PATH="${TARGET_PATH}"
  68. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  69. rm -f "${pkgdir}/.stamp_built"
  70. rm -f "${pkgdir}/.stamp_installed"
  71. elif [ ! -f "${pkgdir}/.stamp_built" ]; then
  72. rm -f "${pkgdir}/.stamp_installed"
  73. fi
  74. }
  75. function _postbuild() {
  76. unset AR
  77. unset CC
  78. unset CXX
  79. unset LD
  80. unset STRIP
  81. unset CFLAGS
  82. unset CPPFLAGS
  83. unset CXXFLAGS
  84. unset LDFLAGS
  85. unset PKG_CONFIG_PATH
  86. export PATH="${OLD_PATH}"
  87. }
  88. # ---------------------------------------------------------------------------------------------------------------------
  89. function build_autoconf() {
  90. local name="${1}"
  91. local version="${2}"
  92. local extraconfrules="${3}"
  93. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  94. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  95. extraconfrules="--host=${TOOLCHAIN_PREFIX} ${extraconfrules}"
  96. fi
  97. _prebuild "${pkgdir}"
  98. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  99. pushd "${pkgdir}"
  100. ./configure --enable-static --disable-shared --disable-maintainer-mode --prefix="${PAWPAW_PREFIX}" ${extraconfrules}
  101. touch .stamp_configured
  102. popd
  103. fi
  104. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  105. pushd "${pkgdir}"
  106. make ${MAKE_ARGS}
  107. touch .stamp_built
  108. popd
  109. fi
  110. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  111. pushd "${pkgdir}"
  112. make ${MAKE_ARGS} install
  113. touch .stamp_installed
  114. popd
  115. fi
  116. _postbuild
  117. }
  118. function build_conf() {
  119. local name="${1}"
  120. local version="${2}"
  121. local extraconfrules="${3}"
  122. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  123. _prebuild "${pkgdir}"
  124. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  125. pushd "${pkgdir}"
  126. ./configure ${extraconfrules}
  127. touch .stamp_configured
  128. popd
  129. fi
  130. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  131. pushd "${pkgdir}"
  132. make ${MAKE_ARGS}
  133. touch .stamp_built
  134. popd
  135. fi
  136. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  137. pushd "${pkgdir}"
  138. make ${MAKE_ARGS} install
  139. touch .stamp_installed
  140. popd
  141. fi
  142. _postbuild
  143. }
  144. function build_cmake() {
  145. local name="${1}"
  146. local version="${2}"
  147. local extraconfrules="${3}"
  148. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  149. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  150. extraconfrules="-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} ${extraconfrules}"
  151. fi
  152. _prebuild "${pkgdir}"
  153. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  154. pushd "${pkgdir}"
  155. # FIXME put this as a patch file
  156. sed -i -e 's/ -Wl,--no-undefined//' CMakeLists.txt
  157. cmake -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_PREFIX="${PAWPAW_PREFIX}" ${extraconfrules}
  158. touch .stamp_configured
  159. popd
  160. fi
  161. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  162. pushd "${pkgdir}"
  163. make ${MAKE_ARGS}
  164. touch .stamp_built
  165. popd
  166. fi
  167. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  168. pushd "${pkgdir}"
  169. make ${MAKE_ARGS} install
  170. touch .stamp_installed
  171. popd
  172. fi
  173. _postbuild
  174. }
  175. function build_make() {
  176. local name="${1}"
  177. local version="${2}"
  178. local extraconfrules="${3}"
  179. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  180. _prebuild "${pkgdir}"
  181. touch "${pkgdir}/.stamp_configured"
  182. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  183. pushd "${pkgdir}"
  184. make PREFIX="${PAWPAW_PREFIX}" ${MAKE_ARGS} ${extraconfrules}
  185. touch .stamp_built
  186. popd
  187. fi
  188. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  189. pushd "${pkgdir}"
  190. make PREFIX="${PAWPAW_PREFIX}" ${MAKE_ARGS} install
  191. touch .stamp_installed
  192. popd
  193. fi
  194. _postbuild
  195. }
  196. function build_meson() {
  197. local name="${1}"
  198. local version="${2}"
  199. local extraconfrules="${3}"
  200. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  201. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  202. extraconfrules="--cross-file ${PAWPAW_ROOT}/setup/meson/${PAWPAW_TARGET}.ini ${extraconfrules}"
  203. fi
  204. _prebuild "${pkgdir}"
  205. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  206. pushd "${pkgdir}"
  207. meson build --buildtype release --prefix "${PAWPAW_PREFIX}" ${extraconfrules}
  208. touch .stamp_configured
  209. popd
  210. fi
  211. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  212. pushd "${pkgdir}"
  213. ninja -v -C build
  214. touch .stamp_built
  215. popd
  216. fi
  217. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  218. pushd "${pkgdir}"
  219. ninja -C build install
  220. touch .stamp_installed
  221. popd
  222. fi
  223. _postbuild
  224. }
  225. function build_waf() {
  226. local name="${1}"
  227. local version="${2}"
  228. local extraconfrules="${3}"
  229. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  230. _prebuild "${pkgdir}"
  231. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  232. pushd "${pkgdir}"
  233. ./waf configure --prefix="${PAWPAW_PREFIX}" ${extraconfrules}
  234. touch .stamp_configured
  235. popd
  236. fi
  237. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  238. pushd "${pkgdir}"
  239. ./waf build
  240. touch .stamp_built
  241. popd
  242. fi
  243. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  244. pushd "${pkgdir}"
  245. ./waf install
  246. touch .stamp_installed
  247. popd
  248. fi
  249. _postbuild
  250. }
  251. # ---------------------------------------------------------------------------------------------------------------------
  252. function build_host_autoconf() {
  253. local name="${1}"
  254. local version="${2}"
  255. local extraconfrules="${3}"
  256. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  257. unset AR
  258. unset CC
  259. unset CXX
  260. unset LD
  261. unset STRIP
  262. unset CFLAGS
  263. unset CPPFLAGS
  264. unset CXXFLAGS
  265. unset LDFLAGS
  266. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  267. pushd "${pkgdir}"
  268. ./configure --enable-static --disable-shared --disable-maintainer-mode --prefix="${PAWPAW_PREFIX}" ${extraconfrules}
  269. touch .stamp_configured
  270. popd
  271. fi
  272. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  273. pushd "${pkgdir}"
  274. make ${MAKE_ARGS}
  275. touch .stamp_built
  276. popd
  277. fi
  278. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  279. pushd "${pkgdir}"
  280. make install
  281. touch .stamp_installed
  282. popd
  283. fi
  284. }
  285. # ---------------------------------------------------------------------------------------------------------------------
  286. function patch_file() {
  287. local name="${1}"
  288. local version="${2}"
  289. local file="${3}"
  290. local rule="${4}"
  291. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  292. sed -i -e "${rule}" "${pkgdir}/${file}"
  293. }
  294. # ---------------------------------------------------------------------------------------------------------------------