Prevent motion estimation components from building unless requested.
[melted] / 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
56                 echo "OPTIMISATIONS=-O4 -pipe -ffast-math -fomit-frame-pointer"
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__"
62                 echo "SHFLAGS=-dynamiclib"
63                 ;;
64                 Linux)
65                 echo "CFLAGS+=-pthread"
66                 echo "SHFLAGS=-shared"
67                 echo "LIBDL=-ldl"
68                 echo "RDYNAMIC=-rdynamic"
69                 ;;
70                 *)
71                 ;;
72                 esac
73                 echo "LIBSUF=$LIBSUF"
74         ) > config.mak
75
76         echo "#!/bin/sh" > mlt-config
77         (
78                 echo export version=$version
79                 echo export prefix=$prefix
80                 echo export bindir=$prefix/bin
81         ) >> mlt-config
82
83         cat < mlt-config-template >> mlt-config
84
85         echo -n > packages.dat
86 }
87
88 function build_pkgconfig
89 {
90         for i in framework valerie miracle
91         do
92                 echo "prefix=$prefix" >mlt-$i.pc
93                 echo "exec_prefix=$prefix" >>mlt-$i.pc
94                 echo "libdir=$prefix/lib" >>mlt-$i.pc
95                 echo "includedir=$prefix/include" >>mlt-$i.pc
96                 echo "version=$version" >>mlt-$i.pc
97                 echo "cflags=`grep ^$i packages.dat | cut -f 2`" >>mlt-$i.pc
98                 echo "libs=`grep ^$i packages.dat | cut -f 3`" >>mlt-$i.pc
99                 cat mlt-$i.pc.in >>mlt-$i.pc
100         done
101 }
102
103 # Debug mode
104 set +x
105
106 # Define build directory for scripts called
107 export build_dir=`dirname $0`
108 export prefix=/usr/local
109 export help=0
110 export version=0.1.1
111 export debug=true
112 export mmx=true
113 export gpl=false
114 export cpu=
115 export motionest=false
116
117 # Determine OS
118 targetos=$(uname -s)
119 # Chose appropriate suffix for libraries
120 case $targetos in
121         Darwin)
122         LIBSUF=".dylib"
123         mmx=false
124         ;;
125         Linux)
126         LIBSUF=".so"
127         ;;
128         *)
129         LIBSUF=".so"
130         ;;
131 esac
132 export LIBSUF
133
134 # Iterate through arguments
135 for i in "$@"
136 do
137         case $i in
138                 --help )                        help=1 ;;
139                 --prefix=* )            prefix="${i#--prefix=}" ;;
140                 --disable-debug )       debug=false ;;
141                 --disable-mmx )         mmx=false ;;
142                 --enable-gpl )          gpl=true ;;
143                 --enable-motion-est )   motionest=true ;;
144                 --cpu=* )                       cpu="${i#--cpu=}" ;;
145         esac
146 done
147
148 # Double check mmx (may end up disabling mmx on non-linux platforms incorrectly)
149 if [ "$mmx" = "true" ]
150 then
151         grep mmx /proc/cpuinfo > /dev/null 2>&1 || mmx=false
152 fi
153
154 # Show help if requested
155 [ $help = 1 ] && show_help || build_config
156
157 # Iterate through each of the components
158 for i in framework modules inigo valerie miracle humperdink
159 do
160         if [ -x src/$i/configure ]
161         then
162                 [ $help = 0 ] && echo "Configuring `basename $i`:"
163                 olddir=`pwd`
164                 cd src/$i
165                 ./configure "$@"
166                 [ $? != 0 ] && exit 1
167                 cd $olddir
168         fi
169 done
170
171 # Build the pkg-config files
172 build_pkgconfig
173
174 # Report GPL Usage
175 [ $help != 1 ] && 
176 ( [ "$gpl" = "false" ] && 
177 echo "GPL Components are disabled" || 
178 echo "GPL License Used" )
179
180 if [ "$motionest" = "true" -a "$gpl" = "false" ]
181 then
182         echo "Add the --enable-gpl flag to build the motion estimation components."
183 fi