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.

732 lines
21KB

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