This repository was archived by the owner on Apr 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathbuild_mconf.sh
137 lines (117 loc) · 3.48 KB
/
build_mconf.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
NDK_DIR=~/Codes/android-ndk-r6b
if [ ! -d "$NDK_DIR" ]; then
echo "Please set correctly your Android Native Development Kit path"
echo "Current path: $NDK_DIR"
return
fi
if [ `cat $NDK_DIR/RELEASE.TXT | grep 'r6b' | wc -l` -eq 0 ]; then
echo "This script is prepared to compile FFmpeg using the NDK version r6b"
echo "Please download the right version of NDK"
return
fi
PREBUILT=$NDK_DIR/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86
PLATFORM=$NDK_DIR/platforms/android-8/arch-arm
clean() {
rm -f jni/*.tmp
rm -f jni/*_files.mk
}
list_files() {
rm -f ../$1_source.tmp
# run a fake make
make --dry-run | \
# select the just the files from the wanted library
egrep -i "$1/" | \
# select all the occurrences of .c and .S filenames
grep "[^ ]*\.[cS]" -o | \
# put the result on .mk file
sort >> ../$1_source.tmp
# point corrections
if [ $1 = 'libavcodec' ];
then
echo 'libavcodec/rawdec.c' >> ../$1_source.tmp
fi
echo 'LOCAL_SRC_FILES := \' > ../$1_files.mk
cat ../$1_source.tmp | \
# put a \ at the end of each line
sed -e 's:$: \\:g' >> ../$1_files.mk
cat ../$1_source.tmp > ../base.tmp
rm -f ../$1_header.tmp; touch ../$1_header.tmp
while [ `cat ../base.tmp | wc -l` -gt 0 ]
do
rm -f ../include.tmp
for filename in `cat ../base.tmp`
do
if [ -e $filename ]
then
folder=`dirname $filename`
cat $filename | \
# keeps the lines with #include "<anything>"
# grep '^#include "[^"]*"' | \
grep '^#include "[^"]*"' >> ../include.tmp
# keeps only the header name
# sed -e 's:\([^"]*\)\"\([^"]*\)\".*:\2:' | \
# include the folder name (in case it is not already there)
# sed -e "/^lib/!s/.*/\0\n$folder\/\0/g" >> ../include.tmp
fi
done
# keeps only the header name
sed -i 's:\([^"]*\)\"\([^"]*\)\".*:\2:' ../include.tmp
# include the folder name (in case it is not already there)
sed -i "/^lib/!s/.*/\0\n$folder\/\0/g" ../include.tmp
rm -f ../base.tmp; touch ../base.tmp
for filename in `cat ../include.tmp`
do
if [ -e $filename ]
then
if [ `cat ../$1_header.tmp | grep "$filename" | wc -l` -eq 0 ]
then
echo $filename >> ../$1_header.tmp
echo $filename >> ../base.tmp
fi
fi
done
done
# copy all the headers to a specific folder
for filename in `cat ../$1_header.tmp`
do
if [ -e $filename ]
then
mkdir -p `dirname ../built_headers/$filename`
cp $filename ../built_headers/$filename > /dev/null 2>&1
fi
done
}
clean
cd jni/ffmpeg
./configure --target-os=linux \
--disable-everything \
--disable-postproc \
--disable-avfilter \
--disable-network \
--disable-ffmpeg \
--disable-ffprobe \
--arch=arm \
--enable-version3 \
--enable-gpl \
--enable-nonfree \
--enable-cross-compile \
--enable-encoder=flv \
--enable-decoder=flv \
--cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
--nm=$PREBUILT/bin/arm-linux-androideabi-nm \
--extra-cflags="-fPIC -DANDROID -I$PLATFORM/usr/include" \
--enable-armv5te \
--extra-ldflags="-Wl,-T,$PREBUILT/arm-linux-androideabi/lib/ldscripts/armelf_linux_eabi.x -Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/crtbegin.o $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/crtend.o -lc -lm -ldl" \
--logfile=../configure.log
rm -rf ../built_headers
mkdir ../built_headers
list_files 'libavutil'
list_files 'libavcodec'
list_files 'libavformat'
list_files 'libswscale'
cd ../..
$NDK_DIR/ndk-build clean
$NDK_DIR/ndk-build -j 8
clean