taaz's yapping
[platform/upstream/gstreamer.git] / autogen.sh
1 #!/bin/bash
2 # Run this to generate all the initial makefiles, etc.
3
4 DIE=0
5 package=GStreamer
6 srcfile=gst/gstobject.h
7 #DEBUG=defined
8
9 for a in common libs/ext/cothreads; do
10   if test ! -d $a;
11   then
12     echo "+ getting $a from cvs"
13     cvs co $a
14   fi
15 done
16
17 CONFIGURE_OPT='--enable-maintainer-mode --enable-plugin-builddir'
18
19 for i in $@; do
20     if test "$i" = "--autogen-noconfigure"; then
21         NOCONFIGURE=defined
22         echo "+ configure run disabled"
23     elif test "$i" = "--autogen-nocheck"; then
24         NOCHECK=defined
25         echo "+ autotools version check disabled"
26     elif test "$i" = "--autogen-debug"; then
27         DEBUG=defined
28         echo "+ debug output enabled"
29     elif test "$i" = "--help"; then
30         echo "autogen.sh help options: "
31         echo " --autogen-noconfigure    don't run the configure script"
32         echo " --autogen-nocheck        don't do version checks"
33         echo " --autogen-debug          debug the autogen process"
34         echo "continuing with the autogen in order to get configure help messages..."
35     fi
36 done
37
38 debug ()
39 # print out a debug message if DEBUG is a defined variable
40 {
41   if test ! -z "$DEBUG"
42   then
43     echo "DEBUG: $1"
44   fi
45 }
46
47 version_check ()
48 # check the version of a package
49 # first argument : package name (executable)
50 # second argument : source download url
51 # rest of arguments : major, minor, micro version
52 {
53   PACKAGE=$1
54   URL=$2
55   MAJOR=$3
56   MINOR=$4
57   MICRO=$5
58
59   WRONG=
60
61   debug "major $MAJOR minor $MINOR micro $MICRO"
62   VERSION=$MAJOR
63   if test ! -z "$MINOR"; then VERSION=$VERSION.$MINOR; else MINOR=0; fi
64   if test ! -z "$MICRO"; then VERSION=$VERSION.$MICRO; else MICRO=0; fi
65
66   debug "major $MAJOR minor $MINOR micro $MICRO"
67   
68   test -z "$NOCHECK" && {
69       echo -n "+ checking for $1 >= $VERSION ... "
70   } || {
71       return 0
72   }
73   
74   ($PACKAGE --version) < /dev/null > /dev/null 2>&1 || 
75   {
76         echo
77         echo "You must have $PACKAGE installed to compile $package."
78         echo "Download the appropriate package for your distribution,"
79         echo "or get the source tarball at $URL"
80         return 1
81   }
82   # the following line is carefully crafted sed magic
83   pkg_version=`$PACKAGE --version|head -n 1|sed 's/^[a-zA-z\.\ ()]*//;s/ .*$//'`
84   debug "pkg_version $pkg_version"
85   pkg_major=`echo $pkg_version | cut -d. -f1`
86   pkg_minor=`echo $pkg_version | cut -d. -f2`
87   pkg_micro=`echo $pkg_version | cut -d. -f3`
88   test -z "$pkg_minor" && pkg_minor=0
89   test -z "$pkg_micro" && pkg_micro=0
90
91   debug "found major $pkg_major minor $pkg_minor micro $pkg_micro"
92
93   #start checking the version
94   debug "version check"
95
96   if [ ! "$pkg_major" -gt "$MAJOR" ]; then
97     debug "$pkg_major -le $MAJOR"
98     if [ "$pkg_major" -lt "$MAJOR" ]; then
99       WRONG=1
100     elif [ ! "$pkg_minor" -gt "$MINOR" ]; then
101       if [ "$pkg_minor" -lt "$MINOR" ]; then
102         WRONG=1
103       elif [ "$pkg_micro" -lt "$MICRO" ]; then
104         WRONG=1
105       fi
106     fi
107   fi
108
109   if test ! -z "$WRONG"; then
110     echo "found $pkg_version, not ok !"
111     echo
112     echo "You must have $PACKAGE $VERSION or greater to compile $package."
113     echo "Get the latest version from $URL"
114     return 1
115   else
116     echo "found $pkg_version, ok."
117   fi
118 }
119
120 # autoconf 2.52d has a weird issue involving a yes:no error
121 # so don't allow it's use
122 ac_version=`autoconf --version|head -n 1|sed 's/^[a-zA-z\.\ ()]*//;s/ .*$//'`
123 if test "$ac_version" = "2.52d"; then
124   echo "autoconf 2.52d has an issue with our current build."
125   echo "We don't know who's to blame however.  So until we do, get a"
126   echo "regular version.  RPM's of a working version are on the gstreamer site."
127   exit 1
128 fi
129
130
131 if test -z "$*"; then
132         echo "This autogen script will automatically run ./configure as:"
133         echo "./configure $CONFIGURE_OPT"
134         echo "To pass any other options, please specify them on the $0"
135         echo "command line."
136         echo
137 fi
138
139 version_check "autoconf" "ftp://ftp.gnu.org/pub/gnu/autoconf/" 2 52 || DIE=1
140 version_check "automake" "ftp://ftp.gnu.org/pub/gnu/automake/" 1 5 || DIE=1
141 version_check "libtool" "ftp://ftp.gnu.org/pub/gnu/libtool/" 1 4 0 || DIE=1
142 version_check "pkg-config" "http://www.freedesktop.org/software/pkgconfig" 0 8 0 || DIE=1
143
144 if test "$DIE" -eq 1; then
145         exit 1
146 fi
147
148 test -f $srcfile || {
149         echo "You must run this script in the top-level $package directory"
150         exit 1
151 }
152
153 echo "+ running aclocal ..."
154 cat m4/*.m4 >acinclude.m4;aclocal $ACLOCAL_FLAGS || {
155         echo
156         echo "aclocal failed - check that all needed development files are present on system"
157         exit 1
158 }
159
160 # FIXME : why does libtoolize keep complaining about aclocal ?
161 echo "+ not running libtoolize until libtool fix has flown downstream"
162 #echo "+ running libtoolize ..."
163 #libtoolize --copy --force || {
164 #       echo
165 #       echo "libtoolize failed"
166 #       exit 1
167 #}
168
169 echo "+ running autoheader ... "
170 autoheader || {
171         echo
172         echo "autoheader failed"
173         exit 1
174 }
175 # touch the stamp-h.in build stamp so we don't re-run autoheader in maintainer mode -- wingo
176 echo timestamp > stamp-h.in 2> /dev/null
177 echo "+ running autoconf ... "
178 autoconf || {
179         echo
180         echo "autoconf failed"
181         exit 1
182 }
183 echo "+ running automake ... "
184 automake -a -c || {
185         echo
186         echo "automake failed"
187         exit 1
188 }
189
190 dnl echo
191 dnl echo "+ running autogen.sh in libs/ext/cothreads..."
192 dnl pushd libs/ext/cothreads > /dev/null
193 dnl echo
194 dnl ./autogen.sh --autogen-noconfigure --autogen-nocheck
195 dnl popd > /dev/null
196 dnl echo
197
198 test -n "$NOCONFIGURE" && {
199     echo "skipping configure stage for package $package, as requested."
200     echo "autogen.sh done."
201     exit 0
202 }
203
204 echo "+ running configure ... "
205 echo "./configure default flags: $CONFIGURE_OPT"
206 echo "using: $CONFIGURE_OPT $@"
207 echo
208
209 ./configure $CONFIGURE_OPT "$@" || {
210         echo
211         echo "configure failed"
212         exit 1
213 }
214
215 echo 
216 echo "Now type 'make' to compile $package."