Whamcloud - gitweb
Branch b_hd_kdmu
[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                 Sun provides RPMs which can be installed alongside your
35                 existing autoconf/make RPMs, if you are nervous about
36                 upgrading.  See
37
38                 http://downloads.lustre.org/public/tools/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 if [ -d kernel_patches ] ; then
82     # This is ldiskfs
83     REQUIRED_DIRS="build"
84     CONFIGURE_DIRS=""
85 else
86     REQUIRED_DIRS="build libcfs lnet lustre"
87     OPTIONAL_DIRS="snmp portals"
88     CONFIGURE_DIRS="libsysio lustre-iokit ldiskfs spl zfs"
89 fi
90
91 for dir in $REQUIRED_DIRS ; do
92     if [ ! -d "$dir" ] ; then
93         cat >&2 <<EOF
94 Your tree seems to be missing $dir.
95 Please read README.lustrecvs for details.
96 EOF
97         exit 1
98     fi
99     ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I $PWD/$dir/autoconf"
100 done
101 # optional directories for Lustre
102 for dir in $OPTIONAL_DIRS; do
103     if [ -d "$dir" ] ; then
104         ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I $PWD/$dir/autoconf"
105     fi
106 done
107
108 for AMVER in 1.7 1.8 1.9 1.10; do
109      [ "$(which automake-$AMVER 2> /dev/null)" ] && break
110 done
111
112 [ "$AMVER" = "1.10" ] && AMOPT="-W no-portability"
113
114 check_version automake automake-$AMVER "1.7.8"
115 check_version autoconf autoconf "2.57"
116
117 echo "Running aclocal-$AMVER $ACLOCAL_FLAGS..."
118 aclocal-$AMVER $ACLOCAL_FLAGS || exit 1
119 echo "Running autoheader..."
120 autoheader || exit 1
121 echo "Running automake-$AMVER..."
122 automake-$AMVER -a -c $AMOPT || exit 1
123 echo "Running autoconf..."
124 autoconf || exit 1
125
126 # Run autogen.sh in these directories
127 for dir in $CONFIGURE_DIRS; do
128     if [ -d $dir ] ; then
129         pushd $dir >/dev/null
130         echo "Running autogen for $dir..."
131         sh autogen.sh || exit $?
132         popd >/dev/null
133     fi
134 done