gst-autogen.sh 3.5 KB
Newer Older
1
# a silly hack that generates autoregen.sh but it's handy
2 3 4 5 6 7
# Remove the old autoregen.sh first to create a new file,
# as the current one may be being read by the shell executing
# this script.
if [ -f "autoregen.sh" ]; then
  rm autoregen.sh
fi
8
echo "#!/bin/sh" > autoregen.sh
9
echo "./autogen.sh $@ \$@" >> autoregen.sh
10 11
chmod +x autoregen.sh

12 13 14 15 16 17 18 19 20 21 22
# helper functions for autogen.sh

debug ()
# print out a debug message if DEBUG is a defined variable
{
  if test ! -z "$DEBUG"
  then
    echo "DEBUG: $1"
  fi
}

23

24 25
autogen_options ()
{
26
  if test "x$1" = "x"; then
27 28 29
    return 0
  fi

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
30 31
  while test "x$1" != "x" ; do
    optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
32 33
    case "$1" in
      --noconfigure)
34
          NOCONFIGURE=defined
35
	  AUTOGEN_EXT_OPT="$AUTOGEN_EXT_OPT --noconfigure"
36
          echo "+ configure run disabled"
37 38 39 40
          shift
          ;;
      --nocheck)
	  AUTOGEN_EXT_OPT="$AUTOGEN_EXT_OPT --nocheck"
41 42
          NOCHECK=defined
          echo "+ autotools version check disabled"
43 44
          shift
          ;;
45
      -d|--debug)
46
          DEBUG=defined
47
	  AUTOGEN_EXT_OPT="$AUTOGEN_EXT_OPT --debug"
48
          echo "+ debug output enabled"
49 50 51 52
          shift
          ;;
      -h|--help)
          echo "autogen.sh (autogen options) -- (configure options)"
53
          echo "autogen.sh help options: "
54 55
          echo " --noconfigure            don't run the configure script"
          echo " --nocheck                don't do version checks"
56 57 58 59 60
          echo " --debug                  debug the autogen process"
          echo
          echo " --with-autoconf PATH     use autoconf in PATH"
          echo " --with-automake PATH     use automake in PATH"
          echo
61 62
          echo "Any argument either not in the above list or after a '--' will be "
          echo "passed to ./configure."
63
	  exit 1
64
          ;;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
65 66 67
      --with-automake=*)
          AUTOMAKE=$optarg
          echo "+ using alternate automake in $optarg"
68
	  CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-automake=$AUTOMAKE"
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
69
          shift
70
          ;;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
71 72 73
      --with-autoconf=*)
          AUTOCONF=$optarg
          echo "+ using alternate autoconf in $optarg"
74
	  CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-autoconf=$AUTOCONF"
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
75
          shift
76
          ;;
77 78 79
      --) shift ; break ;;
      *)
          echo "+ passing argument $1 to configure"
80
	  CONFIGURE_EXT_OPT="$CONFIGURE_EXT_OPT $1"
81 82
          shift
          ;;
83
    esac
84
  done
85

86
  for arg do CONFIGURE_EXT_OPT="$CONFIGURE_EXT_OPT $arg"; done
87
  if test ! -z "$CONFIGURE_EXT_OPT"
88 89 90
  then
    echo "+ options passed to configure: $CONFIGURE_EXT_OPT"
  fi
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
}

toplevel_check ()
{
  srcfile=$1
  test -f $srcfile || {
        echo "You must run this script in the top-level $package directory"
        exit 1
  }
}

tool_run ()
{
  tool=$1
  options=$2
106
  run_if_fail=$3
107 108 109 110
  echo "+ running $tool $options..."
  $tool $options || {
    echo
    echo $tool failed
111
    eval $run_if_fail
112 113 114
    exit 1
  }
}
115 116 117 118 119 120 121 122 123 124 125 126 127 128

install_git_hooks ()
{
  if test -d .git; then
    # install pre-commit hook for doing clean commits
    for hook in pre-commit; do
      if test ! \( -x .git/hooks/$hook -a -L .git/hooks/$hook \); then
        echo "+ Installing git $hook hook"
        rm -f .git/hooks/$hook
        ln -s ../../common/hooks/$hook.hook .git/hooks/$hook || {
          # if we couldn't create a symbolic link, try doing a plain cp
          if cp common/hooks/pre-commit.hook .git/hooks/pre-commit; then
            chmod +x .git/hooks/pre-commit;
          else
Felipe Contreras's avatar
Felipe Contreras committed
129
            echo "********** Couldn't install git $hook hook **********";
130 131 132 133 134 135
          fi
        }
      fi
    done
  fi
}