Build modification to ffmpeg/avformat
[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-cvs          - Obtain ffmpeg from CVS
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
14 EOF
15
16 else
17         targetos=$(uname -s)
18         case $targetos in
19         Darwin)
20                 export LIBSUF=.dylib
21                 ;;
22         Linux)
23                 export LIBSUF=.so
24                 ;;
25         *)
26                 ;;
27         esac
28                 
29         echo > config.mak
30
31         export static_ffmpeg=
32         export shared_ffmpeg=`whereis ffmpeg | cut -f 2 -d' '`
33         export extra_libs=
34         export cvs_ffmpeg=
35         export avformat_suffix=
36
37         if [ "$shared_ffmpeg" != "" ]
38         then
39                 # Chop ffmpeg 
40                 shared_ffmpeg=`dirname $shared_ffmpeg`
41                 # Chop bin 
42                 shared_ffmpeg=`dirname $shared_ffmpeg`
43         fi
44
45         for i in "$@"
46         do
47                 case $i in
48                         --avformat-static=* )   static_ffmpeg="${i#--avformat-static=}" ;;
49                         --avformat-shared=* )   shared_ffmpeg="${i#--avformat-shared=}" ;;
50                         --avformat-ldextra=* )  extra_libs="${i#--avformat-ldextra=}" ;;
51                         --avformat-cvs )                cvs_ffmpeg=true ;;
52                         --avformat-suffix=* )   avformat_suffix="${i#--avformat-suffix=}" ;;
53                 esac
54         done
55
56         if [ "$cvs_ffmpeg" != "" ]
57         then
58                 [ ! -d "ffmpeg" ] && ( 
59                         echo
60                         echo "Checking out ffmpeg/avformat - no password required"
61                         echo
62                         cvs -z9 -d:pserver:anonymous@mplayerhq.hu:/cvsroot/ffmpeg login
63                         cvs -z9 -d:pserver:anonymous@mplayerhq.hu:/cvsroot/ffmpeg co ffmpeg
64                 )
65                 [ -d "ffmpeg" ] && ( cd ffmpeg ; ./configure --enable-shared --build-suffix="$avformat_suffix" )
66                 #[ ! -f "ffmpeg/ffmpeg.patch" ] && ( cd ffmpeg ; cp ../ffmpeg.patch . ; patch -p0 < ffmpeg.patch )
67                 echo "CFLAGS+=-I`pwd`/ffmpeg/libavformat -I`pwd`/ffmpeg/libavcodec" >> config.mak
68                 echo "LOCAL_FFMPEG=1" >> config.mak
69                 extra_libs="$extra_libs -lz"
70         elif [ "$static_ffmpeg" != "" ]
71         then 
72                 if [ -d "$static_ffmpeg" ]
73                 then
74                         echo "CFLAGS+=-I$static_ffmpeg/libavformat -I$static_ffmpeg/libavcodec" >> config.mak
75                         echo "LDFLAGS+=-L$static_ffmpeg/libavformat -L$static_ffmpeg/libavcodec" >> config.mak
76                         [ $targetos = "Darwin" ] &&
77                                 echo "LDFLAGS+=-single_module" >> config.mak
78                 else
79                         echo "avformat: Invalid path specified: $static_ffmpeg"
80                         touch ../disable-avformat
81                         echo 0
82                 fi
83         else 
84                 if [ -d "$shared_ffmpeg/include/ffmpeg" -a -f "$shared_ffmpeg/lib/libavformat.so" ]
85                 then
86                         echo "CFLAGS+=-I$shared_ffmpeg/include/ffmpeg " >> config.mak
87                         echo "LDFLAGS+=-L$shared_ffmpeg/lib" >> config.mak
88                 else
89                         echo "avformat: No build environment found. "
90                         echo "          Try configuring mlt with --avformat-cvs."
91                         touch ../disable-avformat
92                         exit 0
93                 fi
94         fi
95
96         echo "EXTRA_LIBS=$extra_libs" >> config.mak
97         echo "AVFORMAT_SUFFIX=$avformat_suffix" >> config.mak
98
99 cat << EOF >> ../producers.dat
100 avformat                libmltavformat$LIBSUF
101 EOF
102
103 cat << EOF >> ../filters.dat
104 avdeinterlace   libmltavformat$LIBSUF
105 avresample              libmltavformat$LIBSUF
106 avcolour_space  libmltavformat$LIBSUF
107 EOF
108
109 cat << EOF >> ../consumers.dat
110 avformat                libmltavformat$LIBSUF
111 EOF
112
113 fi
114