--avformat-swscale with --avformat-svn is only permitted with --enable-gpl
[melted] / src / modules / avformat / configure
1 #!/bin/sh
2
3
4 if [ "$help" = "1" ]
5 then
6         cat << EOF
7 FFMPEG/avformat options:
8
9   --avformat-svn          - Obtain ffmpeg from Subversion
10   --avformat-shared=path  - Link against a shared installation of ffmpeg (default)
11   --avformat-static=path  - Link against a static ffmpeg dev tree
12   --avformat-ldextra=libs - Provide additional libs to link with
13   --avformat-suffix=suff  - Specify a custom suffix for an ffmpeg shared build
14   --avformat-swscale      - Use ffmpeg libswcale instead of img_convert
15
16 EOF
17
18 else
19         targetos=$(uname -s)
20         case $targetos in
21         Darwin)
22                 export LIBSUF=.dylib
23                 ;;
24         Linux)
25                 export LIBSUF=.so
26                 ;;
27         *)
28                 ;;
29         esac
30                 
31         bits=$(uname -m)
32         case $bits in
33         x86_64)
34                 export LIBDIR=lib64
35                 ;;
36         *)
37                 export LIBDIR=lib
38                 ;;
39         esac
40
41         echo > config.mak
42
43         export static_ffmpeg=
44         export shared_ffmpeg=`which ffmpeg`
45         export extra_libs=
46         export svn_ffmpeg=
47         export avformat_suffix=
48         export swscale=
49
50         if [ "$shared_ffmpeg" != "" -a -f "$shared_ffmpeg" ]
51         then
52                 # Chop ffmpeg 
53                 shared_ffmpeg=`dirname $shared_ffmpeg`
54                 # Chop bin 
55                 shared_ffmpeg=`dirname $shared_ffmpeg`
56         fi
57
58         for i in "$@"
59         do
60                 case $i in
61                         --avformat-static=* )   static_ffmpeg="${i#--avformat-static=}" ;;
62                         --avformat-shared=* )   shared_ffmpeg="${i#--avformat-shared=}" ;;
63                         --avformat-ldextra=* )  extra_libs="${i#--avformat-ldextra=}" ;;
64                         --avformat-svn )                svn_ffmpeg=true ;;
65                         --avformat-cvs )                svn_ffmpeg=true ;;
66                         --avformat-suffix=* )   avformat_suffix="${i#--avformat-suffix=}" ;;
67                         --avformat-swscale )    swscale=true ;;
68                 esac
69         done
70
71         if [ "$svn_ffmpeg" != "" ]
72         then
73                 if [ "$gpl" = "true" ]
74                 then
75                         enable_gpl="--enable-gpl"
76                         if [ "$swscale" != "" ]
77                         then
78                                         enable_swscale="--enable-swscaler"
79                                         echo "SWSCALE=1" >> config.mak
80                         fi
81                 elif [ "$swscale" != "" ]
82                 then
83                         echo
84                         echo "ERROR        ERROR        ERROR        ERROR        ERROR        ERROR"
85                         echo "--enable-gpl is required to use --avformat-swscale with --avformat-svn!"
86                         echo
87                         exit
88                 fi
89                 if [ ! -d "ffmpeg" ]
90                 then
91                         echo
92                         echo "Checking out ffmpeg/avformat - no password required"
93                         echo
94                         svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
95                 fi
96                 [ -d "ffmpeg" ] && ( cd ffmpeg ; ./configure $enable_gpl $enable_swscale )
97                 #[ ! -f "ffmpeg/ffmpeg.patch" ] && ( cd ffmpeg ; cp ../ffmpeg.patch . ; patch -p0 < ffmpeg.patch )
98                 echo "CFLAGS+=-I`pwd`/ffmpeg/libavformat -I`pwd`/ffmpeg/libavcodec -I`pwd`/ffmpeg/libavutil -I`pwd`/ffmpeg/libswscale" >> config.mak
99                 echo "LDFLAGS+=-L`pwd`/ffmpeg/libavformat -L`pwd`/ffmpeg/libavcodec -L`pwd`/ffmpeg/libavutil -L`pwd`/ffmpeg/libswscale" >> config.mak
100                 [ $targetos = "Darwin" ] &&
101                         echo "LDFLAGS+=-single_module" >> config.mak
102                 echo "LOCAL_FFMPEG=1" >> config.mak
103                 extra_libs="$extra_libs -lz"
104         elif [ "$static_ffmpeg" != "" ]
105         then 
106                 if [ -d "$static_ffmpeg" ]
107                 then
108                         echo "CFLAGS+=-I$static_ffmpeg/libavformat -I$static_ffmpeg/libavcodec -I$static_ffmpeg/libavutil" >> config.mak
109                         echo "LDFLAGS+=-L$static_ffmpeg/libavformat -L$static_ffmpeg/libavcodec -L$static_ffmpeg/libavutil" >> config.mak
110                         [ $targetos = "Darwin" ] &&
111                                 echo "LDFLAGS+=-single_module" >> config.mak
112                         if [ "$swscale" != "" ]
113                         then
114                                 echo "CFLAGS+=-I$static_ffmpeg/libswscale" >> config.mak
115                                 echo "LDFLAGS+=-L$static_ffmpeg/libswscale" >> config.mak
116                                 echo "SWSCALE=1" >> config.mak
117                         fi
118                 else
119                         echo "avformat: Invalid path specified: $static_ffmpeg"
120                         touch ../disable-avformat
121                         echo 0
122                 fi
123         else 
124                 if [ -d "$shared_ffmpeg/include/ffmpeg" -a -f "$shared_ffmpeg/$LIBDIR/libavformat$avformat_suffix$LIBSUF" ]
125                 then
126                         echo "CFLAGS+=-I$shared_ffmpeg/include/ffmpeg " >> config.mak
127                         echo "LDFLAGS+=-L$shared_ffmpeg/$LIBDIR" >> config.mak
128                         [ "$swscale" != "" ] && echo "SWSCALE=1" >> config.mak
129                 else
130                         echo "avformat: No build environment found. "
131                         echo "          Try configuring mlt with --avformat-svn."
132                         touch ../disable-avformat
133                         exit 0
134                 fi
135         fi
136
137         echo "EXTRA_LIBS=$extra_libs" >> config.mak
138         echo "AVFORMAT_SUFFIX=$avformat_suffix" >> config.mak
139
140 cat << EOF >> ../producers.dat
141 avformat                libmltavformat$LIBSUF
142 EOF
143
144 cat << EOF >> ../filters.dat
145 avdeinterlace   libmltavformat$LIBSUF
146 avresample              libmltavformat$LIBSUF
147 avcolour_space  libmltavformat$LIBSUF
148 EOF
149
150 cat << EOF >> ../consumers.dat
151 avformat                libmltavformat$LIBSUF
152 EOF
153
154 fi
155