For debugging purposes, show all sed's available in PATH on SunOS systems.
[platform/upstream/curl.git] / buildconf
1 #!/bin/sh
2 #***************************************************************************
3 #                                  _   _ ____  _
4 #  Project                     ___| | | |  _ \| |
5 #                             / __| | | | |_) | |
6 #                            | (__| |_| |  _ <| |___
7 #                             \___|\___/|_| \_\_____|
8 #
9 # Copyright (C) 1998 - 2008, 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 #--------------------------------------------------------------------------
31 # findtool works as 'which' but we use a different name to make it more
32 # obvious we aren't using 'which'! ;-)
33 #
34 findtool(){
35   file="$1"
36
37   old_IFS=$IFS; IFS=':'
38   for path in $PATH
39   do
40     IFS=$old_IFS
41     # echo "checks for $file in $path" >&2
42     if test -f "$path/$file"; then
43       echo "$path/$file"
44       return
45     fi
46   done
47   IFS=$old_IFS
48 }
49
50 #--------------------------------------------------------------------------
51 # Ensure that buildconf runs from the subdirectory where configure.ac lives
52 #
53 if test ! -f configure.ac ||
54   test ! -f src/main.c ||
55   test ! -f lib/urldata.h ||
56   test ! -f include/curl/curl.h; then
57   echo "Can not run buildconf from outside of curl's source subdirectory!"
58   echo "Change to the subdirectory where buildconf is found, and try again."
59   exit 1
60 fi
61
62 #--------------------------------------------------------------------------
63 # autoconf 2.57 or newer
64 #
65 need_autoconf="2.57"
66 ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
67 if test -z "$ac_version"; then
68   echo "buildconf: autoconf not found."
69   echo "            You need autoconf version $need_autoconf or newer installed."
70   exit 1
71 fi
72 IFS=.; set $ac_version; IFS=' '
73 if test "$1" = "2" -a "$2" -lt "57" || test "$1" -lt "2"; then
74   echo "buildconf: autoconf version $ac_version found."
75   echo "            You need autoconf version $need_autoconf or newer installed."
76   echo "            If you have a sufficient autoconf installed, but it"
77   echo "            is not named 'autoconf', then try setting the"
78   echo "            AUTOCONF environment variable."
79   exit 1
80 fi
81
82 echo "buildconf: autoconf version $ac_version (ok)"
83
84 #--------------------------------------------------------------------------
85 # autoheader 2.50 or newer
86 #
87 ah_version=`${AUTOHEADER:-autoheader} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
88 if test -z "$ah_version"; then
89   echo "buildconf: autoheader not found."
90   echo "            You need autoheader version 2.50 or newer installed."
91   exit 1
92 fi
93 IFS=.; set $ah_version; IFS=' '
94 if test "$1" = "2" -a "$2" -lt "50" || test "$1" -lt "2"; then
95   echo "buildconf: autoheader version $ah_version found."
96   echo "            You need autoheader version 2.50 or newer installed."
97   echo "            If you have a sufficient autoheader installed, but it"
98   echo "            is not named 'autoheader', then try setting the"
99   echo "            AUTOHEADER environment variable."
100   exit 1
101 fi
102
103 echo "buildconf: autoheader version $ah_version (ok)"
104
105 #--------------------------------------------------------------------------
106 # automake 1.7 or newer
107 #
108 need_automake="1.7"
109 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/'`
110 if test -z "$am_version"; then
111   echo "buildconf: automake not found."
112   echo "            You need automake version $need_automake or newer installed."
113   exit 1
114 fi
115 IFS=.; set $am_version; IFS=' '
116 if test "$1" = "1" -a "$2" -lt "7" || test "$1" -lt "1"; then
117   echo "buildconf: automake version $am_version found."
118   echo "            You need automake version $need_automake or newer installed."
119   echo "            If you have a sufficient automake installed, but it"
120   echo "            is not named 'automake', then try setting the"
121   echo "            AUTOMAKE environment variable."
122   exit 1
123 fi
124
125 echo "buildconf: automake version $am_version (ok)"
126
127 ac=`findtool ${ACLOCAL:-aclocal}`
128 if test -z "$ac"; then
129   echo "buildconf: aclocal not found. Weird automake installation!"
130   exit 1
131 else
132   echo "buildconf: aclocal found"
133 fi
134
135 #--------------------------------------------------------------------------
136 # libtool check
137 #
138 LIBTOOL_WANTED_MAJOR=1
139 LIBTOOL_WANTED_MINOR=4
140 LIBTOOL_WANTED_PATCH=2
141 LIBTOOL_WANTED_VERSION=1.4.2
142
143 # this approach that tries 'glibtool' first is some kind of work-around for
144 # some BSD-systems I believe that use to provide the GNU libtool named
145 # glibtool, with 'libtool' being something completely different.
146 libtool=`findtool glibtool 2>/dev/null`
147 if test ! -x "$libtool"; then
148   libtool=`findtool ${LIBTOOL:-libtool}`
149 fi
150
151 if test -z "$LIBTOOLIZE"; then
152   # set the LIBTOOLIZE here so that glibtoolize is used if glibtool was found
153   # $libtool is already the full path
154   libtoolize="${libtool}ize"
155 else
156   libtoolize=`findtool $LIBTOOLIZE`
157 fi
158
159 lt_pversion=`$libtool --version 2>/dev/null|head -n 2|sed -e 's/^[^0-9]*//g' -e 's/[- ].*//'`
160 if test -z "$lt_pversion"; then
161   echo "buildconf: libtool not found."
162   echo "            You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
163   exit 1
164 fi
165 lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$//'`
166 IFS=.; set $lt_version; IFS=' '
167 lt_status="good"
168
169 major=$1
170 minor=$2
171 patch=$3
172
173 if test "$major" = "$LIBTOOL_WANTED_MAJOR"; then
174    if test "$minor" -lt "$LIBTOOL_WANTED_MINOR"; then
175       lt_status="bad"
176    elif test -n "$LIBTOOL_WANTED_PATCH"; then
177        if test "$minor" -gt "$LIBTOOL_WANTED_MINOR"; then
178          lt_status="good"
179        elif test -n "$patch"; then
180           if test "$patch" -lt "$LIBTOOL_WANTED_PATCH"; then
181              lt_status="bad"
182           fi
183        else
184           lt_status="bad"
185        fi
186    fi
187 fi
188 if test $lt_status != "good"; then
189   echo "buildconf: libtool version $lt_pversion found."
190   echo "            You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
191   exit 1
192 fi
193
194 echo "buildconf: libtool version $lt_version (ok)"
195
196 if test -f "$libtoolize"; then
197   echo "buildconf: libtoolize found"
198 else
199   echo "buildconf: libtoolize not found. Weird libtool installation!"
200   exit 1
201 fi
202
203 #--------------------------------------------------------------------------
204 # m4 check
205 #
206 m4=`${M4:-m4} --version 2>/dev/null|head -n 1`;
207 m4_version=`echo $m4 | sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//'`
208
209 if { echo $m4 | grep "GNU" >/dev/null 2>&1; } then
210   echo "buildconf: GNU m4 version $m4_version (ok)"
211 else
212   echo "buildconf: m4 version $m4 found. You need a GNU m4 installed!"
213   exit 1
214 fi
215
216 #--------------------------------------------------------------------------
217 # perl check
218 #
219 PERL=`findtool ${PERL:-perl}`
220
221 #--------------------------------------------------------------------------
222 # Remove files generated on previous buildconf/configure run.
223 #
224 for fname in aclocal.m4 \
225              aclocal.m4.bak \
226              config.guess \
227              config.log \
228              config.status \
229              config.sub \
230              configure \
231              depcomp \
232              libtool \
233              ltmain.sh \
234              Makefile \
235              Makefile.in ; do
236   if test -f "$fname" ; then
237     rm -f "$fname"
238   fi
239 done
240 if test -d autom4te.cache; then
241   rm -f -r autom4te.cache
242 fi
243 if test -d docs/examples/.deps; then
244   rm -f -r docs/examples/.deps
245 fi
246 if test -d lib/.deps; then
247   rm -f -r lib/.deps
248 fi
249 if test -d src/.deps; then
250   rm -f -r src/.deps
251 fi
252 if test -d tests/libtest/.deps; then
253   rm -f -r tests/libtest/.deps
254 fi
255 if test -d tests/server/.deps; then
256   rm -f -r tests/server/.deps
257 fi
258
259 #--------------------------------------------------------------------------
260 # Remove files generated in c-ares subdir on previous buildconf/configure run.
261 #
262 if test -d ares; then
263   cd ares
264   for fname in aclocal.m4 \
265                aclocal.m4.bak \
266                compile \
267                config.h \
268                config.h.in \
269                config.guess \
270                config.log \
271                config.status \
272                config.sub \
273                configure \
274                depcomp \
275                libtool \
276                ltmain.sh \
277                missing \
278                Makefile \
279                Makefile.in ; do
280     if test -f "$fname" ; then
281       rm -f "$fname"
282     fi
283   done
284   if test -d autom4te.cache; then
285     rm -f -r autom4te.cache
286   fi
287   if test -d .deps; then
288     rm -f -r .deps
289   fi
290   cd ..
291 fi
292
293 #--------------------------------------------------------------------------
294 # run the correct scripts now
295 #
296
297 tmp_host_type=`uname -a | sed '/SunOS/s/.*\(SunOS\).*/\1/'`
298 if test "x$tmp_host_type" = "xSunOS"; then
299   ACLOCAL_FLAGS="$ACLOCAL_FLAGS --verbose"
300
301   echo "buildconf: PATH: $PATH"
302
303   # show all available sed's in PATH order
304   old_IFS=$IFS; IFS=':'
305   for path in $PATH
306   do
307     IFS=$old_IFS
308     if test -f "$path/sed"; then
309       echo "buildconf: sed: $path/sed"
310     fi
311   done
312   IFS=$old_IFS
313   echo "buildconf: SED: $SED"
314
315 fi
316
317 echo "buildconf: running libtoolize"
318 $libtoolize --copy --automake --force || die "The libtoolize command failed"
319 echo "buildconf: running aclocal"
320 ${ACLOCAL:-aclocal} $ACLOCAL_FLAGS || die "The aclocal command line failed"
321 if test -n "$PERL"; then
322   echo "buildconf: running aclocal hack to convert all mv to mv -f"
323   $PERL -i.bak -pe 's/\bmv +([^-\s])/mv -f $1/g' aclocal.m4
324 else
325   echo "buildconf: perl not found"
326   exit 1
327 fi
328 echo "buildconf: running autoheader"
329 ${AUTOHEADER:-autoheader} || die "The autoheader command failed"
330 echo "buildconf: cp lib/config.h.in src/config.h.in"
331 cp lib/config.h.in src/config.h.in
332 echo "buildconf: running autoconf"
333 ${AUTOCONF:-autoconf}     || die "The autoconf command failed"
334
335 if test -d ares; then
336   cd ares
337   echo "buildconf: running in ares"
338   ./buildconf
339   cd ..
340 fi
341
342 echo "buildconf: running automake"
343 ${AUTOMAKE:-automake} -a -c  || die "The automake command failed"
344
345 echo "buildconf: OK"
346 exit 0