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