Add better checks and docs for build tools
authorPádraig Brady <P@draigBrady.com>
Tue, 21 Oct 2008 21:40:12 +0000 (22:40 +0100)
committerPádraig Brady <P@draigBrady.com>
Wed, 22 Oct 2008 15:31:57 +0000 (16:31 +0100)
Prompted by a report from Ed Avis:
<http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/14710>

* README-hacking: Organise LZMA and Valgrind as
as optional requirements rather than in their own sections.
Mention bootstrap will now check tool versions.
* README-prereq: Make a start on specific instructions
for optaining build tools. Currently we just have notes
for Fedora linux.
* bootstrap.conf: Add the list of tools and versions required.
* bootstrap: Add the logic to check for the required tools,
and list all required tools and versions if any are missing.

README-hacking
README-prereq [new file with mode: 0644]
bootstrap
bootstrap.conf

index 2e3c83a..f51bb01 100644 (file)
@@ -8,8 +8,8 @@ These requirements do not apply when building from a distribution tarball.
 We've opted to keep only the highest-level sources in the GIT repository.
 This eases our maintenance burden, (fewer merges etc.), but imposes more
 requirements on anyone wishing to build from the just-checked-out sources.
-For example, you have to use the latest stable versions of the maintainer
-tools we depend upon, including:
+Specific tools and versions will be checked for and listed by the
+bootstrap script shown below, and will include:
 
 - Automake <http://www.gnu.org/software/automake/>
 - Autoconf <http://www.gnu.org/software/autoconf/>
@@ -22,13 +22,15 @@ tools we depend upon, including:
 - Rsync <http://samba.anu.edu.au/rsync/>
 - Tar <http://www.gnu.org/software/tar/>
 
