]> git.sesse.net Git - mlt/blob - src/modules/avformat/configure
Add configure option --avformat-svn-version.
[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
66         for i in "$@"
67         do
68                 case $i in
69                         --avformat-static=* )   static_ffmpeg="${i#--avformat-static=}" ;;
70                         --avformat-shared=* )   shared_ffmpeg="${i#--avformat-shared=}" ;;
71                         --avformat-ldextra=* )  extra_libs="${i#--avformat-ldextra=}" ;;
72                         --avformat-svn )                svn_ffmpeg=true ;;
73                         --avformat-svn-extra=* ) svn_ffmpeg_extra="${i#--avformat-svn-extra=}" ;;
74                         --avformat-svn-version=* )      svn_rev="${i#--avformat-svn-version=}" ;;
75                         --avformat-cvs )                svn_ffmpeg=true ;;
76                         --avformat-suffix=* )   avformat_suffix="${i#--avformat-suffix=}" ;;
77                         --avformat-swscale )    swscale=true ;;
78                         --avformat-swscaler )   swscale=true ;;
79                         --avformat-no-codecs )  codecs=false ;;
80                         --avformat-no-filters ) filters=false ;;
81                 esac
82         done
83
84         if [ "$svn_ffmpeg" != "" ]
85         then
86                 if [ "$gpl" = "true" ]
87                 then
88                         enable_gpl="--enable-gpl"
89                         [ "$swscale" != "" ] && [ "$svn_rev" = "0.5" ] &&
90                                 enable_swscale="--enable-swscale"
91                 fi
92                 if [ ! -d "ffmpeg" ]
93                 then
94                         echo
95                         echo "Checking out ffmpeg/avformat revision $svn_rev - no password required"
96                         echo
97                         if [ "$svn_rev" = "0.5" ]; then
98                                 svn checkout svn://svn.mplayerhq.hu/ffmpeg/branches/$svn_rev ffmpeg
99                         else
100                                 svn checkout -r $svn_rev svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
101                         fi
102                 fi
103                 [ -d "ffmpeg" ] && ( cd ffmpeg ; ./configure $enable_gpl $enable_swscale $svn_ffmpeg_extra )
104                 #[ ! -f "ffmpeg/ffmpeg.patch" ] && ( cd ffmpeg ; cp ../ffmpeg.patch . ; patch -p0 < ffmpeg.patch )
105                 echo "CFLAGS+=-I`pwd`/ffmpeg -I`pwd`/ffmpeg/libavformat -I`pwd`/ffmpeg/libavcodec -I`pwd`/ffmpeg/libavutil -I`pwd`/ffmpeg/libavdevice" >> config.mak
106                 echo "LDFLAGS+=-L`pwd`/ffmpeg/libavformat -L`pwd`/ffmpeg/libavcodec -L`pwd`/ffmpeg/libavutil -L`pwd`/ffmpeg/libavdevice" >> config.mak
107                 if [ "$swscale" != "" ] || [ "$svn_rev" = "HEAD" ]
108                 then
109                         echo "CFLAGS+=-I`pwd`/ffmpeg/libswscale" >> config.mak
110                         echo "LDFLAGS+=-L`pwd`/ffmpeg/libswscale" >> config.mak
111                         echo "SWSCALE=1" >> config.mak
112                 fi
113                 [ $targetos = "Darwin" ] &&
114                         echo "LDFLAGS+=-single_module" >> config.mak
115                 echo "LOCAL_FFMPEG=1" >> config.mak
116                 echo "LDFLAGS+=-Wl,-Bsymbolic" >> config.mak
117                 extra_libs="$extra_libs -lm -lz -lbz2"
118         elif [ "$static_ffmpeg" != "" ]
119         then 
120                 if [ -d "$static_ffmpeg" ]
121                 then
122                         echo "CFLAGS+=-I$static_ffmpeg/libavformat -I$static_ffmpeg/libavcodec -I$static_ffmpeg/libavutil -I$static_ffmpeg/libavdevice" >> config.mak
123                         echo "LDFLAGS+=-L$static_ffmpeg/libavformat -L$static_ffmpeg/libavcodec -L$static_ffmpeg/libavutil -L$static_ffmpeg/libavdevice" >> config.mak
124                         [ $targetos = "Darwin" ] &&
125                                 echo "LDFLAGS+=-single_module" >> config.mak
126                         if [ "$swscale" != "" ]
127                         then
128                                 echo "CFLAGS+=-I$static_ffmpeg/libswscale" >> config.mak
129                                 echo "LDFLAGS+=-L$static_ffmpeg/libswscale" >> config.mak
130                                 echo "SWSCALE=1" >> config.mak
131                         fi
132                         echo "LDFLAGS+=-Wl,-Bsymbolic" >> config.mak
133                         extra_libs="$extra_libs -lm -lz -lbz2"
134                 else
135                         echo "avformat: Invalid path specified: $static_ffmpeg"
136                         touch ../disable-avformat
137                         echo 0
138                 fi
139         elif [ "$shared_ffmpeg" != "" ]
140         then
141                 echo "PREFIX=$shared_ffmpeg" >> config.mak
142                 echo "CFLAGS+=$(pkg-config --cflags libavformat) $TMP_CFLAGS" >> config.mak
143                 echo "LDFLAGS+=$(pkg-config --libs libavformat)" >> config.mak
144                 [ -d "$shared_ffmpeg/include/ffmpeg/libavformat" ] &&
145                         echo "CFLAGS+=-I$shared_ffmpeg/include/ffmpeg/libavformat -I$shared_ffmpeg/include/ffmpeg/libavcodec" >> config.mak
146                 [ -d "$shared_ffmpeg/include/libavformat" ] &&
147                         echo "CFLAGS+=-I$shared_ffmpeg/include/libavformat -I$shared_ffmpeg/include/libavcodec" >> config.mak
148                 avcodec_version=$(pkg-config --modversion libavcodec)
149                 if [ "$swscale" != "" ] || ( [ $(echo $avcodec_version | cut -d. -f1) -ge 52 ] && [ $(echo $avcodec_version | cut -d. -f2) -ge 21 ] )
150                 then
151                         [ -d "$shared_ffmpeg/include/ffmpeg/libswscale" ] &&
152                                 echo "CFLAGS+=-I$shared_ffmpeg/include/ffmpeg/libswscale" >> config.mak
153                         [ -d "$shared_ffmpeg/include/libswscale" ] &&
154                                 echo "CFLAGS+=-I$shared_ffmpeg/include/libswscale" >> config.mak
155                         echo "SWSCALE=1" >> config.mak
156                 fi
157         else
158                 echo "avformat: No build environment found. "
159                 echo "          Try configuring mlt with --avformat-svn."
160                 touch ../disable-avformat
161                 exit 0
162         fi
163
164         echo "EXTRA_LIBS=$extra_libs" >> config.mak
165         echo "AVFORMAT_SUFFIX=$avformat_suffix" >> config.mak
166         [ "$codecs" = "true" ] && echo "CODECS=1" >> config.mak
167         [ "$filters" = "true" ] && echo "FILTERS=1" >> config.mak
168         exit 0
169
170 fi