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