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.

374 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="${TARGET_PKG_CONFIG}"
  65. export PKG_CONFIG_PATH="${TARGET_PKG_CONFIG_PATH}"
  66. unset CPPFLAGS
  67. export OLD_PATH="${PATH}"
  68. export PATH="${TARGET_PATH}"
  69. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  70. rm -f "${pkgdir}/.stamp_built"
  71. rm -f "${pkgdir}/.stamp_installed"
  72. elif [ ! -f "${pkgdir}/.stamp_built" ]; then
  73. rm -f "${pkgdir}/.stamp_installed"
  74. fi
  75. }
  76. function _postbuild() {
  77. unset AR
  78. unset CC
  79. unset CXX
  80. unset LD
  81. unset STRIP
  82. unset CFLAGS
  83. unset CPPFLAGS
  84. unset CXXFLAGS
  85. unset LDFLAGS
  86. unset PKG_CONFIG
  87. unset PKG_CONFIG_PATH
  88. export PATH="${OLD_PATH}"
  89. }
  90. # ---------------------------------------------------------------------------------------------------------------------
  91. function build_autoconf() {
  92. local name="${1}"
  93. local version="${2}"
  94. local extraconfrules="${3}"
  95. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  96. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  97. extraconfrules="--host=${TOOLCHAIN_PREFIX} ${extraconfrules}"
  98. fi
  99. _prebuild "${pkgdir}"
  100. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  101. pushd "${pkgdir}"
  102. ./configure --enable-static --disable-shared --disable-maintainer-mode --prefix="${PAWPAW_PREFIX}" ${extraconfrules}
  103. touch .stamp_configured
  104. popd
  105. fi
  106. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  107. pushd "${pkgdir}"
  108. make ${MAKE_ARGS}
  109. touch .stamp_built
  110. popd
  111. fi
  112. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  113. pushd "${pkgdir}"
  114. make ${MAKE_ARGS} install
  115. touch .stamp_installed
  116. popd
  117. fi
  118. _postbuild
  119. }
  120. function build_conf() {
  121. local name="${1}"
  122. local version="${2}"
  123. local extraconfrules="${3}"
  124. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  125. _prebuild "${pkgdir}"
  126. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  127. pushd "${pkgdir}"
  128. ./configure ${extraconfrules}
  129. touch .stamp_configured
  130. popd
  131. fi
  132. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  133. pushd "${pkgdir}"
  134. make ${MAKE_ARGS}
  135. touch .stamp_built
  136. popd
  137. fi
  138. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  139. pushd "${pkgdir}"
  140. make ${MAKE_ARGS} install
  141. touch .stamp_installed
  142. popd
  143. fi
  144. _postbuild
  145. }
  146. function build_cmake() {
  147. local name="${1}"
  148. local version="${2}"
  149. local extraconfrules="${3}"
  150. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  151. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  152. extraconfrules="-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} ${extraconfrules}"
  153. fi
  154. _prebuild "${pkgdir}"
  155. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  156. pushd "${pkgdir}"
  157. # FIXME put this as a patch file
  158. sed -i -e 's/ -Wl,--no-undefined//' CMakeLists.txt
  159. cmake -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_PREFIX="${PAWPAW_PREFIX}" ${extraconfrules}
  160. touch .stamp_configured
  161. popd
  162. fi
  163. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  164. pushd "${pkgdir}"
  165. make ${MAKE_ARGS}
  166. touch .stamp_built
  167. popd
  168. fi
  169. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  170. pushd "${pkgdir}"
  171. make ${MAKE_ARGS} install
  172. touch .stamp_installed
  173. popd
  174. fi
  175. _postbuild
  176. }
  177. function build_make() {
  178. local name="${1}"
  179. local version="${2}"
  180. local extraconfrules="${3}"
  181. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  182. _prebuild "${pkgdir}"
  183. touch "${pkgdir}/.stamp_configured"
  184. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  185. pushd "${pkgdir}"
  186. make PREFIX="${PAWPAW_PREFIX}" ${MAKE_ARGS} ${extraconfrules}
  187. touch .stamp_built
  188. popd
  189. fi
  190. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  191. pushd "${pkgdir}"
  192. make PREFIX="${PAWPAW_PREFIX}" ${MAKE_ARGS} install
  193. touch .stamp_installed
  194. popd
  195. fi
  196. _postbuild
  197. }
  198. function build_meson() {
  199. local name="${1}"
  200. local version="${2}"
  201. local extraconfrules="${3}"
  202. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  203. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  204. extraconfrules="--cross-file ${PAWPAW_ROOT}/setup/meson/${PAWPAW_TARGET}.ini ${extraconfrules}"
  205. fi
  206. _prebuild "${pkgdir}"
  207. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  208. pushd "${pkgdir}"
  209. meson build --buildtype release --prefix "${PAWPAW_PREFIX}" ${extraconfrules}
  210. touch .stamp_configured
  211. popd
  212. fi
  213. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  214. pushd "${pkgdir}"
  215. ninja -v -C build
  216. touch .stamp_built
  217. popd
  218. fi
  219. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  220. pushd "${pkgdir}"
  221. ninja -C build install
  222. touch .stamp_installed
  223. popd
  224. fi
  225. _postbuild
  226. }
  227. function build_waf() {
  228. local name="${1}"
  229. local version="${2}"
  230. local extraconfrules="${3}"
  231. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  232. _prebuild "${pkgdir}"
  233. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  234. pushd "${pkgdir}"
  235. ./waf configure --prefix="${PAWPAW_PREFIX}" ${extraconfrules}
  236. touch .stamp_configured
  237. popd
  238. fi
  239. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  240. pushd "${pkgdir}"
  241. ./waf build
  242. touch .stamp_built
  243. popd
  244. fi
  245. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  246. pushd "${pkgdir}"
  247. ./waf install
  248. touch .stamp_installed
  249. popd
  250. fi
  251. _postbuild
  252. }
  253. # ---------------------------------------------------------------------------------------------------------------------
  254. function build_host_autoconf() {
  255. local name="${1}"
  256. local version="${2}"
  257. local extraconfrules="${3}"
  258. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  259. unset AR
  260. unset CC
  261. unset CXX
  262. unset LD
  263. unset STRIP
  264. unset CFLAGS
  265. unset CPPFLAGS
  266. unset CXXFLAGS
  267. unset LDFLAGS
  268. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  269. pushd "${pkgdir}"
  270. ./configure --enable-static --disable-shared --disable-maintainer-mode --prefix="${PAWPAW_PREFIX}" ${extraconfrules}
  271. touch .stamp_configured
  272. popd
  273. fi
  274. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  275. pushd "${pkgdir}"
  276. make ${MAKE_ARGS}
  277. touch .stamp_built
  278. popd
  279. fi
  280. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  281. pushd "${pkgdir}"
  282. make install
  283. touch .stamp_installed
  284. popd
  285. fi
  286. }
  287. # ---------------------------------------------------------------------------------------------------------------------
  288. function patch_file() {
  289. local name="${1}"
  290. local version="${2}"
  291. local file="${3}"
  292. local rule="${4}"
  293. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  294. sed -i -e "${rule}" "${pkgdir}/${file}"
  295. }
  296. # ---------------------------------------------------------------------------------------------------------------------