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