| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # Exit on error |
| 4 | set -e |
| 5 | |
| 6 | # Query OS and machine |
| 7 | uname=`uname` |
| 8 | machine=`gcc -dumpmachine` |
| 9 | |
| 10 | # Number of parallel jobs |
| 11 | if [[ $uname == *MINGW* ]]; then |
| 12 | jobs=$NUMBER_OF_PROCESSORS |
| 13 | elif [[ $uname == Darwin ]]; then |
| 14 | jobs=$(sysctl -n hw.activecpu) |
| 15 | elif [[ $uname == *FreeBSD* ]]; then |
| 16 | jobs=$(sysctl -n hw.ncpu) |
| 17 | else |
| 18 | jobs=$(nproc) |
| 19 | fi |
| 20 | |
| 21 | # macOS target version |
| 22 | if [[ $uname == Darwin ]]; then |
| 23 | MACOSX_TARGET=$MACOSX_DEPLOYMENT_TARGET |
| 24 | if [[ -z $MACOSX_TARGET ]]; then |
| 25 | MACOSX_TARGET=`sw_vers | awk '$1 == "ProductVersion:" { print $2 }'` |
| 26 | fi |
| 27 | fi |
| 28 | |
| 29 | # Standard CFLAGS |
| 30 | cflags="-O3 -DNDEBUG" |
| 31 | |
| 32 | if [[ $uname == Darwin ]] && [[ $BUILD_PPC == True ]]; then |
| 33 | cflags="$cflags -arch ppc -mcpu=G4" |
| 34 | asflags="-arch ppc" |
| 35 | ldflags="-Wl,-x -arch ppc" |
| 36 | ppc=true |
| 37 | elif [[ $uname == Darwin ]] && [[ $BUILD_X86 == True ]]; then |
| 38 | cflags="$cflags -arch i386 -march=prescott" |
| 39 | asflags="-arch i386" |
| 40 | ldflags="-Wl,-x -arch i386" |
| 41 | x86=true |
| 42 | elif [[ $uname == Darwin ]] && [[ $BUILD_ARM64 == True ]]; then |
| 43 | cflags="$cflags -arch arm64 -mcpu=apple-m1" |
| 44 | asflags="-arch arm64" |
| 45 | ldflags="-Wl,-x -arch arm64" |
| 46 | cmakeflags="-DCMAKE_OSX_ARCHITECTURES=arm64" |
| 47 | host="aarch64-apple-darwin20.1.0" |
| 48 | arm64=true |
| 49 | elif [[ $uname == Darwin ]]; then |
| 50 | if [[ ${MACOSX_TARGET%%.*} -ge 11 ]]; then |
| 51 | cflags="$cflags -arch x86_64 -march=haswell" |
| 52 | else |
| 53 | cflags="$cflags -arch x86_64 -march=core2" |
| 54 | fi |
| 55 | asflags="-arch x86_64" |
| 56 | ldflags="-Wl,-x -arch x86_64" |
| 57 | cmakeflags="-DCMAKE_OSX_ARCHITECTURES=x86_64" |
| 58 | host="x86_64-apple-darwin20.1.0" |
| 59 | x86_64=true |
| 60 | elif [[ $machine == *amd64* || $machine == *x86_64* ]] && [[ $BUILD_ARM64 != True ]] && [[ $BUILD_X86 != True ]] && [[ $uname != *MINGW* || $BUILD_X86_64 == True ]]; then |
| 61 | cflags="$cflags -m64 -march=x86-64" |
| 62 | ldflags="-m64" |
| 63 | x86_64=true |
| 64 | elif [[ $machine == *amd64* || $machine == *x86_64* ]] && [[ $BUILD_ARM64 == True ]]; then |
| 65 | cflags="$cflags -march=armv8-a+simd" |
| 66 | host="aarch64-w64-mingw32" |
| 67 | arm64=true |
| 68 | elif [[ $machine == *aarch64* ]]; then |
| 69 | cflags="$cflags -I/usr/local/include -march=armv8-a+simd" |
| 70 | arm64=true |
| 71 | elif [[ $machine == *arm* ]]; then |
| 72 | cflags="$cflags -I/usr/local/include -march=armv7-a+simd" |
| 73 | arm=true |
| 74 | elif [[ $machine == *riscv64* ]]; then |
| 75 | cflags="$cflags -I/usr/local/include -march=rv64gc" |
| 76 | riscv64=true |
| 77 | elif [[ $machine == *powerpc64le* ]]; then |
| 78 | cflags="$cflags -I/usr/local/include -mcpu=powerpc64le" |
| 79 | ppc64el=true |
| 80 | elif [[ $machine == *i586* || $machine == *i686* ]] || [[ $BUILD_X86 == True ]]; then |
| 81 | cflags="$cflags -m32 -march=pentium4" |
| 82 | ldflags="-m32" |
| 83 | x86=true |
| 84 | fi |
| 85 | |
| 86 | # Include glibc version header on Linux to allow older glibc |
| 87 | if [[ $uname == Linux ]]; then |
| 88 | export cflags="$cflags -include $(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/headers/glibc_version_header.h" |
| 89 | fi |
| 90 | |
| 91 | if [[ $uname == FreeBSD ]]; then |
| 92 | export cflags="$cflags -I/usr/local/include" |
| 93 | export ldflags="$ldflags -L/usr/local/lib" |
| 94 | fi |
| 95 | |
| 96 | cflags_unroll="-funroll-loops" |
| 97 | |
| 98 | # Set host triple on Linux |
| 99 | if [[ $uname == Linux ]]; then |
| 100 | if [[ $x86_64 == true ]]; then |
| 101 | host="x86_64-linux-gnu" |
| 102 | elif [[ $x86 == true ]]; then |
| 103 | host="i386-linux-gnu" |
| 104 | elif [[ $arm64 == true ]]; then |
| 105 | host="aarch64-linux-gnu" |
| 106 | elif [[ $arm == true ]]; then |
| 107 | host="arm-linux-gnueabihf" |
| 108 | elif [[ $riscv64 == true ]]; then |
| 109 | host="riscv64-linux-gnu" |
| 110 | elif [[ $ppc64el == true ]]; then |
| 111 | host="powerpc64le-linux-gnu" |
| 112 | fi |
| 113 | fi |
| 114 | |
| 115 | # Set compiler and tools |
| 116 | export CC=gcc |
| 117 | export CXX=g++ |
| 118 | export MAKE=make |
| 119 | export SUDO=sudo |
| 120 | export DL="wget -O" |
| 121 | export PATCH="patch --binary" |
| 122 | |
| 123 | if [[ $uname == *MINGW* ]] && [[ $arm64 == true ]]; then |
| 124 | export CC=aarch64-w64-mingw32-clang |
| 125 | export CXX=aarch64-w64-mingw32-clang++ |
| 126 | fi |
| 127 | |
| 128 | if [[ $uname == Darwin ]]; then |
| 129 | MACOSX_MINOR_VERSION=${MACOSX_TARGET#*.} |
| 130 | if [[ ${MACOSX_TARGET%%.*} -ge 11 ]] || [[ ${MACOSX_MINOR_VERSION%%.*} -ge 7 ]]; then |
| 131 | export CC=clang |
| 132 | export CXX=clang++ |
| 133 | fi |
| 134 | fi |
| 135 | |
| 136 | if [[ $uname == *FreeBSD* ]]; then |
| 137 | export CC=clang |
| 138 | export CXX=clang++ |
| 139 | export MAKE=gmake |
| 140 | export PATCH=patch |
| 141 | fi |
| 142 | |
| 143 | if [[ $uname == Haiku ]]; then |
| 144 | export SUDO= |
| 145 | fi |
| 146 | |
| 147 | if [[ $uname == Darwin ]]; then |
| 148 | export DL="curl -L -o" |
| 149 | fi |
| 150 | |
| 151 | # Setup environment |
| 152 | export CFLAGS="$cflags $cflags_unroll" |
| 153 | export ASFLAGS="$asflags" |
| 154 | export LDFLAGS="$ldflags" |
| 155 | |
| 156 | if [[ $uname == *MINGW* ]]; then |
| 157 | execext=exe |
| 158 | sharedext=dll |
| 159 | sharedinfix=-* |
| 160 | else |
| 161 | execext= |
| 162 | sharedext=so |
| 163 | sharedinfix= |
| 164 | fi |
| 165 | |
| 166 | if [[ $uname == Haiku ]]; then |
| 167 | prefix="--prefix=/system/non-packaged" |
| 168 | fi |
| 169 | |
| 170 | # Package versions |
| 171 | exhale_version=1.2.2 |
| 172 | faac_version=1.40 |
| 173 | faad2_version=2.11.2 |
| 174 | fdk_aac_version=2.0.3 |
| 175 | ffmpeg_version=8.1 |
| 176 | flac_version=1.5.0 |
| 177 | lame_version=3.100 |
| 178 | libcdio_version=2.3.0 |
| 179 | libcdio_paranoia_version=10.2+2.0.2 |
| 180 | libcdrip_version=2.4a |
| 181 | libogg_version=1.3.6 |
| 182 | libsamplerate_version=0.2.2 |
| 183 | libsndfile_version=1.2.2 |
| 184 | mac_version=12.60 |
| 185 | mp4v2_version=2.1.3 |
| 186 | mpg123_version=1.33.4 |
| 187 | musepack_version=4.75 |
| 188 | opus_version=1.6.1 |
| 189 | rnnoise_version=9acc1e5 |
| 190 | rubberband_version=4.0.0 |
| 191 | speex_version=1.2.1 |
| 192 | vorbis_version=1.3.7 |
| 193 | wavpack_version=5.8.1 |
| 194 | |
| 195 | # Package locations |
| 196 | exhale_location=https://gitlab.com/ecodis/exhale/-/archive/v$exhale_version/exhale-v$exhale_version.tar.bz2 |
| 197 | faac_location=https://github.com/knik0/faac/archive/faac-${faac_version}.tar.gz |
| 198 | faad2_location=https://github.com/knik0/faad2/archive/${faad2_version}.tar.gz |
| 199 | fdk_aac_location=https://sourceforge.net/projects/opencore-amr/files/fdk-aac/fdk-aac-$fdk_aac_version.tar.gz |
| 200 | ffmpeg_location=https://ffmpeg.org/releases/ffmpeg-$ffmpeg_version.tar.xz |
| 201 | flac_location=https://github.com/xiph/flac/releases/download/$flac_version/flac-$flac_version.tar.xz |
| 202 | lame_location=https://sourceforge.net/projects/lame/files/lame/$lame_version/lame-$lame_version.tar.gz |
| 203 | libcdio_location=https://github.com/libcdio/libcdio/releases/download/$libcdio_version/libcdio-$libcdio_version.tar.bz2 |
| 204 | libcdio_paranoia_location=https://github.com/libcdio/libcdio-paranoia/releases/download/release-$libcdio_paranoia_version/libcdio-paranoia-$libcdio_paranoia_version.tar.bz2 |
| 205 | libcdrip_location=http://cdrip.org/releases/libcdrip-$libcdrip_version.zip |
| 206 | libogg_location=https://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-$libogg_version.tar.xz |
| 207 | libsamplerate_location=https://github.com/libsndfile/libsamplerate/releases/download/$libsamplerate_version/libsamplerate-$libsamplerate_version.tar.xz |
| 208 | libsndfile_location=https://github.com/libsndfile/libsndfile/releases/download/$libsndfile_version/libsndfile-$libsndfile_version.tar.xz |
| 209 | mac_location=https://freac.org/patches/MAC_${mac_version%.*}${mac_version#*.}_SDK.zip |
| 210 | mp4v2_location=https://github.com/enzo1982/mp4v2/releases/download/v$mp4v2_version/mp4v2-$mp4v2_version.tar.bz2 |
| 211 | mpg123_location=https://mpg123.org/download/mpg123-$mpg123_version.tar.bz2 |
| 212 | musepack_location=https://files.musepack.net/source/musepack_src_r${musepack_version%.*}${musepack_version#*.}.tar.gz |
| 213 | opus_location=https://ftp.osuosl.org/pub/xiph/releases/opus/opus-$opus_version.tar.gz |
| 214 | rnnoise_location=https://codeload.github.com/xiph/rnnoise/zip/$rnnoise_version |
| 215 | rubberband_location=https://breakfastquay.com/files/releases/rubberband-$rubberband_version.tar.bz2 |
| 216 | speex_location=https://ftp.osuosl.org/pub/xiph/releases/speex/speex-$speex_version.tar.gz |
| 217 | vorbis_location=https://ftp.osuosl.org/pub/xiph/releases/vorbis/libvorbis-$vorbis_version.tar.xz |
| 218 | wavpack_location=https://github.com/dbry/WavPack/releases/download/$wavpack_version/wavpack-$wavpack_version.tar.xz |
| 219 | |
| 220 | # Patch locations |
| 221 | lame_patches=(https://freac.org/patches/lame-$lame_version-sse-20171014.diff https://freac.org/patches/lame-$lame_version-fastcrc.diff) |
| 222 | lame_patch_levels=(0 1) |
| 223 | |
| 224 | lame_patches_ppc=(https://freac.org/patches/lame-$lame_version-altivec-20171014.diff https://freac.org/patches/lame-$lame_version-fastcrc.diff) |
| 225 | lame_patch_levels_ppc=(0 1) |
| 226 | |
| 227 | rubberband_patches=(https://freac.org/patches/rubberband-$rubberband_version-fixed.diff) |
| 228 | rubberband_patch_levels=(1) |
| 229 | |
| 230 | vorbis_patches=(https://freac.org/patches/libvorbis-$vorbis_version-aotuv-b6.03.patch https://freac.org/patches/libvorbis-$vorbis_version-aotuv-b6.03-lancer.patch https://freac.org/patches/libvorbis-$vorbis_version-macos-fix.patch) |
| 231 | vorbis_patch_levels=(1 1 1) |
| 232 | |
| 233 | # Keep using FFmpeg 4.3.9 on macOS PPC |
| 234 | if [[ $uname == Darwin ]] && [[ $BUILD_PPC == True ]]; then |
| 235 | ffmpeg_version=4.3.9 |
| 236 | ffmpeg_location=https://ffmpeg.org/releases/ffmpeg-$ffmpeg_version.tar.xz |
| 237 | fi |
| 238 | |
| 239 | # Keep using libsndfile 1.0.30 on macOS x86 |
| 240 | if [[ $uname == Darwin ]] && [[ $BUILD_X86 == True ]]; then |
| 241 | libsndfile_version=1.0.30 |
| 242 | libsndfile_location=https://github.com/libsndfile/libsndfile/releases/download/v$libsndfile_version/libsndfile-$libsndfile_version.tar.bz2 |
| 243 | fi |
| 244 | |
| 245 | # Keep using Rubber Band 1.8.2 on macOS PPC |
| 246 | if [[ $uname == Darwin ]] && [[ $BUILD_PPC == True ]]; then |
| 247 | rubberband_version=1.8.2 |
| 248 | rubberband_location=https://breakfastquay.com/files/releases/rubberband-$rubberband_version.tar.bz2 |
| 249 | fi |
| 250 | |
| 251 | # Main build function |
| 252 | build () { |
| 253 | archive=${1##*/} |
| 254 | |
| 255 | if [[ -z $folder ]]; then |
| 256 | if [[ $archive == *.tar.* ]]; then folder=${archive%.tar.*}; fi |
| 257 | if [[ $archive == *.zip ]]; then folder=${archive%.zip}; fi |
| 258 | fi |
| 259 | |
| 260 | if [[ $1 == *://* ]]; then $DL $archive $1; fi |
| 261 | |
| 262 | rm -fr $folder |
| 263 | |
| 264 | if [[ $archive == *.tar.gz ]]; then tar xfz $archive; fi |
| 265 | if [[ $archive == *.tar.bz2 ]]; then tar xfj $archive; fi |
| 266 | if [[ $archive == *.tar.xz ]]; then tar xfJ $archive; fi |
| 267 | if [[ $archive == *.zip ]]; then unzip $archive; fi |
| 268 | |
| 269 | cd $folder |
| 270 | |
| 271 | index=0 |
| 272 | |
| 273 | for patch in ${patches[@]}; do |
| 274 | $DL ../${patch##*/} $patch |
| 275 | |
| 276 | if [ ${#patch_levels[index]} -gt 0 ]; then |
| 277 | $PATCH -E -p${patch_levels[index]} < ../${patch##*/} |
| 278 | else |
| 279 | $PATCH -E -p1 < ../${patch##*/} |
| 280 | fi |
| 281 | |
| 282 | set +e |
| 283 | let index++ |
| 284 | set -e |
| 285 | done |
| 286 | |
| 287 | eval $prepare |
| 288 | |
| 289 | if [[ ! -f ./configure ]]; then |
| 290 | if [[ -f ./configure.in ]] || [[ -f ./configure.ac ]]; then |
| 291 | autoreconf -i |
| 292 | fi |
| 293 | fi |
| 294 | |
| 295 | parent=.. |
| 296 | |
| 297 | if [[ -f ./configure ]]; then |
| 298 | chmod a+x configure |
| 299 | if [[ -z $host_flags && ! -z $host ]]; then |
| 300 | eval $configure_exports ./configure --host=$host $configure_flags $prefix |
| 301 | else |
| 302 | eval $configure_exports ./configure $host_flags $configure_flags $prefix |
| 303 | fi |
| 304 | elif [[ -f Makefile ]] || [[ -f makefile ]]; then |
| 305 | true |
| 306 | elif [[ -f CMakeLists.txt ]]; then |
| 307 | parent=../.. |
| 308 | mkdir .build |
| 309 | cd .build |
| 310 | if [[ $uname == *MINGW* ]]; then |
| 311 | cmake .. -G "MSYS Makefiles" $cmakeflags $cmake_flags |
| 312 | else |
| 313 | cmake .. $cmakeflags $cmake_flags |
| 314 | fi |
| 315 | elif [[ -f meson.build ]]; then |
| 316 | parent=../.. |
| 317 | mkdir .build |
| 318 | cd .build |
| 319 | if [[ $uname == *MINGW* ]] && [[ $arm64 == true ]]; then |
| 320 | echo [properties] > cross.options |
| 321 | echo skip_sanity_check=true >> cross.options |
| 322 | meson setup .. $mesonflags $meson_flags --libdir lib --cross-file cross.options |
| 323 | elif [[ $uname == Darwin ]]; then |
| 324 | echo [host_machine] > cross.options |
| 325 | echo system=\'macos\' >> cross.options |
| 326 | if [[ $x86 == true ]]; then |
| 327 | echo cpu_family=\'x86\' >> cross.options |
| 328 | echo cpu=\'x86\' >> cross.options |
| 329 | echo endian=\'little\' >> cross.options |
| 330 | elif [[ $x86_64 == true ]]; then |
| 331 | echo cpu_family=\'x86_64\' >> cross.options |
| 332 | echo cpu=\'x86_64\' >> cross.options |
| 333 | echo endian=\'little\' >> cross.options |
| 334 | elif [[ $arm64 == true ]]; then |
| 335 | echo cpu_family=\'aarch64\' >> cross.options |
| 336 | echo cpu=\'aarch64\' >> cross.options |
| 337 | echo endian=\'little\' >> cross.options |
| 338 | fi |
| 339 | meson setup .. $mesonflags $meson_flags --libdir lib --cross-file cross.options |
| 340 | else |
| 341 | meson setup .. $mesonflags $meson_flags --libdir lib |
| 342 | fi |
| 343 | fi |
| 344 | |
| 345 | if [[ -f build.ninja ]]; then |
| 346 | ninja $ninja_flags -j$jobs |
| 347 | else |
| 348 | $MAKE $make_flags -j$jobs |
| 349 | fi |
| 350 | |
| 351 | index=0 |
| 352 | |
| 353 | if [[ $uname == *MINGW* ]]; then |
| 354 | files=($2) |
| 355 | targets=($3) |
| 356 | |
| 357 | for file in ${files[@]}; do |
| 358 | strip --strip-all $file |
| 359 | cp $file $parent/${targets[index]} |
| 360 | |
| 361 | if [[ ${targets[index]} == *.$sharedext ]]; then |
| 362 | peflags -d1 -n1 $parent/${targets[index]} |
| 363 | else |
| 364 | peflags -n1 $parent/${targets[index]} |
| 365 | fi |
| 366 | |
| 367 | set +e |
| 368 | let index++ |
| 369 | set -e |
| 370 | done |
| 371 | elif [[ -n "$install_script" ]]; then |
| 372 | $SUDO bash -c "$install_script" |
| 373 | else |
| 374 | if [[ -f ./install-sh ]]; then |
| 375 | chmod a+x install-sh |
| 376 | fi |
| 377 | |
| 378 | if [[ -f build.ninja ]]; then |
| 379 | $SUDO ninja $ninja_flags -j$jobs install |
| 380 | else |
| 381 | $SUDO $MAKE $make_flags -j$jobs install |
| 382 | fi |
| 383 | fi |
| 384 | |
| 385 | cd $parent |
| 386 | |
| 387 | unset patches |
| 388 | unset patch_levels |
| 389 | unset prepare |
| 390 | unset configure_exports |
| 391 | unset configure_flags |
| 392 | unset cmake_flags |
| 393 | unset meson_flags |
| 394 | unset host_flags |
| 395 | unset make_flags |
| 396 | unset ninja_flags |
| 397 | unset install_script |
| 398 | unset folder |
| 399 | |
| 400 | export CFLAGS="$cflags $cflags_unroll" |
| 401 | export ASFLAGS="$asflags" |
| 402 | export LDFLAGS="$ldflags" |
| 403 | |
| 404 | unset GNUTARGET |
| 405 | } |
| 406 | |
| 407 | packages=$@ |
| 408 | |
| 409 | if [ ${#packages[0]} -eq 0 ]; then |
| 410 | echo "Usage: build.sh [{list of packages}|all]" |
| 411 | echo "Available packages: exhale faac faad2 fdk-aac ffmpeg flac lame libcdio libcdio-paranoia libcdrip libogg libsamplerate libsndfile mac mp4v2 mpg123 musepack opus rnnoise rubberband speex vorbis wavpack" |
| 412 | echo |
| 413 | elif [ "${packages[0]}" == all ]; then |
| 414 | if [[ $uname == Darwin ]]; then |
| 415 | packages=( exhale faad2 fdk-aac ffmpeg flac lame libcdio libcdio-paranoia libogg libsamplerate libsndfile mac mp4v2 mpg123 opus speex vorbis wavpack ) |
| 416 | elif [[ $uname == Haiku ]]; then |
| 417 | packages=( exhale faac faad2 fdk-aac flac lame libogg mpg123 opus speex vorbis ) |
| 418 | elif [[ $uname == *MINGW* ]]; then |
| 419 | packages=( exhale faac faad2 fdk-aac ffmpeg flac lame libcdio libcdio-paranoia libcdrip libogg libsamplerate libsndfile mac mp4v2 mpg123 musepack opus rnnoise rubberband speex vorbis wavpack ) |
| 420 | else |
| 421 | packages=( exhale faac faad2 fdk-aac ffmpeg flac lame libcdio libcdio-paranoia libogg libsamplerate libsndfile mac mp4v2 mpg123 musepack opus rnnoise rubberband speex vorbis wavpack ) |
| 422 | fi |
| 423 | fi |
| 424 | |
| 425 | for package in ${packages[@]}; do |
| 426 | if [ $package == exhale ]; then |
| 427 | # Build exhale |
| 428 | if [[ $uname == *MINGW* ]]; then |
| 429 | prepare="sed -i -e \"s/-fPIC//\" src/makefile.base && sed -i -e \"s/= g../= \$\(CXX\)/\" src/makefile.base && sed -i -e \"s/= .(CPP)/= \$\(CXX\)/\" src/makefile.base && sed -i -e \"s/-ldl//\" src/app/makefile && sed -i -e \"s/printf_s/printf/\" src/app/exhaleApp.cpp && sed -i -e \"s/ú#+/-/\" src/app/exhaleApp.cpp" |
| 430 | if [[ $arm64 == true ]]; then |
| 431 | prepare="$prepare; sed -i -e \"s/-l.(PRD_NAME).*/& -lstdc++/\" src/app/makefile" |
| 432 | else |
| 433 | prepare="$prepare; sed -i -e \"s/-l.(PRD_NAME).*/& -lstdc++.static/\" src/app/makefile" |
| 434 | fi |
| 435 | export CXXFLAGS="$cflags $cflags_unroll -DEXHALE_DYN_LINK" |
| 436 | fi |
| 437 | if [[ $uname == Haiku ]]; then |
| 438 | make_flags="LIBS=" |
| 439 | install_script="mkdir -p /system/non-packaged/bin && cp bin/exhale /system/non-packaged/bin" |
| 440 | else |
| 441 | install_script="mkdir -p /usr/local/bin && cp bin/exhale /usr/local/bin" |
| 442 | fi |
| 443 | build $exhale_location bin/exhale.$execext exhale.$execext |
| 444 | |
| 445 | elif [ $package == faac ]; then |
| 446 | # Build FAAC |
| 447 | folder=faac-faac-${faac_version} |
| 448 | if [[ $uname == *MINGW* ]] && [[ $x86 == true ]]; then |
| 449 | export LDFLAGS="$ldflags -Wl,--kill-at" |
| 450 | fi |
| 451 | if [[ $x86_64 == true ]]; then |
| 452 | if [[ $CC != clang ]]; then |
| 453 | export CFLAGS="$cflags $cflags_unroll -mfpmath=387" |
| 454 | fi |
| 455 | fi |
| 456 | meson_flags="-Dfrontend=false" |
| 457 | build $faac_location libfaac/libfaac$sharedinfix.$sharedext FAAC.$sharedext |
| 458 | |
| 459 | elif [ $package == faad2 ]; then |
| 460 | # Build FAAD2 |
| 461 | folder=faad2-${faad2_version} |
| 462 | prepare="sed -i -e \"s/PACKAGE_VERSION;/\\\"${faad2_version}\\\";/\" libfaad/decoder.c" |
| 463 | build $faad2_location libfaad.$sharedext FAAD2.$sharedext |
| 464 | |
| 465 | elif [ $package == fdk-aac ]; then |
| 466 | # Build FDK-AAC |
| 467 | export CXXFLAGS="$cflags $cflags_unroll" |
| 468 | build $fdk_aac_location .libs/libfdk-aac$sharedinfix.$sharedext FDK-AAC.$sharedext |
| 469 | |
| 470 | elif [ $package == ffmpeg ]; then |
| 471 | # Build ffmpeg |
| 472 | export CFLAGS="$cflags" |
| 473 | configure_flags="--disable-autodetect --disable-doc --enable-gpl --enable-small --enable-runtime-cpudetect --disable-response-files" |
| 474 | if [[ $arm == true || $arm64 == true || $riscv64 == true || $ppc64el == true ]] && [[ `uname -m` == x86_64 ]]; then |
| 475 | host_flags="--enable-cross-compile" |
| 476 | if [[ $arm64 == true ]]; then |
| 477 | host_flags="$host_flags --arch=aarch64" |
| 478 | elif [[ $arm == true ]]; then |
| 479 | host_flags="$host_flags --arch=arm" |
| 480 | elif [[ $riscv64 == true ]]; then |
| 481 | host_flags="$host_flags --arch=riscv" |
| 482 | elif [[ $ppc64el == true ]]; then |
| 483 | host_flags="$host_flags --arch=ppc64" |
| 484 | fi |
| 485 | if [[ $uname == Linux ]]; then |
| 486 | host_flags="$host_flags --target-os=linux" |
| 487 | elif [[ $uname == *MINGW* ]]; then |
| 488 | host_flags="$host_flags --target-os=win32 --cross-prefix=aarch64-w64-mingw32-" |
| 489 | fi |
| 490 | else |
| 491 | host_flags=" " |
| 492 | fi |
| 493 | if [[ $uname == *MINGW* ]]; then |
| 494 | make_flags="V=1" |
| 495 | elif [[ $uname == Darwin ]]; then |
| 496 | configure_flags="$configure_flags --disable-audiotoolbox" |
| 497 | if [[ $ppc == true ]]; then |
| 498 | configure_flags="$configure_flags --disable-swscale" |
| 499 | host_flags="--arch=ppc" |
| 500 | elif [[ $x86_64 == true ]]; then |
| 501 | host_flags="--arch=x86_64" |
| 502 | elif [[ $x86 == true ]]; then |
| 503 | host_flags="--arch=i386" |
| 504 | elif [[ $arm64 == true ]]; then |
| 505 | configure_flags="$configure_flags --enable-cross-compile --disable-asm" |
| 506 | host_flags="--arch=aarch64" |
| 507 | fi |
| 508 | fi |
| 509 | build $ffmpeg_location ffmpeg.$execext ffmpeg.$execext |
| 510 | |
| 511 | elif [ $package == flac ]; then |
| 512 | # Build FLAC |
| 513 | export CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0" |
| 514 | configure_flags="--disable-cpplibs --disable-programs --disable-examples --disable-doxygen-docs" |
| 515 | if [[ $x86_64 == true ]] || [[ $arm64 == true ]] || [[ $riscv64 == true ]] || [[ $ppc64el == true ]]; then |
| 516 | if [[ $uname == *MINGW* ]]; then |
| 517 | prepare="sed -i -e \"s/#undef FLAC__CPU_IA32//\" config.h.in" |
| 518 | if [[ $x86_64 == true ]]; then |
| 519 | prepare="$prepare; sed -i -e \"s/#undef FLAC__CPU_X86_64/#define FLAC__CPU_X86_64 1/\" config.h.in" |
| 520 | else |
| 521 | prepare="$prepare; sed -i -e \"s/HAVE_SYS_PARAM_H/HAVE_xxx_PARAM_H/\" src/libFLAC/include/private/macros.h" |
| 522 | fi |
| 523 | fi |
| 524 | configure_flags="$configure_flags --enable-64-bit-words" |
| 525 | fi |
| 526 | if [[ $uname == Linux ]] && [[ $arm == true ]]; then |
| 527 | export CFLAGS="$CFLAGS -O2" |
| 528 | elif [[ $uname == Darwin ]]; then |
| 529 | configure_flags="$configure_flags --disable-asm-optimizations" |
| 530 | elif [[ $uname == *MINGW* ]]; then |
| 531 | export CFLAGS="$CFLAGS -DWINPTHREAD_STATIC=1 -I$(pwd)/libogg-$libogg_version/include" |
| 532 | export LDFLAGS="$LDFLAGS -L$(pwd)/libogg-$libogg_version/src/.libs" |
| 533 | if [[ $x86 == true ]]; then |
| 534 | export GNUTARGET=pe-i386 |
| 535 | fi |
| 536 | fi |
| 537 | build $flac_location src/libFLAC/.libs/libFLAC$sharedinfix.$sharedext FLAC.$sharedext |
| 538 | if [[ $uname == *MINGW* ]]; then |
| 539 | sed -i -b -e "s/libogg-0.dll/Ogg.dll\x00\x00\x00\x00\x00/" FLAC.$sharedext |
| 540 | fi |
| 541 | |
| 542 | elif [ $package == lame ]; then |
| 543 | # Build LAME |
| 544 | if [[ $ppc == true ]]; then |
| 545 | patches=${lame_patches_ppc[@]} |
| 546 | patch_levels=(${lame_patch_levels_ppc[@]}) |
| 547 | elif [[ $x86 == true ]] || [[ $x86_64 == true ]]; then |
| 548 | patches=${lame_patches[@]} |
| 549 | patch_levels=(${lame_patch_levels[@]}) |
| 550 | fi |
| 551 | prepare="sed -i -e \"/lame_init_old/d\" include/libmp3lame.sym" |
| 552 | configure_flags="--disable-frontend" |
| 553 | if [[ $ppc == true ]]; then |
| 554 | export CFLAGS="$cflags $cflags_unroll -faltivec -DALTIVEC" |
| 555 | elif [[ $x86 == true ]]; then |
| 556 | if [[ $uname == *MINGW* ]] || [[ $uname == FreeBSD ]] || [[ $uname == Darwin ]]; then |
| 557 | export CFLAGS="$cflags $cflags_unroll -mfpmath=sse" |
| 558 | fi |
| 559 | |
| 560 | configure_flags="$configure_flags --enable-nasm" |
| 561 | fi |
| 562 | build $lame_location libmp3lame/.libs/libmp3lame$sharedinfix.$sharedext LAME.$sharedext |
| 563 | |
| 564 | elif [ $package == libcdio ]; then |
| 565 | # Build libcdio |
| 566 | export CFLAGS="$cflags -Os" |
| 567 | configure_flags="--disable-cxx --disable-example-progs" |
| 568 | build $libcdio_location lib/driver/.libs/libcdio$sharedinfix.$sharedext libcdio.$sharedext |
| 569 | |
| 570 | elif [ $package == libcdio-paranoia ]; then |
| 571 | # Build libcdio-paranoia |
| 572 | export CFLAGS="$cflags -Os" |
| 573 | if [[ $uname == Darwin ]]; then |
| 574 | prepare="sed -i -e \"s/-Wl,--version-script=.*\\.la\\.ver//\" lib/*/Makefile.in" |
| 575 | fi |
| 576 | configure_exports="LIBCDIO_CFLAGS=\"-I.\" LIBCDIO_LIBS=\"-lcdio\"" |
| 577 | build $libcdio_paranoia_location "lib/cdda_interface/.libs/libcdio_cdda$sharedinfix.$sharedext lib/paranoia/.libs/libcdio_paranoia$sharedinfix.$sharedext" "libcdio_cdda.$sharedext libcdio_paranoia.$sharedext" |
| 578 | |
| 579 | elif [ $package == libcdrip ]; then |
| 580 | # Build libcdrip |
| 581 | export CFLAGS="$cflags -Os" |
| 582 | configure_flags="--disable-cxx" |
| 583 | if [[ $x86 == true ]]; then |
| 584 | build $libcdrip_location bin/x86/CDRip.$sharedext CDRip.$sharedext |
| 585 | elif [[ $x86_64 == true ]]; then |
| 586 | make_flags="-f Makefile.x64" |
| 587 | build $libcdrip_location bin/x86-64/CDRip.$sharedext CDRip.$sharedext |
| 588 | elif [[ $arm64 == true ]]; then |
| 589 | make_flags="-f Makefile.arm64" |
| 590 | build $libcdrip_location bin/arm64/CDRip.$sharedext CDRip.$sharedext |
| 591 | fi |
| 592 | |
| 593 | elif [ $package == libogg ]; then |
| 594 | # Build Ogg |
| 595 | build $libogg_location src/.libs/libogg$sharedinfix.$sharedext Ogg.$sharedext |
| 596 | |
| 597 | elif [ $package == libsamplerate ]; then |
| 598 | # Build libsamplerate |
| 599 | if [[ $CC != clang ]] && [[ $x86_64 == true ]]; then |
| 600 | export CFLAGS="$cflags $cflags_unroll -mfpmath=387" |
| 601 | fi |
| 602 | build $libsamplerate_location src/.libs/libsamplerate$sharedinfix.$sharedext SampleRate.$sharedext |
| 603 | |
| 604 | elif [ $package == libsndfile ]; then |
| 605 | # Build libsndfile |
| 606 | export CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0" |
| 607 | prepare="sed -i -e \"s/immintrin\.h/emmintrin.h/\" src/common.h" |
| 608 | if [[ $uname == *MINGW* ]] && [[ $x86 == true ]]; then |
| 609 | configure_exports="RC=\"windres -F pe-i386\"" |
| 610 | elif [[ $uname == Darwin ]]; then |
| 611 | export LDFLAGS="$cflags $ldflags" |
| 612 | fi |
| 613 | configure_flags="--disable-full-suite --disable-external-libs --disable-mpeg --disable-alsa" |
| 614 | build $libsndfile_location src/.libs/libsndfile$sharedinfix.$sharedext SndFile.$sharedext |
| 615 | |
| 616 | elif [ $package == mac ]; then |
| 617 | # Build Monkey's Audio |
| 618 | archive=${mac_location##*/} |
| 619 | folder=${archive%.zip} |
| 620 | $DL $archive $mac_location |
| 621 | rm -fr $folder; unzip -d $folder $archive |
| 622 | rm $archive; zip -m -r $archive $folder |
| 623 | export CXXFLAGS="$cflags $cflags_unroll" |
| 624 | cmake_flags="-DBUILD_UTIL=OFF" |
| 625 | build $archive MACDll.$sharedext MACDll.$sharedext |
| 626 | |
| 627 | elif [ $package == mp4v2 ]; then |
| 628 | # Build mp4v2 |
| 629 | configure_flags="--disable-optimize" |
| 630 | export CXXFLAGS="$cflags -Os" |
| 631 | if [[ $uname == *MINGW* ]] && [[ $x86 == true ]]; then |
| 632 | export LDFLAGS="$ldflags -lstdc++.static" |
| 633 | elif [[ $uname == *MINGW* ]] && [[ $arm64 == true ]]; then |
| 634 | export LDFLAGS="$ldflags -lclang_rt.builtins-aarch64" |
| 635 | elif [[ $uname == Darwin ]]; then |
| 636 | prepare="sed -i -e \"s/keep_private_externs/keep_private_externs $ldflags/\" configure" |
| 637 | fi |
| 638 | build $mp4v2_location .libs/libmp4v2$sharedinfix.$sharedext MP4v2.$sharedext |
| 639 | |
| 640 | elif [ $package == mpg123 ]; then |
| 641 | # Build mpg123 |
| 642 | configure_flags="--disable-modules --disable-components --enable-libmpg123" |
| 643 | if [[ $uname == *MINGW* ]]; then |
| 644 | export CFLAGS="$cflags $cflags_unroll -DWIN32" |
| 645 | elif [[ $uname == Darwin ]]; then |
| 646 | export CFLAGS="$cflags $cflags_unroll -std=c99" |
| 647 | fi |
| 648 | if [[ $ppc == true ]]; then |
| 649 | configure_flags="$configure_flags --with-cpu=altivec" |
| 650 | elif [[ $x86_64 == true ]]; then |
| 651 | if [[ $uname == Darwin ]]; then |
| 652 | configure_flags="$configure_flags --with-cpu=x86-64_alone" |
| 653 | else |
| 654 | configure_flags="$configure_flags --with-cpu=x86-64" |
| 655 | fi |
| 656 | elif [[ $x86 == true ]]; then |
| 657 | configure_flags="$configure_flags --with-cpu=sse" |
| 658 | elif [[ $arm == true ]]; then |
| 659 | configure_flags="$configure_flags --with-cpu=neon" |
| 660 | elif [[ $arm64 == true ]]; then |
| 661 | configure_flags="$configure_flags --with-cpu=neon64" |
| 662 | fi |
| 663 | build $mpg123_location src/libmpg123/.libs/libmpg123$sharedinfix.$sharedext mpg123.$sharedext |
| 664 | |
| 665 | elif [ $package == musepack ]; then |
| 666 | # Build MusePack |
| 667 | prepare="touch include/config.h.in; head -n 34 configure.in >> configure.ac; echo \"AM_CONDITIONAL([HAVE_VISIBILITY], [false])\" >> configure.ac; echo \"AC_CHECK_LIB([m],[cos])\" >> configure.ac; tail -n 18 configure.in >> configure.ac; rm configure.in; mkdir -p m4; sed -i -e \"s/const/extern const/\" libmpcdec/requant.h" |
| 668 | configure_flags="--disable-shared" |
| 669 | if [[ $uname == *MINGW* ]]; then |
| 670 | prepare="$prepare; sed -i -e \"s/mpc2sv8//\" Makefile.am; sed -i -e \"s/\*mingw32\*/*mingw*/\" configure.ac" |
| 671 | if [[ $arm64 == true ]]; then |
| 672 | prepare="$prepare; sed -i -e \"s/__MINGW32__/__MINGWxx__/\" mpcenc/mpcenc.c" |
| 673 | fi |
| 674 | fi |
| 675 | build $musepack_location "mpcenc/mpcenc.$execext mpcdec/mpcdec.$execext" "mpcenc.$execext mpcdec.$execext" |
| 676 | |
| 677 | elif [ $package == opus ]; then |
| 678 | # Build Opus |
| 679 | export CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0" |
| 680 | if [[ $x86 == true ]]; then |
| 681 | export CFLAGS="$CFLAGS -mfpmath=sse" |
| 682 | fi |
| 683 | configure_flags="--enable-float-approx --enable-osce --enable-qext --disable-hardening --disable-extra-programs" |
| 684 | if [[ $uname == Darwin ]] && [[ $x86_64 != true ]]; then |
| 685 | configure_flags="$configure_flags --disable-intrinsics" |
| 686 | elif [[ $uname == *MINGW* ]] && [[ $arm64 == true ]]; then |
| 687 | configure_exports="ARM_DOTPROD_INTR_CFLAGS=\"$CFLAGS\"" |
| 688 | configure_flags="$configure_flags --disable-rtcd" |
| 689 | elif [[ $arm == true ]]; then |
| 690 | configure_flags="$configure_flags --disable-intrinsics --disable-rtcd" |
| 691 | fi |
| 692 | build $opus_location .libs/libopus$sharedinfix.$sharedext Opus.$sharedext |
| 693 | |
| 694 | elif [ $package == rnnoise ]; then |
| 695 | # Build RNNoise |
| 696 | archive=rnnoise-${rnnoise_location##*/}.zip |
| 697 | $DL $archive $rnnoise_location |
| 698 | zip -d $archive rnnoise-$rnnoise_version/TRAINING |
| 699 | build $archive .libs/librnnoise$sharedinfix.$sharedext RNNoise.$sharedext |
| 700 | |
| 701 | elif [ $package == rubberband ]; then |
| 702 | # Build RubberBand |
| 703 | export CXXFLAGS="$cflags $cflags_unroll" |
| 704 | if [[ $uname == Darwin ]] && [[ $BUILD_PPC == True ]]; then |
| 705 | patches=${rubberband_patches[@]} |
| 706 | patch_levels=(${rubberband_patch_levels[@]}) |
| 707 | configure_exports="FFTW_CFLAGS=\" \" FFTW_LIBS=\" \" SRC_CFLAGS=\" \" SRC_LIBS=\" \" Vamp_CFLAGS=\" \" Vamp_LIBS=\" \"" |
| 708 | prepare="sed -i -e \"s/-Wl,-Bsymbolic//\" Makefile.in && sed -i -e \"s/ -Wl,-soname=.*//\" Makefile.in && sed -i -e \"s/:= .so/:= .dylib/\" Makefile.in" |
| 709 | configure_exports="$configure_exports SNDFILE_CFLAGS=\" \" SNDFILE_LIBS=\"-lsndfile\"" |
| 710 | build $rubberband_location lib/librubberband.$sharedext RubberBand.$sharedext |
| 711 | else |
| 712 | meson_flags="-Dfft=builtin -Dresampler=builtin -Djni=disabled -Dladspa=disabled -Dlv2=disabled -Dvamp=disabled -Dcmdline=disabled -Dtests=disabled" |
| 713 | build $rubberband_location librubberband$sharedinfix.$sharedext RubberBand.$sharedext |
| 714 | fi |
| 715 | |
| 716 | elif [ $package == speex ]; then |
| 717 | # Build Speex |
| 718 | if [[ $x86 == true ]]; then |
| 719 | export CFLAGS="$cflags $cflags_unroll -mfpmath=sse" |
| 720 | fi |
| 721 | build $speex_location libspeex/.libs/libspeex$sharedinfix.$sharedext Speex.$sharedext |
| 722 | |
| 723 | elif [ $package == vorbis ]; then |
| 724 | # Build Vorbis |
| 725 | patches=${vorbis_patches[@]} |
| 726 | patch_levels=(${vorbis_patch_levels[@]}) |
| 727 | if [[ $x86 != true ]]; then |
| 728 | export CFLAGS="$cflags" |
| 729 | else |
| 730 | if [[ $uname == Darwin ]]; then |
| 731 | export CFLAGS="$cflags -mno-sse" |
| 732 | else |
| 733 | export CFLAGS="$cflags -mfpmath=sse" |
| 734 | fi |
| 735 | fi |
| 736 | if [[ $uname == *MINGW* ]]; then |
| 737 | export CFLAGS="$CFLAGS -I$(pwd)/libogg-$libogg_version/include" |
| 738 | export LDFLAGS="$LDFLAGS -L$(pwd)/libogg-$libogg_version/src/.libs" |
| 739 | fi |
| 740 | build $vorbis_location "lib/.libs/libvorbis$sharedinfix.$sharedext lib/.libs/libvorbisenc$sharedinfix.$sharedext" "Vorbis.$sharedext VorbisEnc.$sharedext" |
| 741 | if [[ $uname == *MINGW* ]]; then |
| 742 | sed -i -b -e "s/libogg-0.dll/Ogg.dll\x00\x00\x00\x00\x00/" Vorbis.$sharedext |
| 743 | |
| 744 | sed -i -b -e "s/libogg-0.dll/Ogg.dll\x00\x00\x00\x00\x00/" VorbisEnc.$sharedext |
| 745 | sed -i -b -e "s/libvorbis-0.dll/Vorbis.dll\x00\x00\x00\x00\x00/" VorbisEnc.$sharedext |
| 746 | fi |
| 747 | |
| 748 | elif [ $package == wavpack ]; then |
| 749 | # Build WavPack |
| 750 | configure_flags="--disable-shared" |
| 751 | if [[ $uname == *MINGW* ]]; then |
| 752 | configure_flags="$configure_flags --disable-asm" |
| 753 | configure_exports="MSYSTEM=MINGW32" |
| 754 | elif [[ $uname == Darwin ]]; then |
| 755 | configure_flags="$configure_flags --disable-asm" |
| 756 | fi |
| 757 | build $wavpack_location "cli/wavpack.$execext cli/wvunpack.$execext" "wavpack.$execext wvunpack.$execext" |
| 758 | fi |
| 759 | done |