Whamcloud - gitweb
3c3bf5f6869c300ad9c9b91d7dd981ea6397ac0d
[fs/lustre-release.git] / build / autogen.sh
1 #!/bin/bash
2
3 # taken from gnome-common/macros2/autogen.sh
4 compare_versions() {
5     ch_min_version=$1
6     ch_actual_version=$2
7     ch_status=0
8     IFS="${IFS=         }"; ch_save_IFS="$IFS"; IFS="."
9     set $ch_actual_version
10     for ch_min in $ch_min_version; do
11         ch_cur=`echo $1 | sed 's/[^0-9].*$//'`; shift # remove letter suffixes
12         if [ -z "$ch_min" ]; then break; fi
13         if [ -z "$ch_cur" ]; then ch_status=1; break; fi
14         if [ $ch_cur -gt $ch_min ]; then break; fi
15         if [ $ch_cur -lt $ch_min ]; then ch_status=1; break; fi
16     done
17     IFS="$ch_save_IFS"
18     return $ch_status
19 }
20
21 error_msg() {
22         echo "$cmd is $1.  version $required is required to build Lustre."
23
24         if [ -e /usr/lib/autolustre/bin/$cmd ]; then
25                 cat >&2 <<-EOF
26                 You apparently already have Lustre-specific autoconf/make RPMs
27                 installed on your system at /usr/lib/autolustre/share/$cmd.
28                 Please set your PATH to point to those versions:
29
30                 export PATH="/usr/lib/autolustre/bin:\$PATH"
31                 EOF
32         else
33                 cat >&2 <<-EOF
34                 CFS provides RPMs which can be installed alongside your
35                 existing autoconf/make RPMs, if you are nervous about
36                 upgrading.  See
37
38                 ftp://ftp.lustre.org/pub/other/autolustre/README.autolustre
39
40                 You may be able to download newer version from:
41
42                 http://ftp.gnu.org/gnu/$cmd/$cmd-$required.tar.gz
43         EOF
44         fi
45         [ "$cmd" = "autoconf" -a "$required" = "2.57" ] && cat >&2 <<EOF
46
47 or for RH9 systems you can use:
48
49 ftp://fr2.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/autoconf-2.57-3.noarch.rpm
50 EOF
51         [ "$cmd" = "automake-1.7" -a "$required" = "1.7.8" ] && cat >&2 <<EOF
52
53 or for RH9 systems you can use:
54
55 ftp://fr2.rpmfind.net/linux/fedora/core/1/i386/os/Fedora/RPMS/automake-1.7.8-1.noarch.rpm
56 EOF
57         exit 1
58 }
59
60 check_version() {
61     local tool
62     local cmd
63     local required
64     local version
65
66     tool=$1
67     cmd=$2
68     required=$3
69     echo -n "checking for $cmd $required... "
70     if ! $cmd --version >/dev/null ; then
71         error_msg "missing"
72     fi
73     version=$($cmd --version | awk "BEGIN { IGNORECASE=1 } /$tool \(GNU $tool\)/ { print \$4 }")
74     echo "found $version"
75     if ! compare_versions "$required" "$version" ; then
76         error_msg "too old"
77     fi
78 }
79
80 echo "Checking for a complete tree..."
81 for dir in build portals lustre ; do
82     if [ ! -d "$dir" ] ; then
83         cat >&2 <<EOF
84 Your tree seems to be missing $dir.
85 Please read README.lustrecvs for details.
86 EOF
87         exit 1
88     fi
89     ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I $PWD/$dir/autoconf"
90 done
91
92 check_version automake automake-1.7 "1.7.8"
93 check_version autoconf autoconf "2.57"
94
95 echo "Running aclocal-1.7 $ACLOCAL_FLAGS..."
96 aclocal-1.7 $ACLOCAL_FLAGS
97 echo "Running autoheader..."
98 autoheader
99 echo "Running automake-1.7..."
100 automake-1.7 -a -c
101 echo "Running autoconf..."
102 autoconf
103
104 if [ -d libsysio ] ; then
105     pushd libsysio >/dev/null
106     echo "Running autogen for libsysio..."
107     sh autogen.sh
108     popd >/dev/null
109 fi