]> git.sesse.net Git - mlt/blob - src/modules/avformat/configure
654133b768f293aa81a1c466b6018bbe253d37cc
[mlt] / src / modules / avformat / configure
1 #!/bin/sh
2
3 # Determine whether to recommend/use the HEAD revision of FFmpeg (unreleased)
4 # or a specific revision based upon whether the last digit of our version
5 # is even or odd. An odd MLT version number always represents unreleased.
6 svn_rev="0.6.1"
7 micro_version=$(echo $version | cut -d . -f 3)
8 odd_version=$(($micro_version % 2))
9 [ "$odd_version" -eq "1" ] && svn_rev="HEAD"
10
11 if [ "$help" = "1" ]
12 then
13         cat << EOF
14 FFmpeg/avformat options:
15
16   --avformat-svn          - Obtain FFmpeg from its Subversion repository
17   --avformat-svn-version  - Specify a particular revision for --avformat-svn
18   --avformat-svn-extra    - Add extra configure options for --avformat-svn
19   --avformat-shared=path  - Link against a shared installation of FFmpeg (default)
20   --avformat-static=path  - Link against a static FFmpeg development tree
21   --avformat-ldextra=libs - Provide additional libs to link with
22   --avformat-suffix=suff  - Specify a custom suffix for a shared build of FFmpeg
23   --avformat-swscale      - Use libswcale instead of img_convert
24   --avformat-no-codecs    - Disable the producer and consumer to avoid the FFmpeg codecs
25   --avformat-no-filters   - Disable the filters to make a codecs+muxers-only plugin
26   --avformat-no-devices   - Disable support for libavdevice
27   --avformat-no-vdpau     - Disable support for NVIDIA VDPAU
28
29   NOTE: The recommended version of FFmpeg is $([ "$svn_rev" = "0.6.1" ] && echo $svn_rev || echo SVN-r$svn_rev).
30
31 EOF
32
33 else
34         targetos=$(uname -s)
35         case $targetos in
36         Darwin)
37                 export LIBSUF=.dylib
38                 ;;
39         Linux|FreeBSD)
40                 export LIBSUF=.so
41                 ;;
42         *)
43                 ;;
44         esac
45                 
46         bits=$(uname -m)
47         case $bits in
48         x86_64)
49                 [ -d /usr/lib/lib64 ] && export LIBDIR=lib64 || export LIBDIR=lib
50                 ;;
51         *)
52                 export LIBDIR=lib
53                 ;;
54         esac
55
56         echo > config.mak
57
58         export static_ffmpeg=
59         export shared_ffmpeg=$(pkg-config --variable=prefix libavformat)
60         export extra_libs=
61         export svn_ffmpeg=
62         export svn_ffmpeg_extra=
63         export avformat_suffix=
64         export swscale=
65         export codecs=true
66         export filters=true
67         export devices=true
68         export vdpau=true
69         pkg-config x11 > /dev/null 2>&1
70         export x11=$?
71
72         for i in "$@"
73         do
74                 case $i in
75                         --avformat-static=* )   static_ffmpeg="${i#--avformat-static=}" ;;
76                         --avformat-shared=* )   shared_ffmpeg="${i#--avformat-shared=}" ;;
77                         --avformat-ldextra=* )  extra_libs="${i#--avformat-ldextra=}" ;;
78                         --avformat-svn )                svn_ffmpeg=true ;;
79                         --avformat-svn-extra=* ) svn_ffmpeg_extra="${i#--avformat-svn-extra=}" ;;
80                         --avformat-svn-version=* )      svn_rev="${i#--avformat-svn-version=}" ;;
81                         --avformat-cvs )                svn_ffmpeg=true ;;
82                         --avformat-suffix=* )   avformat_suffix="${i#--avformat-suffix=}" ;;
83                         --avformat-swscale )    swscale=true ;;
84                         --avformat-swscaler )   swscale=true ;;
85                         --avformat-no-codecs )  codecs=false ;;
86                         --avformat-no-filters ) filters=false ;;
87                         --avformat-no-devices ) devices=false ;;
88                         --avformat-no-vdpau )   vdpau=false ;;
89                 esac
90         done
91
92         if [ "$svn_ffmpeg" != "" ]
93         then
94                 if [ "$gpl" = "true" ]  
95                 then
96                         enable_gpl="--enable-gpl"
97                         [ "$swscale" != "" ] && [ "$svn_rev" = "0.5" ] &&
98                                 enable_swscale="--enable-swscale"
99                 fi
100                 if [ ! -d "ffmpeg" ]
101                 then
102                         echo
103                         echo "Checking out ffmpeg/avformat revision $svn_rev - no password required"
104                         echo
105                         if [ "$svn_rev" = "0.6.1" ] || [ "$svn_rev" = "0.6" ] || [ "$svn_rev" = "0.5" ]
106                         then
107                                 svn checkout svn://svn.mplayerhq.hu/ffmpeg/branches/$svn_rev ffmpeg
108                         else
109                                 svn checkout -r $svn_rev svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
110                         fi
111                 fi
112                 [ "$devices" = "false" ] && disable_devices="--disable-devices"
113                 [ -d "ffmpeg" ] && ( cd ffmpeg ; ./configure $enable_gpl $disable_devices $enable_swscale $svn_ffmpeg_extra --extra-cflags=-fPIC )
114                 #[ ! -f "ffmpeg/ffmpeg.patch" ] && ( cd ffmpeg ; cp ../ffmpeg.patch . ; patch -p0 < ffmpeg.patch )
115                 echo "CFLAGS+=-DAVDATADIR=\\\"${prefix}/share/ffmpeg/\\\"" >> config.mak
116                 echo "CFLAGS+=-I`pwd`/ffmpeg" >> config.mak
117                 echo "LDFLAGS+=-L`pwd`/ffmpeg/libavformat -L`pwd`/ffmpeg/libavcodec -L`pwd`/ffmpeg/libavutil" >> config.mak
118                 if [ "$swscale" != "" ] || [ "$svn_rev" = "HEAD" ] || [ "$svn_rev" = "0.6.1" ] || [ "$svn_rev" = "0.6" ] || [ "$svn_rev" = "0.5" ]
119                 then
120                         echo "LDFLAGS+=-L`pwd`/ffmpeg/libswscale" >> config.mak
121                         echo "SWSCALE=1" >> config.mak
122                 fi
123                 if [ "$devices" = "true" ]
124                 then
125                         echo "LDFLAGS+=-L`pwd`/ffmpeg/libavdevice" >> config.mak
126                 fi
127                 [ $targetos = "Darwin" ] &&
128                         echo "LDFLAGS+=-single_module" >> config.mak
129                 echo "LOCAL_FFMPEG=1" >> config.mak
130                 echo "LDFLAGS+=-Wl,-Bsymbolic" >> config.mak
131                 extra_libs="$extra_libs -lm -lz -lbz2"
132                 
133                 if [ "$vdpau" = "true" ]
134                 then
135                         printf "#include <libavcodec/vdpau.h>\n int main(){ VdpBitstreamBuffer test; test.struct_version; return 0;}" | gcc -I"`pwd`/ffmpeg" $CFLAGS -c -x c -  >/dev/null 2>&1
136                         [ "$x11" = "0" -a "$?" = "0" ] && echo "VDPAU=1" >> config.mak
137                 fi
138         elif [ "$static_ffmpeg" != "" ]
139         then 
140                 if [ -d "$static_ffmpeg" ]
141                 then
142                         echo "CFLAGS+=-DAVDATADIR=\\\"${static_ffmpeg}/ffpresets/\\\"" >> config.mak
143                         echo "CFLAGS+=-I$static_ffmpeg" >> config.mak
144                         echo "LDFLAGS+=-L$static_ffmpeg/libavformat -L$static_ffmpeg/libavcodec -L$static_ffmpeg/libavutil" >> config.mak
145                         [ $targetos = "Darwin" ] &&
146                                 echo "LDFLAGS+=-single_module" >> config.mak
147                         if [ "$swscale" != "" ]
148                         then
149                                 echo "LDFLAGS+=-L$static_ffmpeg/libswscale" >> config.mak
150                                 echo "SWSCALE=1" >> config.mak
151                         fi
152                         if [ "$devices" = "true" ]
153                         then
154                                 echo "LDFLAGS+=-L$static_ffmpeg/libavdevice" >> config.mak
155                         fi
156                         echo "LDFLAGS+=-Wl,-Bsymbolic" >> config.mak
157                         extra_libs="$extra_libs -lm -lz -lbz2"
158                         
159                         if [ "$vdpau" = "true" ]
160                         then
161                                 printf "#include <libavcodec/vdpau.h>\n int main(){ VdpBitstreamBuffer test; test.struct_version; return 0;}" | gcc -I"$static_ffmpeg" $CFLAGS -c -x c -  >/dev/null 2>&1
162                                 [ "$x11" = "0" -a "$?" = "0" ] && echo "VDPAU=1" >> config.mak
163                         fi
164                 else
165                         echo "avformat: Invalid path specified: $static_ffmpeg"
166                         touch ../disable-avformat
167                         echo 0
168                 fi
169         elif [ "$shared_ffmpeg" != "" ]
170         then
171                 echo "PREFIX=$shared_ffmpeg" >> config.mak
172                 echo "CFLAGS+=-DAVDATADIR=\\\"${shared_ffmpeg}/share/ffmpeg/\\\"" >> config.mak
173                 echo "CFLAGS+=$(pkg-config --cflags libavformat)" >> config.mak
174                 echo "LDFLAGS+=$(pkg-config --libs-only-L libavformat)" >> config.mak
175                 if [ "$devices" = "true" ]
176                 then
177                         echo "CFLAGS+=$(pkg-config --cflags libavdevice)" >> config.mak
178                         echo "LDFLAGS+=$(pkg-config --libs-only-L libavdevice)" >> config.mak
179                 fi
180                 avcodec_version=$(pkg-config --modversion libavcodec)
181                 if [ "$swscale" != "" ] || ( [ $(echo $avcodec_version | cut -d. -f1) -ge 52 ] && [ $(echo $avcodec_version | cut -d. -f2) -ge 21 ] )
182                 then
183                         echo "CFLAGS+=$(pkg-config --cflags libswscale)" >> config.mak
184                         echo "LDFLAGS+=$(pkg-config --libs-only-L libswscale)" >> config.mak
185                         echo "SWSCALE=1" >> config.mak
186                 fi
187                 
188                 if [ "$vdpau" = "true" ]
189                 then
190                         printf "#include <libavcodec/vdpau.h>\n int main(){ VdpBitstreamBuffer test; test.struct_version; return 0;}" | gcc -I"$(pkg-config --cflags libavformat)" -I"$shared_ffmpeg/include" $CFLAGS -c -x c -  >/dev/null 2>&1
191                         [ "$x11" = "0" -a "$?" = "0" ] && echo "VDPAU=1" >> config.mak
192                 fi
193         else
194                 echo "avformat: No build environment found. "
195                 echo "          Try configuring mlt with --avformat-svn."
196                 touch ../disable-avformat
197                 exit 0
198         fi
199
200         echo "EXTRA_LIBS=$extra_libs" >> config.mak
201         echo "AVFORMAT_SUFFIX=$avformat_suffix" >> config.mak
202         [ "$codecs" = "true" ] && echo "CODECS=1" >> config.mak
203         [ "$filters" = "true" ] && echo "FILTERS=1" >> config.mak
204         [ "$devices" = "true" ] && echo "DEVICES=1" >> config.mak
205         exit 0
206
207 fi