1 | #!/bin/bash
|
---|
2 |
|
---|
3 | set -e
|
---|
4 |
|
---|
5 | function usage {
|
---|
6 | echo "Usage:"
|
---|
7 | echo "$0 platform ffmpeg_ver"
|
---|
8 | echo "platform: sh4 | sh4_new"
|
---|
9 | echo "ffmpeg_ver: 1.0.10 | 1.1.16 | 1.2.12 | 2.0.7 | 2.2.16 | 2.5.11 | 2.6.9 | 2.7.7 | 2.8.7 | 3.0.2 | 3.1.1 "
|
---|
10 | exit 1
|
---|
11 | }
|
---|
12 |
|
---|
13 | if [ "$#" -ne 2 ];
|
---|
14 | then
|
---|
15 | usage
|
---|
16 | fi
|
---|
17 |
|
---|
18 | EPLATFORM=$1
|
---|
19 |
|
---|
20 | if [ "$EPLATFORM" != "sh4" -a "$EPLATFORM" != "sh4_new" ];
|
---|
21 | then
|
---|
22 | echo "Please give supported platform (sh4|sh4_new) version!"
|
---|
23 | usage
|
---|
24 | fi
|
---|
25 |
|
---|
26 | FFMPEG_VERSION=""
|
---|
27 | ffmpegVersionArray=( "1.0.10" "1.1.16" "1.2.12" "2.0.7" "2.2.16" "2.5.11" "2.6.9" "2.7.7" "2.8.7" "3.0.2" "3.1.1" )
|
---|
28 | for i in "${ffmpegVersionArray[@]}"
|
---|
29 | do
|
---|
30 | if [ "$i" == "$2" ];
|
---|
31 | then
|
---|
32 | FFMPEG_VERSION=$2
|
---|
33 | break
|
---|
34 | fi
|
---|
35 | done
|
---|
36 |
|
---|
37 | if [ "$FFMPEG_VERSION" == "" ];
|
---|
38 | then
|
---|
39 | echo "Please give supported ffmpeg (1.0.10 | 1.1.16 | 1.2.12 | 2.0.7 | 2.2.16 | 2.5.11 | 2.6.9 | 2.7.7 | 2.8.7 | 3.0.2 | 3.1.1) version!"
|
---|
40 | usage
|
---|
41 | fi
|
---|
42 |
|
---|
43 | case "$EPLATFORM" in
|
---|
44 | sh4)
|
---|
45 | BASE_PATH="/home/sulge/e2/tdt/tdt/tufsbox/"
|
---|
46 | export TOOLCHAIN_NAME="sh4-linux"
|
---|
47 | export PATH=$BASE_PATH"devkit/sh4/bin/":$PATH
|
---|
48 | export SYSROOT=""
|
---|
49 | CFLAGS=" -I$BASE_PATH/cdkroot/ -L$BASE_PATH/cdkroot/ "
|
---|
50 | LDFLAGS=" -L$BASE_PATH/cdkroot/ -L$BASE_PATH/cdkroot/ "
|
---|
51 |
|
---|
52 | OPENSSL_VER="openssl-1.0.2g"
|
---|
53 | OPENSSL_PATH="/mnt/new2/new_openssl_sh4/$OPENSSL_VER"
|
---|
54 |
|
---|
55 | FFMPEG_CFLAGS=" -I$BASE_PATH/cdkroot/ -I$OPENSSL_PATH/include "
|
---|
56 | FFMPEG_LDFLAGS=" -I$BASE_PATH/cdkroot/ -L$OPENSSL_PATH "
|
---|
57 | ;;
|
---|
58 | sh4_new)
|
---|
59 | BASE_PATH="/mnt/new2/openatv/build-enviroment/builds/openatv/spark/tmp/sysroots/"
|
---|
60 | export TOOLCHAIN_NAME="sh4-oe-linux"
|
---|
61 | export PATH=$BASE_PATH"i686-linux/usr/bin/sh4-oe-linux/":$PATH
|
---|
62 | export SYSROOT=$BASE_PATH"spark"
|
---|
63 | CFLAGS=" "
|
---|
64 | FFMPEG_CFLAGS=" "
|
---|
65 | ;;
|
---|
66 | *)
|
---|
67 | usage
|
---|
68 | exit 1
|
---|
69 | esac
|
---|
70 |
|
---|
71 | CFLAGS="$CFLAGS -pipe -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE "
|
---|
72 |
|
---|
73 | export CROSS_COMPILE=$TOOLCHAIN_NAME"-"
|
---|
74 |
|
---|
75 | SOURCE_FILES="main/exteplayer.c"
|
---|
76 | SOURCE_FILES+=" container/container.c"
|
---|
77 | SOURCE_FILES+=" container/container_ffmpeg.c"
|
---|
78 | SOURCE_FILES+=" manager/manager.c"
|
---|
79 | SOURCE_FILES+=" manager/audio.c"
|
---|
80 | SOURCE_FILES+=" manager/video.c"
|
---|
81 | SOURCE_FILES+=" manager/subtitle.c"
|
---|
82 | SOURCE_FILES+=" output/linuxdvb_sh4.c"
|
---|
83 | SOURCE_FILES+=" output/output_subtitle.c"
|
---|
84 | SOURCE_FILES+=" output/output.c"
|
---|
85 |
|
---|
86 | SOURCE_FILES+=" output/writer/common/pes.c"
|
---|
87 | SOURCE_FILES+=" output/writer/common/misc.c"
|
---|
88 |
|
---|
89 | SOURCE_FILES+=" output/writer/sh4/writer.c"
|
---|
90 | SOURCE_FILES+=" output/writer/sh4/aac.c"
|
---|
91 | SOURCE_FILES+=" output/writer/sh4/ac3.c"
|
---|
92 | #SOURCE_FILES+=" output/writer/sh4/divx.c"
|
---|
93 | SOURCE_FILES+=" output/writer/sh4/divx2.c"
|
---|
94 | SOURCE_FILES+=" output/writer/sh4/dts.c"
|
---|
95 | SOURCE_FILES+=" output/writer/sh4/h263.c"
|
---|
96 | SOURCE_FILES+=" output/writer/sh4/h264.c"
|
---|
97 | SOURCE_FILES+=" output/writer/sh4/mp3.c"
|
---|
98 | SOURCE_FILES+=" output/writer/sh4/mpeg2.c"
|
---|
99 | SOURCE_FILES+=" output/writer/sh4/pcm.c"
|
---|
100 | SOURCE_FILES+=" output/writer/sh4/vc1.c"
|
---|
101 | #SOURCE_FILES+=" output/writer/sh4/vorbis.c"
|
---|
102 | SOURCE_FILES+=" output/writer/sh4/wma.c"
|
---|
103 | SOURCE_FILES+=" output/writer/sh4/wmv.c"
|
---|
104 | SOURCE_FILES+=" playback/playback.c"
|
---|
105 |
|
---|
106 | CURR_PATH=$PWD
|
---|
107 |
|
---|
108 | EXTEPLAYER3_OUT_FILE=$CURR_PATH"/tmp/out/$EPLATFORM/exteplayer3_ffmpeg"$FFMPEG_VERSION
|
---|
109 |
|
---|
110 | function buildFFmpeg
|
---|
111 | {
|
---|
112 | FFMPEG_VERSION=$1
|
---|
113 | FFMPEG_BASE_PATH=$CURR_PATH"/tmp/ffmpeg/"
|
---|
114 | mkdir -p $FFMPEG_BASE_PATH"tmp/$EPLATFORM/"
|
---|
115 | FFMPEG_PATH=$FFMPEG_BASE_PATH"tmp/$EPLATFORM/ffmpeg-"$FFMPEG_VERSION
|
---|
116 |
|
---|
117 | SOURCE_URL="http://ffmpeg.org/releases/ffmpeg-"$FFMPEG_VERSION".tar.gz"
|
---|
118 | OUT_FILE=$FFMPEG_BASE_PATH"tmp/ffmpeg-"$FFMPEG_VERSION".tar.gz"
|
---|
119 |
|
---|
120 | if [ "true" == "$2" ] || [ ! -d $FFMPEG_PATH ];
|
---|
121 | then
|
---|
122 | if [ -d $FFMPEG_PATH ] && [ "true" == "$3" ];
|
---|
123 | then
|
---|
124 | rm -rf $FFMPEG_PATH
|
---|
125 | fi
|
---|
126 |
|
---|
127 | if [ ! -f $OUT_FILE ];
|
---|
128 | then
|
---|
129 | wget $SOURCE_URL -O $OUT_FILE
|
---|
130 | fi
|
---|
131 |
|
---|
132 | if [ ! -d $FFMPEG_PATH ];
|
---|
133 | then
|
---|
134 | tar -zxf $OUT_FILE -C $FFMPEG_BASE_PATH"tmp/$EPLATFORM/"
|
---|
135 | fi
|
---|
136 |
|
---|
137 | CONFIGURE_PATH=$FFMPEG_BASE_PATH"/scripts_$EPLATFORM/configure_"$FFMPEG_VERSION".sh"
|
---|
138 |
|
---|
139 | $FFMPEG_BASE_PATH"/scripts_$EPLATFORM/make.sh" $FFMPEG_PATH $CONFIGURE_PATH $SYSROOT "$FFMPEG_CFLAGS"
|
---|
140 | else
|
---|
141 | #CONFIGURE_PATH=$FFMPEG_BASE_PATH"/scripts_$EPLATFORM/configure_"$FFMPEG_VERSION".sh"
|
---|
142 | #$FFMPEG_BASE_PATH"/scripts_$EPLATFORM/make.sh" $FFMPEG_PATH $CONFIGURE_PATH $SYSROOT
|
---|
143 | echo "Skip ffmpeg build"
|
---|
144 | fi
|
---|
145 | }
|
---|
146 |
|
---|
147 | # rebuild ffmpeg libs, force rebuild
|
---|
148 | buildFFmpeg $FFMPEG_VERSION "false" "false"
|
---|
149 |
|
---|
150 | rm -rf $EXTEPLAYER3_OUT_FILE
|
---|
151 |
|
---|
152 | echo "FFMPEG_PATH = $FFMPEG_PATH"
|
---|
153 | if [ "$SYSROOT" != "" ];
|
---|
154 | then
|
---|
155 | SYSROOT_VAR="--sysroot=$SYSROOT"
|
---|
156 | else
|
---|
157 | SYSROOT_VAR=""
|
---|
158 | fi
|
---|
159 | "$CROSS_COMPILE"gcc -fdata-sections -ffunction-sections -Wl,--gc-sections -Os $CFLAGS $SYSROOT_VAR $LDFLAGS $CPPFLAGS -I"$CURR_PATH"/include -I$FFMPEG_PATH/usr/include/ -L$FFMPEG_PATH/usr/lib/ $SOURCE_FILES -o $EXTEPLAYER3_OUT_FILE -Wfatal-errors -lpthread -lavformat -lavcodec -lavutil -lswresample
|
---|
160 | "$CROSS_COMPILE"strip -s $EXTEPLAYER3_OUT_FILE
|
---|
161 |
|
---|
162 | exit 0
|
---|
163 |
|
---|
164 | FFMPEG_PACK_TMP=tmp/ffmpeg/tmp/ffmpeg"$FFMPEG_VERSION"_$EPLATFORM
|
---|
165 | rm -rf $FFMPEG_PACK_TMP
|
---|
166 | mkdir $FFMPEG_PACK_TMP
|
---|
167 |
|
---|
168 | cp -R tmp/ffmpeg/tmp/ffmpeg-"$FFMPEG_VERSION"/usr $FFMPEG_PACK_TMP"/usr"
|
---|
169 | cd $FFMPEG_PACK_TMP
|
---|
170 | rm -Rf usr/include
|
---|
171 | rm -Rf usr/share
|
---|
172 | rm -Rf usr/lib/pk*
|
---|
173 | echo ">>>>>>>>>>>>>>>>>>>>>>"
|
---|
174 | tar -zcvf ../ffmpeg"$FFMPEG_VERSION"_$EPLATFORM.tar.gz usr
|
---|
175 |
|
---|
176 |
|
---|