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