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