]> git.sesse.net Git - mlt/blob - src/modules/avformat/configure
863c5f409616adced253806055f685f102fe0a42
[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="19873"
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
27   NOTE: The recommended version of FFmpeg is $([ "$svn_rev" = "0.5" ] && echo $svn_rev || echo SVN-r$svn_rev).
28
29 EOF
30
31 else
32         targetos=$(uname -s)
33         case $targetos in
34         Darwin)
35                 export LIBSUF=.dylib
36                 ;;
37         Linux|FreeBSD)
38                 export LIBSUF=.so
39                 ;;
40         *)
41                 ;;
42         esac
43                 
44         bits=$(uname -m)
45         case $bits in
46         x86_64)
47                 [ -d /usr/lib/lib64 ] && export LIBDIR=lib64 || export LIBDIR=lib
48                 ;;
49         *)
50                 export LIBDIR=lib
51                 ;;
52         esac
53
54         echo > config.mak
55
56         export static_ffmpeg=
57         export shared_ffmpeg=$(pkg-config --variable=prefix libavformat)
58         export extra_libs=
59         export svn_ffmpeg=
60         export svn_ffmpeg_extra=
61         export avformat_suffix=
62         export swscale=
63         export codecs=true
64         export filters=true
65         pkg-config x11 > /dev/null 2>&1
66         export x11=$?
67
68         for i in "$@"
69         do
70                 case $i in
71                         --avformat-static=* )   static_ffmpeg="${i#--avformat-static=}" ;;
72                         --avformat-shared=* )   shared_ffmpeg="${i#--avformat-shared=}" ;;
73                         --avformat-ldextra=* )  extra_libs="${i#--avformat-ldextra=}" ;;
74                         --avformat-svn )                svn_ffmpeg=true ;;
75                         --avformat-svn-extra=* ) svn_ffmpeg_extra="${i#--avformat-svn-extra=}" ;;
76                         --avformat-svn-version=* )      svn_rev="${i#--avformat-svn-version=}" ;;
77                         --avformat-cvs )                svn_ffmpeg=true ;;
78                         --avformat-suffix=* )   avformat_suffix="${i#--avformat-suffix=}" ;;
79                         --avformat-swscale )    swscale=true ;;
80                         --avformat-swscaler )   swscale=true ;;
81                         --avformat-no-codecs )  codecs=false ;;
82                         --avformat-no-filters ) filters=false ;;
83                 esac
84         done
85
86         if [ "$svn_ffmpeg" != "" ]
87         then
88                 if [ "$gpl" = "true" ]
89                 then
90                         enable_gpl="--enable-gpl"
91                         [ "$swscale" != "" ] && [ "$svn_rev" = "0.5" ] &&
92                                 enable_swscale="--enable-swscale"
93                 fi
94                 if [ ! -d "ffmpeg" ]
95                 then
96                         echo
97                         echo "Checking out ffmpeg/avformat revision $svn_rev - no password required"
98                         echo
99                         if [ "$svn_rev" = "0.5" ]; then
100                                 svn checkout svn://svn.mplayerhq.hu/ffmpeg/branches/$svn_rev ffmpeg
101                         else
102                                 svn checkout -r $svn_rev svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
103                         fi
104                 fi
105                 [ -d "ffmpeg" ] && ( cd ffmpeg ; ./configure $enable_gpl $enable_swscale $svn_ffmpeg_extra )
106                 #[ ! -f "ffmpeg/ffmpeg.patch" ] && ( cd ffmpeg ; cp ../ffmpeg.patch . ; patch -p0 < ffmpeg.patch )
107                 echo "CFLAGS+=-I`pwd`/ffmpeg -I`pwd`/ffmpeg/libavformat -I`pwd`/ffmpeg/libavcodec -I`pwd`/ffmpeg/libavutil -I`pwd`/ffmpeg/libavdevice" >> config.mak
108                 echo "LDFLAGS+=-L`pwd`/ffmpeg/libavformat -L`pwd`/ffmpeg/libavcodec -L`pwd`/ffmpeg/libavutil -L`pwd`/ffmpeg/libavdevice" >> config.mak
109                 if [ "$swscale" != "" ] || [ "$svn_rev" = "HEAD" ]
110                 then
111                         echo "CFLAGS+=-I`pwd`/ffmpeg/libswscale" >> config.mak
112                         echo "LDFLAGS+=-L`pwd`/ffmpeg/libswscale" >> config.mak
113                         echo "SWSCALE=1" >> config.mak
114                 fi
115                 [ $targetos = "Darwin" ] &&
116                         echo "LDFLAGS+=-single_module" >> config.mak
117                 echo "LOCAL_FFMPEG=1" >> config.mak
118                 echo "LDFLAGS+=-Wl,-Bsymbolic" >> config.mak
119                 extra_libs="$extra_libs -lm -lz -lbz2"
120                 
121                 echo -e "#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
122                 [ "$x11" = "0" -a "$?" = "0" ] && echo "VDPAU=1" >> config.mak
123         elif [ "$static_ffmpeg" != "" ]
124         then 
125                 if [ -d "$static_ffmpeg" ]
126                 then
127                         echo "CFLAGS+=-I$static_ffmpeg/libavformat -I$static_ffmpeg/libavcodec -I$static_ffmpeg/libavutil -I$static_ffmpeg/libavdevice" >> config.mak
128                         echo "LDFLAGS+=-L$static_ffmpeg/libavformat -L$static_ffmpeg/libavcodec -L$static_ffmpeg/libavutil -L$static_ffmpeg/libavdevice" >> config.mak
129                         [ $targetos = "Darwin" ] &&
130                                 echo "LDFLAGS+=-single_module" >> config.mak
131                         if [ "$swscale" != "" ]
132                         then
133                                 echo "CFLAGS+=-I$static_ffmpeg/libswscale" >> config.mak
134                                 echo "LDFLAGS+=-L$static_ffmpeg/libswscale" >> config.mak
135                                 echo "SWSCALE=1" >> config.mak
136                         fi
137                         echo "LDFLAGS+=-Wl,-Bsymbolic" >> config.mak
138                         extra_libs="$extra_libs -lm -lz -lbz2"
139                         
140                         echo -e "#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
141                         [ "$x11" = "0" -a "$?" = "0" ] && echo "VDPAU=1" >> config.mak
142                 else
143                         echo "avformat: Invalid path specified: $static_ffmpeg"
144                         touch ../disable-avformat
145                         echo 0
146                 fi
147         elif [ "$shared_ffmpeg" != "" ]
148         then
149                 echo "PREFIX=$shared_ffmpeg" >> config.mak
150                 echo "CFLAGS+=$(pkg-config --cflags libavformat) $TMP_CFLAGS" >> config.mak
151                 echo "LDFLAGS+=$(pkg-config --libs libavformat)" >> config.mak
152                 [ -d "$shared_ffmpeg/include/ffmpeg/libavformat" ] &&
153                         echo "CFLAGS+=-I$shared_ffmpeg/include/ffmpeg/libavformat -I$shared_ffmpeg/include/ffmpeg/libavcodec" >> config.mak
154                 [ -d "$shared_ffmpeg/include/libavformat" ] &&
155                         echo "CFLAGS+=-I$shared_ffmpeg/include/libavformat -I$shared_ffmpeg/include/libavcodec" >> config.mak
156                 avcodec_version=$(pkg-config --modversion libavcodec)
157                 if [ "$swscale" != "" ] || ( [ $(echo $avcodec_version | cut -d. -f1) -ge 52 ] && [ $(echo $avcodec_version | cut -d. -f2) -ge 21 ] )
158                 then
159                         [ -d "$shared_ffmpeg/include/ffmpeg/libswscale" ] &&
160                                 echo "CFLAGS+=-I$shared_ffmpeg/include/ffmpeg/libswscale" >> config.mak
161                         [ -d "$shared_ffmpeg/include/libswscale" ] &&
162                                 echo "CFLAGS+=-I$shared_ffmpeg/include/libswscale" >> config.mak
163                         echo "SWSCALE=1" >> config.mak
164                 fi
165                 
166                 echo -e "#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
167                 [ "$x11" = "0" -a "$?" = "0" ] && echo "VDPAU=1" >> config.mak
168         else
169                 echo "avformat: No build environment found. "
170                 echo "          Try configuring mlt with --avformat-svn."
171                 touch ../disable-avformat
172                 exit 0
173         fi
174
175         echo "EXTRA_LIBS=$extra_libs" >> config.mak
176         echo "AVFORMAT_SUFFIX=$avformat_suffix" >> config.mak
177         [ "$codecs" = "true" ] && echo "CODECS=1" >> config.mak
178         [ "$filters" = "true" ] && echo "FILTERS=1" >> config.mak
179         exit 0
180
181 fi