Whamcloud - gitweb
ca6572d5b1cdf344fd8bbfae8f9980bb9aefacfa
[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/$tool/$tool-$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 "/$tool \(GNU/ { 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 # required directories
82 for dir in build lnet portals lustre ; do
83     if [ ! -d "$dir" ] ; then
84         cat >&2 <<EOF
85 Your tree seems to be missing $dir.
86 Please read README.lustrecvs for details.
87 EOF
88         exit 1
89     fi
90     ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I $PWD/$dir/autoconf"
91 done
92 # some are optional
93 for dir in snmp ; do
94     if [ -d "$dir" ] ; then
95         ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I $PWD/$dir/autoconf"
96     fi
97 done
98
99 check_version automake automake-1.7 "1.7.8"
100 check_version autoconf autoconf "2.57"
101
102 echo "Running aclocal-1.7 $ACLOCAL_FLAGS..."
103 aclocal-1.7 $ACLOCAL_FLAGS
104 echo "Running autoheader..."
105 autoheader
106 echo "Running automake-1.7..."
107 automake-1.7 -a -c
108 echo "Running autoconf..."
109 autoconf
110
111 if [ -d libsysio ] ; then
112     pushd libsysio >/dev/null
113     echo "Running autogen for libsysio..."
114     sh autogen.sh
115     popd >/dev/null
116 fi