]> git.sesse.net Git - mlt/blob - configure
Version modules and data directories, and melt
[mlt] / configure
1 #!/bin/sh
2
3 export version=0.8.8
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   --rename-melt           - Give melt executable a different name.
22   --no-compat-dirs        - Do not create compatibility, unversioned, files and 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 "compat_dirs=$compat_dirs"
61                 echo "compat_nomelt=$compat_nomelt"
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=${libdir}/mlt-${soversion}"
136                 echo "mltdatadir=${datadir}/mlt-${soversion}"
137                 echo "meltname=${meltname}"
138         ) > config.mak
139
140         echo "#!/bin/sh" > mlt-config
141         (
142                 echo export version=$version
143                 echo export prefix=$prefix
144                 echo export libdir=$libdir
145                 echo export bindir=$prefix/bin
146         ) >> mlt-config
147
148         cat < mlt-config-template >> mlt-config
149
150         echo -n > packages.dat
151 }
152
153 build_pkgconfig()
154 {
155         echo prefix="$prefix" > mlt-framework.pc
156         (
157                 echo exec_prefix=$prefix
158                 echo libdir=$libdir
159                 echo includedir=$prefix/include
160                 echo datadir=$datadir
161                 echo mandir=$mandir
162                 echo version=$version
163                 echo cflags=`grep ^framework packages.dat | cut -f 2`
164                 echo libs=`grep ^framework packages.dat | cut -f 3`
165                 echo moduledir=${libdir}/mlt-${soversion}
166                 echo mltdatadir=${datadir}/mlt-${soversion}
167                 echo meltbin=${prefix}/bin/${meltname}
168         ) >> mlt-framework.pc
169         cat mlt-framework.pc.in >>mlt-framework.pc
170
171         echo prefix="$prefix" > mlt++.pc
172         (
173                 echo exec_prefix=$prefix
174                 echo libdir=$libdir
175                 echo includedir=$prefix/include
176                 echo datadir=$datadir
177                 echo mandir=$mandir
178                 echo version=$version
179                 echo cflags=`grep ^mlt++ packages.dat | cut -f 2`
180                 echo libs=`grep ^mlt++ packages.dat | cut -f 3`
181         ) >> mlt++.pc
182         cat mlt++.pc.in >>mlt++.pc
183 }
184
185 # Debug mode
186 set +x
187
188 # Define build directory for scripts called
189 export build_dir=`dirname $0`
190 export prefix=/usr/local
191 export libdir=""
192 export datadir=""
193 export mandir=""
194 export help=0
195 export optimisations=true
196 export debug=true
197 export mmx=true
198 export sse=true
199 export sse2=true
200 export gpl=false
201 export gpl3=false
202 export arch=
203 export cpu=
204 export targetos=$(uname -s)
205 export targetarch=
206 export amd64=false
207 export compat_dirs=true
208 export compat_nomelt=false
209
210 # Define the compiler used in tests (gcc is not installed everywhere)
211 : ${CC:=gcc}
212
213 # Iterate through arguments
214 for i in "$@"
215 do
216         case $i in
217                 --help )                help=1 ;;
218                 --prefix=* )            prefix="${i#--prefix=}" ;;
219                 --libdir=* )            libdir="${i#--libdir=}" ;;
220                 --datadir=* )           datadir="${i#--datadir=}" ;;
221                 --mandir=* )            mandir="${i#--mandir=}" ;;
222                 --rename-melt=* )       meltname="${i#--rename-melt=}"; compat_nomelt=true ;;
223                 --no-compat-dirs )      compat_dirs=false ;;
224                 --enable-debug )        optimisations=false ;;
225                 --disable-debug )       debug=false ;;
226                 --disable-mmx )         mmx=false; sse=false; sse2=false ;;
227                 --disable-sse )         sse=false; sse2=false ;;
228                 --disable-sse2 )        sse2=false ;;
229                 --enable-gpl )          gpl=true ;;
230                 --enable-gpl3 )         gpl3=true ;;
231                 --arch=* )              arch="${i#--arch=}" ;;
232                 --cpu=* )               cpu="${i#--cpu=}" ;;
233                 --target-os=* )         targetos="${i#--target-os=}" ;;
234                 --target-arch=* )       targetarch="${i#--target-arch=}" ;;
235         esac
236 done
237
238 if [ -z "${meltname}" ]
239 then
240         meltname=melt${soversion}
241 fi
242
243 # Chose appropriate suffix for libraries
244 case $targetos in
245         Darwin)
246         LIBSUF=".dylib"
247         if [ "$targetarch" = "" ]
248         then
249                 sysctl -a hw | grep "x86_64: 1" > /dev/null
250                 [ "$?" = "0" ] && targetarch="amd64"
251         fi
252         ;;
253         Linux|FreeBSD|NetBSD)
254         LIBSUF=".so"
255         ;;
256         MINGW32_NT-*|MinGW|mingw)
257         targetos="MinGW"
258         LIBSUF=".dll"
259         ;;
260         *)
261         LIBSUF=".so"
262         ;;
263 esac
264 export LIBSUF
265
266 # Determine if we are compiling for 64-bit Intel architecture
267 [ "$targetarch" = "" ] && targetarch=$(uname -m)
268 [ "$targetarch" = "amd64" -o "$targetarch" = "x86_64" ] && amd64=true
269
270 # Determine the libdir if it's not specified in the args
271 [ "$libdir" = "" ] && libdir=$prefix/lib
272 [ "$datadir" = "" ] && datadir=$prefix/share
273 [ "$mandir" = "" ] && mandir=$prefix/share/man
274
275 export moduledir=${libdir}/mlt-${soversion}
276 export mltdatadir=${datadir}/mlt-${soversion}
277
278 # Double check MMX (Darwin, Linux and FreeBSD supported, may end up disabling MMX on other platforms incorrectly)
279 if [ "$mmx" = "true" ]
280 then
281         case $targetos in
282                 Darwin)
283                 sysctl -a hw | grep "mmx: 1" > /dev/null || mmx=false
284                 ;;
285                 Linux)
286                 grep mmx /proc/cpuinfo > /dev/null 2>&1 || mmx=false
287                 ;;
288                 FreeBSD)
289                 [ "$(make -V MACHINE_CPU:Mmmx)" ] || mmx=false
290                 ;;
291                 *)
292                 grep mmx /proc/cpuinfo > /dev/null 2>&1 || mmx=false
293                 ;;
294         esac
295 fi
296
297 # Double check SSE (Darwin, Linux and FreeBSD supported, may end up disabling SSE on other platforms incorrectly)
298 if [ "$sse" = "true" ]
299 then
300         case $targetos in
301                 Darwin)
302                 sysctl -a hw | grep "sse: 1" > /dev/null || sse=false
303                 ;;
304                 Linux)
305                 grep sse /proc/cpuinfo > /dev/null 2>&1 || sse=false
306                 ;;
307                 FreeBSD)
308                 [ "$(make -V MACHINE_CPU:Msse)" ] || sse=false
309                 ;;
310                 *)
311                 grep sse /proc/cpuinfo > /dev/null 2>&1 || sse=false
312                 ;;
313         esac
314 fi
315
316 # Double check SSE2 (Darwin, Linux and FreeBSD supported, may end up disabling SSE2 on other platforms incorrectly)
317 if [ "$sse2" = "true" ]
318 then
319         case $targetos in
320                 Darwin)
321                 sysctl -a hw | grep "sse2: 1" > /dev/null || sse2=false
322                 ;;
323                 Linux)
324                 grep sse2 /proc/cpuinfo > /dev/null 2>&1 || sse2=false
325                 ;;
326                 FreeBSD)
327                 [ "$(make -V MACHINE_CPU:Msse2)" ] || sse2=false
328                 ;;
329                 *)
330                 grep sse2 /proc/cpuinfo > /dev/null 2>&1 || sse2=false
331                 ;;
332         esac
333 fi
334
335 # Show help if requested
336 if [ $help = 1 ]
337 then
338         show_help
339 else
340         # Log the configuration history
341         date >> config.log
342         echo "$0 $@" >> config.log
343
344         build_config
345 fi
346
347 # Iterate through each of the components
348 for i in framework modules melt mlt++ swig
349 do
350         if [ -x src/$i/configure ]
351         then
352                 [ $help = 0 ] && echo "Configuring `basename $i`:"
353                 olddir=`pwd`
354                 cd src/$i
355                 CC="$CC" ./configure "$@"
356                 [ $? != 0 ] && exit 1
357                 cd $olddir
358         fi
359 done
360
361 # Build the pkg-config files
362 build_pkgconfig
363
364 # Report license Usage
365 if [ $help != 1 ]
366 then
367         if [ "$gpl" = "false" ]
368         then
369                 echo "LGPLv2.1 license used; GPL components disabled"
370         elif [ "$gpl3" = "false" ]
371         then
372                 echo "GPLv2 license used; GPLv3 components disabled"
373         else
374                 echo "GPLv3 license used"
375         fi
376 fi