more flapping wings about in wild abandonment
[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       echo "+ NOT checking for $1 >= $VERSION, as requested ..."
62       return 0
63   }
64   
65   ($PACKAGE --version) < /dev/null > /dev/null 2>&1 || 
66   {
67         echo
68         echo "You must have $PACKAGE installed to compile $package."
69         echo "Download the appropriate package for your distribution,"
70         echo "or get the source tarball at $URL"
71         return 1
72   }
73   # the following line is carefully crafted sed magic
74   pkg_version=`$PACKAGE --version|head -n 1|sed 's/^[a-zA-z\.\ ()]*//;s/ .*$//'`
75   debug "pkg_version $pkg_version"
76   pkg_major=`echo $pkg_version | cut -d. -f1`
77   pkg_minor=`echo $pkg_version | cut -d. -f2`
78   pkg_micro=`echo $pkg_version | cut -d. -f3`
79   test -z "$pkg_minor" && pkg_minor=0
80   test -z "$pkg_micro" && pkg_micro=0
81
82   debug "found major $pkg_major minor $pkg_minor micro $pkg_micro"
83
84   #start checking the version
85   debug "version check"
86
87   if [ ! "$pkg_major" \> "$MAJOR" ]; then
88     debug "$pkg_major <= $MAJOR"
89     if [ "$pkg_major" \< "$MAJOR" ]; then
90       WRONG=1
91     elif [ ! "$pkg_minor" \> "$MINOR" ]; then
92       if [ "$pkg_minor" \< "$MINOR" ]; then
93         WRONG=1
94       elif [ "$pkg_micro" \< "$MICRO" ]; then
95         WRONG=1
96       fi
97     fi
98   fi
99
100   if test ! -z "$WRONG"; then
101     echo "found $pkg_version, not ok !"
102     echo
103     echo "You must have $PACKAGE $VERSION or greater to compile $package."
104     echo "Get the latest version from $URL"
105     return 1
106   else
107     echo "found $pkg_version, ok."
108   fi
109 }
110
111 # autoconf 2.52d has a weird issue involving a yes:no error
112 # so don't allow it's use
113 ac_version=`autoconf --version|head -n 1|sed 's/^[a-zA-z\.\ ()]*//;s/ .*$//'`
114 if test "$ac_version" = "2.52d"; then
115   echo "autoconf 2.52d has an issue with our current build."
116   echo "We don't know who's to blame however.  So until we do, get a"
117   echo "regular version.  RPM's of a working version are on the gstreamer site."
118   exit 1
119 fi
120
121
122 version_check "autoconf" "ftp://ftp.gnu.org/pub/gnu/autoconf/" 2 52 || DIE=1
123 version_check "automake" "ftp://ftp.gnu.org/pub/gnu/automake/" 1 5 || DIE=1
124 version_check "libtool" "ftp://ftp.gnu.org/pub/gnu/libtool/" 1 4 0 || DIE=1
125 version_check "pkg-config" "http://www.freedesktop.org/software/pkgconfig" 0 8 0 || DIE=1
126
127 if test "$DIE" -eq 1; then
128         exit 1
129 fi
130
131 test -f $srcfile || {
132         echo "You must run this script in the top-level $package directory"
133         exit 1
134 }
135
136 if test -z "$*"; then
137         echo "I am going to run ./configure with no arguments - if you wish "
138         echo "to pass any to it, please specify them on the $0 command line."
139 fi
140
141 echo "+ creating acinclude.m4"
142 cat m4/*.m4 > acinclude.m4
143
144 echo "+ running aclocal ..."
145 aclocal $ACLOCAL_FLAGS || {
146         echo
147         echo "aclocal failed - check that all needed development files are present on system"
148         exit 1
149 }
150
151 # FIXME : why does libtoolize keep complaining about aclocal ?
152 ## echo "+ running libtoolize ..."
153 ## libtoolize --copy --force
154
155 echo "+ running autoheader ... "
156 autoheader || {
157         echo
158         echo "autoheader failed"
159         exit 1
160 }
161 # touch the stamp-h.in build stamp so we don't re-run autoheader in maintainer mode -- wingo
162 echo timestamp > stamp-h.in 2> /dev/null
163 echo "+ running autoconf ... "
164 autoconf || {
165         echo
166         echo "autoconf failed"
167         exit 1
168 }
169 echo "+ running automake ... "
170 automake -a -c || {
171         echo
172         echo "automake failed"
173         exit 1
174 }
175
176 CONFIGURE_OPT='--enable-maintainer-mode --enable-plugin-builddir --enable-debug --enable-DEBUG'
177
178 # if enable exists, add an -enable option for each of the lines in that file
179 if test -f enable; then
180   for a in `cat enable`; do
181     CONFIGURE_OPT="$CONFIGURE_OPT --enable-$a"
182   done
183 fi
184
185 # if disable exists, add an -disable option for each of the lines in that file
186 if test -f disable; then
187   for a in `cat disable`; do
188     CONFIGURE_OPT="$CONFIGURE_OPT --disable-$a"
189   done
190 fi
191
192 test -n "$NOCONFIGURE" && {
193     echo "skipping configure stage for package $package, as requested."
194     echo "autogen.sh done."
195     exit 0
196 }
197
198 echo "+ running configure ... "
199 echo "./configure default flags: $CONFIGURE_OPT"
200 echo "using: $CONFIGURE_OPT $@"
201 echo
202
203 ./configure $CONFIGURE_OPT "$@" || {
204         echo
205         echo "configure failed"
206         exit 1
207 }
208
209 echo 
210 echo "Now type 'make' to compile $package."