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