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