a little bit more output
[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 if test "x$1" = "x-d"; then echo "+ debug output enabled"; DEBUG=defined; fi
9
10 debug ()
11 # print out a debug message if DEBUG is a defined variable
12 {
13   if test ! -z "$DEBUG"
14   then
15     echo "DEBUG: $1"
16   fi
17 }
18
19 version_check ()
20 # check the version of a package
21 # first argument : package name (executable)
22 # second argument : source download url
23 # rest of arguments : major, minor, micro version
24 {
25   PACKAGE=$1
26   URL=$2
27   MAJOR=$3
28   MINOR=$4
29   MICRO=$5
30
31
32   debug "major $MAJOR minor $MINOR micro $MICRO"
33   VERSION=$MAJOR
34   if test ! -z "$MINOR"; then VERSION=$VERSION.$MINOR; else MINOR=0; fi
35   if test ! -z "$MICRO"; then VERSION=$VERSION.$MICRO; else MICRO=0; fi
36
37   debug "major $MAJOR minor $MINOR micro $MICRO"
38   echo -n "+ checking for $1 > $VERSION ... "
39   ($PACKAGE --version) < /dev/null > /dev/null 2>&1 || 
40   {
41         echo
42         echo "You must have $PACKAGE installed to compile $package."
43         echo "Download the appropriate package for your distribution,"
44         echo "or get the source tarball at $URL"
45         return 1
46   }
47   # the following line is carefully crafted sed magic
48   pkg_version=`$PACKAGE --version|head -n 1|sed 's/^[a-zA-z\.\ ()]*//;s/ .*$//'`
49   debug "pkg_version $pkg_version"
50   pkg_major=`echo $pkg_version | cut -d. -f1`
51   pkg_minor=`echo $pkg_version | cut -d. -f2`
52   pkg_micro=`echo $pkg_version | cut -d. -f3`
53   test -z "$pkg_minor" && pkg_minor=0
54   test -z "$pkg_micro" && pkg_micro=0
55
56   debug "found major $pkg_major minor $pkg_minor micro $pkg_micro"
57
58   #start checking the version
59   debug "version check"
60
61   if [ ! "$pkg_major" \> "$MAJOR" ]; then
62     debug "$pkg_major <= $MAJOR"
63     if [ "$pkg_major" \< "$MAJOR" ]; then
64       WRONG=1
65     elif [ ! "$pkg_minor" \> "$MINOR" ]; then
66       if [ "$pkg_minor" \< "$MINOR" ]; then
67         WRONG=1
68       elif [ "$pkg_micro" \< "$MICRO" ]; then
69         WRONG=1
70       fi
71     fi
72   fi
73
74   if test ! -z "$WRONG"; then
75     echo "- found $pkg_version, not ok !"
76     echo
77     echo "You must have $PACKAGE $VERSION or greater to compile $package."
78     echo "Get the latest version from $URL"
79     return 1
80   else
81     echo "- found $pkg_version, ok."
82   fi
83 }
84
85 version_check "autoconf" "ftp://ftp.gnu.org/pub/gnu/autoconf/" 2 52 || DIE=1
86 version_check "automake" "ftp://ftp.gnu.org/pub/gnu/automake/" 1 5 || DIE=1
87 version_check "libtool" "ftp://ftp.gnu.org/pub/gnu/libtool/" 1 4 0 || DIE=1
88 version_check "pkg-config" "http://www.freedesktop.org/software/pkgconfig" 0 7 0 || DIE=1
89
90 echo
91
92 if test "$DIE" -eq 1; then
93         exit 1
94 fi
95
96 test -f $srcfile || {
97         echo "You must run this script in the top-level $package directory"
98         exit 1
99 }
100
101 if test -z "$*"; then
102         echo "I am going to run ./configure with no arguments - if you wish "
103         echo "to pass any to it, please specify them on the $0 command line."
104 fi
105
106 # FIXME : why does libtoolize keep complaining about aclocal ?
107 echo "+ running libtoolize ..."
108 libtoolize --copy --force
109
110 echo "+ running aclocal ..."
111 aclocal $ACLOCAL_FLAGS || {
112         echo
113         echo "aclocal failed - check that all needed development files are present on system"
114         exit 1
115 }
116 echo "+ running autoheader ... "
117 autoheader || {
118         echo
119         echo "autoheader failed"
120         exit 1
121 }
122 echo "+ running autoconf ... "
123 autoconf || {
124         echo
125         echo "autoconf failed"
126         #exit 1
127 }
128 echo "+ running automake ... "
129 automake --add-missing || {
130         echo
131         echo "automake failed"
132         #exit 1
133 }
134
135 # now remove the cache, because it can be considered dangerous in this case
136 echo "+ removing config.cache ... "
137 rm -f config.cache
138
139 CONFIGURE_OPT='--enable-maintainer-mode --enable-plugin-builddir --enable-debug --enable-DEBUG'
140
141 echo "+ running configure ... "
142 echo "./configure default flags: $CONFIGURE_OPT"
143 echo "using: $CONFIGURE_OPT $@"
144 echo
145
146 ./configure $CONFIGURE_OPT "$@" || {
147         echo
148         echo "configure failed"
149         exit 1
150 }
151
152 echo 
153 echo "Now type 'make' to compile $package."