]> git.sesse.net Git - mlt/blob - configure
Set version to 0.5.10.
[mlt] / configure
1 #!/bin/sh
2
3 export version=0.5.10
4 export soversion=2
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 -fPIC -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+=-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+=-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+=-pthread"
96                 echo "SHFLAGS=-shared"
97                 echo "RDYNAMIC=-rdynamic"
98                 echo "LDFLAGS+=-Wl,--no-undefined -Wl,--as-needed"
99                 ;;
100                 *)
101                 ;;
102                 esac
103                 echo "LIBSUF=$LIBSUF"
104         ) > config.mak
105
106         echo "#!/bin/sh" > mlt-config
107         (
108                 echo export version=$version
109                 echo export prefix=$prefix
110                 echo export libdir=$libdir
111                 echo export bindir=$prefix/bin
112         ) >> mlt-config
113
114         cat < mlt-config-template >> mlt-config
115
116         echo -n > packages.dat
117 }
118
119 build_pkgconfig()
120 {
121         echo prefix="$prefix" > mlt-framework.pc
122         (
123                 echo exec_prefix=$prefix
124                 echo libdir=$libdir
125                 echo includedir=$prefix/include
126                 echo datadir=$datadir
127                 echo mandir=$mandir
128                 echo version=$version
129                 echo cflags=`grep ^framework packages.dat | cut -f 2`
130                 echo libs=`grep ^framework packages.dat | cut -f 3`
131         ) >> mlt-framework.pc
132         cat mlt-framework.pc.in >>mlt-framework.pc
133
134         echo prefix="$prefix" > mlt++.pc
135         (
136                 echo exec_prefix=$prefix
137                 echo libdir=$libdir
138                 echo includedir=$prefix/include
139                 echo datadir=$datadir
140                 echo mandir=$mandir
141                 echo version=$version
142                 echo cflags=`grep ^mlt++ packages.dat | cut -f 2`
143                 echo libs=`grep ^mlt++ packages.dat | cut -f 3`
144         ) >> mlt++.pc
145         cat mlt++.pc.in >>mlt++.pc
146 }
147
148 # Debug mode
149 set +x
150
151 # Define build directory for scripts called
152 export build_dir=`dirname $0`
153 export prefix=/usr/local
154 export libdir=""
155 export datadir=""
156 export mandir=""
157 export help=0
158 export debug=true
159 export mmx=true
160 export sse=true
161 export sse2=true
162 export gpl=false
163 export arch=
164 export cpu=
165 export targetos=
166
167 # Determine OS
168 targetos=$(uname -s)
169 # Chose appropriate suffix for libraries
170 case $targetos in
171         Darwin)
172         LIBSUF=".dylib"
173         ;;
174         Linux|FreeBSD)
175         LIBSUF=".so"
176         ;;
177         *)
178         LIBSUF=".so"
179         ;;
180 esac
181 export LIBSUF
182
183 # Iterate through arguments
184 for i in "$@"
185 do
186         case $i in
187                 --help )                        help=1 ;;
188                 --prefix=* )            prefix="${i#--prefix=}" ;;
189                 --libdir=* )            libdir="${i#--libdir=}" ;;
190                 --datadir=* )           datadir="${i#--datadir=}" ;;
191                 --mandir=* )            mandir="${i#--mandir=}" ;;
192                 --disable-debug )       debug=false ;;
193                 --disable-mmx )         mmx=false; sse=false; sse2=false ;;
194                 --disable-sse )         sse=false; sse2=false ;;
195                 --disable-sse2 )        sse2=false ;;
196                 --enable-gpl )          gpl=true ;;
197                 --arch=* )                      arch="${i#--arch=}" ;;
198                 --cpu=* )                       cpu="${i#--cpu=}" ;;
199         esac
200 done
201
202 # Determine the libdir if it's not specified in the args
203 [ "$libdir" = "" ] && libdir=$prefix/lib
204 [ "$datadir" = "" ] && datadir=$prefix/share
205 [ "$mandir" = "" ] && mandir=$prefix/share/man
206
207 # Double check MMX (Darwin, Linux and FreeBSD supported, may end up disabling MMX on other platforms incorrectly)
208 if [ "$mmx" = "true" ]
209 then
210         case $targetos in
211                 Darwin)
212                 sysctl -a hw | grep "mmx: 1" > /dev/null || mmx=false
213                 ;;
214                 Linux)
215                 grep mmx /proc/cpuinfo > /dev/null 2>&1 || mmx=false
216                 ;;
217                 FreeBSD)
218                 [ "$(make -V MACHINE_CPU:Mmmx)" ] || mmx=false
219                 ;;
220                 *)
221                 grep mmx /proc/cpuinfo > /dev/null 2>&1 || mmx=false
222                 ;;
223         esac
224 fi
225
226 # Double check SSE (Darwin, Linux and FreeBSD supported, may end up disabling SSE on other platforms incorrectly)
227 if [ "$sse" = "true" ]
228 then
229         case $targetos in
230                 Darwin)
231                 sysctl -a hw | grep "sse: 1" > /dev/null || sse=false
232                 ;;
233                 Linux)
234                 grep sse /proc/cpuinfo > /dev/null 2>&1 || sse=false
235                 ;;
236                 FreeBSD)
237                 [ "$(make -V MACHINE_CPU:Msse)" ] || sse=false
238                 ;;
239                 *)
240                 grep sse /proc/cpuinfo > /dev/null 2>&1 || sse=false
241                 ;;
242         esac
243 fi
244
245 # Double check SSE2 (Darwin, Linux and FreeBSD supported, may end up disabling SSE2 on other platforms incorrectly)
246 if [ "$sse2" = "true" ]
247 then
248         case $targetos in
249                 Darwin)
250                 sysctl -a hw | grep "sse2: 1" > /dev/null || sse2=false
251                 ;;
252                 Linux)
253                 grep sse2 /proc/cpuinfo > /dev/null 2>&1 || sse2=false
254                 ;;
255                 FreeBSD)
256                 [ "$(make -V MACHINE_CPU:Msse2)" ] || sse2=false
257                 ;;
258                 *)
259                 grep sse2 /proc/cpuinfo > /dev/null 2>&1 || sse2=false
260                 ;;
261         esac
262 fi
263
264 # Show help if requested
265 if [ $help = 1 ]
266 then
267         show_help
268 else
269         # Log the configuration history
270         date >> config.log
271         echo "$0 $@" >> config.log
272
273         build_config
274 fi
275
276 # Iterate through each of the components
277 for i in framework modules melt mlt++ swig
278 do
279         if [ -x src/$i/configure ]
280         then
281                 [ $help = 0 ] && echo "Configuring `basename $i`:"
282                 olddir=`pwd`
283                 cd src/$i
284                 ./configure "$@"
285                 [ $? != 0 ] && exit 1
286                 cd $olddir
287         fi
288 done
289
290 # Build the pkg-config files
291 build_pkgconfig
292
293 # Report GPL Usage
294 [ $help != 1 ] && 
295 ( [ "$gpl" = "false" ] && 
296 echo "GPL Components are disabled" || 
297 echo "GPL License Used" )