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