76f4986bdbc7591f5969dd2b24e20873e95183db
[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" \> "$MAJOR" ]; then
89     debug "$pkg_major <= $MAJOR"
90     if [ "$pkg_major" \< "$MAJOR" ]; then
91       WRONG=1
92     elif [ ! "$pkg_minor" \> "$MINOR" ]; then
93       if [ "$pkg_minor" \< "$MINOR" ]; then
94         WRONG=1
95       elif [ "$pkg_micro" \< "$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 "+ creating acinclude.m4"
146 cat m4/*.m4 > acinclude.m4
147
148 echo "+ running aclocal ..."
149 aclocal $ACLOCAL_FLAGS || {
150         echo
151         echo "aclocal failed - check that all needed development files are present on system"
152         exit 1
153 }
154
155 # FIXME : why does libtoolize keep complaining about aclocal ?
156 echo "+ not running libtoolize until libtool fix has flown downstream"
157 #echo "+ running libtoolize ..."
158 #libtoolize --copy --force || {
159 #       echo
160 #       echo "libtoolize failed"
161 #       exit 1
162 #}
163
164 echo "+ running autoheader ... "
165 autoheader || {
166         echo
167         echo "autoheader failed"
168         exit 1
169 }
170 # touch the stamp-h.in build stamp so we don't re-run autoheader in maintainer mode -- wingo
171 echo timestamp > stamp-h.in 2> /dev/null
172 echo "+ running autoconf ... "
173 autoconf || {
174         echo
175         echo "autoconf failed"
176         exit 1
177 }
178 echo "+ running automake ... "
179 automake -a -c || {
180         echo
181         echo "automake failed"
182         exit 1
183 }
184
185 echo
186 echo "+ running autogen.sh in gst/cothreads..."
187 pushd gst/cothreads > /dev/null
188 echo
189 ./autogen.sh --autogen-noconfigure --autogen-nocheck
190 popd > /dev/null
191 echo
192
193 test -n "$NOCONFIGURE" && {
194     echo "skipping configure stage for package $package, as requested."
195     echo "autogen.sh done."
196     exit 0
197 }
198
199 echo "+ running configure ... "
200 echo "./configure default flags: $CONFIGURE_OPT"
201 echo "using: $CONFIGURE_OPT $@"
202 echo
203
204 ./configure $CONFIGURE_OPT "$@" || {
205         echo
206         echo "configure failed"
207         exit 1
208 }
209
210 echo 
211 echo "Now type 'make' to compile $package."