sox/configure, Makefile: try to make sox build smarter about library dependencies...
[melted] / src / modules / sox / configure
1 #!/bin/sh
2
3 if [ "$help" != "1" ]
4 then
5
6         which libst-config > /dev/null 2>&1
7         if [ $? -eq 0 ]
8         then
9                 disable_sox=0
10
11                 # determine if we need libsndfile
12                 ldd $(which sox) | grep libsndfile > /dev/null
13                 [ $? -eq 0 ] && libsndfile="-lsndfile"
14
15                 # determine if we need libsamplerate
16                 ldd $(which sox) | grep libsamplerate > /dev/null
17                 [ $? -eq 0 ] && libsamplerate="-lsamplerate"
18
19                 echo "CFLAGS += $(libst-config --cflags) -I../../" > config.mak
20                 echo "LDFLAGS += -lst $(libst-config --libs) $libsndfile $libsamplerate" >> config.mak
21         else
22                 sox --version 2> /dev/null | grep 'v14.' > /dev/null
23                 disable_sox=$?
24                 if [ $disable_sox -eq 0 ]
25                 then
26                         LIBDIR=lib
27                         bits=$(uname -m)
28                         case $bits in
29                         x86_64)
30                                 [ -d /usr/lib/lib64 ] && export LIBDIR=lib64 || export LIBDIR=lib
31                                 ;;
32                         *)
33                                 export LIBDIR=lib
34                                 ;;
35                         esac
36
37                         sox=$(which sox)
38                         # chop sox
39                         soxdir=$(dirname $sox)
40                         # chop bin
41                         soxdir=$(dirname $soxdir)
42
43                         # determine if we need libsamplerate
44                         ldd "$sox" | grep libsamplerate > /dev/null
45                         [ $? -eq 0 ] && libsamplerate="-lsamplerate"
46
47                         echo "CFLAGS += -DSOX14 -I$soxdir/include" > config.mak
48                         echo "LDFLAGS += -L$soxdir/$LIBDIR -lsox -lsfx $libsamplerate" >> config.mak
49                 fi
50         fi
51
52         if [ "$disable_sox" != "0" ]
53         then
54                 echo "- sox not found: disabling"
55                 touch ../disable-sox
56         fi
57
58         exit 0
59 fi