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