]> git.sesse.net Git - mlt/blob - configure
add support for timecode and clock time strings to the framework
[mlt] / configure
1 #!/bin/sh
2
3 export version=0.7.9
4 export soversion=5
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   --datadir=directory     - data directory (default: $prefix/share)
20   --mandir=directory      - man documentation directory (default: $prefix/share/man)
21   --enable-gpl            - Enable GPLv2 components
22   --enable-gpl3           - Enable GPLv3 components
23   --enable-debug          - Compile without optimizations support (default: off)
24   --disable-debug         - Compile without debug support (default: on)
25   --disable-mmx           - Compile without MMX support (default: on)
26   --disable-sse           - Compile without SSE support (default: on)
27   --disable-sse2          - Compile without SSE2 support (default: on)
28   --arch='arch'           - Compile for a specific architecture (default: none)
29   --cpu='cpu'             - Compile for a specific CPU (default: none)
30
31 Module disable options:
32
33 EOF
34
35         for i in src/modules/*
36         do
37                 [ -d $i ] && [ "`basename $i`" != "CVS" ] && echo `basename $i` `[ -f $i/gpl ] && echo [GPL]`
38         done |
39         awk '{ printf( "  --disable-%-14.14s- Disable the %s module %s\n", $1, $1, $2 ); }'
40
41         echo
42         echo "  NOTE: libraries marked [GPL] will not be built unless --enable-gpl is stipulated."
43         echo
44 }
45
46 build_config()
47 {
48         (
49                 echo "version=$version"
50                 echo "soversion=$soversion"
51                 echo "prefix=$prefix"
52                 echo "libdir=$libdir"
53                 echo "bindir=$prefix/bin"
54                 echo "datadir=$datadir"
55                 echo "mandir=$mandir"
56                 echo "targetos=$targetos"
57
58                 [ "$mmx" = "true" ] && 
59                 echo "MMX_FLAGS=-DUSE_MMX"
60
61                 [ "$sse" = "true" ] && 
62                 echo "SSE_FLAGS=-DUSE_SSE"
63
64                 [ "$sse2" = "true" ] && 
65                 echo "SSE2_FLAGS=-DUSE_SSE2"
66
67                 [ "$debug" = "true" ] && 
68                 echo "DEBUG_FLAGS=-g"
69
70                 echo "LARGE_FILE=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE"
71
72                 [ "$arch" != "" ] && echo "TARGETARCH=-march=$arch"
73                 [ "$cpu" != "" ] && echo "TARGETCPU=-mcpu=$cpu"
74                 if [ "$optimisations" = "true" ]
75                 then
76                         echo "OPTIMISATIONS=-O2 -pipe"
77                         # Since gcc 4.6, this optimization enabled with -O1 causes filter_line_sse2 to crash.
78                         echo "OPTIMISATIONS+=-fno-tree-dominator-opts"
79                         # Since gcc 4.6, this optimization enabled with -O2 causes filter_line_sse2 to crash.
80                         echo "OPTIMISATIONS+=-fno-tree-pre"
81                 fi
82
83                 echo "CFLAGS+=-Wall -DPIC \$(TARGETARCH) \$(TARGETCPU) \$(OPTIMISATIONS) \$(MMX_FLAGS) \$(SSE_FLAGS) \$(SSE2_FLAGS) \$(DEBUG_FLAGS) \$(LARGE_FILE)"
84
85                 case $targetos in
86                 Darwin)
87                 sysctl -a hw | grep "x86_64: 1" > /dev/null && echo "ARCH_X86_64=1" && echo "CFLAGS+=-DARCH_X86_64"
88                 echo "CFLAGS+=-fPIC -D__DARWIN__ `sdl-config --cflags`"
89                 echo "SHFLAGS=-dynamiclib"
90                 echo "LDFLAGS+=`sdl-config --libs`"
91                 ;;
92                 Linux|GNU/kFreeBSD|GNU)
93                 [ "$(uname -m)" = "x86_64" ] && echo "ARCH_X86_64=1" && echo "CFLAGS+=-DARCH_X86_64"
94                 [ "$optimisations" = "true" ] &&
95                         echo "OPTIMISATIONS+=-ffast-math"
96                 echo "CFLAGS+=-fPIC -pthread"
97                 echo "SHFLAGS=-shared"
98                 echo "LIBDL=-ldl"
99                 echo "RDYNAMIC=-rdynamic"
100                 echo "LDFLAGS+=-Wl,--no-undefined -Wl,--as-needed"
101                 ;;
102                 FreeBSD)
103                 [ "$(uname -m)" = "amd64" -o "$(uname -m)" = "x86_64" ] && echo "ARCH_X86_64=1" && echo "CFLAGS+=-DARCH_X86_64"
104                 [ "$optimisations" = "true" ] &&
105                         echo "OPTIMISATIONS+=-ffast-math"
106                 echo "CFLAGS+=-fPIC -pthread"
107                 echo "SHFLAGS=-shared"
108                 echo "RDYNAMIC=-rdynamic"
109                 echo "LDFLAGS+=-Wl,--no-undefined -Wl,--as-needed"
110                 ;;
111                 NetBSD)
112                 [ "$(uname -m)" = "amd64" ] && echo "ARCH_X86_64=1" && echo "CFLAGS+=-DARCH_X86_64"
113                 [ "$optimisations" = "true" ] &&
114                         echo "OPTIMISATIONS+=-ffast-math"
115                 echo "CFLAGS+=-pthread"
116                 echo "SHFLAGS=-shared"
117                 echo "RDYNAMIC=-rdynamic"
118                 echo "LDFLAGS+=-Wl,--no-undefined -Wl,--as-needed"
119                 ;;
120                 MinGW)
121                 [ "$(uname -m)" = "x86_64" ] && echo "ARCH_X86_64=1" && echo "CFLAGS+=-DARCH_X86_64"
122                 [ "$optimisations" = "true" ] &&
123                         echo "OPTIMISATIONS+=-ffast-math"
124                 echo "SHFLAGS=-shared"
125                 echo "LIBDL=-ldl"
126                 echo "RDYNAMIC="
127                 echo "LDFLAGS+=-Wl,--no-undefined -Wl,--as-needed"
128                 ;;              
129                 *)
130                 ;;
131                 esac
132                 echo "LIBSUF=$LIBSUF"
133         ) > config.mak
134
135         echo "#!/bin/sh" > mlt-config
136         (
137                 echo export version=$version
138                 echo export prefix=$prefix
139                 echo export libdir=$libdir
140                 echo export bindir=$prefix/bin
141         ) >> mlt-config
142
143         cat < mlt-config-template >> mlt-config
144
145         echo -n > packages.dat
146 }
147
148 build_pkgconfig()
149 {
150         echo prefix="$prefix" > mlt-framework.pc
151         (
152                 echo exec_prefix=$prefix
153                 echo libdir=$libdir
154                 echo includedir=$prefix/include
155                 echo datadir=$datadir
156                 echo mandir=$mandir
157                 echo version=$version
158                 echo cflags=`grep ^framework packages.dat | cut -f 2`
159                 echo libs=`grep ^framework packages.dat | cut -f 3`
160         ) >> mlt-framework.pc
161         cat mlt-framework.pc.in >>mlt-framework.pc
162
163         echo prefix="$prefix" > mlt++.pc
164         (
165                 echo exec_prefix=$prefix
166                 echo libdir=$libdir
167                 echo includedir=$prefix/include
168                 echo datadir=$datadir
169                 echo mandir=$mandir
170                 echo version=$version
171                 echo cflags=`grep ^mlt++ packages.dat | cut -f 2`
172                 echo libs=`grep ^mlt++ packages.dat | cut -f 3`
173         ) >> mlt++.pc
174         cat mlt++.pc.in >>mlt++.pc
175 }
176
177 # Debug mode
178 set +x
179
180 # Define build directory for scripts called
181 export build_dir=`dirname $0`
182 export prefix=/usr/local
183 export libdir=""
184 export datadir=""
185 export mandir=""
186 export help=0
187 export optimisations=true
188 export debug=true
189 export mmx=true
190 export sse=true
191 export sse2=true
192 export gpl=false
193 export gpl3=false
194 export arch=
195 export cpu=
196 export targetos=
197
198 # Determine OS
199 targetos=$(uname -s)
200 # Chose appropriate suffix for libraries
201 case $targetos in
202         Darwin)
203         LIBSUF=".dylib"
204         ;;
205         Linux|FreeBSD|NetBSD)
206         LIBSUF=".so"
207         ;;
208         MINGW32_NT-*)
209         targetos="MinGW"
210         LIBSUF=".dll"
211         ;;
212         *)
213         LIBSUF=".so"
214         ;;
215 esac
216 export LIBSUF
217
218 # Iterate through arguments
219 for i in "$@"
220 do
221         case $i in
222                 --help )                        help=1 ;;
223                 --prefix=* )            prefix="${i#--prefix=}" ;;
224                 --libdir=* )            libdir="${i#--libdir=}" ;;
225                 --datadir=* )           datadir="${i#--datadir=}" ;;
226                 --mandir=* )            mandir="${i#--mandir=}" ;;
227                 --enable-debug )        optimisations=false ;;
228                 --disable-debug )       debug=false ;;
229                 --disable-mmx )         mmx=false; sse=false; sse2=false ;;
230                 --disable-sse )         sse=false; sse2=false ;;
231                 --disable-sse2 )        sse2=false ;;
232                 --enable-gpl )          gpl=true ;;
233                 --enable-gpl3 )         gpl3=true ;;
234                 --arch=* )                      arch="${i#--arch=}" ;;
235                 --cpu=* )                       cpu="${i#--cpu=}" ;;
236         esac
237 done
238
239 # Determine the libdir if it's not specified in the args
240 [ "$libdir" = "" ] && libdir=$prefix/lib
241 [ "$datadir" = "" ] && datadir=$prefix/share
242 [ "$mandir" = "" ] && mandir=$prefix/share/man
243
244 # Double check MMX (Darwin, Linux and FreeBSD supported, may end up disabling MMX on other platforms incorrectly)
245 if [ "$mmx" = "true" ]
246 then
247         case $targetos in
248                 Darwin)
249                 sysctl -a hw | grep "mmx: 1" > /dev/null || mmx=false
250                 ;;
251                 Linux)
252                 grep mmx /proc/cpuinfo > /dev/null 2>&1 || mmx=false
253                 ;;
254                 FreeBSD)
255                 [ "$(make -V MACHINE_CPU:Mmmx)" ] || mmx=false
256                 ;;
257                 *)
258                 grep mmx /proc/cpuinfo > /dev/null 2>&1 || mmx=false
259                 ;;
260         esac
261 fi
262
263 # Double check SSE (Darwin, Linux and FreeBSD supported, may end up disabling SSE on other platforms incorrectly)
264 if [ "$sse" = "true" ]
265 then
266         case $targetos in
267                 Darwin)
268                 sysctl -a hw | grep "sse: 1" > /dev/null || sse=false
269                 ;;
270                 Linux)
271                 grep sse /proc/cpuinfo > /dev/null 2>&1 || sse=false
272                 ;;
273                 FreeBSD)
274                 [ "$(make -V MACHINE_CPU:Msse)" ] || sse=false
275                 ;;
276                 *)
277                 grep sse /proc/cpuinfo > /dev/null 2>&1 || sse=false
278                 ;;
279         esac
280 fi
281
282 # Double check SSE2 (Darwin, Linux and FreeBSD supported, may end up disabling SSE2 on other platforms incorrectly)
283 if [ "$sse2" = "true" ]
284 then
285         case $targetos in
286                 Darwin)
287                 sysctl -a hw | grep "sse2: 1" > /dev/null || sse2=false
288                 ;;
289                 Linux)
290                 grep sse2 /proc/cpuinfo > /dev/null 2>&1 || sse2=false
291                 ;;
292                 FreeBSD)
293                 [ "$(make -V MACHINE_CPU:Msse2)" ] || sse2=false
294                 ;;
295                 *)
296                 grep sse2 /proc/cpuinfo > /dev/null 2>&1 || sse2=false
297                 ;;
298         esac
299 fi
300
301 # Show help if requested
302 if [ $help = 1 ]
303 then
304         show_help
305 else
306         # Log the configuration history
307         date >> config.log
308         echo "$0 $@" >> config.log
309
310         build_config
311 fi
312
313 # Iterate through each of the components
314 for i in framework modules melt mlt++ swig
315 do
316         if [ -x src/$i/configure ]
317         then
318                 [ $help = 0 ] && echo "Configuring `basename $i`:"
319                 olddir=`pwd`
320                 cd src/$i
321                 ./configure "$@"
322                 [ $? != 0 ] && exit 1
323                 cd $olddir
324         fi
325 done
326
327 # Build the pkg-config files
328 build_pkgconfig
329
330 # Report license Usage
331 if [ $help != 1 ]
332 then
333         if [ "$gpl" = "false" ]
334         then
335                 echo "LGPLv2.1 license used; GPL components disabled"
336         elif [ "$gpl3" = "false" ]
337         then
338                 echo "GPLv2 license used; GPLv3 components disabled"
339         else
340                 echo "GPLv3 license used"
341         fi
342 fi