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