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.

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