2014-12-14 16:50:18 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
2014-12-17 08:50:28 +08:00
|
|
|
if [ -z $1 ]; then
|
|
|
|
SOURCE_DIR="filter_audio/"
|
|
|
|
else
|
|
|
|
SOURCE_DIR="$1/"
|
|
|
|
fi
|
2014-12-14 16:50:18 +08:00
|
|
|
|
2014-12-17 08:50:28 +08:00
|
|
|
if [ -z "$2" ]; then
|
|
|
|
LIB_DIR="/usr/local/lib/"
|
|
|
|
INCLUDE_DIR="/usr/local/include/"
|
|
|
|
else
|
|
|
|
LIB_DIR="$2/lib/"
|
|
|
|
INCLUDE_DIR="$2/include/"
|
|
|
|
fi
|
|
|
|
|
2015-01-05 19:25:32 +08:00
|
|
|
WINDOWS_VERSION=$(cmd.exe /c ver 2>/dev/null | grep "Microsoft Windows")
|
|
|
|
if [ ! -z "$WINDOWS_VERSION" ]; then
|
2015-01-20 09:26:01 +08:00
|
|
|
EXT="dll"
|
2015-01-05 19:25:32 +08:00
|
|
|
BIN_DIR="$2/bin/"
|
2015-01-20 09:26:01 +08:00
|
|
|
STATIC_EXT="$EXT.a"
|
2015-01-05 19:25:32 +08:00
|
|
|
else
|
|
|
|
BIN_DIR=$LIB_DIR
|
2015-01-20 09:26:01 +08:00
|
|
|
EXT="so"
|
|
|
|
STATIC_EXT="a"
|
2015-01-05 19:25:32 +08:00
|
|
|
fi
|
|
|
|
|
2014-12-17 08:50:28 +08:00
|
|
|
echo "Cloning filter_audio from GitHub.com"
|
|
|
|
git clone https://github.com/irungentoo/filter_audio.git $SOURCE_DIR
|
2015-02-22 03:41:55 +08:00
|
|
|
[ $? -eq 0 ] || exit 1
|
2014-12-17 08:50:28 +08:00
|
|
|
|
|
|
|
echo "Compiling filter_audio"
|
2014-12-14 16:50:18 +08:00
|
|
|
cd $SOURCE_DIR
|
|
|
|
gcc -c -fPIC filter_audio.c aec/*.c agc/*.c ns/*.c other/*.c -lm -lpthread
|
2015-02-22 03:41:55 +08:00
|
|
|
[ $? -eq 0 ] || exit 1
|
2014-12-14 16:50:18 +08:00
|
|
|
|
2014-12-17 08:50:28 +08:00
|
|
|
echo "Creating shared object file"
|
2015-02-22 04:01:11 +08:00
|
|
|
if [ ! -z "$WINDOWS_VERSION" ]; then
|
|
|
|
# This is for MingGW:
|
|
|
|
gcc *.o -shared -o libfilteraudio.$EXT -Wl,--out-implib,libfilteraudio.$STATIC_EXT
|
|
|
|
[ $? -eq 0 ] || exit 1
|
|
|
|
else
|
|
|
|
# This is for rest of the world:
|
|
|
|
make
|
|
|
|
[ $? -eq 0 ] || exit 1
|
|
|
|
ln libfilteraudio.$EXT.* libfilteraudio.so
|
|
|
|
fi
|
2014-12-14 16:50:18 +08:00
|
|
|
|
2014-12-17 08:50:28 +08:00
|
|
|
echo "Cleaning up"
|
2014-12-14 16:50:18 +08:00
|
|
|
rm *.o
|
|
|
|
|
2015-01-05 19:25:32 +08:00
|
|
|
muhcmd="cp libfilteraudio.$EXT $BIN_DIR"
|
2014-12-17 08:50:28 +08:00
|
|
|
[ -z "$2" ] && muhcmd="sudo $muhcmd"
|
|
|
|
echo "Installing libfilteraudio.so with $muhcmd"
|
2015-02-22 02:59:54 +08:00
|
|
|
$muhcmd || exit 1
|
2014-12-14 16:50:18 +08:00
|
|
|
|
2015-01-20 09:26:01 +08:00
|
|
|
muhcmd="cp libfilteraudio.$STATIC_EXT $LIB_DIR"
|
2015-01-05 19:25:32 +08:00
|
|
|
[ -z "$2" ] && muhcmd="sudo $muhcmd"
|
2015-01-20 09:26:01 +08:00
|
|
|
echo "Installing libfilteraudio.$STATIC_EXT with $muhcmd"
|
2015-02-22 02:59:54 +08:00
|
|
|
$muhcmd || exit 1
|
2015-01-05 19:25:32 +08:00
|
|
|
|
2014-12-17 08:50:28 +08:00
|
|
|
muhcmd="cp *.h $INCLUDE_DIR"
|
|
|
|
[ -z "$2" ] && muhcmd="sudo $muhcmd"
|
|
|
|
echo "Installing include files with $muhcmd"
|
2015-02-22 02:59:54 +08:00
|
|
|
$muhcmd || exit 1
|
2014-12-14 16:50:18 +08:00
|
|
|
|
|
|
|
echo "Finished."
|