]> git.sesse.net Git - mlt/blob - src/modules/avformat/configure
9824d3362553855ef63cdcaa5c832730bde09829
[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 ffmpeg_ver="0.10.4"
7 libav_ver="0.8.3"
8 micro_version=$(echo $version | cut -d . -f 3)
9 odd_version=$(($micro_version % 2))
10 [ "$odd_version" -eq "1" ] && ffmpeg_ver="HEAD" && libav_ver="HEAD"
11
12 if [ "$help" = "1" ]
13 then
14         cat << EOF
15 FFmpeg/avformat options:
16
17   --avformat-shared=path  - Link against a shared installation of libavformat (default)
18   --avformat-static=path  - Link against a static build of libavformat
19   --avformat-ldextra=libs - Provide additional libs to link with
20   --avformat-swscale      - Use libswcale instead of img_convert (with --avformat-static)
21   --avformat-suffix=suff  - Specify a custom suffix
22   --avformat-no-codecs    - Disable the producer and consumer to avoid the codecs
23   --avformat-no-filters   - Disable the filters to make a codecs+muxers-only plugin
24   --avformat-no-devices   - Disable support for libavdevice
25   --avformat-vdpau        - Enable support for NVIDIA VDPAU
26
27   NOTE: The recommended version of FFmpeg is $ffmpeg_ver or libav $libav_ver.
28
29 EOF
30
31 else
32         targetos=$(uname -s)
33         case $targetos in
34         Darwin)
35                 export LIBSUF=.dylib
36                 ;;
37         Linux|FreeBSD|NetBSD)
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=
58         export extra_libs=
59         export avformat_suffix=
60         export swscale=
61         export codecs=true
62         export filters=true
63         export devices=true
64         export vdpau=false
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-suffix=* )   avformat_suffix="${i#--avformat-suffix=}" ;;
75                         --avformat-swscale )    swscale=true ;;
76                         --avformat-swscaler )   swscale=true ;;
77                         --avformat-no-codecs )  codecs=false ;;
78                         --avformat-no-filters ) filters=false ;;
79                         --avformat-no-devices ) devices=false ;;
80                         --avformat-no-vdpau )   vdpau=false ;;
81                         --avformat-vdpau )      vdpau=true ;;
82                 esac
83         done
84
85         : ${shared_ffmpeg:=$(pkg-config --variable=prefix libavformat${avformat_suffix})}
86
87         if [ "$static_ffmpeg" != "" ]
88         then 
89                 if [ -d "$static_ffmpeg" ]
90                 then
91                         echo "CFLAGS+=-DAVDATADIR=\\\"${static_ffmpeg}/ffpresets/\\\"" >> config.mak
92                         echo "CFLAGS+=-I$static_ffmpeg" >> config.mak
93                         echo "LDFLAGS+=-L$static_ffmpeg/libavformat -L$static_ffmpeg/libavcodec -L$static_ffmpeg/libavutil" >> config.mak
94                         [ $targetos = "Darwin" ] &&
95                                 echo "LDFLAGS+=-single_module" >> config.mak
96                         if [ "$swscale" != "" ]
97                         then
98                                 echo "LDFLAGS+=-L$static_ffmpeg/libswscale" >> config.mak
99                                 echo "SWSCALE=1" >> config.mak
100                         fi
101                         if [ "$devices" = "true" ]
102                         then
103                                 echo "LDFLAGS+=-L$static_ffmpeg/libavdevice" >> config.mak
104                         fi
105                         echo "LDFLAGS+=-Wl,-Bsymbolic" >> config.mak
106                         extra_libs="$extra_libs -lm -lz -lbz2"
107                         
108                         if [ "$vdpau" = "true" ]
109                         then
110                                 printf "#include <libavcodec/vdpau.h>\n int main(){ VdpBitstreamBuffer test; test.struct_version; return 0;}" | $CC -I"$static_ffmpeg" $CFLAGS -c -x c -  >/dev/null 2>&1
111                                 [ "$x11" = "0" -a "$?" = "0" ] && echo "VDPAU=1" >> config.mak
112                         fi
113                 else
114                         echo "avformat: Invalid path specified: $static_ffmpeg"
115                         touch ../disable-avformat
116                         echo 0
117                 fi
118         elif [ "$shared_ffmpeg" != "" ]
119         then
120                 echo "PREFIX=$shared_ffmpeg" >> config.mak
121                 case $targetos in
122                         MINGW32_NT-*)
123                                 echo "CFLAGS+=-DAVDATADIR=\\\"share/ffmpeg/\\\"" >> config.mak
124                         ;;
125                         *)
126                                 echo "CFLAGS+=-DAVDATADIR=\\\"${shared_ffmpeg}/share/ffmpeg${avformat_suffix}/\\\"" >> config.mak
127                         ;;
128                 esac
129                 echo "CFLAGS+=$(pkg-config --cflags libavformat${avformat_suffix})" >> config.mak
130                 echo "LDFLAGS+=$(pkg-config --libs-only-L libavformat${avformat_suffix})" >> config.mak
131                 if [ "$devices" = "true" ]
132                 then
133                         echo "CFLAGS+=$(pkg-config --cflags libavdevice${avformat_suffix})" >> config.mak
134                         echo "LDFLAGS+=$(pkg-config --libs-only-L libavdevice${avformat_suffix})" >> config.mak
135                 fi
136                 avcodec_version=$(pkg-config --modversion libavcodec${avformat_suffix})
137                 if [ "$swscale" != "" ] || [ $(echo $avcodec_version | cut -d. -f1) -gt 52 ] || ( [ $(echo $avcodec_version | cut -d. -f1) -ge 52 ] && [ $(echo $avcodec_version | cut -d. -f2) -ge 21 ] )
138                 then
139                         echo "CFLAGS+=$(pkg-config --cflags libswscale${avformat_suffix})" >> config.mak
140                         echo "LDFLAGS+=$(pkg-config --libs-only-L libswscale${avformat_suffix})" >> config.mak
141                         echo "SWSCALE=1" >> config.mak
142                 fi
143                 
144                 if [ "$vdpau" = "true" ]
145                 then
146                         printf "#include <libavcodec/vdpau.h>\n int main(){ VdpBitstreamBuffer test; test.struct_version; return 0;}" | $CC $(pkg-config --cflags libavformat${avformat_suffix}) -I"$shared_ffmpeg/include" $CFLAGS -c -x c -  >/dev/null 2>&1
147                         [ "$x11" = "0" -a "$?" = "0" ] && echo "VDPAU=1" >> config.mak
148                 fi
149         else
150                 echo "- libavformat not found: disabling"
151                 touch ../disable-avformat
152                 exit 0
153         fi
154
155         echo "EXTRA_LIBS=$extra_libs" >> config.mak
156         echo "AVFORMAT_SUFFIX=$avformat_suffix" >> config.mak
157         [ "$codecs" = "true" ] && echo "CODECS=1" >> config.mak
158         [ "$filters" = "true" ] && echo "FILTERS=1" >> config.mak
159         [ "$devices" = "true" ] && echo "DEVICES=1" >> config.mak
160         exit 0
161
162 fi