~ubuntu-branches/ubuntu/precise/transmageddon/precise

« back to all changes in this revision

Viewing changes to common/gst-autogen.sh

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2009-10-14 08:28:43 UTC
  • Revision ID: james.westby@ubuntu.com-20091014082843-uxbyrcqydc13zrim
Tags: upstream-0.14
ImportĀ upstreamĀ versionĀ 0.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# a silly hack that generates autoregen.sh but it's handy
 
2
# Remove the old autoregen.sh first to create a new file,
 
3
# as the current one may be being read by the shell executing
 
4
# this script.
 
5
if [ -f "autoregen.sh" ]; then
 
6
  rm autoregen.sh
 
7
fi
 
8
echo "#!/bin/sh" > autoregen.sh
 
9
echo "./autogen.sh $@ \$@" >> autoregen.sh
 
10
chmod +x autoregen.sh
 
11
 
 
12
# helper functions for autogen.sh
 
13
 
 
14
debug ()
 
15
# print out a debug message if DEBUG is a defined variable
 
16
{
 
17
  if test ! -z "$DEBUG"
 
18
  then
 
19
    echo "DEBUG: $1"
 
20
  fi
 
21
}
 
22
 
 
23
version_check ()
 
24
# check the version of a package
 
25
# first argument : package name (executable)
 
26
# second argument : optional path where to look for it instead
 
27
# third argument : source download url
 
28
# rest of arguments : major, minor, micro version
 
29
# all consecutive ones : suggestions for binaries to use
 
30
# (if not specified in second argument)
 
31
{
 
32
  PACKAGE=$1
 
33
  PKG_PATH=$2
 
34
  URL=$3
 
35
  MAJOR=$4
 
36
  MINOR=$5
 
37
  MICRO=$6
 
38
 
 
39
  # for backwards compatibility, we let PKG_PATH=PACKAGE when PKG_PATH null
 
40
  if test -z "$PKG_PATH"; then PKG_PATH=$PACKAGE; fi
 
41
  debug "major $MAJOR minor $MINOR micro $MICRO"
 
42
  VERSION=$MAJOR
 
43
  if test ! -z "$MINOR"; then VERSION=$VERSION.$MINOR; else MINOR=0; fi
 
44
  if test ! -z "$MICRO"; then VERSION=$VERSION.$MICRO; else MICRO=0; fi
 
45
 
 
46
  debug "major $MAJOR minor $MINOR micro $MICRO"
 
47
  
 
48
  for SUGGESTION in $PKG_PATH; do 
 
49
    COMMAND="$SUGGESTION"
 
50
 
 
51
    # don't check if asked not to
 
52
    test -z "$NOCHECK" && {
 
53
      echo -n "  checking for $COMMAND >= $VERSION ... "
 
54
    } || {
 
55
      # we set a var with the same name as the package, but stripped of
 
56
      # unwanted chars
 
57
      VAR=`echo $PACKAGE | sed 's/-//g'`
 
58
      debug "setting $VAR"
 
59
      eval $VAR="$COMMAND"
 
60
      return 0
 
61
    }
 
62
 
 
63
    debug "checking version with $COMMAND"
 
64
    ($COMMAND --version) < /dev/null > /dev/null 2>&1 || 
 
65
    {
 
66
      echo "not found."
 
67
      continue
 
68
    }
 
69
    # strip everything that's not a digit, then use cut to get the first field
 
70
    pkg_version=`$COMMAND --version|head -n 1|sed 's/^.*)[^0-9]*//'|cut -d' ' -f1`
 
71
    debug "pkg_version $pkg_version"
 
72
    # remove any non-digit characters from the version numbers to permit numeric
 
73
    # comparison
 
74
    pkg_major=`echo $pkg_version | cut -d. -f1 | sed s/[a-zA-Z\-].*//g`
 
75
    pkg_minor=`echo $pkg_version | cut -d. -f2 | sed s/[a-zA-Z\-].*//g`
 
76
    pkg_micro=`echo $pkg_version | cut -d. -f3 | sed s/[a-zA-Z\-].*//g`
 
77
    test -z "$pkg_major" && pkg_major=0
 
78
    test -z "$pkg_minor" && pkg_minor=0
 
79
    test -z "$pkg_micro" && pkg_micro=0
 
80
    debug "found major $pkg_major minor $pkg_minor micro $pkg_micro"
 
81
 
 
82
    #start checking the version
 
83
    debug "version check"
 
84
 
 
85
    # reset check
 
86
    WRONG=
 
87
 
 
88
    if [ ! "$pkg_major" -gt "$MAJOR" ]; then
 
89
      debug "major: $pkg_major <= $MAJOR"
 
90
      if [ "$pkg_major" -lt "$MAJOR" ]; then
 
91
        debug "major: $pkg_major < $MAJOR"
 
92
        WRONG=1
 
93
      elif [ ! "$pkg_minor" -gt "$MINOR" ]; then
 
94
        debug "minor: $pkg_minor <= $MINOR"
 
95
        if [ "$pkg_minor" -lt "$MINOR" ]; then
 
96
          debug "minor: $pkg_minor < $MINOR"
 
97
          WRONG=1
 
98
        elif [ "$pkg_micro" -lt "$MICRO" ]; then
 
99
          debug "micro: $pkg_micro < $MICRO"
 
100
          WRONG=1
 
101
        fi
 
102
      fi
 
103
    fi
 
104
 
 
105
    if test ! -z "$WRONG"; then
 
106
      echo "found $pkg_version, not ok !"
 
107
      continue
 
108
    else
 
109
      echo "found $pkg_version, ok."
 
110
      # we set a var with the same name as the package, but stripped of
 
111
      # unwanted chars
 
112
      VAR=`echo $PACKAGE | sed 's/-//g'`
 
113
      debug "setting $VAR"
 
114
      eval $VAR="$COMMAND"
 
115
      return 0
 
116
    fi
 
117
  done
 
118
 
 
119
  echo "not found !"
 
120
  echo "You must have $PACKAGE installed to compile $package."
 
121
  echo "Download the appropriate package for your distribution,"
 
122
  echo "or get the source tarball at $URL"
 
123
  return 1;
 
124
}
 