-Valgrind <http://valgrind.org/> is also highly recommended, if
-Valgrind supports your architecture.
-
 Only building the initial full source tree will be a bit painful.
 Later, a plain `git pull && make' should be sufficient.
 
-* LZMA
+- Valgrind
+
+Valgrind <http://valgrind.org/> is also highly recommended, if
+Valgrind supports your architecture. See also README-valgrind.
+
+- LZMA
 
 This package's build procedure uses LZMA to create a compressed
 distribution tarball.  Using this feature of Automake requires
@@ -40,23 +42,24 @@ from <http://tukaani.org/lzma/>.
 
 You can get a copy of the source repository like this:
 
-       $ git clone git://git.sv.gnu.org/coreutils
+        $ git clone git://git.sv.gnu.org/coreutils
+        $ cd coreutils
 
-The next step is to get other files needed to build, which are
-extracted from other source packages:
+The next step is to get and check other files needed to build,
+which are extracted from other source packages:
 
-       $ ./bootstrap
+        $ ./bootstrap
 
 And there you are!  Just
 
-       $ ./configure
-       $ make
-       $ make check
+        $ ./configure
+        $ make
+        $ make check
 
 At this point, there should be no difference between your local copy,
 and the GIT master copy:
 
-       $ git diff
+        $ git diff
 
 should output no difference.
 
@@ -78,3 +81,7 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Local Variables:
+indent-tabs-mode: nil
+End:
diff --git a/README-prereq b/README-prereq
new file mode 100644 (file)
index 0000000..7456114
--- /dev/null
@@ -0,0 +1,30 @@
+Detailed below are concrete examples for
+getting the prerequisites for particular systems.
+
+- linux - fedora
+
+  This shows the steps for getting the required tools to build coreutils 7.0
+  on a Fedora 8 system. We try to use official packages where possible.
+  The 3 methods described for making these required packages available, should
+  help clarify build requirements on any linux system at least.
+
+  1. Make sure offical distro git package is installed
+    # yum install git
+
+  2. The distro autoconf is too old, but there is a newer one available
+  so we rebuild that and make it available to the full system:
+    # yum install emacs #autoconf build requires emacs (20MB)
+    # rpmbuild --rebuild http://download.fedora.redhat.com/pub/fedora/linux/development/source/SRPMS/autoconf-2.63-1.fc10.src.rpm
+    # rpm -Uvh /usr/src/redhat/RPMS/noarch/autoconf-2.63-1.fc8.noarch.rpm
+  Apply the same method to install the lzma package.
+
+  3. The latest released automake (1.10.1) was not new enough, so we download
+  and build automake-1.10a from its repository and make it available
+  just to coreutils:
+    # yum install help2man #required to build automake fully
+    $ git clone git://git.sv.gnu.org/automake.git
+    $ cd automake && ./configure --prefix=$HOME/coreutils/deps
+    $ make install
+
+  Now we can build coreutils as described in README-hacking
+  as long as $PATH starts with $HOME/coreutils/deps
index 0895eb7..5ba4525 100755 (executable)
--- a/bootstrap
+++ b/bootstrap
@@ -222,6 +222,92 @@ if test ! -d $build_aux; then
   done
 fi
 
+# Note this deviates from the version comparison in automake
+# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
+# but this should suffice as we won't be specifying old
+# version formats or redundant trailing .0 in bootstrap.conf.
+# If we did want full compatibility then we should probably
+# use m4_version_compare from autoconf.
+sort_ver() { #sort -V is not generally available
+  ver1="$1"
+  ver2="$2"
+
+  #split on '.' and compare each component
+  i=1
+  while : ; do
+    p1=$(echo "$ver1" | cut -d. -f$i)
+    p2=$(echo "$ver2" | cut -d. -f$i)
+    if [ ! "$p1" ]; then
+      echo "$1 $2"
+      break
+    elif [ ! "$p2" ]; then
+      echo "$2 $1"
+      break
+    elif [ ! "$p1" = "$p2" ]; then
+      if [ "$p1" -gt "$p2" ] 2>/dev/null; then #numeric comparision
+        echo "$2 $1"
+      elif [ "$p2" -gt "$p1" ] 2>/dev/null; then #numeric comparision
+        echo "$1 $2"
+      else #numeric, then lexographic comparison
+        lp=$(printf "$p1\n$p2\n" | LANG=C sort -n | tail -n1)
+        if [ "$lp" = "$p2" ]; then
+          echo "$1 $2"
+        else
+          echo "$2 $1"
+        fi
+      fi
+      break
+    fi
+    i=$(($i+1))
+  done
+}
+
+get_version() {
+  app=$1
+
+  $app --version >/dev/null 2>&1 || return 1
+
+  $app --version |
+  sed -n 's/[^0-9.]*\([0-9]\{1,\}\.[.a-z0-9-]\{,\}\).*/\1/p;T;q'
+}
+
+check_versions() {
+  ret=0
+
+  while read app req_ver; do
+    inst_ver=$(get_version $app)
+    if [ ! "$inst_ver" ]; then
+      echo "Error: '$app' not found" >&2
+      ret=1
+    elif [ ! "$req_ver" = "-" ]; then
+      latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
+      if [ ! "$latest_ver" = "$inst_ver" ]; then
+        echo "Error: '$app' version == $inst_ver is too old" >&2
+        echo "       '$app' version >= $req_ver is required" >&2
+        ret=1
+      fi
+    fi
+  done
+
+  return $ret
+}
+
+print_versions() {
+  echo "Program    Min_version"
+  echo "----------------------"
+  printf "$buildreq"
+  echo "----------------------"
+  #can't depend on column -t
+}
+
+if ! printf "$buildreq" | check_versions; then
+  test -f README-prereq &&
+  echo "Please see README-prereq for notes on obtaining these prerequisite programs:" >&2
+  echo
+  print_versions
+  exit 1
+fi
+
 echo "$0: Bootstrapping from checked-out $package sources..."
 
 # See if we can use gnulib's git-merge-changelog merge driver.
index c6698f1..a434263 100644 (file)
@@ -161,5 +161,22 @@ fi
 
 gnulib_tool_option_extras="--tests-base=$bt/gnulib-tests --with-tests"
 
+# Build prerequisites
+buildreq="\
+autoconf   2.61
+automake   1.10a
+autopoint  -
+bison      -
+gettext    -
+git        1.4.4
+gperf      -
+gzip       -
+lzma       -
+makeinfo   -
+perl       5.5
+rsync      -
+tar        -
+"
+
 # Automake requires that ChangeLog exist.
 touch ChangeLog