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