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.

384 lines
9.6KB

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