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.

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