adopt to winsock
[melted] / configure
1 #!/bin/sh
2
3 export version=0.3.11
4 export soversion=2
5
6 show_help()
7 {
8         cat << EOF
9 Non-autotool config script for Melted.
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 disables 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                 echo "LDFLAGS+=-Wl,--as-needed"
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                 echo "LDFLAGS+=-Wl,--as-needed"
91                 ;;
92                 *)
93                 ;;
94                 esac
95                 echo "LIBSUF=$LIBSUF"
96                 
97                 echo "CFLAGS += `pkg-config --cflags mlt-framework`"
98                 echo "LDFLAGS += `pkg-config --libs mlt-framework`"
99
100         ) > config.mak
101
102         echo -n > packages.dat
103 }
104
105 build_pkgconfig()
106 {
107         for i in mvcp melted melted++
108         do
109                 echo prefix="$prefix" > mlt-$i.pc
110                 (
111                         echo exec_prefix=$prefix
112                         echo libdir=$libdir
113                         echo includedir=$prefix/include
114                         echo version=$version
115                         echo cflags=`grep ^$i packages.dat | cut -f 2`
116                         echo libs=`grep ^$i packages.dat | cut -f 3`
117                 ) >> mlt-$i.pc
118                 cat mlt-$i.pc.in >>mlt-$i.pc
119         done
120 }
121
122 # Debug mode
123 set +x
124
125 # Define build directory for scripts called
126 export build_dir=`dirname $0`
127 export prefix=/usr/local
128 export libdir=""
129 export help=0
130 export debug=true
131 export mmx=true
132 export sse=true
133 export gpl=false
134 export arch=
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; sse=false ;;
163                 --disable-sse )         sse=false ;;
164                 --enable-gpl )          gpl=true ;;
165                 --arch=* )                      arch="${i#--arch=}" ;;
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 (Darwin, 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 (Darwin, 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 mvcp melted melted++ mvcp-client modules
225 do
226         if [ "$gpl" = "true" -o ! -f src/$i/gpl ]
227         then
228                 if [ -x src/$i/configure ]
229                 then
230                         [ $help = 0 ] && echo "Configuring `basename $i`:"
231                         olddir=`pwd`
232                         cd src/$i
233                         ./configure "$@"
234                         [ $? != 0 ] && exit 1
235                         cd $olddir
236                 fi
237         fi
238 done
239
240 # Build the pkg-config files
241 build_pkgconfig
242
243 # Report GPL Usage
244 [ $help != 1 ] && 
245 ( [ "$gpl" = "false" ] && 
246 echo "GPL Components are disabled" || 
247 echo "GPL License Used" )