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