leo_sobral@2: # a silly hack that generates autoregen.sh but it's handy leo_sobral@2: echo "#!/bin/sh" > autoregen.sh leo_sobral@2: echo "./autogen.sh $@ \$@" >> autoregen.sh leo_sobral@2: chmod +x autoregen.sh leo_sobral@2: leo_sobral@2: # helper functions for autogen.sh leo_sobral@2: leo_sobral@2: debug () leo_sobral@2: # print out a debug message if DEBUG is a defined variable leo_sobral@2: { leo_sobral@2: if test ! -z "$DEBUG" leo_sobral@2: then leo_sobral@2: echo "DEBUG: $1" leo_sobral@2: fi leo_sobral@2: } leo_sobral@2: leo_sobral@2: version_check () leo_sobral@2: # check the version of a package leo_sobral@2: # first argument : package name (executable) leo_sobral@2: # second argument : optional path where to look for it instead leo_sobral@2: # third argument : source download url leo_sobral@2: # rest of arguments : major, minor, micro version leo_sobral@2: # all consecutive ones : suggestions for binaries to use leo_sobral@2: # (if not specified in second argument) leo_sobral@2: { leo_sobral@2: PACKAGE=$1 leo_sobral@2: PKG_PATH=$2 leo_sobral@2: URL=$3 leo_sobral@2: MAJOR=$4 leo_sobral@2: MINOR=$5 leo_sobral@2: MICRO=$6 leo_sobral@2: leo_sobral@2: # for backwards compatibility, we let PKG_PATH=PACKAGE when PKG_PATH null leo_sobral@2: if test -z "$PKG_PATH"; then PKG_PATH=$PACKAGE; fi leo_sobral@2: debug "major $MAJOR minor $MINOR micro $MICRO" leo_sobral@2: VERSION=$MAJOR leo_sobral@2: if test ! -z "$MINOR"; then VERSION=$VERSION.$MINOR; else MINOR=0; fi leo_sobral@2: if test ! -z "$MICRO"; then VERSION=$VERSION.$MICRO; else MICRO=0; fi leo_sobral@2: leo_sobral@2: debug "major $MAJOR minor $MINOR micro $MICRO" leo_sobral@2: leo_sobral@2: for SUGGESTION in $PKG_PATH; do leo_sobral@2: COMMAND="$SUGGESTION" leo_sobral@2: leo_sobral@2: # don't check if asked not to leo_sobral@2: test -z "$NOCHECK" && { leo_sobral@2: echo -n " checking for $COMMAND >= $VERSION ... " leo_sobral@2: } || { leo_sobral@2: # we set a var with the same name as the package, but stripped of leo_sobral@2: # unwanted chars leo_sobral@2: VAR=`echo $PACKAGE | sed 's/-//g'` leo_sobral@2: debug "setting $VAR" leo_sobral@2: eval $VAR="$COMMAND" leo_sobral@2: return 0 leo_sobral@2: } leo_sobral@2: leo_sobral@2: debug "checking version with $COMMAND" leo_sobral@2: ($COMMAND --version) < /dev/null > /dev/null 2>&1 || leo_sobral@2: { leo_sobral@2: echo "not found." leo_sobral@2: continue leo_sobral@2: } leo_sobral@2: # strip everything that's not a digit, then use cut to get the first field leo_sobral@2: pkg_version=`$COMMAND --version|head -n 1|sed 's/^[^0-9]*//'|cut -d' ' -f1` leo_sobral@2: debug "pkg_version $pkg_version" leo_sobral@2: # remove any non-digit characters from the version numbers to permit numeric leo_sobral@2: # comparison leo_sobral@2: pkg_major=`echo $pkg_version | cut -d. -f1 | sed s/[a-zA-Z\-].*//g` leo_sobral@2: pkg_minor=`echo $pkg_version | cut -d. -f2 | sed s/[a-zA-Z\-].*//g` leo_sobral@2: pkg_micro=`echo $pkg_version | cut -d. -f3 | sed s/[a-zA-Z\-].*//g` leo_sobral@2: test -z "$pkg_major" && pkg_major=0 leo_sobral@2: test -z "$pkg_minor" && pkg_minor=0 leo_sobral@2: test -z "$pkg_micro" && pkg_micro=0 leo_sobral@2: debug "found major $pkg_major minor $pkg_minor micro $pkg_micro" leo_sobral@2: leo_sobral@2: #start checking the version leo_sobral@2: debug "version check" leo_sobral@2: leo_sobral@2: # reset check leo_sobral@2: WRONG= leo_sobral@2: leo_sobral@2: if [ ! "$pkg_major" -gt "$MAJOR" ]; then leo_sobral@2: debug "major: $pkg_major <= $MAJOR" leo_sobral@2: if [ "$pkg_major" -lt "$MAJOR" ]; then leo_sobral@2: debug "major: $pkg_major < $MAJOR" leo_sobral@2: WRONG=1 leo_sobral@2: elif [ ! "$pkg_minor" -gt "$MINOR" ]; then leo_sobral@2: debug "minor: $pkg_minor <= $MINOR" leo_sobral@2: if [ "$pkg_minor" -lt "$MINOR" ]; then leo_sobral@2: debug "minor: $pkg_minor < $MINOR" leo_sobral@2: WRONG=1 leo_sobral@2: elif [ "$pkg_micro" -lt "$MICRO" ]; then leo_sobral@2: debug "micro: $pkg_micro < $MICRO" leo_sobral@2: WRONG=1 leo_sobral@2: fi leo_sobral@2: fi leo_sobral@2: fi leo_sobral@2: leo_sobral@2: if test ! -z "$WRONG"; then leo_sobral@2: echo "found $pkg_version, not ok !" leo_sobral@2: continue leo_sobral@2: else leo_sobral@2: echo "found $pkg_version, ok." leo_sobral@2: # we set a var with the same name as the package, but stripped of leo_sobral@2: # unwanted chars leo_sobral@2: VAR=`echo $PACKAGE | sed 's/-//g'` leo_sobral@2: debug "setting $VAR" leo_sobral@2: eval $VAR="$COMMAND" leo_sobral@2: return 0 leo_sobral@2: fi leo_sobral@2: done leo_sobral@2: leo_sobral@2: echo "not found !" leo_sobral@2: echo "You must have $PACKAGE installed to compile $package." leo_sobral@2: echo "Download the appropriate package for your distribution," leo_sobral@2: echo "or get the source tarball at $URL" leo_sobral@2: return 1; leo_sobral@2: } leo_sobral@2: leo_sobral@2: aclocal_check () leo_sobral@2: { leo_sobral@2: # normally aclocal is part of automake leo_sobral@2: # so we expect it to be in the same place as automake leo_sobral@2: # so if a different automake is supplied, we need to adapt as well leo_sobral@2: # so how's about replacing automake with aclocal in the set var, leo_sobral@2: # and saving that in $aclocal ? leo_sobral@2: # note, this will fail if the actual automake isn't called automake* leo_sobral@2: # or if part of the path before it contains it leo_sobral@2: if [ -z "$automake" ]; then leo_sobral@2: echo "Error: no automake variable set !" leo_sobral@2: return 1 leo_sobral@2: else leo_sobral@2: aclocal=`echo $automake | sed s/automake/aclocal/` leo_sobral@2: debug "aclocal: $aclocal" leo_sobral@2: if [ "$aclocal" != "aclocal" ]; leo_sobral@2: then leo_sobral@2: CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-aclocal=$aclocal" leo_sobral@2: fi leo_sobral@2: if [ ! -x `which $aclocal` ]; then leo_sobral@2: echo "Error: cannot execute $aclocal !" leo_sobral@2: return 1 leo_sobral@2: fi leo_sobral@2: fi leo_sobral@2: } leo_sobral@2: leo_sobral@2: autoheader_check () leo_sobral@2: { leo_sobral@2: # same here - autoheader is part of autoconf leo_sobral@2: # use the same voodoo leo_sobral@2: if [ -z "$autoconf" ]; then leo_sobral@2: echo "Error: no autoconf variable set !" leo_sobral@2: return 1 leo_sobral@2: else leo_sobral@2: autoheader=`echo $autoconf | sed s/autoconf/autoheader/` leo_sobral@2: debug "autoheader: $autoheader" leo_sobral@2: if [ "$autoheader" != "autoheader" ]; leo_sobral@2: then leo_sobral@2: CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-autoheader=$autoheader" leo_sobral@2: fi leo_sobral@2: if [ ! -x `which $autoheader` ]; then leo_sobral@2: echo "Error: cannot execute $autoheader !" leo_sobral@2: return 1 leo_sobral@2: fi leo_sobral@2: fi leo_sobral@2: leo_sobral@2: } leo_sobral@2: leo_sobral@2: autoconf_2_52d_check () leo_sobral@2: { leo_sobral@2: # autoconf 2.52d has a weird issue involving a yes:no error leo_sobral@2: # so don't allow it's use leo_sobral@2: test -z "$NOCHECK" && { leo_sobral@2: ac_version=`$autoconf --version|head -n 1|sed 's/^[a-zA-Z\.\ ()]*//;s/ .*$//'` leo_sobral@2: if test "$ac_version" = "2.52d"; then leo_sobral@2: echo "autoconf 2.52d has an issue with our current build." leo_sobral@2: echo "We don't know who's to blame however. So until we do, get a" leo_sobral@2: echo "regular version. RPM's of a working version are on the gstreamer site." leo_sobral@2: exit 1 leo_sobral@2: fi leo_sobral@2: } leo_sobral@2: return 0 leo_sobral@2: } leo_sobral@2: leo_sobral@2: die_check () leo_sobral@2: { leo_sobral@2: # call with $DIE leo_sobral@2: # if set to 1, we need to print something helpful then die leo_sobral@2: DIE=$1 leo_sobral@2: if test "x$DIE" = "x1"; leo_sobral@2: then leo_sobral@2: echo leo_sobral@2: echo "- Please get the right tools before proceeding." leo_sobral@2: echo "- Alternatively, if you're sure we're wrong, run with --nocheck." leo_sobral@2: exit 1 leo_sobral@2: fi leo_sobral@2: } leo_sobral@2: leo_sobral@2: autogen_options () leo_sobral@2: { leo_sobral@2: if test "x$1" = "x"; then leo_sobral@2: return 0 leo_sobral@2: fi leo_sobral@2: leo_sobral@2: while test "x$1" != "x" ; do leo_sobral@2: optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` leo_sobral@2: case "$1" in leo_sobral@2: --noconfigure) leo_sobral@2: NOCONFIGURE=defined leo_sobral@2: AUTOGEN_EXT_OPT="$AUTOGEN_EXT_OPT --noconfigure" leo_sobral@2: echo "+ configure run disabled" leo_sobral@2: shift leo_sobral@2: ;; leo_sobral@2: --nocheck) leo_sobral@2: AUTOGEN_EXT_OPT="$AUTOGEN_EXT_OPT --nocheck" leo_sobral@2: NOCHECK=defined leo_sobral@2: echo "+ autotools version check disabled" leo_sobral@2: shift leo_sobral@2: ;; leo_sobral@2: --debug) leo_sobral@2: DEBUG=defined leo_sobral@2: AUTOGEN_EXT_OPT="$AUTOGEN_EXT_OPT --debug" leo_sobral@2: echo "+ debug output enabled" leo_sobral@2: shift leo_sobral@2: ;; leo_sobral@2: --prefix=*) leo_sobral@2: CONFIGURE_EXT_OPT="$CONFIGURE_EXT_OPT --prefix=$optarg" leo_sobral@2: echo "+ passing --prefix=$optarg to configure" leo_sobral@2: shift leo_sobral@2: ;; leo_sobral@2: --prefix) leo_sobral@2: shift leo_sobral@2: echo "DEBUG: $1" leo_sobral@2: CONFIGURE_EXT_OPT="$CONFIGURE_EXT_OPT --prefix=$1" leo_sobral@2: echo "+ passing --prefix=$1 to configure" leo_sobral@2: shift leo_sobral@2: ;; leo_sobral@2: -h|--help) leo_sobral@2: echo "autogen.sh (autogen options) -- (configure options)" leo_sobral@2: echo "autogen.sh help options: " leo_sobral@2: echo " --noconfigure don't run the configure script" leo_sobral@2: echo " --nocheck don't do version checks" leo_sobral@2: echo " --debug debug the autogen process" leo_sobral@2: echo " --prefix will be passed on to configure" leo_sobral@2: echo leo_sobral@2: echo " --with-autoconf PATH use autoconf in PATH" leo_sobral@2: echo " --with-automake PATH use automake in PATH" leo_sobral@2: echo leo_sobral@2: echo "to pass options to configure, put them as arguments after -- " leo_sobral@2: exit 1 leo_sobral@2: ;; leo_sobral@2: --with-automake=*) leo_sobral@2: AUTOMAKE=$optarg leo_sobral@2: echo "+ using alternate automake in $optarg" leo_sobral@2: CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-automake=$AUTOMAKE" leo_sobral@2: shift leo_sobral@2: ;; leo_sobral@2: --with-autoconf=*) leo_sobral@2: AUTOCONF=$optarg leo_sobral@2: echo "+ using alternate autoconf in $optarg" leo_sobral@2: CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-autoconf=$AUTOCONF" leo_sobral@2: shift leo_sobral@2: ;; leo_sobral@2: --disable*|--enable*|--with*) leo_sobral@2: echo "+ passing option $1 to configure" leo_sobral@2: CONFIGURE_EXT_OPT="$CONFIGURE_EXT_OPT $1" leo_sobral@2: shift leo_sobral@2: ;; leo_sobral@2: --) shift ; break ;; leo_sobral@2: *) echo "- ignoring unknown autogen.sh argument $1"; shift ;; leo_sobral@2: esac leo_sobral@2: done leo_sobral@2: leo_sobral@2: for arg do CONFIGURE_EXT_OPT="$CONFIGURE_EXT_OPT $arg"; done leo_sobral@2: if test ! -z "$CONFIGURE_EXT_OPT" leo_sobral@2: then leo_sobral@2: echo "+ options passed to configure: $CONFIGURE_EXT_OPT" leo_sobral@2: fi leo_sobral@2: } leo_sobral@2: leo_sobral@2: toplevel_check () leo_sobral@2: { leo_sobral@2: srcfile=$1 leo_sobral@2: test -f $srcfile || { leo_sobral@2: echo "You must run this script in the top-level $package directory" leo_sobral@2: exit 1 leo_sobral@2: } leo_sobral@2: } leo_sobral@2: leo_sobral@2: leo_sobral@2: tool_run () leo_sobral@2: { leo_sobral@2: tool=$1 leo_sobral@2: options=$2 leo_sobral@2: run_if_fail=$3 leo_sobral@2: echo "+ running $tool $options..." leo_sobral@2: $tool $options || { leo_sobral@2: echo leo_sobral@2: echo $tool failed leo_sobral@2: eval $run_if_fail leo_sobral@2: exit 1 leo_sobral@2: } leo_sobral@2: }