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