125
 
 
126
aclocal_check ()
 
127
{
 
128
  # normally aclocal is part of automake
 
129
  # so we expect it to be in the same place as automake
 
130
  # so if a different automake is supplied, we need to adapt as well
 
131
  # so how's about replacing automake with aclocal in the set var,
 
132
  # and saving that in $aclocal ?
 
133
  # note, this will fail if the actual automake isn't called automake*
 
134
  # or if part of the path before it contains it
 
135
  if [ -z "$automake" ]; then
 
136
    echo "Error: no automake variable set !"
 
137
    return 1
 
138
  else
 
139
    aclocal=`echo $automake | sed s/automake/aclocal/`
 
140
    debug "aclocal: $aclocal"
 
141
    if [ "$aclocal" != "aclocal" ];
 
142
    then
 
143
      CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-aclocal=$aclocal"
 
144
    fi
 
145
    if [ ! -x `which $aclocal` ]; then
 
146
      echo "Error: cannot execute $aclocal !"
 
147
      return 1
 
148
    fi
 
149
  fi
 
150
}
 
151
 
 
152
autoheader_check ()
 
153
{
 
154
  # same here - autoheader is part of autoconf
 
155
  # use the same voodoo
 
156
  if [ -z "$autoconf" ]; then
 
157
    echo "Error: no autoconf variable set !"
 
158
    return 1
 
159
  else
 
160
    autoheader=`echo $autoconf | sed s/autoconf/autoheader/`
 
161
    debug "autoheader: $autoheader"
 
162
    if [ "$autoheader" != "autoheader" ];
 
163
    then
 
164
      CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-autoheader=$autoheader"
 
165
    fi
 
166
    if [ ! -x `which $autoheader` ]; then
 
167
      echo "Error: cannot execute $autoheader !"
 
168
      return 1
 
169
    fi
 
170
  fi
 
171
 
 
172
}
 
173
autoconf_2_52d_check ()
 
174
{
 
175
  # autoconf 2.52d has a weird issue involving a yes:no error
 
176
  # so don't allow it's use
 
177
  test -z "$NOCHECK" && {
 
178
    ac_version=`$autoconf --version|head -n 1|sed 's/^[a-zA-Z\.\ ()]*//;s/ .*$//'`
 
179
    if test "$ac_version" = "2.52d"; then
 
180
      echo "autoconf 2.52d has an issue with our current build."
 
181
      echo "We don't know who's to blame however.  So until we do, get a"
 
182
      echo "regular version.  RPM's of a working version are on the gstreamer site."
 
183
      exit 1
 
184
    fi
 
185
  }
 
186
  return 0
 
187
}
 
