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.

756 lines
22KB

  1. #!/bin/bash
  2. # NOTE `setup/check_target.sh` and `setup/env.sh` must be imported before this one, in that order
  3. # ---------------------------------------------------------------------------------------------------------------------
  4. function download() {
  5. local name="${1}"
  6. local version="${2}"
  7. local dlbaseurl="${3}"
  8. local dlext="${4}"
  9. local dlmethod="${5}"
  10. local dlname="${6}"
  11. if [ -z "${dlext}" ]; then
  12. dlext="tar.gz"
  13. fi
  14. if [ -z "${dlname}" ]; then
  15. dlname="${name}"
  16. fi
  17. local dlfile="${PAWPAW_DOWNLOADDIR}/${dlname}-${version}.${dlext}"
  18. local dlfolder="${PAWPAW_BUILDDIR}/${name}-${version}"
  19. if [ ! -f "${dlfile}" ]; then
  20. if [ -n "${dlmethod}" ] && [ "${dlmethod}" = "git" ]; then
  21. local tmprepodir="${PAWPAW_TMPDIR}/${dlname}-${version}"
  22. rm -rf "${tmprepodir}"
  23. git clone --recursive "${dlbaseurl}" "${tmprepodir}"
  24. git -C "${tmprepodir}" checkout "${version}"
  25. git -C "${tmprepodir}" submodule update --recursive --init
  26. tar --exclude=".git" -czf "${dlfile}" -C "${PAWPAW_TMPDIR}" "${dlname}-${version}"
  27. rm -rf "${tmprepodir}"
  28. else
  29. local dlurl1
  30. local dlurl2
  31. if echo ${dlbaseurl} | grep -q github.com | grep -q -v releases; then
  32. if [ x"${dlmethod}" = x"nv" ]; then
  33. dlurl1="${dlbaseurl}/${version}.${dlext}"
  34. dlurl2="${KXSTUDIO_FILES_URL}/${version}.${dlext}"
  35. else
  36. dlurl1="${dlbaseurl}/v${version}.${dlext}"
  37. dlurl2="${KXSTUDIO_FILES_URL}/v${version}.${dlext}"
  38. fi
  39. elif [ "${dlext}" = "orig.tar.gz" ]; then
  40. dlurl1="${dlbaseurl}/${dlname}_${version}.${dlext}"
  41. dlurl2="${KXSTUDIO_FILES_URL}/${dlname}_${version}.${dlext}"
  42. else
  43. dlurl1="${dlbaseurl}/${dlname}-${version}.${dlext}"
  44. dlurl2="${KXSTUDIO_FILES_URL}/${dlname}-${version}.${dlext}"
  45. fi
  46. curl -L "${dlurl1}" -o "${dlfile}" --fail || curl -L "${dlurl2}" -o "${dlfile}" --fail
  47. fi
  48. fi
  49. if [ ! -d "${dlfolder}" ]; then
  50. mkdir "${dlfolder}"
  51. tar -xf "${dlfile}" -C "${dlfolder}" --strip-components=1
  52. fi
  53. }
  54. function copy_download() {
  55. local name1="${1}"
  56. local name2="${2}"
  57. local version="${3}"
  58. local dlext="${4}"
  59. if [ -z "${dlext}" ]; then
  60. dlext="tar.gz"
  61. fi
  62. local dlfile1="${PAWPAW_DOWNLOADDIR}/${name1}-${version}.${dlext}"
  63. local dlfolder2="${PAWPAW_BUILDDIR}/${name2}-${version}"
  64. if [ ! -d "${dlfolder2}" ]; then
  65. mkdir "${dlfolder2}"
  66. tar -xf "${dlfile1}" -C "${dlfolder2}" --strip-components=1
  67. fi
  68. }
  69. function git_clone() {
  70. local name="${1}"
  71. local hash="${2}"
  72. local repourl="${3}"
  73. local dlname="${4}"
  74. if [ -z "${dlname}" ]; then
  75. dlname="${name}"
  76. fi
  77. local dlfile="${PAWPAW_DOWNLOADDIR}/${dlname}-${hash}.tar.gz"
  78. local dlfolder="${PAWPAW_BUILDDIR}/${name}-${hash}"
  79. if [ ! -f "${dlfile}" ]; then
  80. local tmprepodir="${PAWPAW_TMPDIR}/${dlname}-${hash}"
  81. rm -rf "${tmprepodir}"
  82. git clone --recursive "${repourl}" "${tmprepodir}"
  83. git -C "${tmprepodir}" checkout "${hash}"
  84. git -C "${tmprepodir}" submodule update --recursive --init
  85. tar --exclude=".git" -czf "${dlfile}" -C "${PAWPAW_TMPDIR}" "${dlname}-${hash}"
  86. rm -rf "${tmprepodir}"
  87. fi
  88. if [ ! -d "${dlfolder}" ]; then
  89. mkdir "${dlfolder}"
  90. tar -xf "${dlfile}" -C "${dlfolder}" --strip-components=1
  91. fi
  92. }
  93. # ---------------------------------------------------------------------------------------------------------------------
  94. function _prebuild() {
  95. local name="${1}"
  96. local pkgdir="${2}"
  97. export AR="${TARGET_AR}"
  98. export CC="${TARGET_CC}"
  99. export CXX="${TARGET_CXX}"
  100. export DLLWRAP="${TARGET_DLLWRAP}"
  101. export LD="${TARGET_LD}"
  102. export NM="${TARGET_NM}"
  103. export RANLIB="${TARGET_RANLIB}"
  104. export STRIP="${TARGET_STRIP}"
  105. export WINDRES="${TARGET_WINDRES}"
  106. export CFLAGS="${TARGET_CFLAGS} ${EXTRA_CFLAGS}"
  107. export CXXFLAGS="${TARGET_CXXFLAGS} ${EXTRA_CXXFLAGS}"
  108. export LDFLAGS="${TARGET_LDFLAGS} ${EXTRA_LDFLAGS}"
  109. export PKG_CONFIG_PATH="${TARGET_PKG_CONFIG_PATH}"
  110. if [ -n "${EXTRA_CPPFLAGS}" ]; then
  111. export CPPFLAGS="${EXTRA_CPPFLAGS}"
  112. else
  113. unset CPPFLAGS
  114. fi
  115. export OLD_PATH="${PATH}"
  116. export PATH="${TARGET_PATH}"
  117. if [ -d "${PAWPAW_ROOT}/patches/${name}" ] && [ ! -f "${pkgdir}/.stamp_cleanup" ]; then
  118. for p in $(ls "${PAWPAW_ROOT}/patches/${name}/" | grep "\.patch$" | sort); do
  119. if [ ! -f "${pkgdir}/.stamp_applied_${p}" ]; then
  120. patch -p1 -d "${pkgdir}" -i "${PAWPAW_ROOT}/patches/${name}/${p}"
  121. touch "${pkgdir}/.stamp_applied_${p}"
  122. fi
  123. done
  124. fi
  125. if [ -d "${PAWPAW_ROOT}/patches/${name}/${PAWPAW_TARGET}" ] && [ ! -f "${pkgdir}/.stamp_cleanup" ]; then
  126. for p in $(ls "${PAWPAW_ROOT}/patches/${name}/${PAWPAW_TARGET}/" | grep "\.patch$" | sort); do
  127. if [ ! -f "${pkgdir}/.stamp_applied_${p}" ]; then
  128. patch -p1 -d "${pkgdir}" -i "${PAWPAW_ROOT}/patches/${name}/${PAWPAW_TARGET}/${p}"
  129. touch "${pkgdir}/.stamp_applied_${p}"
  130. fi
  131. done
  132. fi
  133. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  134. rm -f "${pkgdir}/.stamp_built"
  135. rm -f "${pkgdir}/.stamp_installed"
  136. rm -f "${pkgdir}/.stamp_verified"
  137. rm -f "${pkgdir}/CMakeCache.txt"
  138. elif [ ! -f "${pkgdir}/.stamp_built" ]; then
  139. rm -f "${pkgdir}/.stamp_installed"
  140. rm -f "${pkgdir}/.stamp_verified"
  141. elif [ ! -f "${pkgdir}/.stamp_installed" ]; then
  142. rm -f "${pkgdir}/.stamp_verified"
  143. fi
  144. }
  145. function _postbuild() {
  146. unset AR
  147. unset CC
  148. unset CXX
  149. unset DLLWRAP
  150. unset LD
  151. unset NM
  152. unset RANLIB
  153. unset STRIP
  154. unset WINDRES
  155. unset CFLAGS
  156. unset CPPFLAGS
  157. unset CXXFLAGS
  158. unset LDFLAGS
  159. unset PKG_CONFIG_PATH
  160. unset EXTRA_CFLAGS
  161. unset EXTRA_CPPFLAGS
  162. unset EXTRA_CXXFLAGS
  163. unset EXTRA_LDFLAGS
  164. unset EXTRA_MAKE_ARGS
  165. export PATH="${OLD_PATH}"
  166. }
  167. # ---------------------------------------------------------------------------------------------------------------------
  168. function build_autoconf() {
  169. local name="${1}"
  170. local version="${2}"
  171. local extraconfrules="${3}"
  172. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  173. if [ "${WASM}" -eq 1 ]; then
  174. extraconfrules="--host=x86_64-linux-gnu ${extraconfrules}"
  175. elif [ -n "${TOOLCHAIN_PREFIX}" ]; then
  176. extraconfrules="--host=${TOOLCHAIN_PREFIX} ac_cv_host=${TOOLCHAIN_PREFIX} ${extraconfrules}"
  177. fi
  178. _prebuild "${name}" "${pkgdir}"
  179. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  180. pushd "${pkgdir}"
  181. ./configure --enable-static --disable-shared --disable-debug --disable-doc --disable-docs --disable-maintainer-mode --prefix="${PAWPAW_PREFIX}" ${extraconfrules}
  182. touch .stamp_configured
  183. popd
  184. fi
  185. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  186. pushd "${pkgdir}"
  187. make ${MAKE_ARGS} ${EXTRA_MAKE_ARGS}
  188. touch .stamp_built
  189. popd
  190. fi
  191. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  192. pushd "${pkgdir}"
  193. make ${MAKE_ARGS} install -j 1
  194. touch .stamp_installed
  195. popd
  196. fi
  197. _postbuild
  198. }
  199. function build_autoconfgen() {
  200. local name="${1}"
  201. local version="${2}"
  202. local extraconfrules="${3}"
  203. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  204. local EXTRA_CFLAGS2="${EXTRA_CFLAGS}"
  205. local EXTRA_CXXFLAGS2="${EXTRA_CXXFLAGS}"
  206. local EXTRA_LDFLAGS2="${EXTRA_LDFLAGS}"
  207. local EXTRA_MAKE_ARGS2="${EXTRA_MAKE_ARGS}"
  208. _prebuild "${name}" "${pkgdir}"
  209. if [ ! -f "${pkgdir}/.stamp_preconfigured" ]; then
  210. pushd "${pkgdir}"
  211. if [ -f utils/autogen.sh ]; then
  212. ./utils/autogen.sh
  213. else
  214. ${autoconf}
  215. fi
  216. touch .stamp_preconfigured
  217. popd
  218. fi
  219. _postbuild
  220. export EXTRA_CFLAGS="${EXTRA_CFLAGS2}"
  221. export EXTRA_CXXFLAGS="${EXTRA_CXXFLAGS2}"
  222. export EXTRA_LDFLAGS="${EXTRA_LDFLAGS2}"
  223. export EXTRA_MAKE_ARGS="${EXTRA_MAKE_ARGS2}"
  224. build_autoconf "${name}" "${version}" "${extraconfrules}"
  225. }
  226. function build_conf() {
  227. local name="${1}"
  228. local version="${2}"
  229. local extraconfrules="${3}"
  230. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  231. _prebuild "${name}" "${pkgdir}"
  232. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  233. pushd "${pkgdir}"
  234. ./configure ${extraconfrules}
  235. touch .stamp_configured
  236. popd
  237. fi
  238. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  239. pushd "${pkgdir}"
  240. make ${MAKE_ARGS} ${EXTRA_MAKE_ARGS}
  241. touch .stamp_built
  242. popd
  243. fi
  244. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  245. pushd "${pkgdir}"
  246. make ${MAKE_ARGS} -j 1 install
  247. touch .stamp_installed
  248. popd
  249. fi
  250. _postbuild
  251. }
  252. function build_cmake() {
  253. local name="${1}"
  254. local version="${2}"
  255. local extraconfrules="${3}"
  256. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  257. _prebuild "${name}" "${pkgdir}"
  258. mkdir -p "${pkgdir}/build"
  259. if [ "${WASM}" -eq 1 ]; then
  260. CMAKE_EXE_WRAPPER="emcmake"
  261. elif [ "${CROSS_COMPILING}" -eq 1 ]; then
  262. local CMAKE_AR=$(which ${TARGET_AR})
  263. local CMAKE_RANLIB=$(which ${TARGET_RANLIB})
  264. extraconfrules+=" -DCMAKE_CROSSCOMPILING=ON"
  265. extraconfrules+=" -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}"
  266. extraconfrules+=" -DCMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}"
  267. extraconfrules+=" -DCMAKE_AR=${CMAKE_AR}"
  268. extraconfrules+=" -DCMAKE_C_COMPILER_AR=${CMAKE_AR}"
  269. extraconfrules+=" -DCMAKE_CXX_COMPILER_AR=${CMAKE_AR}"
  270. extraconfrules+=" -DCMAKE_RANLIB=${CMAKE_RANLIB}"
  271. extraconfrules+=" -DCMAKE_C_COMPILER_RANLIB=${CMAKE_RANLIB}"
  272. extraconfrules+=" -DCMAKE_CXX_COMPILER_RANLIB=${CMAKE_RANLIB}"
  273. if [ -n "${EXE_WRAPPER}" ]; then
  274. extraconfrules+=" -DCMAKE_CROSSCOMPILING_EMULATOR=${EXE_WRAPPER}"
  275. fi
  276. fi
  277. if [ "${MACOS}" -eq 1 ]; then
  278. if [ "${MACOS_UNIVERSAL_10_15}" -eq 1 ]; then
  279. OSX_ARCHS="arm64;x86_64"
  280. OSX_TARGET="10.15"
  281. elif [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  282. OSX_ARCHS="arm64;x86_64"
  283. OSX_TARGET="10.12"
  284. else
  285. OSX_ARCHS="x86_64"
  286. OSX_TARGET="10.8"
  287. fi
  288. extraconfrules+=" -DCMAKE_OSX_ARCHITECTURES=${OSX_ARCHS}"
  289. extraconfrules+=" -DCMAKE_OSX_DEPLOYMENT_TARGET=${OSX_TARGET}"
  290. extraconfrules+=" -DCMAKE_OSX_SYSROOT=macosx"
  291. elif [ "${WIN32}" -eq 1 ]; then
  292. extraconfrules+=" -DCMAKE_RC_COMPILER=${WINDRES}"
  293. fi
  294. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  295. pushd "${pkgdir}/build"
  296. ${CMAKE_EXE_WRAPPER} ${cmake} -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_PREFIX="${PAWPAW_PREFIX}" ${extraconfrules} ..
  297. touch ../.stamp_configured
  298. popd
  299. fi
  300. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  301. pushd "${pkgdir}/build"
  302. make ${MAKE_ARGS} ${EXTRA_MAKE_ARGS}
  303. touch ../.stamp_built
  304. popd
  305. fi
  306. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  307. pushd "${pkgdir}/build"
  308. make ${MAKE_ARGS} -j 1 install
  309. touch ../.stamp_installed
  310. popd
  311. fi
  312. _postbuild
  313. }
  314. function build_make() {
  315. local name="${1}"
  316. local version="${2}"
  317. local extraconfrules="${3}"
  318. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  319. _prebuild "${name}" "${pkgdir}"
  320. touch "${pkgdir}/.stamp_configured"
  321. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  322. pushd "${pkgdir}"
  323. make PREFIX="${PAWPAW_PREFIX}" PKG_CONFIG="${TARGET_PKG_CONFIG}" ${MAKE_ARGS} ${extraconfrules}
  324. touch .stamp_built
  325. popd
  326. fi
  327. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  328. pushd "${pkgdir}"
  329. make PREFIX="${PAWPAW_PREFIX}" PKG_CONFIG="${TARGET_PKG_CONFIG}" ${MAKE_ARGS} ${extraconfrules} -j 1 install
  330. touch .stamp_installed
  331. popd
  332. fi
  333. _postbuild
  334. }
  335. function build_meson() {
  336. local name="${1}"
  337. local version="${2}"
  338. local extraconfrules="${3}"
  339. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  340. if [ "${CROSS_COMPILING}" -eq 1 ] && [ "${LINUX}" -eq 0 ]; then
  341. extraconfrules="--cross-file "${PAWPAW_ROOT}/setup/meson/${PAWPAW_TARGET}.ini" ${extraconfrules}"
  342. fi
  343. _prebuild "${name}" "${pkgdir}"
  344. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  345. pushd "${pkgdir}"
  346. env NINJA="${ninja}" ${meson} build --buildtype release --prefix "${PAWPAW_PREFIX}" --libdir lib ${extraconfrules}
  347. touch .stamp_configured
  348. popd
  349. fi
  350. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  351. pushd "${pkgdir}"
  352. ${ninja} -v -C build
  353. touch .stamp_built
  354. popd
  355. fi
  356. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  357. pushd "${pkgdir}"
  358. ${ninja} -C build install
  359. touch .stamp_installed
  360. popd
  361. fi
  362. _postbuild
  363. }
  364. function build_python() {
  365. local name="${1}"
  366. local version="${2}"
  367. local extraconfrules="${3}"
  368. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  369. local python="python$(echo ${PYTHON_VERSION} | cut -b 1,2,3)"
  370. _prebuild "${name}" "${pkgdir}"
  371. # remove flags not compatible with python
  372. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fvisibility=hidden//')"
  373. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-ffast-math//')"
  374. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  375. export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fno-strict-aliasing -flto//')"
  376. export CXXFLAGS="$(echo ${CXXFLAGS} | sed -e 's/-fvisibility=hidden//')"
  377. export CXXFLAGS="$(echo ${CXXFLAGS} | sed -e 's/-fvisibility-inlines-hidden//')"
  378. export CXXFLAGS="$(echo ${CXXFLAGS} | sed -e 's/-ffast-math//')"
  379. export CXXFLAGS="$(echo ${CXXFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  380. export CXXFLAGS="$(echo ${CXXFLAGS} | sed -e 's/-fno-strict-aliasing -flto//')"
  381. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,-dead_strip,-dead_strip_dylibs,-x//')"
  382. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,-O1,--gc-sections,--no-undefined//')"
  383. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,--as-needed,--strip-all//')"
  384. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
  385. export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-fno-strict-aliasing -flto//')"
  386. # add host/native binaries to path
  387. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  388. export PATH="${PAWPAW_PREFIX}-host/bin:${PATH}"
  389. fi
  390. touch "${pkgdir}/.stamp_configured"
  391. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  392. pushd "${pkgdir}"
  393. ${python} setup.py build ${extraconfrules} --verbose
  394. touch .stamp_built
  395. popd
  396. fi
  397. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  398. pushd "${pkgdir}"
  399. # always try twice, python checks for installed deps and fails the first time
  400. ${python} setup.py install --prefix="${PAWPAW_PREFIX}" ${extraconfrules} --verbose || \
  401. ${python} setup.py install --prefix="${PAWPAW_PREFIX}" ${extraconfrules} --verbose
  402. touch .stamp_installed
  403. popd
  404. fi
  405. _postbuild
  406. }
  407. function build_qmake() {
  408. local name="${1}"
  409. local version="${2}"
  410. local extraconfrules="${3}"
  411. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  412. _prebuild "${name}" "${pkgdir}"
  413. # if [ "${CROSS_COMPILING}" -eq 1 ]; then
  414. # export PKG_CONFIG_LIBDIR="${TARGET_PKG_CONFIG_PATH}"
  415. # export PKG_CONFIG_SYSROOT_DIR="/"
  416. # fi
  417. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  418. pushd "${pkgdir}"
  419. qmake ${extraconfrules}
  420. touch .stamp_configured
  421. popd
  422. fi
  423. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  424. pushd "${pkgdir}"
  425. make ${MAKE_ARGS} ${EXTRA_MAKE_ARGS}
  426. touch .stamp_built
  427. popd
  428. fi
  429. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  430. pushd "${pkgdir}"
  431. make ${MAKE_ARGS} -j 1 install
  432. touch .stamp_installed
  433. popd
  434. fi
  435. # unset PKG_CONFIG_LIBDIR
  436. # unset PKG_CONFIG_SYSROOT_DIR
  437. _postbuild
  438. }
  439. function build_waf() {
  440. local name="${1}"
  441. local version="${2}"
  442. local extraconfrules="${3}"
  443. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  444. local python=python3
  445. if ! which python3 > /dev/null; then
  446. python=python
  447. fi
  448. _prebuild "${name}" "${pkgdir}"
  449. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  450. pushd "${pkgdir}"
  451. ${python} waf configure --prefix="${PAWPAW_PREFIX}" ${extraconfrules}
  452. touch .stamp_configured
  453. popd
  454. fi
  455. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  456. pushd "${pkgdir}"
  457. ${python} waf build ${WAF_ARGS}
  458. touch .stamp_built
  459. popd
  460. fi
  461. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  462. pushd "${pkgdir}"
  463. ${python} waf install ${WAF_ARGS} --prefix="${PAWPAW_PREFIX}" ${extraconfrules} -j 1
  464. rm -f ${PAWPAW_PREFIX}/lib/lv2/*/*.a
  465. touch .stamp_installed
  466. popd
  467. fi
  468. _postbuild
  469. }
  470. # ---------------------------------------------------------------------------------------------------------------------
  471. function run_make() {
  472. local name="${1}"
  473. local version="${2}"
  474. local makerule="${3}"
  475. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  476. _prebuild "${name}" "${pkgdir}"
  477. if [ ! -f "${pkgdir}/.stamp_custom_run" ]; then
  478. pushd "${pkgdir}"
  479. make ${MAKE_ARGS} ${makerule}
  480. touch .stamp_custom_run
  481. popd
  482. fi
  483. _postbuild
  484. }
  485. # ---------------------------------------------------------------------------------------------------------------------
  486. function build_host_autoconf() {
  487. local name="${1}"
  488. local version="${2}"
  489. local extraconfrules="${3}"
  490. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  491. unset AR
  492. unset CC
  493. unset CXX
  494. unset LD
  495. unset STRIP
  496. unset CFLAGS
  497. unset CPPFLAGS
  498. unset CXXFLAGS
  499. unset LDFLAGS
  500. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  501. pushd "${pkgdir}"
  502. ./configure --enable-static --disable-shared --disable-maintainer-mode --prefix="${PAWPAW_PREFIX}" ${extraconfrules}
  503. touch .stamp_configured
  504. popd
  505. fi
  506. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  507. pushd "${pkgdir}"
  508. make ${MAKE_ARGS}
  509. touch .stamp_built
  510. popd
  511. fi
  512. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  513. pushd "${pkgdir}"
  514. make ${MAKE_ARGS} install -j 1
  515. touch .stamp_installed
  516. popd
  517. fi
  518. }
  519. # ---------------------------------------------------------------------------------------------------------------------
  520. function patch_file() {
  521. local name="${1}"
  522. local version="${2}"
  523. local file="${3}"
  524. local rule="${4}"
  525. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  526. if [ -e "${pkgdir}/${file}" ]; then
  527. sed -i -e "${rule}" "${pkgdir}/${file}"
  528. fi
  529. }
  530. function copy_file() {
  531. local name="${1}"
  532. local version="${2}"
  533. local source="${3}"
  534. local target="${4}"
  535. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  536. if [ ! -e "${pkgdir}/${target}" ] || [ "${source}" -nt "${target}" ]; then
  537. pushd "${pkgdir}"
  538. cp -v "${source}" "${target}"
  539. popd
  540. fi
  541. }
  542. function install_file() {
  543. local name="${1}"
  544. local version="${2}"
  545. local source="${3}"
  546. local targetdir="${4}"
  547. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  548. if [ ! -e "${PAWPAW_PREFIX}/${targetdir}/$(basename ${source})" ]; then
  549. pushd "${pkgdir}"
  550. cp -v "${source}" "${PAWPAW_PREFIX}/${targetdir}/"
  551. popd
  552. fi
  553. }
  554. function link_file() {
  555. local name="${1}"
  556. local version="${2}"
  557. local source="${3}"
  558. local target="${4}"
  559. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  560. if [ ! -e "${pkgdir}/${target}" ]; then
  561. pushd "${pkgdir}"
  562. ln -sfv "${source}" "${target}"
  563. popd
  564. fi
  565. }
  566. function remove_file() {
  567. local name="${1}"
  568. local version="${2}"
  569. local file="${3}"
  570. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  571. if [ -e "${pkgdir}/${file}" ]; then
  572. rm -fv "${pkgdir}/${file}"
  573. fi
  574. }
  575. # ---------------------------------------------------------------------------------------------------------------------
  576. function patch_osx_binary_libs() {
  577. local file="${1}"
  578. if [ -L "${file}" ]; then
  579. return 0
  580. fi
  581. idname=$(otool -D "${file}")
  582. if otool -L "${file}" | grep -v ":" | grep -v "${idname}" | grep -q "${PAWPAW_PREFIX}"; then
  583. #install_name_tool -change "@rpath/QtCore.framework/Versions/5/QtCore" "@executable_path/QtCore" "${file}"
  584. #install_name_tool -change "@rpath/QtGui.framework/Versions/5/QtGui" "@executable_path/QtGui" "${file}"
  585. #install_name_tool -change "@rpath/QtWidgets.framework/Versions/5/QtWidgets" "@executable_path/QtWidgets" "${file}"
  586. #install_name_tool -change "@rpath/QtXml.framework/Versions/5/QtXml" "@executable_path/QtXml" "${file}"
  587. install_name_tool -change "@executable_path/../Frameworks/libjack.0.dylib" "/usr/local/lib/libjack.0.dylib" "${file}"
  588. install_name_tool -change "${PAWPAW_PREFIX}/jack2/lib/libjack.0.dylib" "/usr/local/lib/libjack.0.dylib" "${file}"
  589. install_name_tool -change "${PAWPAW_PREFIX}/jack2/lib/libjacknet.0.dylib" "/usr/local/lib/libjacknet.0.dylib" "${file}"
  590. install_name_tool -change "${PAWPAW_PREFIX}/jack2/lib/libjackserver.0.dylib" "/usr/local/lib/libjackserver.0.dylib" "${file}"
  591. fi
  592. }
  593. function patch_osx_qtapp() {
  594. local name="${1}"
  595. local version="${2}"
  596. local appfile="${3}"
  597. local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  598. _prebuild "${name}" "${pkgdir}"
  599. mkdir -p "${appfile}/Contents/PlugIns/platforms"
  600. mkdir -p "${appfile}/Contents/PlugIns/printsupport"
  601. cp -v "${PAWPAW_PREFIX}/lib/qt5/plugins/platforms/libqcocoa.dylib" "${appfile}/Contents/PlugIns/platforms/"
  602. cp -v "${PAWPAW_PREFIX}/lib/qt5/plugins/printsupport/libcocoaprintersupport.dylib" "${appfile}/Contents/PlugIns/printsupport/"
  603. macdeployqt "${appfile}"
  604. rm -f "${appfile}/Contents/Frameworks/libjack.0.1.0.dylib"
  605. _postbuild
  606. }
  607. # ---------------------------------------------------------------------------------------------------------------------