]> git.sesse.net Git - mlt/blob - configure
+ OS/X Tiger patch
[mlt] / configure
1 #!/bin/sh
2
3 function show_help
4 {
5         cat << EOF
6 Non-autotool config script for MLT.
7
8 Help options:
9
10   --help                  - this information
11
12 General build options:
13
14   --prefix=directory      - install prefix for path (default: $prefix)
15   --enable-gpl            - Enable GPL components
16   --enable-motion-est     - Enable motion estimation components
17   --disable-debug         - Compile without debug support (default: on)
18   --disable-mmx           - Compile without MMX support (default: on)
19   --cpu='cpu'             - Compile for a specific CPU/architectre (default: none)
20
21 Module disables options:
22
23 EOF
24
25         for i in src/modules/*
26         do
27                 [ -d $i ] && [ "`basename $i`" != "CVS" ] && echo `basename $i` `[ -f $i/gpl ] && echo [GPL]`
28         done |
29         awk '{ printf( "  --disable-%-14.14s- Disable the %s module %s\n", $1, $1, $2 ); }'
30
31         echo
32         echo "  NOTE: libraries marked [GPL] will not be built unless --enable-gpl is stipulated."
33         echo
34 }
35
36 function build_config
37 {
38         (
39                 echo "version=$version"
40                 echo "prefix=$prefix"
41                 echo "bindir=$prefix/bin"
42                 echo "targetos=$targetos"
43
44                 [ "$mmx" = "true" ] && 
45                 echo "MMX_FLAGS=-DUSE_MMX"
46
47                 [ "$debug" = "true" ] && 
48                 echo "DEBUG_FLAGS=-g"
49
50                 echo "LARGE_FILE=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE"
51
52                 [ "$cpu" != "" ] &&
53                 echo "TARGETARCH=-march=$cpu" &&
54                 echo "TARGETCPU=-mcpu=$cpu"
55                 echo "OPTIMISATIONS=-O4 -pipe -fomit-frame-pointer"
56
57                 echo "CFLAGS+=-Wall -fPIC -DPIC \$(TARGETARCH) \$(TARGETCPU) \$(OPTIMISATIONS) \$(MMX_FLAGS) \$(DEBUG_FLAGS) \$(LARGE_FILE)"
58
59                 case $targetos in
60                 Darwin)
61                 echo "CFLAGS+=-D__DARWIN__ `sdl-config --cflags`"
62                 echo "SHFLAGS=-dynamiclib"
63                 echo "LDFLAGS+=`sdl-config --libs`"
64                 ;;
65                 Linux)
66                 echo "OPTIMISATIONS+=-ffast-math"
67                 echo "CFLAGS+=-pthread"
68                 echo "SHFLAGS=-shared"
69                 echo "LIBDL=-ldl"
70                 echo "RDYNAMIC=-rdynamic"
71                 ;;
72                 *)
73                 ;;
74                 esac
75                 echo "LIBSUF=$LIBSUF"
76         ) > config.mak
77
78         echo "#!/bin/sh" > mlt-config
79         (
80                 echo export version=$version
81                 echo export prefix=$prefix
82                 echo export bindir=$prefix/bin
83         ) >> mlt-config
84
85         cat < mlt-config-template >> mlt-config
86
87         echo -n > packages.dat
88 }
89
90 function build_pkgconfig
91 {
92         for i in framework valerie miracle
93         do
94                 echo "prefix=$prefix" >mlt-$i.pc
95                 echo "exec_prefix=$prefix" >>mlt-$i.pc
96                 echo "libdir=$prefix/lib" >>mlt-$i.pc
97                 echo "includedir=$prefix/include" >>mlt-$i.pc
98                 echo "version=$version" >>mlt-$i.pc
99                 echo "cflags=`grep ^$i packages.dat | cut -f 2`" >>mlt-$i.pc
100                 echo "libs=`grep ^$i packages.dat | cut -f 3`" >>mlt-$i.pc
101                 cat mlt-$i.pc.in >>mlt-$i.pc
102         done
103 }
104
105 # Debug mode
106 set +x
107
108 # Define build directory for scripts called
109 export build_dir=`dirname $0`
110 export prefix=/usr/local
111 export help=0
112 export version=0.1.1
113 export debug=true
114 export mmx=true
115 export gpl=false
116 export cpu=
117 export motionest=false
118
119 # Determine OS
120 targetos=$(uname -s)
121 # Chose appropriate suffix for libraries
122 case $targetos in
123         Darwin)
124         LIBSUF=".dylib"
125         mmx=false
126         ;;
127         Linux)
128         LIBSUF=".so"
129         ;;
130         *)
131         LIBSUF=".so"
132         ;;
133 esac
134 export LIBSUF
135
136 # Iterate through arguments
137 for i in "$@"
138 do
139         case $i in
140                 --help )                        help=1 ;;
141                 --prefix=* )            prefix="${i#--prefix=}" ;;
142                 --disable-debug )       debug=false ;;
143                 --disable-mmx )         mmx=false ;;
144                 --enable-gpl )          gpl=true ;;
145                 --enable-motion-est )   motionest=true ;;
146                 --cpu=* )                       cpu="${i#--cpu=}" ;;
147         esac
148 done
149
150 # Double check mmx (may end up disabling mmx on non-linux platforms incorrectly)
151 if [ "$mmx" = "true" ]
152 then
153         grep mmx /proc/cpuinfo > /dev/null 2>&1 || mmx=false
154 fi
155
156 # Show help if requested
157 [ $help = 1 ] && show_help || build_config
158
159 # Iterate through each of the components
160 for i in framework modules inigo valerie miracle humperdink
161 do
162         if [ -x src/$i/configure ]
163         then
164                 [ $help = 0 ] && echo "Configuring `basename $i`:"
165                 olddir=`pwd`
166                 cd src/$i
167                 ./configure "$@"
168                 [ $? != 0 ] && exit 1
169                 cd $olddir
170         fi
171 done
172
173 # Build the pkg-config files
174 build_pkgconfig
175
176 # Report GPL Usage
177 [ $help != 1 ] && 
178 ( [ "$gpl" = "false" ] && 
179 echo "GPL Components are disabled" || 
180 echo "GPL License Used" )
181
182 if [ "$motionest" = "true" -a "$gpl" = "false" ]
183 then
184         echo "Add the --enable-gpl flag to build the motion estimation components."
185 fi