]> git.sesse.net Git - mlt/blob - configure
set interim version 0.7.5
[mlt] / configure
1 #!/bin/sh
2
3 export version=0.7.5
4 export soversion=4
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                 if [ "$optimisations" = "true" ]
74                 then
75                         echo "OPTIMISATIONS=-O2 -pipe"
76                         # Since gcc 4.6, this optimization enabled with -O1 causes filter_line_sse2 to crash.
77                         echo "OPTIMISATIONS+=-fno-tree-dominator-opts"
78                         # Since gcc 4.6, this optimization enabled with -O2 causes filter_line_sse2 to crash.
79                         echo "OPTIMISATIONS+=-fno-tree-pre"
80                 fi
81
82                 echo "CFLAGS+=-Wall -DPIC \$(TARGETARCH) \$(TARGETCPU) \$(OPTIMISATIONS) \$(MMX_FLAGS) \$(SSE_FLAGS) \$(SSE2_FLAGS) \$(DEBUG_FLAGS) \$(LARGE_FILE)"
83
84                 case $targetos in
85                 Darwin)
86                 sysctl -a hw | grep "x86_64: 1" > /dev/null && echo "ARCH_X86_64=1" && echo "CFLAGS+=-DARCH_X86_64"
87                 echo "CFLAGS+=-fPIC -D__DARWIN__ `sdl-config --cflags`"
88                 echo "SHFLAGS=-dynamiclib"
89                 echo "LDFLAGS+=`sdl-config --libs`"
90                 ;;
91                 Linux|GNU/kFreeBSD)
92                 [ "$(uname -m)" = "x86_64" ] && echo "ARCH_X86_64=1" && echo "CFLAGS+=-DARCH_X86_64"
93                 [ "$optimisations" = "true" ] &&
94                         echo "OPTIMISATIONS+=-ffast-math"
95                 echo "CFLAGS+=-fPIC -pthread"
96                 echo "SHFLAGS=-shared"
97                 echo "LIBDL=-ldl"
98                 echo "RDYNAMIC=-rdynamic"
99                 echo "LDFLAGS+=-Wl,--no-undefined -Wl,--as-needed"
100                 ;;
101                 FreeBSD)
102                 [ "$(uname -m)" = "amd64" -o "$(uname -m)" = "x86_64" ] && echo "ARCH_X86_64=1" && echo "CFLAGS+=-DARCH_X86_64"
103                 [ "$optimisations" = "true" ] &&
104                         echo "OPTIMISATIONS+=-ffast-math"
105                 echo "CFLAGS+=-fPIC -pthread"
106                 echo "SHFLAGS=-shared"
107                 echo "RDYNAMIC=-rdynamic"
108                 echo "LDFLAGS+=-Wl,--no-undefined -Wl,--as-needed"
109                 ;;
110                 NetBSD)
111                 [ "$(uname -m)" = "amd64" ] && echo "ARCH_X86_64=1" && echo "CFLAGS+=-DARCH_X86_64"
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                 [ "$(uname -m)" = "x86_64" ] && echo "ARCH_X86_64=1" && echo "CFLAGS+=-DARCH_X86_64"
121                 [ "$optimisations" = "true" ] &&
122                         echo "OPTIMISATIONS+=-ffast-math"
123                 echo "SHFLAGS=-shared"
124                 echo "LIBDL=-ldl"
125                 echo "RDYNAMIC="
126                 echo "LDFLAGS+=-Wl,--no-undefined -Wl,--as-needed"
127                 ;;              
128                 *)
129                 ;;
130                 esac
131                 echo "LIBSUF=$LIBSUF"
132         ) > config.mak
133
134         echo "#!/bin/sh" > mlt-config
135         (
136                 echo export version=$version
137                 echo export prefix=$prefix
138                 echo export libdir=$libdir
139                 echo export bindir=$prefix/bin
140         ) >> mlt-config
141
142         cat < mlt-config-template >> mlt-config
143
144         echo -n > packages.dat
145 }
146
147 build_pkgconfig()
148 {
149         echo prefix="$prefix" > mlt-framework.pc
150         (
151                 echo exec_prefix=$prefix
152                 echo libdir=$libdir
153                 echo includedir=$prefix/include
154                 echo datadir=$datadir
155                 echo mandir=$mandir
156                 echo version=$version
157                 echo cflags=`grep ^framework packages.dat | cut -f 2`
158                 echo libs=`grep ^framework packages.dat | cut -f 3`
159         ) >> mlt-framework.pc
160         cat mlt-framework.pc.in >>mlt-framework.pc
161
162         echo prefix="$prefix" > mlt++.pc
163         (
164                 echo exec_prefix=$prefix
165                 echo libdir=$libdir
166                 echo includedir=$prefix/include
167                 echo datadir=$datadir
168                 echo mandir=$mandir
169                 echo version=$version
170                 echo cflags=`grep ^mlt++ packages.dat | cut -f 2`
171                 echo libs=`grep ^mlt++ packages.dat | cut -f 3`
172         ) >> mlt++.pc
173         cat mlt++.pc.in >>mlt++.pc
174 }
175
176 # Debug mode
177 set +x
178
179 # Define build directory for scripts called
180 export build_dir=`dirname $0`
181 export prefix=/usr/local
182 export libdir=""
183 export datadir=""
184 export mandir=""
185 export help=0
186 export optimisations=true
187 export debug=true
188 export mmx=true
189 export sse=true
190 export sse2=true
191 export gpl=false
192 export arch=
193 export cpu=
194 export targetos=
195
196 # Determine OS
197 targetos=$(uname -s)
198 # Chose appropriate suffix for libraries
199 case $targetos in
200         Darwin)
201         LIBSUF=".dylib"
202         ;;
203         Linux|FreeBSD|NetBSD)
204         LIBSUF=".so"
205         ;;
206         MINGW32_NT-*)
207         targetos="MinGW"
208         LIBSUF=".dll"
209         ;;
210         *)
211         LIBSUF=".so"
212         ;;
213 esac
214 export LIBSUF
215
216 # Iterate through arguments
217 for i in "$@"
218 do
219         case $i in
220                 --help )                        help=1 ;;
221                 --prefix=* )            prefix="${i#--prefix=}" ;;
222                 --libdir=* )            libdir="${i#--libdir=}" ;;
223                 --datadir=* )           datadir="${i#--datadir=}" ;;
224                 --mandir=* )            mandir="${i#--mandir=}" ;;
225                 --enable-debug )        optimisations=false ;;
226                 --disable-debug )       debug=false ;;
227                 --disable-mmx )         mmx=false; sse=false; sse2=false ;;
228                 --disable-sse )         sse=false; sse2=false ;;
229                 --disable-sse2 )        sse2=false ;;
230                 --enable-gpl )          gpl=true ;;
231                 --arch=* )                      arch="${i#--arch=}" ;;
232                 --cpu=* )                       cpu="${i#--cpu=}" ;;
233         esac
234 done
235
236 # Determine the libdir if it's not specified in the args
237 [ "$libdir" = "" ] && libdir=$prefix/lib
238 [ "$datadir" = "" ] && datadir=$prefix/share
239 [ "$mandir" = "" ] && mandir=$prefix/share/man
240
241 # Double check MMX (Darwin, Linux and FreeBSD supported, may end up disabling MMX on other platforms incorrectly)
242 if [ "$mmx" = "true" ]
243 then
244         case $targetos in
245                 Darwin)
246                 sysctl -a hw | grep "mmx: 1" > /dev/null || mmx=false
247                 ;;
248                 Linux)
249                 grep mmx /proc/cpuinfo > /dev/null 2>&1 || mmx=false
250                 ;;
251                 FreeBSD)
252                 [ "$(make -V MACHINE_CPU:Mmmx)" ] || mmx=false
253                 ;;
254                 *)
255                 grep mmx /proc/cpuinfo > /dev/null 2>&1 || mmx=false
256                 ;;
257         esac
258 fi
259
260 # Double check SSE (Darwin, Linux and FreeBSD supported, may end up disabling SSE on other platforms incorrectly)
261 if [ "$sse" = "true" ]
262 then
263         case $targetos in
264                 Darwin)
265                 sysctl -a hw | grep "sse: 1" > /dev/null || sse=false
266                 ;;
267                 Linux)
268                 grep sse /proc/cpuinfo > /dev/null 2>&1 || sse=false
269                 ;;
270                 FreeBSD)
271                 [ "$(make -V MACHINE_CPU:Msse)" ] || sse=false
272                 ;;
273                 *)
274                 grep sse /proc/cpuinfo > /dev/null 2>&1 || sse=false
275                 ;;
276         esac
277 fi
278
279 # Double check SSE2 (Darwin, Linux and FreeBSD supported, may end up disabling SSE2 on other platforms incorrectly)
280 if [ "$sse2" = "true" ]
281 then
282         case $targetos in
283                 Darwin)
284                 sysctl -a hw | grep "sse2: 1" > /dev/null || sse2=false
285                 ;;
286                 Linux)
287                 grep sse2 /proc/cpuinfo > /dev/null 2>&1 || sse2=false
288                 ;;
289                 FreeBSD)
290                 [ "$(make -V MACHINE_CPU:Msse2)" ] || sse2=false
291                 ;;
292                 *)
293                 grep sse2 /proc/cpuinfo > /dev/null 2>&1 || sse2=false
294                 ;;
295         esac
296 fi
297
298 # Show help if requested
299 if [ $help = 1 ]
300 then
301         show_help
302 else
303         # Log the configuration history
304         date >> config.log
305         echo "$0 $@" >> config.log
306
307         build_config
308 fi
309
310 # Iterate through each of the components
311 for i in framework modules melt mlt++ swig
312 do
313         if [ -x src/$i/configure ]
314         then
315                 [ $help = 0 ] && echo "Configuring `basename $i`:"
316                 olddir=`pwd`
317                 cd src/$i
318                 ./configure "$@"
319                 [ $? != 0 ] && exit 1
320                 cd $olddir
321         fi
322 done
323
324 # Build the pkg-config files
325 build_pkgconfig
326
327 # Report GPL Usage
328 [ $help != 1 ] && 
329 ( [ "$gpl" = "false" ] && 
330 echo "GPL Components are disabled" || 
331 echo "GPL License Used" )