188
 
 
189
die_check ()
 
190
{
 
191
  # call with $DIE
 
192
  # if set to 1, we need to print something helpful then die
 
193
  DIE=$1
 
194
  if test "x$DIE" = "x1";
 
195
  then
 
196
    echo
 
197
    echo "- Please get the right tools before proceeding."
 
198
    echo "- Alternatively, if you're sure we're wrong, run with --nocheck."
 
199
    exit 1
 
200
  fi
 
201
}
 
202
 
 
203
autogen_options ()
 
204
{
 
205
  if test "x$1" = "x"; then
 
206
    return 0
 
207
  fi
 
208
 
 
209
  while test "x$1" != "x" ; do
 
210
    optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
 
211
    case "$1" in
 
212
      --noconfigure)
 
213
          NOCONFIGURE=defined
 
214
          AUTOGEN_EXT_OPT="$AUTOGEN_EXT_OPT --noconfigure"
 
215
          echo "+ configure run disabled"
 
216
          shift
 
217
          ;;
 
218
      --nocheck)
 
219
          AUTOGEN_EXT_OPT="$AUTOGEN_EXT_OPT --nocheck"
 
220
          NOCHECK=defined
 
221
          echo "+ autotools version check disabled"
 
222
          shift
 
223
          ;;
 
224
      --debug)
 
225
          DEBUG=defined
 
226
          AUTOGEN_EXT_OPT="$AUTOGEN_EXT_OPT --debug"
 
227
          echo "+ debug output enabled"
 
228
          shift
 
229
          ;;
 
230
      -h|--help)
 
231
          echo "autogen.sh (autogen options) -- (configure options)"
 
232
          echo "autogen.sh help options: "
 
233
          echo " --noconfigure            don't run the configure script"
 
234
          echo " --nocheck                don't do version checks"
 
235
          echo " --debug                  debug the autogen process"
 
236
          echo
 
237
          echo " --with-autoconf PATH     use autoconf in PATH"
 
238
          echo " --with-automake PATH     use automake in PATH"
 
239
          echo
 
240
          echo "Any argument either not in the above list or after a '--' will be "
 
241
          echo "passed to ./configure."
 
242
          exit 1
 
243
          ;;
 
244
      --with-automake=*)
 
245
          AUTOMAKE=$optarg
 
246
          echo "+ using alternate automake in $optarg"
 
247
          CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-automake=$AUTOMAKE"
 
248
          shift
 
249
          ;;
 
250
      --with-autoconf=*)
 
251
          AUTOCONF=$optarg
 
252
          echo "+ using alternate autoconf in $optarg"
 
253
          CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-autoconf=$AUTOCONF"
 
254
          shift
 
255
          ;;
 
256
      --) shift ; break ;;
 
257
      *)
 
258
          echo "+ passing argument $1 to configure"
 
259
          CONFIGURE_EXT_OPT="$CONFIGURE_EXT_OPT $1"
 
260
          shift
 
261
          ;;
 
262
    esac
 
263
  done
 
264
 
 
265
  for arg do CONFIGURE_EXT_OPT="$CONFIGURE_EXT_OPT $arg"; done
 
266
  if test ! -z "$CONFIGURE_EXT_OPT"
 
267
  then
 
268
    echo "+ options passed to configure: $CONFIGURE_EXT_OPT"
 
269
  fi
 
270
}
 
271
 
 
272
toplevel_check ()
 
273
{
 
274
  srcfile=$1
 
275
  test -f $srcfile || {
 
276
        echo "You must run this script in the top-level $package directory"
 
277
        exit 1
 
278
  }
 
279
}
 
280
 
 
281
 
 
282
tool_run ()
 
283
{
 
284
  tool=$1
 
285
  options=$2
 
286
  run_if_fail=$3
 
287
  echo "+ running $tool $options..."
 
288
  $tool $options || {
 
289
    echo
 
290
    echo $tool failed
 
291
    eval $run_if_fail
 
292
    exit 1
 
293
  }
 
294
}