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