Initial "gts1" commit.
[tac_plus.git] / autogen-body
diff --git a/autogen-body b/autogen-body
new file mode 100644 (file)
index 0000000..6856444
--- /dev/null
@@ -0,0 +1,259 @@
+#
+#      autogen-body
+#
+#      Placed into the public domain by
+#      Partition Surprise Team <surprise-dev@lists.sourceforge.net>
+#
+#      $Id$
+#
+
+
+# Executable code to be included from ./autogen script
+
+# Expected variables:
+# defaultCONFDEFS, project, want_tarZ, upload, docdir, subdirs, CLEAN_LOCAL
+# function PREP_LOCAL
+
+set -e
+t=/tmp/autogen.$$
+autogen_failed=true
+cleaup_dir="$PWD"
+automake_reqd=""
+function cleanup
+{
+  cd "$cleanup_dir"
+  rm -f "$t.*"
+  if $automake_gnu;then for i in $automake_reqd;do if [ '!' -s "$i" ];then rm -f "$i";fi;done;fi
+}
+EXITmsg_do=true
+trap '
+  cleanup
+  if $autogen_failed;then
+    if $EXITmsg_do;then
+      echo -e "\n$0 failed! Try the following command to debug it: set -x"
+      EXITmsg_do=false
+      fi
+    exit 1
+    fi
+  ' EXIT
+
+if [ "$1" = help -o "$1" = -h -o "$1" = --help ];then cat <<EOHELP
+Beware!: "autogen" is a tool only for maintainers.
+
+Supported parameters:
+    rpm: Build RPM packages locally (needs /usr/src/(redhat|packages)/ access)
+    rpmtest: Build RPM like "rpm" but w/o gpg/pgp signing
+    rpmup: Like rpm target but also uploads the result
+    tar: Build tar file (its basename dir-based) with only vital files incl. CVS dirs
+    clean: Standard cleanup method
+    fullclean: Like clean but even the .cvsignore files are removed
+    sym: Like clean but don't remove symbolic links, should be equal (check!)
+    copy: Behave exactly like in default mode but copy all instead of symlinks
+$ARGS_HELP_LOCAL
+EOHELP
+  autogen_failed=false
+  exit
+  fi
+
+
+if [ -f "$HOME/.$project.autogen" ];then
+  . "$HOME/.$project.autogen"
+  fi
+CONFDEFS="$defaultCONFDEFS $CONFDEFS"
+
+function funcdo
+{
+local func="$1";
+
+  shift
+  if declare -f "$func" >/dev/null;then
+local func_exit=false
+
+    "$func" "$@"
+    if $func_exit;then exit;fi
+  fi
+}
+funcdo ARGS_LOCAL "$@"
+
+if expr match "$1" "rpm" >/dev/null;then
+  builds="/usr/src/redhat /usr/src/packages"
+  for b in $builds X;do
+    if test -d $b;then break;fi
+    done
+  if [ $b = X ];then
+    echo Build directory not reachable, searched: $builds
+    exit 1
+    fi
+  rm -r -f /var/tmp/$project-*-root $b/BUILD/$project-*
+  specsrc="$project.spec.m4.in"
+  if [ '!' -f "$specsrc" ];then specsrc="$project.spec.in";fi
+  CONFDEFS="`awk '/^(.*)\\$/{x=x$1" ";next}{print x$0;x=""}' <$specsrc \
+            |sed -n 's/^.*\.\/configure \(.*\)$/\1/p'`" ./autogen copy
+  make dist $project.spec
+  cp $project-*.tar.gz $b/SOURCES
+  if [ "$1" = "rpmtest" ];then SIGNIT=;else SIGNIT=--sign;fi
+  rpm -ba $SIGNIT $project.spec
+  if $want_tarZ;then make dist-tarZ;fi
+  rm $b/SOURCES/$project-*.tar.gz
+  mv $b/SRPMS/$project-*.src.rpm .
+  mv $b/RPMS/i386/$project-*.i386.rpm .
+  ls -l $project-*
+  if [ "$1" = rpmup ];then
+    echo "Uploading $[`cat $project-*|wc -c`] bytes..."
+    if [ -n "$upload" ];then
+      scp -v $project-* "$upload"
+    else
+      echo "Upload not done."
+    fi
+  fi
+  autogen_failed=false
+  exit
+fi
+
+function subdo
+{
+  for i in _ $subdirs;do
+    if [ -d $i ];then
+      cd "$i"
+      ./autogen $subdir_args
+      cd ..
+      fi
+    done
+}
+subdir_args="${*:-dist}"
+if [ "$subdir_args" = "copy" ];then
+  subdir_args="copy dist"
+  fi
+
+# maintainer-clean hack is not safe, please list all files for 'rm'.
+# When the filename doesn't contain '/', it is applied to ALL directories.
+# Please note that files exactly in root dir MUST have ./ in the front
+#   (to not to be considered as ALL-directories files).
+
+CLEANFILES="
+  *~ .#*
+  *.orig *.rej
+  core
+  Makefile Makefile.in
+  TAGS tags ID
+  .deps .libs
+  *.[oa] *.l[oa]
+
+  ./errs*
+  ./intl
+  ./configure ./configure.scan
+  ./config.guess ./config.status ./config.sub ./config.log ./config.cache
+  ./config.h ./config.h.in
+  ./confdefs.h ./conftest* ./autoh[0-9]* ./confcache
+  ./stamp-h ./stamp-h.in
+  ./install-sh
+  ./aclocal.m4
+  ./missing
+  ./mkinstalldirs
+  ./libtool ./ltconfig ./ltmain.sh
+  ./ChangeLog
+  ./ABOUT-NLS ./COPYING
+  ./$project-[0-9]* ./$project-devel-[0-9]*
+  ./$project.spec ./$project.m4 ./$project.spec.m4
+  macros/macros.dep
+  po/Makefile.in.in po/POTFILES* po/cat-id-tbl.c po/cat-id-tbl.tmp po/*.gmo po/*.mo po/stamp-cat-id po/$project.pot
+
+  $CLEAN_LOCAL
+  "
+if [ -n "$docdir" ];then
+CLEANFILES="
+  $docdir/*.html
+  $docdir/*.info*
+  $docdir/*.txt
+  $docdir/*.tex
+  $docdir/*.sgml
+  $CLEANFILES"
+  fi
+if [ "$1" != sym ];then CLEANFILES="$CLEANFILES `find . -type l`";fi
+CLEANFILES="`echo "$CLEANFILES"|tr ' ' '\n'|sed 's,^\./\(.*/.*\)$,\1,'|sort|uniq|grep -v '^ *$'`"
+true >"$t.find"
+rm -f "$t.discard"
+echo "$CLEANFILES"|while read -r fi;do
+  if [ "$fi" != "${fi#*/}" ];then
+       echo "$fi" >>"$t.discard"
+  else echo "-o -name $fi" >>"$t.find"
+  fi;done
+for dirpatt in `(find . -type d '!' \( -name CVS $(sed 's,[]*?[],\\&,g' <"$t.find") \)|sort|uniq;cat "$t.discard")|sort|uniq -u`;do
+  for dir in $dirpatt;do if test -d $dir;then
+    (cd $dir
+     (echo "$CLEANFILES"                                                #ALL-dir files
+      echo "$CLEANFILES"|sed -n "s,^\\$(echo $dir|sed 's,^\./,,')/,,p"  #THIS-dir files
+      echo .cvsignore                                                   #MUST be last!
+      )|grep -v / >.cvsignore
+     if [ "$1" = "${1#tar}" ];then
+       rm -rf `
+         if [ "$1" = fullclean ];then cat .cvsignore
+         else grep -v '^\.cvsignore' <.cvsignore
+         fi`
+       fi
+     )
+    fi;done
+  done
+rm -f "$t.find" "$t.discard"
+if [ "$1" = tarprep ];then
+  autogen_failed=false
+  exit
+  fi
+if [ "$1" = tar ];then
+  subdir_args=tarprep
+  subdo
+  mydir="$(basename `pwd`)"
+  cd ..
+  tar cf - \
+    $(for fi in `find "$mydir" -name .cvsignore`;do sed "s,^,--exclude=`dirname $fi`/," <$fi;done) \
+    "$mydir"
+  autogen_failed=false
+  exit
+  fi
+if [ "$1" != "${1#*clean}" ];then
+  subdo
+  autogen_failed=false
+  exit 0
+  fi
+
+funcdo PREP_LOCAL "$@"
+subdo
+
+if [ "$1" = copy ];then COPY=--copy;shift
+else unset COPY|cat  # |cat construction is used to not fail in "set -e" state
+fi
+
+if test -d po;then
+  touch po/POTFILES.in
+fi
+aclocal_opts=""
+if test -d macros;then
+  aclocal_opts="-I macros $aclocal_opts"
+fi
+aclocal $aclocal_opts
+if $want_gettext;then
+  gettextize $COPY
+  rm -f aclocal.m4       # We delete created aclocal.m4 as it's just bug in gettextize. It shouldn't link that file here
+  aclocal $aclocal_opts  # gettextize made some changes of files which need to be reflected
+fi
+if $want_libtool;then
+  libtoolize $COPY
+fi
+autoheader
+automake_opts=""
+if $automake_gnu;then
+  automake_reqd="$automake_reqd ChangeLog README"
+  automake_opts="$automake_opts --gnu"
+  for i in $automake_reqd;do if [ '!' -f "$i" ];then touch "$i";fi;done
+fi
+automake --add-missing $COPY $automake_opts
+cleanup
+autoheader
+autoconf
+
+if [ "$1" != dist ];then
+  # shared/static switching cannot be based on maintainer-mode in configure
+  ./configure --enable-maintainer-mode --enable-shared --disable-static $CONFDEFS
+  fi
+
+autogen_failed=false