updated libtool check to handle things like '1.4b'
[platform/upstream/gstreamer.git] / autogen.sh
1 #!/bin/sh
2 # Run this to generate all the initial makefiles, etc.
3
4 DIE=0
5 package=GStreamer
6 srcfile=gst/gstobject.h
7
8 (autoconf --version) < /dev/null > /dev/null 2>&1 || {
9         echo
10         echo "You must have autoconf installed to compile $package."
11         echo "Download the appropriate package for your distribution,"
12         echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/autoconf/"
13         DIE=1
14 }
15
16 (automake --version) < /dev/null > /dev/null 2>&1 || {
17         echo
18         echo "You must have automake installed to compile $package."
19         echo "Download the appropriate package for your distribution,"
20         echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/automake/"
21         DIE=1
22 }
23 automakevermin=`(automake --version|head -n 1|sed 's/^.* //;s/\./ /g;';echo "1 4")|sort -n|head -n 1`
24 automakevergood=`(automake --version|head -n 1|sed 's/^.* //;s/\./ /g;';echo "1 4f")|sort -n|head -n 1`
25 if test "x$automakevermin" != "x1 4"; then
26 # version is less than 1.4, the minimum suitable version
27         echo
28         echo "You must have automake version 1.4 or greater installed."
29         echo "Download the appropriate package for your distribution,"
30         echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/automake/"
31         DIE=1
32 else
33 if test "x$automakevergood" != "x1 4f"; then
34 echo -n "Checking for patched automake..."
35 # version is less than 1.4f, the version with the patch applied
36 # check that patch is applied
37 cat > autogen.patch.tmp <<EOF
38 --- 1
39 +++ 2
40 @@ -2383,8 +2383,8 @@
41         # to all possible directories, and use it.  If DIST_SUBDIRS is
42         # defined, just use it.
43         local (\$dist_subdir_name);
44 -       if (&variable_defined ('DIST_SUBDIRS')
45 -           || &variable_conditions ('SUBDIRS'))
46 +       if (&variable_conditions ('SUBDIRS')
47 +           || &variable_defined ('DIST_SUBDIRS'))
48         {
49             \$dist_subdir_name = 'DIST_SUBDIRS';
50             if (! &variable_defined ('DIST_SUBDIRS'))
51 EOF
52   if patch -s -f --dry-run `which automake` <autogen.patch.tmp >/dev/null 2>&1;
53   then
54     # Patch succeeded: appropriately patched.
55     echo " found."
56   else
57     # Patch failed: either unpatched or incompatibly patched.
58     if patch -R -s -f --dry-run `which automake` <autogen.patch.tmp >/dev/null 2>&1;
59     then
60       # Reversed patch succeeded: not patched.
61       echo " not found."
62       echo
63       echo "Detected automake version 1.4 (or near) without patch."
64       echo "Your version of automake needs a patch applied in order to operate correctly."
65       echo
66       patchedfile="`pwd`/automake"
67       if test -e $patchedfile; then 
68         PATCHED=0
69       else
70         echo "making a patched version..."
71         patch -R -s -f `which automake` <autogen.patch.tmp -o $patchedfile;
72         chmod +x $patchedfile;
73         PATCHED=1
74       fi
75       echo
76       echo "***************************************************************************"
77       if test -e $patchedfile; then 
78         if test "x$PATCHED" == "x1"; then
79           echo "A patched version of automake is available at:"
80           echo "$patchedfile"
81           echo "You should put this in an appropriate place, or modify \$PATH, so that it is"
82           echo "used in preference to this installed version of automake."
83         fi
84       fi
85       echo "It is not safe to perform the build without a patched automake."
86       echo "Read the README file for an explanation."
87       echo "***************************************************************************"
88       echo
89       DIE=1
90     else
91       # Reversed patch failed: incompatibly patched.
92       echo
93       echo
94       echo "Unable to check whether automake is appropriately patched."
95       echo "Your version of automake may need to have a patch applied."
96       echo "Read the README file for more explanation."
97       echo
98     fi
99   fi
100 rm autogen.patch.tmp
101 fi
102 fi
103
104
105 (pkg-config --version) < /dev/null > /dev/null 2>&1 || {
106         echo
107         echo "You must have pkg-config installed to compile $package."
108         echo "Download the appropriate package for your distribution,"
109         echo "or get the source tarball at:"
110         echo "http://www.freedesktop.org/software/pkgconfig/"
111         DIE=1
112 }
113
114
115 (libtool --version) < /dev/null > /dev/null 2>&1 || {
116         echo
117         echo "You must have libtool installed to compile $package."
118         echo "Get the latest version from ftp://alpha.gnu.org/gnu/libtool/"
119         DIE=1
120 }
121
122 libtool_version=`libtool --version | sed 's/^.* \([0-9a-z\.]*\) .*$/\1/'`
123 libtool_major=`echo $libtool_version | cut -d. -f1`
124 libtool_minor=`echo $libtool_version | cut -d. -f2`
125 libtool_micro=`echo $libtool_version | cut -d. -f3`
126 if [ x$libtool_micro = x ]; then
127         libtool_micro=0
128 fi
129 if [ $libtool_major -le 1 ]; then
130         if [ $libtool_major -lt 1 ]; then
131                 echo
132                 echo "You must have libtool 1.3.5 or greater to compile $package."
133                 echo "Get the latest version from ftp://alpha.gnu.org/gnu/libtool/"
134                 DIE=1
135         elif [ $libtool_minor -le 3 ]; then
136                 if [ $libtool_minor -lt 3 ]; then
137                         echo
138                         echo "You must have libtool 1.3.5 or greater to compile $package."
139                         echo "Get the latest version from ftp://alpha.gnu.org/gnu/libtool/"
140                         DIE=1
141                 elif [ $libtool_micro -lt 5 ]; then
142                         echo
143                         echo "You must have libtool 1.3.5 or greater to compile $package."
144                         echo "Get the latest version from ftp://alpha.gnu.org/gnu/libtool/"
145                         DIE=1
146                 fi
147         fi
148 fi
149
150 if test "$DIE" -eq 1; then
151         exit 1
152 fi
153
154 test -f $srcfile || {
155         echo "You must run this script in the top-level $package directory"
156         exit 1
157 }
158
159 if test -z "$*"; then
160         echo "I am going to run ./configure with no arguments - if you wish "
161         echo "to pass any to it, please specify them on the $0 command line."
162 fi
163
164
165 # Generate configure.in and configure.ac
166 ./makeconfigure <configure.base > configure.in configure.in
167 ./makeconfigure <configure.base > configure.ac configure.ac
168
169 libtoolize --copy --force
170 aclocal $ACLOCAL_FLAGS || {
171         echo
172         echo "aclocal failed - check that all needed development files are present on system"
173         exit 1
174 }
175 autoheader || {
176         echo
177         echo "autoheader failed"
178         exit 1
179 }
180 autoconf || {
181         echo
182         echo "autoconf failed"
183         #exit 1
184 }
185 automake --add-missing || {
186         echo
187         echo "automake failed"
188         #exit 1
189 }
190
191 # now remove the cache, because it can be considered dangerous in this case
192 rm -f config.cache
193
194 # The new configure options for busy application developers (Hadess)
195 #./configure --enable-maintainer-mode --enable-debug --enable-DEBUG "$@" || {
196
197 ./configure --enable-maintainer-mode --enable-plugin-builddir --enable-debug --enable-DEBUG "$@" || {
198         echo
199         echo "configure failed"
200         exit 1
201 }
202
203 echo 
204 echo "Now type 'make' to compile $package."