]> git.sesse.net Git - mlt/blob - src/modules/avformat/configure
set version to 0.8.0
[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.9.2"
7 libav_ver="0.8.2"
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=$(pkg-config --variable=prefix libavformat)
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         if [ "$static_ffmpeg" != "" ]
86         then 
87                 if [ -d "$static_ffmpeg" ]
88                 then
89                         echo "CFLAGS+=-DAVDATADIR=\\\"${static_ffmpeg}/ffpresets/\\\"" >> config.mak
90                         echo "CFLAGS+=-I$static_ffmpeg" >> config.mak
91                         echo "LDFLAGS+=-L$static_ffmpeg/libavformat -L$static_ffmpeg/libavcodec -L$static_ffmpeg/libavutil" >> config.mak
92                         [ $targetos = "Darwin" ] &&
93                                 echo "LDFLAGS+=-single_module" >> config.mak
94                         if [ "$swscale" != "" ]
95                         then
96                                 echo "LDFLAGS+=-L$static_ffmpeg/libswscale" >> config.mak
97                                 echo "SWSCALE=1" >> config.mak
98                         fi
99                         if [ "$devices" = "true" ]
100                         then
101                                 echo "LDFLAGS+=-L$static_ffmpeg/libavdevice" >> config.mak
102                         fi
103                         echo "LDFLAGS+=-Wl,-Bsymbolic" >> config.mak
104                         extra_libs="$extra_libs -lm -lz -lbz2"
105                         
106                         if [ "$vdpau" = "true" ]
107                         then
108                                 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
109                                 [ "$x11" = "0" -a "$?" = "0" ] && echo "VDPAU=1" >> config.mak
110                         fi
111                 else
112                         echo "avformat: Invalid path specified: $static_ffmpeg"
113                         touch ../disable-avformat
114                         echo 0
115                 fi
116         elif [ "$shared_ffmpeg" != "" ]
117         then
118                 echo "PREFIX=$shared_ffmpeg" >> config.mak
119                 case $targetos in
120                         MINGW32_NT-*)
121                                 echo "CFLAGS+=-DAVDATADIR=\\\"share/ffmpeg/\\\"" >> config.mak
122                         ;;
123                         *)
124                                 echo "CFLAGS+=-DAVDATADIR=\\\"${shared_ffmpeg}/share/ffmpeg/\\\"" >> config.mak
125                         ;;
126                 esac
127                 echo "CFLAGS+=$(pkg-config --cflags libavformat)" >> config.mak
128                 echo "LDFLAGS+=$(pkg-config --libs-only-L libavformat)" >> config.mak
129                 if [ "$devices" = "true" ]
130                 then
131                         echo "CFLAGS+=$(pkg-config --cflags libavdevice)" >> config.mak
132                         echo "LDFLAGS+=$(pkg-config --libs-only-L libavdevice)" >> config.mak
133                 fi
134                 avcodec_version=$(pkg-config --modversion libavcodec)
135                 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 ] )
136                 then
137                         echo "CFLAGS+=$(pkg-config --cflags libswscale)" >> config.mak
138                         echo "LDFLAGS+=$(pkg-config --libs-only-L libswscale)" >> config.mak
139                         echo "SWSCALE=1" >> config.mak
140                 fi
141                 
142                 if [ "$vdpau" = "true" ]
143                 then
144                         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
145                         [ "$x11" = "0" -a "$?" = "0" ] && echo "VDPAU=1" >> config.mak
146                 fi
147         else
148                 echo "- libavformat not found: disabling"
149                 touch ../disable-avformat
150                 exit 0
151         fi
152
153         echo "EXTRA_LIBS=$extra_libs" >> config.mak
154         echo "AVFORMAT_SUFFIX=$avformat_suffix" >> config.mak
155         [ "$codecs" = "true" ] && echo "CODECS=1" >> config.mak
156         [ "$filters" = "true" ] && echo "FILTERS=1" >> config.mak
157         [ "$devices" = "true" ] && echo "DEVICES=1" >> config.mak
158         exit 0
159
160 fi