| 1 | #!/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="$(dirname $(readlink -f $0))" |
| 10 | |
| 11 | # Find the examples: |
| 12 | src="$arg" |
| 13 | test x"$src" = x && src="$dir/examples" |
| 14 | cd $src |
| 15 | |
| 16 | # Somewhere to put the binaries: |
| 17 | tmp=`mktemp -d` |
| 18 | |
| 19 | build_examples() { |
| 20 | if [ x"$arg" = x ]; then |
| 21 | echo "Examples in `pwd`; using local headers:" # for when dev pkg not installed |
| 22 | libs=-l$1 |
| 23 | cflags=-I$dir/src |
| 24 | else |
| 25 | echo "Examples in `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; echo $f | grep -q C$ && cc=c++ |
| 31 | out=$tmp/`echo $f | sed "s/.[cC]$//"` |
| 32 | cmd="$cc $cflags -o $out $f $libs -lm" |
| 33 | echo $cmd; $cmd |
| 34 | done |
| 35 | } |
| 36 | |
| 37 | # Determine library: |
| 38 | if [ `basename $0` = inst-check-soxr ]; then |
| 39 | build_examples soxr |
| 40 | gen="dd if=/dev/urandom count=1000" |
| 41 | $tmp/1-single-block 1 2 . |
| 42 | $gen 2> /dev/null | $tmp/2-stream 2>&1 >$tmp/stdout |
| 43 | $gen 2> /dev/null | $tmp/3-options-input-fn 6 7 2 2 0 2>&1 >$tmp/stdout |
| 44 | $gen 2> /dev/null | $tmp/4-split-channels 7 6 2 2 3 2>&1 >$tmp/stdout # Clipping expected here |
| 45 | $gen 2> /dev/null | $tmp/5-variable-rate 2>&1 >$tmp/stdout |
| 46 | else |
| 47 | 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 | rm -rf $tmp |