avformat/configure: fix compiling against shared ffmpeg due to changes in ffmpeg...
[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-swscale"
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 -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                 echo "LDFLAGS+=-Wl,-Bsymbolic" >> config.mak
100                 extra_libs="$extra_libs -lz"
101         elif [ "$static_ffmpeg" != "" ]
102         then 
103                 if [ -d "$static_ffmpeg" ]
104                 then
105                         echo "CFLAGS+=-I$static_ffmpeg/libavformat -I$static_ffmpeg/libavcodec -I$static_ffmpeg/libavutil -I$static_ffmpeg/libavdevice" >> config.mak
106                         echo "LDFLAGS+=-L$static_ffmpeg/libavformat -L$static_ffmpeg/libavcodec -L$static_ffmpeg/libavutil -L$static_ffmpeg/libavdevice" >> config.mak
107                         [ $targetos = "Darwin" ] &&
108                                 echo "LDFLAGS+=-single_module" >> config.mak
109                         if [ "$swscale" != "" ]
110                         then
111                                 echo "CFLAGS+=-I$static_ffmpeg/libswscale" >> config.mak
112                                 echo "LDFLAGS+=-L$static_ffmpeg/libswscale" >> config.mak
113                                 echo "SWSCALE=1" >> config.mak
114                         fi
115                         echo "LDFLAGS+=-Wl,-Bsymbolic" >> config.mak
116                         extra_libs="$extra_libs -lz"
117                 else
118                         echo "avformat: Invalid path specified: $static_ffmpeg"
119                         touch ../disable-avformat
120                         echo 0
121                 fi
122         elif [ "$shared_ffmpeg" != "" ]
123         then
124                 echo "PREFIX=$shared_ffmpeg" >> config.mak
125                 echo "CFLAGS+=$(pkg-config --cflags libavformat) $TMP_CFLAGS" >> config.mak
126                 echo "LDFLAGS+=$(pkg-config --libs libavformat)" >> config.mak
127                 [ -d "$shared_ffmpeg/include/libavformat" ] &&
128                         echo "CFLAGS+=-I$shared_ffmpeg/include/libavformat -I$shared_ffmpeg/include/libavcodec" >> config.mak
129                 if [ "$swscale" != "" ]
130                 then
131                         echo "CFLAGS+=-I$shared_ffmpeg/include/libswscale" >> config.mak
132                         echo "SWSCALE=1" >> config.mak
133                 fi
134         else
135                 echo "avformat: No build environment found. "
136                 echo "          Try configuring mlt with --avformat-svn."
137                 touch ../disable-avformat
138                 exit 0
139         fi
140
141         echo "EXTRA_LIBS=$extra_libs" >> config.mak
142         echo "AVFORMAT_SUFFIX=$avformat_suffix" >> config.mak
143
144 fi