99# www.aomedia.org/license/patent.
1010#
1111
12- OPUS_DIR=" $( cd " $( dirname " $0 " ) " ; pwd -P ) /opus/opus-1.4"
13- AAC_DIR=" $( cd " $( dirname " $0 " ) " ; pwd -P ) /aac/fdk-aac-free-2.0.0"
14- FLAC_DIR=" $( cd " $( dirname " $0 " ) " ; pwd -P ) /flac/flac-1.4.2"
15- CODEC_LIB_DIR=" $( cd " $( dirname " $0 " ) " ; pwd -P ) /lib"
12+ set -e
13+
14+ run ()
15+ {
16+ if [ " $VERBOSE " = " yes" ] ; then
17+ echo " ##### NEW COMMAND"
18+ echo " $@ "
19+ $@ 2>&1
20+ else
21+ if [ -n " $TMPLOG " ] ; then
22+ echo " ##### NEW COMMAND" >> $TMPLOG
23+ echo " $@ " >> $TMPLOG
24+ $@ 2>&1 | tee -a $TMPLOG
25+ else
26+ $@ > /dev/null 2>&1
27+ fi
28+ fi
29+ }
30+
31+ pattern_match ()
32+ {
33+ echo " $2 " | grep -q -E -e " $1 "
34+ }
35+
36+ # Find if a given shell program is available.
37+ #
38+ # $1: variable name
39+ # $2: program name
40+ #
41+ # Result: set $1 to the full path of the corresponding command
42+ # or to the empty/undefined string if not available
43+ #
44+ find_program ()
45+ {
46+ eval $1 =` command -v $2 `
47+ }
48+
49+ prepare_download ()
50+ {
51+ find_program CMD_WGET wget
52+ find_program CMD_CURL curl
53+ find_program CMD_SCRP scp
54+ }
55+
56+ # Download a file with either 'curl', 'wget' or 'scp'
57+ #
58+ # $1: source URL (e.g. http://foo.com, ssh://blah, /some/path)
59+ # $2: target file
60+ download_file ()
61+ {
62+ # Is this HTTP, HTTPS or FTP ?
63+ if pattern_match " ^(http|https|ftp):.*" " $1 " ; then
64+ if [ -n " $CMD_WGET " ] ; then
65+ run $CMD_WGET -O $2 $1
66+ elif [ -n " $CMD_CURL " ] ; then
67+ run $CMD_CURL -L -o $2 $1
68+ else
69+ echo " Please install wget or curl on this machine"
70+ exit 1
71+ fi
72+ return
73+ fi
74+
75+ # Is this SSH ?
76+ # Accept both ssh://<path> or <machine>:<path>
77+ #
78+ if pattern_match " ^(ssh|[^:]+):.*" " $1 " ; then
79+ if [ -n " $CMD_SCP " ] ; then
80+ scp_src=` echo $1 | sed -e s%ssh://%%g`
81+ run $CMD_SCP $scp_src $2
82+ else
83+ echo " Please install scp on this machine"
84+ exit 1
85+ fi
86+ return
87+ fi
88+
89+ # Is this a file copy ?
90+ # Accept both file://<path> or /<path>
91+ #
92+ if pattern_match " ^(file://|/).*" " $1 " ; then
93+ cp_src=` echo $1 | sed -e s%^file://%%g`
94+ run cp -f $cp_src $2
95+ return
96+ fi
97+ }
98+
99+
100+
101+ OPUS_DIR=" $( cd " $( dirname " $0 " ) " ; pwd -P ) /opus"
102+ AAC_DIR=" $( cd " $( dirname " $0 " ) " ; pwd -P ) /aac"
103+ FLAC_DIR=" $( cd " $( dirname " $0 " ) " ; pwd -P ) /flac"
104+ CODECS_DIR=" $( cd " $( dirname " $0 " ) " ; pwd -P ) "
105+ OPUS_TAR=" opus-1.4.tar.gz"
106+ AAC_TAR=" fdk-aac-free-2.0.0.tar.gz"
107+ FLAC_TAR=" flac-1.4.2.tar.xz"
16108
17109declare -a CONFIG_FLAGS_OPUS
18110declare -a CONFIG_FLAGS_AAC
19111declare -a CONFIG_FLAGS_FLAC
20- CONFIG_FLAGS_AAC=" --enable-static --disable-shared"
21- CONFIG_FLAGS_FLAC=" -DWITH_OGG=OFF -DBUILD_CXXLIBS=OFF"
112+ CONFIG_FLAGS_OPUS=" -DCMAKE_C_FLAGS=" -fPIC" "
113+ CONFIG_FLAGS_AAC=" --enable-static --disable-shared --with-pic"
114+ CONFIG_FLAGS_FLAC=" -DWITH_OGG=OFF -DBUILD_CXXLIBS=OFF -DCMAKE_C_FLAGS=" -fPIC" "
115+
116+ OPUS_DOWNLOAD_LINK=" https://downloads.xiph.org/releases/opus/opus-1.4.tar.gz"
117+ AAC_DOWNLOAD_LINK=" https://people.freedesktop.org/~wtay/fdk-aac-free-2.0.0.tar.gz"
118+ FLAC_DOWNLOAD_LINK=" https://downloads.xiph.org/releases/flac/flac-1.4.2.tar.xz"
119+
22120
23121function show_help()
24122{
47145 want_help=yes ;;
48146
49147 --x86_64-mingw_toolchain)
50- CONFIG_FLAGS_OPUS=" -DCMAKE_TOOLCHAIN_FILE=../../../build/cmake/toolchains/x86_64-mingw.cmake -DOPUS_STACK_PROTECTOR=OFF"
51- CONFIG_FLAGS_AAC=" --host=x86_64-w64-mingw32 --enable-static --disable-shared"
52- CONFIG_FLAGS_FLAC=" -DCMAKE_TOOLCHAIN_FILE=../../../build/cmake/toolchains/x86_64-mingw.cmake -DWITH_OGG=OFF -DBUILD_CXXLIBS=OFF -DWITH_STACK_PROTECTOR=OFF"
148+ CONFIG_FLAGS_OPUS=" -DCMAKE_TOOLCHAIN_FILE=../../../build/cmake/toolchains/x86_64-mingw.cmake -DOPUS_STACK_PROTECTOR=OFF -DCMAKE_C_FLAGS= " -fPIC " "
149+ CONFIG_FLAGS_AAC=" --host=x86_64-w64-mingw32 --enable-static --disable-shared --with-pic "
150+ CONFIG_FLAGS_FLAC=" -DCMAKE_TOOLCHAIN_FILE=../../../build/cmake/toolchains/x86_64-mingw.cmake -DWITH_OGG=OFF -DBUILD_CXXLIBS=OFF -DWITH_STACK_PROTECTOR=OFF -DCMAKE_C_FLAGS= " -fPIC " "
53151 shift # past argument with no value
54152 ;;
55153
56154 --arm64-linux_toolchain)
57- CONFIG_FLAGS_OPUS=" -DCMAKE_TOOLCHAIN_FILE=../../../build/cmake/toolchains/arm64-linux.cmake -DOPUS_STACK_PROTECTOR=OFF"
58- CONFIG_FLAGS_AAC=" --host=aarch64-linux-gnu --enable-static --disable-shared"
59- CONFIG_FLAGS_FLAC=" -DCMAKE_TOOLCHAIN_FILE=../../../build/cmake/toolchains/arm64-linux.cmake -DCMAKE_C_FLAGS= " -fPIC " - DWITH_OGG=OFF -DBUILD_CXXLIBS=OFF -DWITH_STACK_PROTECTOR=OFF"
155+ CONFIG_FLAGS_OPUS=" -DCMAKE_TOOLCHAIN_FILE=../../../build/cmake/toolchains/arm64-linux.cmake -DOPUS_STACK_PROTECTOR=OFF -DCMAKE_C_FLAGS= " -fPIC " "
156+ CONFIG_FLAGS_AAC=" --host=aarch64-linux-gnu --enable-static --disable-shared --with-pic "
157+ CONFIG_FLAGS_FLAC=" -DCMAKE_TOOLCHAIN_FILE=../../../build/cmake/toolchains/arm64-linux.cmake -DWITH_OGG=OFF -DBUILD_CXXLIBS=OFF -DWITH_STACK_PROTECTOR=OFF -DCMAKE_C_FLAGS= " -fPIC " "
60158 shift # past argument with no value
61159 ;;
62160
63161 --x86-macos_toolchain)
64- CONFIG_FLAGS_OPUS=" -DCMAKE_TOOLCHAIN_FILE=../../../build/cmake/toolchains/x86-macos.cmake"
65- CONFIG_FLAGS_AAC=" --host=x86_64-apple-darwin20.4 --enable-static --disable-shared"
66- CONFIG_FLAGS_FLAC=" -DCMAKE_TOOLCHAIN_FILE=../../../build/cmake/toolchains/x86-macos.cmake -DWITH_OGG=OFF -DBUILD_CXXLIBS=OFF"
162+ CONFIG_FLAGS_OPUS=" -DCMAKE_TOOLCHAIN_FILE=../../../build/cmake/toolchains/x86-macos.cmake -DCMAKE_C_FLAGS= " -fPIC " "
163+ CONFIG_FLAGS_AAC=" --host=x86_64-apple-darwin20.4 --enable-static --disable-shared --with-pic "
164+ CONFIG_FLAGS_FLAC=" -DCMAKE_TOOLCHAIN_FILE=../../../build/cmake/toolchains/x86-macos.cmake -DWITH_OGG=OFF -DBUILD_CXXLIBS=OFF -DCMAKE_C_FLAGS= " -fPIC " "
67165 shift # past argument with no value
68166 ;;
69167
70168 --arm64-ios_toolchain)
71169 CONFIG_FLAGS_OPUS=" -DCMAKE_TOOLCHAIN_FILE=../../../build/cmake/toolchains/arm64-ios.cmake"
72- CONFIG_FLAGS_AAC=" --host=aarch64-apple-darwin20.4 --enable-static --disable-shared"
73- CONFIG_FLAGS_FLAC=" -DCMAKE_TOOLCHAIN_FILE=../../../build/cmake/toolchains/arm64-ios.cmake -DWITH_OGG=OFF -DBUILD_CXXLIBS=OFF"
170+ CONFIG_FLAGS_AAC=" --host=aarch64-apple-darwin20.4 --enable-static --disable-shared --with-pic "
171+ CONFIG_FLAGS_FLAC=" -DCMAKE_TOOLCHAIN_FILE=../../../build/cmake/toolchains/arm64-ios.cmake -DWITH_OGG=OFF -DBUILD_CXXLIBS=OFF -DCMAKE_C_FLAGS= " -fPIC " "
74172 shift # past argument with no value
75173 ;;
76174
@@ -86,29 +184,114 @@ if test "x$want_help" = xyes; then
86184show_help
87185fi
88186
187+ # Delete old libraries
188+ rm -rf $CODECS_DIR /lib
189+
190+ echo " >>>>>>>>>>>>>>>>>>>>>>>>>>>Codec Download<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
191+
192+ CLEAN=yes
193+ DOWNLOAD=yes
194+
195+ if [ $CLEAN = yes ] ; then
196+ echo " Cleaning: $OPUS_DIR "
197+ rm -f -r $OPUS_DIR
198+
199+ echo " Cleaning: $AAC_DIR "
200+ rm -f -r $AAC_DIR
201+
202+ echo " Cleaning: $FLAC_DIR "
203+ rm -f -r $FLAC_DIR
204+
205+ mkdir $OPUS_DIR
206+ mkdir $AAC_DIR
207+ mkdir $FLAC_DIR
208+ [ " $DOWNLOAD " = " yes" ] || exit 0
209+ fi
210+
211+ # Download OPUS
212+ if [ ! -f $OPUS_DIR /$OPUS_TAR ]
213+ then
214+ echo " Downloading opus please wait..."
215+ prepare_download
216+ download_file $OPUS_DOWNLOAD_LINK $OPUS_DIR /$OPUS_TAR
217+ fi
218+
219+ if [ ! -f $OPUS_DIR /$OPUS_TAR ]
220+ then
221+ echo " Failed to download opus! Please download manually\nand save it in this directory as $OPUS_TAR "
222+ exit 1
223+ fi
224+
225+ if [ -f $OPUS_DIR /$OPUS_TAR ]
226+ then
227+ echo " Unpacking opus"
228+ tar -zxf $OPUS_DIR /$OPUS_TAR -C $OPUS_DIR
229+ fi
230+
231+ # Download AAC
232+ if [ ! -f $AAC_DIR /$AAC_TAR ]
233+ then
234+ echo " Downloading aac please wait..."
235+ prepare_download
236+ download_file $AAC_DOWNLOAD_LINK $AAC_DIR /$AAC_TAR
237+ fi
238+
239+ if [ ! -f $AAC_DIR /$AAC_TAR ]
240+ then
241+ echo " Failed to download aac! Please download manually\nand save it in this directory as $AAC_TAR "
242+ exit 1
243+ fi
244+
245+ if [ -f $AAC_DIR /$AAC_TAR ]
246+ then
247+ echo " Unpacking aac"
248+ tar -zxf $AAC_DIR /$AAC_TAR -C $AAC_DIR
249+ fi
250+
251+ # Download FLAC
252+ if [ ! -f $FLAC_DIR /$FLAC_TAR ]
253+ then
254+ echo " Downloading flac please wait..."
255+ prepare_download
256+ download_file $FLAC_DOWNLOAD_LINK $FLAC_DIR /$FLAC_TAR
257+ fi
258+
259+ if [ ! -f $FLAC_DIR /$FLAC_TAR ]
260+ then
261+ echo " Failed to download flac! Please download manually\nand save it in this directory as $FLAC_TAR "
262+ exit 1
263+ fi
264+
265+ if [ -f $FLAC_DIR /$FLAC_TAR ]
266+ then
267+ echo " Unpacking flac"
268+ tar -xf $FLAC_DIR /$FLAC_TAR -C $FLAC_DIR
269+ fi
270+
271+
89272
90273echo " >>>>>>>>>>>>>>>>>>>>>>>>>>>OPUS Compile<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
91- cd $OPUS_DIR
274+ cd $OPUS_DIR /opus-1.4
92275rm -rf build
93276cmake -B build ./ $CONFIG_FLAGS_OPUS
94277cmake --build build --clean-first
95- cp -f build/libopus.a $CODEC_LIB_DIR
278+ cmake --install build --prefix $CODECS_DIR
96279
97280echo " >>>>>>>>>>>>>>>>>>>>>>>>>>>AAC Compile<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
98- cd $AAC_DIR
281+ cd $AAC_DIR /fdk-aac-free-2.0.0
99282rm -rf build
100283mkdir build
101284cd build
102- ../configure $CONFIG_FLAGS_AAC
285+ ../configure $CONFIG_FLAGS_AAC --prefix= $CODECS_DIR
103286make
104- cp -f .libs/libfdk-aac.a $CODEC_LIB_DIR
287+ make install
105288
106289echo " >>>>>>>>>>>>>>>>>>>>>>>>>>>FLAC Compile<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
107- cd $FLAC_DIR
290+ cd $FLAC_DIR /flac-1.4.2
108291rm -rf build
109292cmake -B build ./ $CONFIG_FLAGS_FLAC
110293cmake --build build --clean-first
111- cp -f build/src/libFLAC/libFLAC.a $CODEC_LIB_DIR
294+ cmake --install build --prefix $CODECS_DIR
112295
113296
114297
0 commit comments