I fell over a new libtool that starts with a newline so we need to fetch
[platform/upstream/curl.git] / buildconf
1 #!/bin/sh
2 #***************************************************************************
3 #                                  _   _ ____  _
4 #  Project                     ___| | | |  _ \| |
5 #                             / __| | | | |_) | |
6 #                            | (__| |_| |  _ <| |___
7 #                             \___|\___/|_| \_\_____|
8 #
9 # Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
10 #
11 # This software is licensed as described in the file COPYING, which
12 # you should have received as part of this distribution. The terms
13 # are also available at http://curl.haxx.se/docs/copyright.html.
14 #
15 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
16 # copies of the Software, and permit persons to whom the Software is
17 # furnished to do so, under the terms of the COPYING file.
18 #
19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 # KIND, either express or implied.
21 #
22 # $Id$
23 ###########################################################################
24
25 die(){
26         echo "$@"
27         exit
28 }
29
30 # this works as 'which' but we use a different name to make it more obvious we
31 # aren't using 'which'! ;-)
32 findtool(){
33   file="$1"
34
35   IFS=":"
36   for path in $PATH
37   do
38     # echo "checks for $file in $path" >&2
39     if test -f "$path/$file"; then
40       echo "$path/$file"
41       return
42     fi
43   done
44 }
45
46 #--------------------------------------------------------------------------
47 # autoconf 2.57 or newer
48 #
49 need_autoconf="2.57"
50 ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
51 if test -z "$ac_version"; then
52   echo "buildconf: autoconf not found."
53   echo "            You need autoconf version $need_autoconf or newer installed."
54   exit 1
55 fi
56 IFS=.; set $ac_version; IFS=' '
57 if test "$1" = "2" -a "$2" -lt "57" || test "$1" -lt "2"; then
58   echo "buildconf: autoconf version $ac_version found."
59   echo "            You need autoconf version $need_autoconf or newer installed."
60   echo "            If you have a sufficient autoconf installed, but it"
61   echo "            is not named 'autoconf', then try setting the"
62   echo "            AUTOCONF environment variable."
63   exit 1
64 fi
65
66 echo "buildconf: autoconf version $ac_version (ok)"
67
68 #--------------------------------------------------------------------------
69 # autoheader 2.50 or newer
70 #
71 ah_version=`${AUTOHEADER:-autoheader} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
72 if test -z "$ah_version"; then
73   echo "buildconf: autoheader not found."
74   echo "            You need autoheader version 2.50 or newer installed."
75   exit 1
76 fi
77 IFS=.; set $ah_version; IFS=' '
78 if test "$1" = "2" -a "$2" -lt "50" || test "$1" -lt "2"; then
79   echo "buildconf: autoheader version $ah_version found."
80   echo "            You need autoheader version 2.50 or newer installed."
81   echo "            If you have a sufficient autoheader installed, but it"
82   echo "            is not named 'autoheader', then try setting the"
83   echo "            AUTOHEADER environment variable."
84   exit 1
85 fi
86
87 echo "buildconf: autoheader version $ah_version (ok)"
88
89 #--------------------------------------------------------------------------
90 # automake 1.7 or newer
91 #
92 need_automake="1.7"
93 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/'`
94 if test -z "$am_version"; then
95   echo "buildconf: automake not found."
96   echo "            You need automake version $need_automake or newer installed."
97   exit 1
98 fi
99 IFS=.; set $am_version; IFS=' '
100 if test "$1" = "1" -a "$2" -lt "7" || test "$1" -lt "1"; then
101   echo "buildconf: automake version $am_version found."
102   echo "            You need automake version $need_automake or newer installed."
103   echo "            If you have a sufficient automake installed, but it"
104   echo "            is not named 'automake', then try setting the"
105   echo "            AUTOMAKE environment variable."
106   exit 1
107 fi
108
109 echo "buildconf: automake version $am_version (ok)"
110
111 ac=`findtool ${ACLOCAL:-aclocal}`
112 if test -z "$ac"; then
113   echo "buildconf: aclocal not found. Weird automake installation!"
114   exit 1
115 else
116   echo "buildconf: aclocal found"
117 fi
118
119 #--------------------------------------------------------------------------
120 # libtool check
121 #
122 LIBTOOL_WANTED_MAJOR=1
123 LIBTOOL_WANTED_MINOR=4
124 LIBTOOL_WANTED_PATCH=2
125 LIBTOOL_WANTED_VERSION=1.4.2
126
127 # this approach that tries 'glibtool' first is some kind of work-around for
128 # some BSD-systems I believe that use to provide the GNU libtool named
129 # glibtool, with 'libtool' being something completely different.
130 libtool=`findtool glibtool 2>/dev/null`
131 if test ! -x "$libtool"; then
132   libtool=`findtool ${LIBTOOL:-libtool}`
133 fi
134
135 if test -z "$LIBTOOLIZE"; then
136   # set the LIBTOOLIZE here so that glibtoolize is used if glibtool was found
137   # $libtool is already the full path
138   libtoolize="${libtool}ize"
139 else
140   libtoolize=`findtool $LIBTOOLIZE`
141 fi
142
143 lt_pversion=`$libtool --version 2>/dev/null|head -n 2|sed -e 's/^[^0-9]*//g' -e 's/[- ].*//'`
144 if test -z "$lt_pversion"; then
145   echo "buildconf: libtool not found."
146   echo "            You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
147   exit 1
148 fi
149 lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$//'`
150 IFS=.; set $lt_version; IFS=' '
151 lt_status="good"
152
153 major=$1
154 minor=$2
155 patch=$3
156
157 if test "$major" = "$LIBTOOL_WANTED_MAJOR"; then
158    if test "$minor" -lt "$LIBTOOL_WANTED_MINOR"; then
159       lt_status="bad"
160    elif test -n "$LIBTOOL_WANTED_PATCH"; then
161        if test "$minor" -gt "$LIBTOOL_WANTED_MINOR"; then
162          lt_status="good"
163        elif test -n "$patch"; then
164           if test "$patch" -lt "$LIBTOOL_WANTED_PATCH"; then
165              lt_status="bad"
166           fi
167        else
168           lt_status="bad"
169        fi
170    fi
171 fi
172 if test $lt_status != "good"; then
173   echo "buildconf: libtool version $lt_pversion found."
174   echo "            You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
175   exit 1
176 fi
177
178 echo "buildconf: libtool version $lt_version (ok)"
179
180 if test -f "$libtoolize"; then
181   echo "buildconf: libtoolize found"
182 else
183   echo "buildconf: libtoolize not found. Weird libtool installation!"
184   exit 1
185 fi
186
187 #--------------------------------------------------------------------------
188 # m4 check
189 #
190 m4=`${M4:-m4} --version 2>/dev/null|head -n 1`;
191 m4_version=`echo $m4 | sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//'`
192
193 if { echo $m4 | grep "GNU" >/dev/null 2>&1; } then
194   echo "buildconf: GNU m4 version $m4_version (ok)"
195 else
196   echo "buildconf: m4 version $m4 found. You need a GNU m4 installed!"
197   exit 1
198 fi
199
200 #--------------------------------------------------------------------------
201 # perl check
202 #
203 PERL=`findtool ${PERL:-perl}`
204
205 # ------------------------------------------------------------
206
207 # run the correct scripts now
208
209 echo "buildconf: running libtoolize"
210 $libtoolize --copy --automake --force || die "The libtoolize command failed"
211 echo "buildconf: running aclocal"
212 ${ACLOCAL:-aclocal} $ACLOCAL_FLAGS || die "The aclocal command line failed"
213 if test -n "$PERL"; then
214   echo "buildconf: running aclocal hack to convert all mv to mv -f"
215   $PERL -i.bak -pe 's/\bmv +([^-\s])/mv -f $1/g' aclocal.m4
216 else
217   echo "buildconf: perl not found"
218   exit 1
219 fi
220 echo "buildconf: running autoheader"
221 ${AUTOHEADER:-autoheader} || die "The autoheader command failed"
222 echo "buildconf: cp lib/config.h.in src/config.h.in"
223 cp lib/config.h.in src/config.h.in
224 echo "buildconf: running autoconf"
225 ${AUTOCONF:-autoconf}     || die "The autoconf command failed"
226
227 if test -d ares; then
228   cd ares
229   echo "buildconf: running in ares"
230   ./buildconf
231   cd ..
232 fi
233
234 echo "buildconf: running automake"
235 ${AUTOMAKE:-automake} -a -c  || die "The automake command failed"
236
237 echo "buildconf: OK"
238 exit 0