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