sox/configure: add OS X and Debian (future?) pkg-config support to sox configuration
[melted] / src / modules / sox / configure
1 #!/bin/sh
2
3 if [ "$help" != "1" ]
4 then
5         # Determine how to lookup dependencies of executable for  OS
6         targetos=$(uname -s)
7         case $targetos in
8         Darwin)
9                 LDD="otool -L"
10                 ;;
11         Linux)
12                 LDD="ldd"
13                 ;;
14         *)
15                 ;;
16         esac
17
18         which libst-config > /dev/null 2>&1
19         if [ $? -eq 0 ]
20         then
21                 disable_sox=0
22
23                 # determine if we need libsndfile
24                 $LDD $(which sox) | grep libsndfile > /dev/null
25                 [ $? -eq 0 ] && libsndfile="-lsndfile"
26
27                 # determine if we need libsamplerate
28                 $LDD $(which sox) | grep libsamplerate > /dev/null
29                 [ $? -eq 0 ] && libsamplerate="-lsamplerate"
30
31                 echo "CFLAGS += $(libst-config --cflags) -I../../" > config.mak
32                 echo "LDFLAGS += -lst $(libst-config --libs) $libsndfile $libsamplerate" >> config.mak
33         else
34                 pkg-config sox
35                 if [ $? -eq 0 ]
36                 then
37                         echo "CFLAGS += $(pkg-config --cflags sox)" > config.mak
38                         echo "LDFLAGS += $(pkg-config --libs sox)" > config.mak
39                 else
40                         sox --version 2> /dev/null | grep 'v14.' > /dev/null
41                         disable_sox=$?
42                         if [ $disable_sox -eq 0 ]
43                         then
44                                 LIBDIR=lib
45                                 bits=$(uname -m)
46                                 case $bits in
47                                 x86_64)
48                                         [ -d /usr/lib/lib64 ] && export LIBDIR=lib64 || export LIBDIR=lib
49                                         ;;
50                                 *)
51                                         export LIBDIR=lib
52                                         ;;
53                                 esac
54
55                                 sox=$(which sox)
56                                 # chop sox
57                                 soxdir=$(dirname $sox)
58                                 # chop bin
59                                 soxdir=$(dirname $soxdir)
60
61                                 # determine if we need libsamplerate
62                                 $LDD "$sox" | grep libsamplerate > /dev/null
63                                 [ $? -eq 0 ] && libsamplerate="-lsamplerate"
64
65                                 echo "CFLAGS += -DSOX14 -I$soxdir/include" > config.mak
66                                 echo "LDFLAGS += -L$soxdir/$LIBDIR -lsox -lsfx $libsamplerate" >> config.mak
67                         fi
68                 fi
69         fi
70
71         if [ "$disable_sox" != "0" ]
72         then
73                 echo "- sox not found: disabling"
74                 touch ../disable-sox
75         fi
76
77         exit 0
78 fi