use ACLOCAL even when using 'find' to find the aclocal tool
[platform/upstream/curl.git] / buildconf
1 #!/bin/sh
2
3 die(){
4         echo "$@"
5         exit
6 }
7
8 # this works as 'which' but we use a different name to make it more obvious we
9 # aren't using 'which'! ;-)
10 findtool(){
11   file="$1"
12
13   IFS=":"
14   for path in $PATH
15   do
16     if test -f "$path/$file"; then
17       echo "$path/$file"
18       return
19     fi
20   done
21 }
22
23 #--------------------------------------------------------------------------
24 # autoconf 2.57 or newer
25 #
26 need_autoconf="2.57"
27 ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
28 if test -z "$ac_version"; then
29   echo "buildconf: autoconf not found."
30   echo "            You need autoconf version $need_autoconf or newer installed."
31   exit 1
32 fi
33 IFS=.; set $ac_version; IFS=' '
34 if test "$1" = "2" -a "$2" -lt "57" || test "$1" -lt "2"; then
35   echo "buildconf: autoconf version $ac_version found."
36   echo "            You need autoconf version $need_autoconf or newer installed."
37   echo "            If you have a sufficient autoconf installed, but it"
38   echo "            is not named 'autoconf', then try setting the"
39   echo "            AUTOCONF environment variable."
40   exit 1
41 fi
42
43 echo "buildconf: autoconf version $ac_version (ok)"
44
45 #--------------------------------------------------------------------------
46 # autoheader 2.50 or newer
47 #
48 ah_version=`${AUTOHEADER:-autoheader} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
49 if test -z "$ah_version"; then
50   echo "buildconf: autoheader not found."
51   echo "            You need autoheader version 2.50 or newer installed."
52   exit 1
53 fi
54 IFS=.; set $ah_version; IFS=' '
55 if test "$1" = "2" -a "$2" -lt "50" || test "$1" -lt "2"; then
56   echo "buildconf: autoheader version $ah_version found."
57   echo "            You need autoheader version 2.50 or newer installed."
58   echo "            If you have a sufficient autoheader installed, but it"
59   echo "            is not named 'autoheader', then try setting the"
60   echo "            AUTOHEADER environment variable."
61   exit 1
62 fi
63
64 echo "buildconf: autoheader version $ah_version (ok)"
65
66 #--------------------------------------------------------------------------
67 # automake 1.7 or newer
68 #
69 need_automake="1.7"
70 am_version=`${AUTOMAKE:-automake} --version 2>/dev/null|head -n 1| sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//' -e 's/\(.*\)\(-p.*\)/\1/'`
71 if test -z "$am_version"; then
72   echo "buildconf: automake not found."
73   echo "            You need automake version $need_automake or newer installed."
74   exit 1
75 fi
76 IFS=.; set $am_version; IFS=' '
77 if test "$1" = "1" -a "$2" -lt "7" || test "$1" -lt "1"; then
78   echo "buildconf: automake version $am_version found."
79   echo "            You need automake version $need_automake or newer installed."
80   echo "            If you have a sufficient automake installed, but it"
81   echo "            is not named 'automake', then try setting the"
82   echo "            AUTOMAKE environment variable."
83   exit 1
84 fi
85
86 echo "buildconf: automake version $am_version (ok)"
87
88 ac=`findtool ${ACLOCAL:-aclocal}`
89 if test -z "$ac"; then
90   echo "buildconf: aclocal not found. Weird automake installation!"
91   exit 1
92 else
93   echo "buildconf: aclocal found"
94 fi
95
96 #--------------------------------------------------------------------------
97 # libtool check
98 #
99 LIBTOOL_WANTED_MAJOR=1
100 LIBTOOL_WANTED_MINOR=4
101 LIBTOOL_WANTED_PATCH=2
102 LIBTOOL_WANTED_VERSION=1.4.2
103
104 # this approach that tries 'glibtool' first is some kind of work-around for
105 # some BSD-systems I believe that use to provide the GNU libtool named
106 # glibtool, with 'libtool' being something completely different.
107 libtool=`findtool glibtool 2>/dev/null`
108 if test ! -x "$libtool"; then
109   libtool=`findtool libtool`
110 fi
111
112 # set the LIBTOOLIZE here so that glibtoolize is used if glibtool was found
113 LIBTOOLIZE="${libtool}ize"
114
115 lt_pversion=`$libtool --version 2>/dev/null|head -n 1|sed -e 's/^[^0-9]*//g' -e 's/[- ].*//'`
116 if test -z "$lt_pversion"; then
117   echo "buildconf: libtool not found."
118   echo "            You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
119   exit 1
120 fi
121 lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$//'`
122 IFS=.; set $lt_version; IFS=' '
123 lt_status="good"
124
125 major=$1
126 minor=$2
127 patch=$3
128
129 if test "$major" = "$LIBTOOL_WANTED_MAJOR"; then
130    if test "$minor" -lt "$LIBTOOL_WANTED_MINOR"; then
131       lt_status="bad"
132    elif test -n "$LIBTOOL_WANTED_PATCH"; then
133        if test "$minor" -gt "$LIBTOOL_WANTED_MINOR"; then
134          lt_status="good"
135        elif test -n "$patch"; then
136           if test "$patch" -lt "$LIBTOOL_WANTED_PATCH"; then
137              lt_status="bad"
138           fi
139        else
140           lt_status="bad"
141        fi
142    fi
143 fi
144 if test $lt_status != "good"; then
145   echo "buildconf: libtool version $lt_pversion found."
146   echo "            You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
147   exit 1
148 fi
149
150 echo "buildconf: libtool version $lt_version (ok)"
151
152 if test -f "$LIBTOOLIZE"; then
153   echo "buildconf: libtoolize found"
154 else
155   echo "buildconf: libtoolize not found. Weird libtool installation!"
156   exit 1
157 fi
158
159 #--------------------------------------------------------------------------
160 # m4 check
161 #
162 m4=`${M4:-m4} --version 2>/dev/null|head -n 1`;
163 m4_version=`echo $m4 | sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//'`
164
165 if { echo $m4 | grep "GNU" >/dev/null 2>&1; } then
166   echo "buildconf: GNU m4 version $m4_version (ok)"
167 else
168   echo "buildconf: m4 version $m4 found. You need a GNU m4 installed!"
169   exit 1
170 fi
171
172 #--------------------------------------------------------------------------
173 # perl check
174 #
175 PERL=`findtool perl`
176
177 # ------------------------------------------------------------
178
179 # run the correct scripts now
180
181 echo "buildconf: running libtoolize"
182 ${LIBTOOLIZE:-libtoolize} --copy --automake --force || die "The libtool command failed"
183 echo "buildconf: running aclocal"
184 ${ACLOCAL:-aclocal} $ACLOCAL_FLAGS || die "The aclocal command line failed"
185 if test -n "$PERL"; then
186   echo "buildconf: running aclocal hack to convert all mv to mv -f"
187   $PERL -i.bak -pe 's/\bmv +([^-\s])/mv -f $1/g' aclocal.m4
188 else
189   echo "buildconf: perl not found"
190   exit 1
191 fi
192 echo "buildconf: running autoheader"
193 ${AUTOHEADER:-autoheader} || die "The autoheader command failed"
194 echo "buildconf: cp lib/config.h.in src/config.h.in"
195 cp lib/config.h.in src/config.h.in
196 echo "buildconf: running autoconf"
197 ${AUTOCONF:-autoconf}     || die "The autoconf command failed"
198
199 if test -d ares; then
200   cd ares
201   echo "buildconf: running ares/libtoolize"
202 ${LIBTOOLIZE:-libtoolize} --copy --automake --force || die "The libtool command failed"
203   echo "buildconf: running ares/aclocal"
204   ${ACLOCAL:-aclocal} $ACLOCAL_FLAGS || die "The ares aclocal command failed"
205   echo "buildconf: running ares/autoconf"
206   ${AUTOCONF:-autoconf}     || die "The ares autoconf command failed"
207   cd ..
208 fi
209
210 echo "buildconf: running automake"
211 ${AUTOMAKE:-automake} -a -c  || die "The automake command failed"
212
213 echo "buildconf: OK"
214 exit 0