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.

179 lines
5.9KB

  1. #!/bin/bash
  2. set -e
  3. cd $(dirname ${0})
  4. PAWPAW_ROOT="${PWD}"
  5. # ---------------------------------------------------------------------------------------------------------------------
  6. # check target
  7. target="${1}"
  8. if [ -z "${target}" ]; then
  9. echo "usage: ${0} <target>"
  10. exit 1
  11. fi
  12. # ---------------------------------------------------------------------------------------------------------------------
  13. # TODO check for depedencies:
  14. # - curl
  15. # - cmake
  16. # - make
  17. # - jq
  18. # - patch
  19. # - python (waf, meson)
  20. # - sed
  21. # - tar
  22. # ---------------------------------------------------------------------------------------------------------------------
  23. # source setup code
  24. source setup/check_target.sh
  25. source setup/env.sh
  26. source setup/functions.sh
  27. source setup/versions.sh
  28. # ---------------------------------------------------------------------------------------------------------------------
  29. # create common directories
  30. mkdir -p "${PAWPAW_BUILDDIR}"
  31. mkdir -p "${PAWPAW_DOWNLOADDIR}"
  32. mkdir -p "${PAWPAW_PREFIX}"
  33. mkdir -p "${PAWPAW_TMPDIR}"
  34. # ---------------------------------------------------------------------------------------------------------------------
  35. # let's use native glib for linux builds
  36. if [ "${LINUX}" -eq 1 ]; then
  37. mkdir -p ${TARGET_PKG_CONFIG_PATH}
  38. if [ ! -e "${TARGET_PKG_CONFIG_PATH}/glib-2.0.pc" ]; then
  39. ln -s $(pkg-config --variable=pcfiledir glib-2.0)/g{io,lib,module,object,thread}-2.0.pc ${TARGET_PKG_CONFIG_PATH}/
  40. fi
  41. if [ ! -e "${TARGET_PKG_CONFIG_PATH}/libpcre.pc" ]; then
  42. ln -s $(pkg-config --variable=pcfiledir libpcre)/libpcre.pc ${TARGET_PKG_CONFIG_PATH}/
  43. fi
  44. fi
  45. # ---------------------------------------------------------------------------------------------------------------------
  46. # pkgconfig
  47. download pkg-config "${PKG_CONFIG_VERSION}" "${PKG_CONFIG_URL}"
  48. build_host_autoconf pkg-config "${PKG_CONFIG_VERSION}" "--enable-indirect-deps --with-internal-glib --with-pc-path=${TARGET_PKG_CONFIG_PATH}"
  49. if [ "${CROSS_COMPILING}" -eq 1 ] && [ ! -e "${PAWPAW_PREFIX}/bin/${TOOLCHAIN_PREFIX_}pkg-config" ]; then
  50. ln -s pkg-config "${PAWPAW_PREFIX}/bin/${TOOLCHAIN_PREFIX_}pkg-config"
  51. fi
  52. # ---------------------------------------------------------------------------------------------------------------------
  53. # libogg
  54. download libogg "${LIBOGG_VERSION}" "${LIBOGG_URL}"
  55. build_autoconf libogg "${LIBOGG_VERSION}"
  56. # ---------------------------------------------------------------------------------------------------------------------
  57. # libvorbis
  58. LIBVORBIS_EXTRAFLAGS="--disable-examples"
  59. download libvorbis "${LIBVORBIS_VERSION}" "${LIBVORBIS_URL}"
  60. build_autoconf libvorbis "${LIBVORBIS_VERSION}" "${LIBVORBIS_EXTRAFLAGS}"
  61. # ---------------------------------------------------------------------------------------------------------------------
  62. # flac (forces intrinsic optimizations on macos-universal target)
  63. FLAC_EXTRAFLAGS="--disable-doxygen-docs --disable-examples --disable-thorough-tests --disable-xmms-plugin"
  64. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  65. FLAC_EXTRAFLAGS+=" ac_cv_header_x86intrin_h=yes asm_opt=yes"
  66. fi
  67. download flac "${FLAC_VERSION}" "${FLAC_URL}" "tar.xz"
  68. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  69. patch_file flac "${FLAC_VERSION}" "configure" 's/amd64|x86_64/amd64|arm|x86_64/'
  70. fi
  71. build_autoconf flac "${FLAC_VERSION}" "${FLAC_EXTRAFLAGS}"
  72. if [ "${CROSS_COMPILING}" -eq 0 ]; then
  73. run_make flac "${FLAC_VERSION}" check
  74. fi
  75. # ---------------------------------------------------------------------------------------------------------------------
  76. # opus
  77. OPUS_EXTRAFLAGS="--enable-custom-modes --enable-float-approx"
  78. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  79. OPUS_EXTRAFLAGS+=" --disable-extra-programs"
  80. fi
  81. if [ "${MACOS_OLD}" -eq 1 ]; then
  82. OPUS_EXTRAFLAGS+=" --disable-intrinsics"
  83. fi
  84. # FIXME macos-universal proper optimizations
  85. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  86. OPUS_EXTRAFLAGS+=" --disable-intrinsics"
  87. fi
  88. download opus "${OPUS_VERSION}" "${OPUS_URL}"
  89. build_autoconf opus "${OPUS_VERSION}" "${OPUS_EXTRAFLAGS}"
  90. if [ "${CROSS_COMPILING}" -eq 0 ]; then
  91. run_make opus "${OPUS_VERSION}" check
  92. fi
  93. # ---------------------------------------------------------------------------------------------------------------------
  94. # libsndfile
  95. LIBSNDFILE_EXTRAFLAGS="--disable-alsa --disable-full-suite --disable-sqlite"
  96. # otherwise tests fail
  97. export EXTRA_CFLAGS="-frounding-math -fsignaling-nans"
  98. if [ "${MACOS_OLD}" -eq 0 ]; then
  99. export EXTRA_CFLAGS+=" -fno-associative-math"
  100. fi
  101. download libsndfile "${LIBSNDFILE_VERSION}" "${LIBSNDFILE_URL}" "tar.bz2"
  102. if [ "${MACOS_OLD}" -eq 1 ]; then
  103. patch_file libsndfile "${LIBSNDFILE_VERSION}" "src/sfconfig.h" 's/#define USE_SSE2/#undef USE_SSE2/'
  104. fi
  105. build_autoconf libsndfile "${LIBSNDFILE_VERSION}" "${LIBSNDFILE_EXTRAFLAGS}"
  106. # FIXME tests fail on macos-universal
  107. if [ "${CROSS_COMPILING}" -eq 0 ] && [ "${MACOS_UNIVERSAL}" -eq 0 ]; then
  108. run_make libsndfile "${LIBSNDFILE_VERSION}" "check -j 8"
  109. fi
  110. # ---------------------------------------------------------------------------------------------------------------------
  111. # libsamplerate
  112. LIBSAMPLERATE_EXTRAFLAGS="--disable-fftw"
  113. # NOTE: sndfile tests use Carbon, not available on macos-universal
  114. if [ "${CROSS_COMPILING}" -eq 1 ] || [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  115. LIBSAMPLERATE_EXTRAFLAGS+=" --disable-sndfile"
  116. fi
  117. download libsamplerate "${LIBSAMPLERATE_VERSION}" "${LIBSAMPLERATE_URL}"
  118. build_autoconf libsamplerate "${LIBSAMPLERATE_VERSION}" "${LIBSAMPLERATE_EXTRAFLAGS}"
  119. if [ "${CROSS_COMPILING}" -eq 0 ] && [ "${MACOS_UNIVERSAL}" -eq 0 ]; then
  120. run_make libsamplerate "${LIBSAMPLERATE_VERSION}" check
  121. fi
  122. # ---------------------------------------------------------------------------------------------------------------------
  123. # zlib (skipped on macOS)
  124. if [ "${MACOS}" -eq 0 ]; then
  125. git_clone zlib "${ZLIB_VERSION}" "https://github.com/madler/zlib.git"
  126. build_conf zlib "${ZLIB_VERSION}" "--static --prefix=${PAWPAW_PREFIX}"
  127. fi
  128. # ---------------------------------------------------------------------------------------------------------------------