]> git.sesse.net Git - mlt/blob - configure
producer_avformat.c: fix build on older versions of ffmpeg; whitespace cleanup
[mlt] / configure
1 #!/bin/sh
2
3 export version=0.3.5
4 export soversion=1
5
6 show_help()
7 {
8         cat << EOF
9 Non-autotool config script for MLT.
10
11 Help options:
12
13   --help                  - this information
14
15 General build options:
16
17   --prefix=directory      - install prefix for path (default: $prefix)
18   --libdir=directory      - lib directory (default: $prefix/lib)
19   --enable-gpl            - Enable GPL components
20   --disable-debug         - Compile without debug support (default: on)
21   --disable-mmx           - Compile without MMX support (default: on)
22   --disable-sse           - Compile without SSE support (default: on)
23   --cpu='cpu'             - Compile for a specific CPU/architectre (default: none)
24
25 Module disables options:
26
27 EOF
28
29         for i in src/modules/*
30         do
31                 [ -d $i ] && [ "`basename $i`" != "CVS" ] && echo `basename $i` `[ -f $i/gpl ] && echo [GPL]`
32         done |
33         awk '{ printf( "  --disable-%-14.14s- Disable the %s module %s\n", $1, $1, $2 ); }'
34
35         echo
36         echo "  NOTE: libraries marked [GPL] will not be built unless --enable-gpl is stipulated."
37         echo
38 }
39
40 build_config()
41 {
42         (
43                 echo "version=$version"
44                 echo "soversion=$soversion"
45                 echo "prefix=$prefix"
46                 echo "libdir=$libdir"
47                 echo "bindir=$prefix/bin"
48                 echo "targetos=$targetos"
49
50                 [ "$mmx" = "true" ] && 
51                 echo "MMX_FLAGS=-DUSE_MMX"
52
53                 [ "$sse" = "true" ] && 
54                 echo "SSE_FLAGS=-DUSE_SSE"
55
56                 [ "$debug" = "true" ] && 
57                 echo "DEBUG_FLAGS=-g"
58
59                 echo "LARGE_FILE=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE"
60
61                 [ "$cpu" != "" ] &&
62                 echo "TARGETARCH=-march=$cpu" &&
63                 echo "TARGETCPU=-mcpu=$cpu"
64                 echo "OPTIMISATIONS=-O3 -pipe -fomit-frame-pointer"
65
66                 echo "CFLAGS+=-Wall -fPIC -DPIC \$(TARGETARCH) \$(TARGETCPU) \$(OPTIMISATIONS) \$(MMX_FLAGS) \$(SSE_FLAGS) \$(DEBUG_FLAGS) \$(LARGE_FILE)"
67
68                 case $targetos in
69                 Darwin)
70                 sysctl -a hw | grep "x86_64: 1" > /dev/null && echo "ARCH_X86_64=1" && echo "CFLAGS+=-DARCH_X86_64"
71                 echo "CFLAGS+=-D__DARWIN__ `sdl-config --cflags`"
72                 echo "SHFLAGS=-dynamiclib"
73                 echo "LDFLAGS+=`sdl-config --libs`"
74                 ;;
75                 Linux)
76                 [ "$(uname -m)" = "x86_64" ] && echo "ARCH_X86_64=1" && echo "CFLAGS+=-DARCH_X86_64"
77                 echo "OPTIMISATIONS+=-ffast-math"
78                 echo "CFLAGS+=-pthread"
79                 echo "SHFLAGS=-shared"
80                 echo "LIBDL=-ldl"
81                 echo "RDYNAMIC=-rdynamic"
82                 ;;
83                 FreeBSD)
84                 [ "$(uname -m)" = "x86_64" ] && echo "ARCH_X86_64=1" && echo "CFLAGS+=-DARCH_X86_64"
85                 echo "OPTIMISATIONS+=-ffast-math"
86                 echo "CFLAGS+=-pthread"
87                 echo "SHFLAGS=-shared"
88                 echo "RDYNAMIC=-rdynamic"
89                 ;;
90                 *)
91                 ;;
92                 esac
93                 echo "LIBSUF=$LIBSUF"
94         ) > config.mak
95
96         echo "#!/bin/sh" > mlt-config
97         (
98                 echo export version=$version
99                 echo export prefix=$prefix
100                 echo export libdir=$libdir
101                 echo export bindir=$prefix/bin
102         ) >> mlt-config
103
104         cat < mlt-config-template >> mlt-config
105
106         echo -n > packages.dat
107 }
108
109 build_pkgconfig()
110 {
111         for i in framework valerie miracle
112         do
113                 echo prefix="$prefix" > mlt-$i.pc
114                 (
115                         echo exec_prefix=$prefix
116                         echo libdir=$libdir
117                         echo includedir=$prefix/include
118                         echo version=$version
119                         echo cflags=`grep ^$i packages.dat | cut -f 2`
120                         echo libs=`grep ^$i packages.dat | cut -f 3`
121                 ) >> mlt-$i.pc
122                 cat mlt-$i.pc.in >>mlt-$i.pc
123         done
124 }
125
126 # Debug mode
127 set +x
128
129 # Define build directory for scripts called
130 export build_dir=`dirname $0`
131 export prefix=/usr/local
132 export libdir=""
133 export help=0
134 export debug=true
135 export mmx=true
136 export sse=true
137 export gpl=false
138 export cpu=
139 export targetos=
140
141 # Determine OS
142 targetos=$(uname -s)
143 # Chose appropriate suffix for libraries
144 case $targetos in
145         Darwin)
146         LIBSUF=".dylib"
147         ;;
148         Linux|FreeBSD)
149         LIBSUF=".so"
150         ;;
151         *)
152         LIBSUF=".so"
153         ;;
154 esac
155 export LIBSUF
156
157 # Iterate through arguments
158 for i in "$@"
159 do
160         case $i in
161                 --help )                        help=1 ;;
162                 --prefix=* )            prefix="${i#--prefix=}" ;;
163                 --libdir=* )            libdir="${i#--libdir=}" ;;
164                 --disable-debug )       debug=false ;;
165                 --disable-mmx )         mmx=false; sse=false ;;
166                 --disable-sse )         sse=false ;;
167                 --enable-gpl )          gpl=true ;;
168                 --cpu=* )                       cpu="${i#--cpu=}" ;;
169         esac
170 done
171
172 # Determine the libdir if it's not specified in the args
173 [ "$libdir" = "" ] && libdir=$prefix/lib
174
175 # Double check mmx (Linux and FreeBSD supported, may end up disabling mmx on other platforms incorrectly)
176 if [ "$mmx" = "true" ]
177 then
178         case $targetos in
179                 Darwin)
180                 sysctl -a hw | grep "mmx: 1" > /dev/null || mmx=false
181                 ;;
182                 Linux)
183                 grep mmx /proc/cpuinfo > /dev/null 2>&1 || mmx=false
184                 ;;
185                 FreeBSD)
186                 [ "$(make -V MACHINE_CPU:Mmmx)" ] || mmx=false
187                 ;;
188                 *)
189                 grep mmx /proc/cpuinfo > /dev/null 2>&1 || mmx=false
190                 ;;
191         esac
192 fi
193
194 # Double check SSE (Linux and FreeBSD supported, may end up disabling SSE on other platforms incorrectly)
195 if [ "$sse" = "true" ]
196 then
197         case $targetos in
198                 Darwin)
199                 sysctl -a hw | grep "sse: 1" > /dev/null || sse=false
200                 ;;
201                 Linux)
202                 grep sse /proc/cpuinfo > /dev/null 2>&1 || sse=false
203                 ;;
204                 FreeBSD)
205                 [ "$(make -V MACHINE_CPU:Msse)" ] || sse=false
206                 ;;
207                 *)
208                 grep sse /proc/cpuinfo > /dev/null 2>&1 || sse=false
209                 ;;
210         esac
211 fi
212
213 # Show help if requested
214 if [ $help = 1 ]
215 then
216         show_help
217 else
218         # Log the configuration history
219         date >> config.log
220         echo "$0 $@" >> config.log
221
222         build_config
223 fi
224
225 # Iterate through each of the components
226 for i in framework modules inigo valerie miracle humperdink
227 do
228         if [ -x src/$i/configure ]
229         then
230                 [ $help = 0 ] && echo "Configuring `basename $i`:"
231                 olddir=`pwd`
232                 cd src/$i
233                 ./configure "$@"
234                 [ $? != 0 ] && exit 1
235                 cd $olddir
236         fi
237 done
238
239 # Build the pkg-config files
240 build_pkgconfig
241
242 # Report GPL Usage
243 [ $help != 1 ] && 
244 ( [ "$gpl" = "false" ] && 
245 echo "GPL Components are disabled" || 
246 echo "GPL License Used" )