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