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