]> git.sesse.net Git - mlt/blob - configure
configure: add soversion variable, move version variables to top for easier access
[mlt] / configure
1 #!/bin/bash
2
3 export version=0.2.5
4 export soversion=0
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   --enable-motion-est     - Enable motion estimation components
21   --disable-debug         - Compile without debug support (default: on)
22   --disable-mmx           - Compile without MMX 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                 [ "$debug" = "true" ] && 
54                 echo "DEBUG_FLAGS=-g"
55
56                 echo "LARGE_FILE=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE"
57
58                 [ "$cpu" != "" ] &&
59                 echo "TARGETARCH=-march=$cpu" &&
60                 echo "TARGETCPU=-mcpu=$cpu"
61                 echo "OPTIMISATIONS=-O4 -pipe -fomit-frame-pointer"
62
63                 echo "CFLAGS+=-Wall -fPIC -DPIC \$(TARGETARCH) \$(TARGETCPU) \$(OPTIMISATIONS) \$(MMX_FLAGS) \$(DEBUG_FLAGS) \$(LARGE_FILE)"
64
65                 case $targetos in
66                 Darwin)
67                 echo "CFLAGS+=-D__DARWIN__ `sdl-config --cflags`"
68                 echo "SHFLAGS=-dynamiclib"
69                 echo "LDFLAGS+=`sdl-config --libs`"
70                 ;;
71                 Linux)
72                 echo "OPTIMISATIONS+=-ffast-math"
73                 echo "CFLAGS+=-pthread"
74                 echo "SHFLAGS=-shared"
75                 echo "LIBDL=-ldl"
76                 echo "RDYNAMIC=-rdynamic"
77                 ;;
78                 *)
79                 ;;
80                 esac
81                 echo "LIBSUF=$LIBSUF"
82         ) > config.mak
83
84         echo "#!/bin/sh" > mlt-config
85         (
86                 echo export version=$version
87                 echo export prefix=$prefix
88                 echo export libdir=$libdir
89                 echo export bindir=$prefix/bin
90         ) >> mlt-config
91
92         cat < mlt-config-template >> mlt-config
93
94         echo -n > packages.dat
95 }
96
97 build_pkgconfig()
98 {
99         for i in framework valerie miracle
100         do
101                 echo prefix="$prefix" > mlt-$i.pc
102                 (
103                         echo exec_prefix=$prefix
104                         echo libdir=$libdir
105                         echo includedir=$prefix/include
106                         echo version=$version
107                         echo cflags=`grep ^$i packages.dat | cut -f 2`
108                         echo libs=`grep ^$i packages.dat | cut -f 3`
109                 ) >> mlt-$i.pc
110                 cat mlt-$i.pc.in >>mlt-$i.pc
111         done
112 }
113
114 # Debug mode
115 set +x
116
117 # Define build directory for scripts called
118 export build_dir=`dirname $0`
119 export prefix=/usr/local
120 export libdir=""
121 export help=0
122 export debug=true
123 export mmx=true
124 export gpl=false
125 export cpu=
126 export motionest=false
127
128 # Determine OS
129 targetos=$(uname -s)
130 # Chose appropriate suffix for libraries
131 case $targetos in
132         Darwin)
133         LIBSUF=".dylib"
134         mmx=false
135         ;;
136         Linux)
137         LIBSUF=".so"
138         ;;
139         *)
140         LIBSUF=".so"
141         ;;
142 esac
143 export LIBSUF
144
145 # Iterate through arguments
146 for i in "$@"
147 do
148         case $i in
149                 --help )                        help=1 ;;
150                 --prefix=* )            prefix="${i#--prefix=}" ;;
151                 --libdir=* )            libdir="${i#--libdir=}" ;;
152                 --disable-debug )       debug=false ;;
153                 --disable-mmx )         mmx=false ;;
154                 --enable-gpl )          gpl=true ;;
155                 --enable-motion-est )   motionest=true ;;
156                 --cpu=* )                       cpu="${i#--cpu=}" ;;
157         esac
158 done
159
160 # Determine the libdir if it's not specified in the args
161 [ "$libdir" = "" ] && libdir=$prefix/lib
162
163 # Double check mmx (may end up disabling mmx on non-linux platforms incorrectly)
164 if [ "$mmx" = "true" ]
165 then
166         grep mmx /proc/cpuinfo > /dev/null 2>&1 || mmx=false
167 fi
168
169 # Show help if requested
170 if [ $help = 1 ]
171 then
172         show_help
173 else
174         # Log the configuration history
175         date >> config.log
176         echo "$0 $@" >> config.log
177
178         build_config
179 fi
180
181 # Iterate through each of the components
182 for i in framework modules inigo valerie miracle humperdink
183 do
184         if [ -x src/$i/configure ]
185         then
186                 [ $help = 0 ] && echo "Configuring `basename $i`:"
187                 olddir=`pwd`
188                 cd src/$i
189                 ./configure "$@"
190                 [ $? != 0 ] && exit 1
191                 cd $olddir
192         fi
193 done
194
195 # Build the pkg-config files
196 build_pkgconfig
197
198 # Report GPL Usage
199 [ $help != 1 ] && 
200 ( [ "$gpl" = "false" ] && 
201 echo "GPL Components are disabled" || 
202 echo "GPL License Used" )
203
204 if [ "$motionest" = "true" -a "$gpl" = "false" ]
205 then
206         echo "Add the --enable-gpl flag to build the motion estimation components."
207 fi