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