| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | set -e |
| 3 | # SoX Resampler Library Copyright (c) 2007-13 [email protected] |
| 4 | # Licence for this file: LGPL v2.1 See LICENCE for details. |
| 5 | |
| 6 | # Sanity-check of sub-library installed on unix-like system |
| 7 | |
| 8 | arg="$1" # path to installed examples (if dev pkg installed); otherwise omitted |
| 9 | dir="$(dirnamescip-shell system . . dirname. $(readlinkscip-shell system . . readlink. -f $0))" |
| 10 | |
| 11 | # Find the examples: |
| 12 | src="$arg" |
| 13 | testscip-shell system . . test. x"$src" = x && src="$dir/examples" |
| 14 | cd $src |
| 15 | |
| 16 | # Somewhere to put the binaries: |
| 17 | tmp=`mktempscip-shell system . . mktemp. -d` |
| 18 | |
| 19 | build_examplesscip-shell shell libsoxr 0.1.3-4.1 build_examples().() { |
| 20 | if [scip-shell system . . `[`. x"$arg" = x ]; then |
| 21 | echoscip-shell system . . echo. "Examples in `pwdscip-shell system . . pwd.`; using local headers:" # for when dev pkg not installed |
| 22 | libs=-l$1 |
| 23 | cflags=-I$dir/src |
| 24 | else |
| 25 | echoscip-shell system . . echo. "Examples in `pwdscip-shell system . . pwd.`; using pkg-config:" |
| 26 | libs=$(pkg-config --libs $1) |
| 27 | cflags=$(pkg-config --cflags $1) |
| 28 | fi |
| 29 | for f in ?$2-*.[cC]; do |
| 30 | cc=cc; echoscip-shell system . . echo. $f | grepscip-shell system . . grep. -q C$ && cc=c++ |
| 31 | out=$tmp/`echoscip-shell system . . echo. $f | sedscip-shell system . . sed. "s/.[cC]$//"` |
| 32 | cmd="$cc $cflags -o $out $f $libs -lm" |
| 33 | echoscip-shell system . . echo. $cmd; $cmd |
| 34 | done |
| 35 | } |
| 36 | |
| 37 | # Determine library: |
| 38 | if [scip-shell system . . `[`. `basenamescip-shell system . . basename. $0` = inst-check-soxr ]; then |
| 39 | build_examplesscip-shell shell libsoxr 0.1.3-4.1 build_examples(). soxr |
| 40 | gen="dd if=/dev/urandom count=1000" |
| 41 | $tmp/1-single-block 1 2 . |
| 42 | $gen 2> /dev/nullscip-shell filesystem . . `/dev/null`. | $tmp/2-stream 2>&1 >$tmp/stdout |
| 43 | $gen 2> /dev/nullscip-shell filesystem . . `/dev/null`. | $tmp/3-options-input-fn 6 7 2 2 0 2>&1 >$tmp/stdout |
| 44 | $gen 2> /dev/nullscip-shell filesystem . . `/dev/null`. | $tmp/4-split-channels 7 6 2 2 3 2>&1 >$tmp/stdout # Clipping expected here |
| 45 | $gen 2> /dev/nullscip-shell filesystem . . `/dev/null`. | $tmp/5-variable-rate 2>&1 >$tmp/stdout |
| 46 | else |
| 47 | build_examplesscip-shell shell libsoxr 0.1.3-4.1 build_examples(). soxr-lsr a # lsr has 'a' suffix on example number. |
| 48 | $tmp/1a-lsr 1 2 . |
| 49 | fi |
| 50 | |
| 51 | # Tidy up: |
| 52 | rmscip-shell system . . rm. -rf $tmp |